aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
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 /CMakeLists.txt
parent8bce9f9da4f28cff658f55f2c5c3c620bc13785c (diff)
downloadportable-f819a2bce7a708147df16b5bef21ccaadf7b9913.tar.gz
portable-f819a2bce7a708147df16b5bef21ccaadf7b9913.tar.bz2
portable-f819a2bce7a708147df16b5bef21ccaadf7b9913.zip
Fix cmake linking libraries
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt24
1 files changed, 7 insertions, 17 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)