aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkinichiro <kinichiro.inoguchi@gmail.com>2018-10-03 20:35:36 +0900
committerkinichiro <kinichiro.inoguchi@gmail.com>2018-10-03 20:35:36 +0900
commitf819a2bce7a708147df16b5bef21ccaadf7b9913 (patch)
treeda7b7edf6464cf6392f44c0c47c214e1b5f88313
parent8bce9f9da4f28cff658f55f2c5c3c620bc13785c (diff)
downloadportable-f819a2bce7a708147df16b5bef21ccaadf7b9913.tar.gz
portable-f819a2bce7a708147df16b5bef21ccaadf7b9913.tar.bz2
portable-f819a2bce7a708147df16b5bef21ccaadf7b9913.zip
Fix cmake linking libraries
-rw-r--r--CMakeLists.txt24
-rw-r--r--crypto/CMakeLists.txt2
-rw-r--r--ssl/CMakeLists.txt3
-rw-r--r--tls/CMakeLists.txt3
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)
58endif() 59endif()
59 60
60if(CMAKE_SYSTEM_NAME MATCHES "MINGW") 61if(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)
76endif() 78endif()
77 79
78if(CMAKE_SYSTEM_NAME MATCHES "SunOS") 80if(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)
84endif() 87endif()
85 88
86add_definitions(-DLIBRESSL_INTERNAL) 89add_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)
104endif() 108endif()
105 109
106if(MSVC) 110if(MSVC)
@@ -262,27 +266,11 @@ if(ENABLE_ASM)
262 endif() 266 endif()
263endif() 267endif()
264 268
265set(OPENSSL_LIBS tls ssl crypto)
266
267# Add additional required libs
268if(WIN32)
269 set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32)
270endif()
271if(CMAKE_SYSTEM_NAME MATCHES "Linux")
272 set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread)
273endif()
274if(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
275 set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread)
276endif()
277if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
278 set(OPENSSL_LIBS ${OPENSSL_LIBS} nsl socket)
279endif()
280
281if(CMAKE_SYSTEM_NAME MATCHES "Linux") 269if(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()
287else() 275else()
288 # Otherwise, simply check if it exists 276 # Otherwise, simply check if it exists
@@ -301,6 +289,8 @@ if(SIZEOF_TIME_T STREQUAL "4")
301endif() 289endif()
302add_definitions(-DSIZEOF_TIME_T=${SIZEOF_TIME_T}) 290add_definitions(-DSIZEOF_TIME_T=${SIZEOF_TIME_T})
303 291
292set(OPENSSL_LIBS tls ssl crypto ${PLATFORM_LDADD})
293
304add_subdirectory(crypto) 294add_subdirectory(crypto)
305add_subdirectory(ssl) 295add_subdirectory(ssl)
306if(LIBRESSL_APPS) 296if(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
815if (BUILD_SHARED_LIBS) 815if (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
52if (BUILD_SHARED_LIBS) 52if (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
41if (BUILD_SHARED_LIBS) 41if (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