diff --git a/CMakeLists.txt b/CMakeLists.txt index 8136e2e..fa7ce92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,9 @@ set(LIBJUICE_SOURCES set(LIBJUICE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/juice/juice.h ) +set(LIBJUICE_PRIVATE_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/src/socket.h +) set(TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test/main.c @@ -59,10 +62,10 @@ set(TESTS_SOURCES set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) -add_library(juice SHARED ${LIBJUICE_SOURCES}) +add_library(juice ${LIBJUICE_SOURCES}) set_target_properties(juice PROPERTIES VERSION ${PROJECT_VERSION}) -target_include_directories(juice PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_include_directories(juice PUBLIC $ $) target_include_directories(juice PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/juice) target_include_directories(juice PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) target_link_libraries(juice PUBLIC Threads::Threads) @@ -86,10 +89,14 @@ endif() if (USE_NETTLE) find_package(Nettle REQUIRED) + find_path(NETTLE_INCLUDE_PATH "nettle/hmac.h" REQUIRED) + target_include_directories(juice PRIVATE ${NETTLE_INCLUDE_PATH}) + target_include_directories(juice-static PRIVATE ${NETTLE_INCLUDE_PATH}) + target_compile_definitions(juice PRIVATE USE_NETTLE=1) - target_link_libraries(juice PRIVATE Nettle::Nettle) + target_link_libraries(juice PRIVATE nettle) target_compile_definitions(juice-static PRIVATE USE_NETTLE=1) - target_link_libraries(juice-static PRIVATE Nettle::Nettle) + target_link_libraries(juice-static PRIVATE nettle) else() target_compile_definitions(juice PRIVATE USE_NETTLE=0) target_compile_definitions(juice-static PRIVATE USE_NETTLE=0) @@ -109,8 +116,13 @@ endif() add_library(LibJuice::LibJuice ALIAS juice) add_library(LibJuice::LibJuiceStatic ALIAS juice-static) -install(TARGETS juice LIBRARY DESTINATION lib) +install(TARGETS juice EXPORT libjuice-config + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) install(FILES ${LIBJUICE_HEADERS} DESTINATION include/juice) +install(FILES ${LIBJUICE_PRIVATE_HEADERS} DESTINATION include/juice/src) if(NOT MSVC) target_compile_options(juice PRIVATE -Wall -Wextra) @@ -145,3 +157,8 @@ if(NOT NO_TESTS) target_link_libraries(juice-tests juice) endif() +install( + EXPORT libjuice-config + NAMESPACE LibJuice:: + DESTINATION share/cmake/libjuice +)