diff --git a/CMakeLists.txt b/CMakeLists.txt index f2d8447a795aa8bee5c9cc675c9c5878a00c6bed..a79ee27293bb2ddb4bcb4f77c20d4f3847e86718 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,15 +403,23 @@ if (OPENDHT_SHARED) endif () if (OPENDHT_C) - add_library (opendht-c SHARED - c/opendht.cpp - c/opendht_c.h - ) - target_compile_definitions(opendht-c PRIVATE OPENDHT_C_BUILD) if (OPENDHT_SHARED) - target_link_libraries(opendht-c opendht) - else () - target_link_libraries(opendht-c opendht-static) + add_library (opendht-c SHARED + c/opendht.cpp + c/opendht_c.h + ) + target_compile_definitions(opendht-c PRIVATE OPENDHT_C_BUILD) + target_link_libraries(opendht-c PRIVATE opendht) + install (TARGETS opendht-c DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT opendht-c) + endif () + + if (OPENDHT_STATIC) + add_library (opendht-c-static STATIC + c/opendht.cpp + c/opendht_c.h + ) + target_link_libraries(opendht-c-static PRIVATE opendht-static) + install (TARGETS opendht-c-static DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT opendht-c-static) endif () # PkgConfig module @@ -420,7 +428,6 @@ if (OPENDHT_C) opendht-c.pc @ONLY ) - install (TARGETS opendht-c DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT opendht-c) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/opendht-c.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install (FILES c/opendht_c.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/opendht) endif () diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index a0af8045dab73eeecf46328d8fe6a0c8e9ee57dd..b56507d0a5259e472cb4f1d28fb3c3a006fe1c21 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,7 +1,9 @@ if (OPENDHT_SHARED) set (OPENDHT_LIBS opendht) + set (OPENDHT_C_LIBS opendht-c) else () set (OPENDHT_LIBS opendht-static) + set (OPENDHT_C_LIBS opendht-c-static) if (MSVC) set (MSC_COMPAT_SOURCES ${MSC_COMPAT_DIR}/wingetopt.c) endif () @@ -9,8 +11,8 @@ endif () function (configure_tool name extra_files) add_executable (${name} ${name}.cpp ${extra_files}) - target_link_libraries (${name} LINK_PUBLIC ${READLINE_LIBRARIES}) - target_link_libraries (${name} LINK_PUBLIC ${OPENDHT_LIBS}) + add_dependencies(${name} ${OPENDHT_LIBS}) + target_link_libraries (${name} LINK_PUBLIC ${OPENDHT_LIBS} ${READLINE_LIBRARIES}) if (MSVC) target_sources(${name} PRIVATE ${MSC_COMPAT_SOURCES}) target_include_directories (${name} PRIVATE ${MSC_COMPAT_DIR}) @@ -29,7 +31,8 @@ endif () if (OPENDHT_C) add_executable (dhtcnode dhtcnode.c) - target_link_libraries (dhtcnode LINK_PUBLIC opendht-c ${READLINE_LIBRARIES}) + add_dependencies(dhtcnode ${OPENDHT_C_LIBS}) + target_link_libraries (dhtcnode LINK_PUBLIC ${OPENDHT_C_LIBS} ${READLINE_LIBRARIES}) target_include_directories (dhtcnode SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/c) endif ()