diff options
author | kinichiro <kinichiro.inoguchi@gmail.com> | 2018-10-03 20:35:36 +0900 |
---|---|---|
committer | kinichiro <kinichiro.inoguchi@gmail.com> | 2018-10-03 20:35:36 +0900 |
commit | f819a2bce7a708147df16b5bef21ccaadf7b9913 (patch) | |
tree | da7b7edf6464cf6392f44c0c47c214e1b5f88313 | |
parent | 8bce9f9da4f28cff658f55f2c5c3c620bc13785c (diff) | |
download | portable-f819a2bce7a708147df16b5bef21ccaadf7b9913.tar.gz portable-f819a2bce7a708147df16b5bef21ccaadf7b9913.tar.bz2 portable-f819a2bce7a708147df16b5bef21ccaadf7b9913.zip |
Fix cmake linking libraries
-rw-r--r-- | CMakeLists.txt | 24 | ||||
-rw-r--r-- | crypto/CMakeLists.txt | 2 | ||||
-rw-r--r-- | ssl/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tls/CMakeLists.txt | 3 |
4 files changed, 10 insertions, 22 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 549849f..27cd8da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -55,6 +55,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux") | |||
55 | add_definitions(-D_BSD_SOURCE) | 55 | add_definitions(-D_BSD_SOURCE) |
56 | add_definitions(-D_POSIX_SOURCE) | 56 | add_definitions(-D_POSIX_SOURCE) |
57 | add_definitions(-D_GNU_SOURCE) | 57 | add_definitions(-D_GNU_SOURCE) |
58 | set(PLATFORM_LDADD ${PLATFORM_LDADD} pthread) | ||
58 | endif() | 59 | endif() |
59 | 60 | ||
60 | if(CMAKE_SYSTEM_NAME MATCHES "MINGW") | 61 | if(CMAKE_SYSTEM_NAME MATCHES "MINGW") |
@@ -73,6 +74,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "HP-UX") | |||
73 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 +DD64 +Otype_safety=off") | 74 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 +DD64 +Otype_safety=off") |
74 | endif() | 75 | endif() |
75 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=600 -D__STRICT_ALIGNMENT") | 76 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=600 -D__STRICT_ALIGNMENT") |
77 | set(PLATFORM_LDADD ${PLATFORM_LDADD} pthread) | ||
76 | endif() | 78 | endif() |
77 | 79 | ||
78 | if(CMAKE_SYSTEM_NAME MATCHES "SunOS") | 80 | if(CMAKE_SYSTEM_NAME MATCHES "SunOS") |
@@ -81,6 +83,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "SunOS") | |||
81 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=600") | 83 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=600") |
82 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBSD_COMP") | 84 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBSD_COMP") |
83 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic") | 85 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic") |
86 | set(PLATFORM_LDADD ${PLATFORM_LDADD} nsl socket) | ||
84 | endif() | 87 | endif() |
85 | 88 | ||
86 | add_definitions(-DLIBRESSL_INTERNAL) | 89 | add_definitions(-DLIBRESSL_INTERNAL) |
@@ -101,6 +104,7 @@ if(WIN32) | |||
101 | add_definitions(-D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS) | 104 | add_definitions(-D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS) |
102 | add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600) | 105 | add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600) |
103 | add_definitions(-DCPPFLAGS -DOPENSSL_NO_SPEED -DNO_SYSLOG -DNO_CRYPT) | 106 | add_definitions(-DCPPFLAGS -DOPENSSL_NO_SPEED -DNO_SYSLOG -DNO_CRYPT) |
107 | set(PLATFORM_LDADD ${PLATFORM_LDADD} ws2_32) | ||
104 | endif() | 108 | endif() |
105 | 109 | ||
106 | if(MSVC) | 110 | if(MSVC) |
@@ -262,27 +266,11 @@ if(ENABLE_ASM) | |||
262 | endif() | 266 | endif() |
263 | endif() | 267 | endif() |
264 | 268 | ||
265 | set(OPENSSL_LIBS tls ssl crypto) | ||
266 | |||
267 | # Add additional required libs | ||
268 | if(WIN32) | ||
269 | set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32) | ||
270 | endif() | ||
271 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") | ||
272 | set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread) | ||
273 | endif() | ||
274 | if(CMAKE_SYSTEM_NAME MATCHES "HP-UX") | ||
275 | set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread) | ||
276 | endif() | ||
277 | if(CMAKE_SYSTEM_NAME MATCHES "SunOS") | ||
278 | set(OPENSSL_LIBS ${OPENSSL_LIBS} nsl socket) | ||
279 | endif() | ||
280 | |||
281 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") | 269 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") |
282 | # Check if we need -lrt to get clock_gettime on Linux | 270 | # Check if we need -lrt to get clock_gettime on Linux |
283 | check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME) | 271 | check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME) |
284 | if (HAVE_CLOCK_GETTIME) | 272 | if (HAVE_CLOCK_GETTIME) |
285 | set(OPENSSL_LIBS ${OPENSSL_LIBS} rt) | 273 | set(PLATFORM_LDADD ${PLATFORM_LDADD} rt) |
286 | endif() | 274 | endif() |
287 | else() | 275 | else() |
288 | # Otherwise, simply check if it exists | 276 | # Otherwise, simply check if it exists |
@@ -301,6 +289,8 @@ if(SIZEOF_TIME_T STREQUAL "4") | |||
301 | endif() | 289 | endif() |
302 | add_definitions(-DSIZEOF_TIME_T=${SIZEOF_TIME_T}) | 290 | add_definitions(-DSIZEOF_TIME_T=${SIZEOF_TIME_T}) |
303 | 291 | ||
292 | set(OPENSSL_LIBS tls ssl crypto ${PLATFORM_LDADD}) | ||
293 | |||
304 | add_subdirectory(crypto) | 294 | add_subdirectory(crypto) |
305 | add_subdirectory(ssl) | 295 | add_subdirectory(ssl) |
306 | if(LIBRESSL_APPS) | 296 | if(LIBRESSL_APPS) |
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 90e127e..8b66001 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt | |||
@@ -814,8 +814,8 @@ target_include_directories(crypto | |||
814 | 814 | ||
815 | if (BUILD_SHARED_LIBS) | 815 | if (BUILD_SHARED_LIBS) |
816 | export_symbol(crypto ${CMAKE_CURRENT_BINARY_DIR}/crypto_p.sym) | 816 | export_symbol(crypto ${CMAKE_CURRENT_BINARY_DIR}/crypto_p.sym) |
817 | target_link_libraries(crypto ${PLATFORM_LDADD}) | ||
817 | if (WIN32) | 818 | if (WIN32) |
818 | target_link_libraries(crypto Ws2_32.lib) | ||
819 | set(CRYPTO_POSTFIX -${CRYPTO_MAJOR_VERSION}) | 819 | set(CRYPTO_POSTFIX -${CRYPTO_MAJOR_VERSION}) |
820 | endif() | 820 | endif() |
821 | set_target_properties(crypto PROPERTIES | 821 | set_target_properties(crypto PROPERTIES |
diff --git a/ssl/CMakeLists.txt b/ssl/CMakeLists.txt index 1a559e6..22dc989 100644 --- a/ssl/CMakeLists.txt +++ b/ssl/CMakeLists.txt | |||
@@ -51,9 +51,8 @@ target_include_directories(ssl | |||
51 | 51 | ||
52 | if (BUILD_SHARED_LIBS) | 52 | if (BUILD_SHARED_LIBS) |
53 | export_symbol(ssl ${CMAKE_CURRENT_SOURCE_DIR}/ssl.sym) | 53 | export_symbol(ssl ${CMAKE_CURRENT_SOURCE_DIR}/ssl.sym) |
54 | target_link_libraries(ssl crypto) | 54 | target_link_libraries(ssl crypto ${PLATFORM_LDADD}) |
55 | if (WIN32) | 55 | if (WIN32) |
56 | target_link_libraries(ssl Ws2_32.lib) | ||
57 | set(SSL_POSTFIX -${SSL_MAJOR_VERSION}) | 56 | set(SSL_POSTFIX -${SSL_MAJOR_VERSION}) |
58 | endif() | 57 | endif() |
59 | set_target_properties(ssl PROPERTIES | 58 | set_target_properties(ssl PROPERTIES |
diff --git a/tls/CMakeLists.txt b/tls/CMakeLists.txt index 3d6dea4..6dc0501 100644 --- a/tls/CMakeLists.txt +++ b/tls/CMakeLists.txt | |||
@@ -40,9 +40,8 @@ target_include_directories(tls | |||
40 | 40 | ||
41 | if (BUILD_SHARED_LIBS) | 41 | if (BUILD_SHARED_LIBS) |
42 | export_symbol(tls ${CMAKE_CURRENT_SOURCE_DIR}/tls.sym) | 42 | export_symbol(tls ${CMAKE_CURRENT_SOURCE_DIR}/tls.sym) |
43 | target_link_libraries(tls ssl crypto) | 43 | target_link_libraries(tls ssl crypto ${PLATFORM_LDADD}) |
44 | if (WIN32) | 44 | if (WIN32) |
45 | target_link_libraries(tls Ws2_32.lib) | ||
46 | set(TLS_POSTFIX -${TLS_MAJOR_VERSION}) | 45 | set(TLS_POSTFIX -${TLS_MAJOR_VERSION}) |
47 | endif() | 46 | endif() |
48 | set_target_properties(tls PROPERTIES | 47 | set_target_properties(tls PROPERTIES |