From ba2c8763b62db914d053b1de36abaebd7d03edd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 25 Jun 2015 09:35:46 +0200 Subject: [PATCH] cmake: adjust libraries linking --- library/CMakeLists.txt | 43 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 585e75ee0..9d08a4a95 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -86,10 +86,6 @@ set(src ${src_tls} ) -if(WIN32) - set(libs ws2_32) -endif(WIN32) - if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes") endif(CMAKE_COMPILER_IS_GNUCC) @@ -98,13 +94,27 @@ if(CMAKE_COMPILER_IS_CLANG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code") endif(CMAKE_COMPILER_IS_CLANG) +if(WIN32) + set(libs ${libs} ws2_32) +endif(WIN32) + +if(USE_PKCS11_HELPER_LIBRARY) + set(libs ${libs} pkcs11-helper) +endif(USE_PKCS11_HELPER_LIBRARY) + +if(ENABLE_ZLIB_SUPPORT) + set(libs ${libs} ${ZLIB_LIBRARIES}) +endif(ENABLE_ZLIB_SUPPORT) + +if(LINK_WITH_PTHREAD) + set(libs ${libs} pthread) +endif() + if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY) message(FATAL_ERROR "Need to choose static or shared mbedtls build!") endif(NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY) if(USE_STATIC_MBEDTLS_LIBRARY AND USE_SHARED_MBEDTLS_LIBRARY) - # if we build both static an shared, then let - # tests and programs link to the shared lib target set(mbedtls_static_target "mbedtls_static") elseif(USE_STATIC_MBEDTLS_LIBRARY) set(mbedtls_static_target "mbedtls") @@ -115,33 +125,16 @@ if(USE_STATIC_MBEDTLS_LIBRARY) set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) target_link_libraries(${mbedtls_static_target} ${libs}) - if(ZLIB_FOUND) - target_link_libraries(${mbedtls_static_target} ${ZLIB_LIBRARIES}) - endif(ZLIB_FOUND) - - if(LINK_WITH_PTHREAD) - target_link_libraries(${mbedtls_static_target} pthread) - endif() - install(TARGETS ${mbedtls_static_target} - DESTINATION ${LIB_INSTALL_DIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + DESTINATION ${LIB_INSTALL_DIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) endif() if(USE_SHARED_MBEDTLS_LIBRARY) add_library(mbedtls SHARED ${src}) set_target_properties(mbedtls PROPERTIES VERSION 1.4.0 SOVERSION 8) - target_link_libraries(mbedtls ${libs}) - if(ZLIB_FOUND) - target_link_libraries(mbedtls ${ZLIB_LIBRARIES}) - endif(ZLIB_FOUND) - - if(LINK_WITH_PTHREAD) - target_link_libraries(mbedtls pthread) - endif() - install(TARGETS mbedtls DESTINATION ${LIB_INSTALL_DIR} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)