-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
90 lines (78 loc) · 3.09 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
cmake_minimum_required(VERSION 3.15)
set(CMAKE_CXX_STANDARD 20)
project(xfer)
add_executable(xfer
main.cpp
secureSocketStream.h
secureSocketStream.cpp
)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/openssl)
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
if (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/openssl/configdata.pm
COMMAND perl ${CMAKE_SOURCE_DIR}/openssl/Configure VC-WIN64A no-shared --release /PDB:NONE
DEPENDS ${CMAKE_SOURCE_DIR}/openssl/Configure ${CMAKE_SOURCE_DIR}/CMakeLists.txt
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openssl
)
else()
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/openssl/configdata.pm
COMMAND perl ${CMAKE_SOURCE_DIR}/openssl/Configure VC-WIN64A no-shared -static --release
DEPENDS ${CMAKE_SOURCE_DIR}/openssl/Configure ${CMAKE_SOURCE_DIR}/CMakeLists.txt
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openssl
)
endif()
add_custom_command(
OUTPUT
${CMAKE_BINARY_DIR}/openssl/libssl.lib
${CMAKE_BINARY_DIR}/openssl/libcrypto.lib
COMMAND nmake
DEPENDS ${CMAKE_BINARY_DIR}/openssl/configdata.pm
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openssl
)
add_custom_target(openssl DEPENDS ${CMAKE_BINARY_DIR}/openssl/libssl.lib ${CMAKE_BINARY_DIR}/openssl/libcrypto.lib)
target_link_libraries(xfer ${CMAKE_BINARY_DIR}/openssl/libssl.lib ${CMAKE_BINARY_DIR}/openssl/libcrypto.lib crypt32.lib)
#elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
else()
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/openssl/configdata.pm
COMMAND ${CMAKE_SOURCE_DIR}/openssl/Configure no-shared -static --release # no-autoalginit no-pinshared
DEPENDS ${CMAKE_SOURCE_DIR}/openssl/Configure ${CMAKE_SOURCE_DIR}/CMakeLists.txt
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openssl
)
add_custom_command(
OUTPUT
${CMAKE_BINARY_DIR}/openssl/libssl.a
${CMAKE_BINARY_DIR}/openssl/libcrypto.a
COMMAND make -j$(nproc)
DEPENDS ${CMAKE_BINARY_DIR}/openssl/configdata.pm
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openssl
)
add_custom_target(openssl DEPENDS ${CMAKE_BINARY_DIR}/openssl/libssl.a ${CMAKE_BINARY_DIR}/openssl/libcrypto.a)
target_link_libraries(xfer ${CMAKE_BINARY_DIR}/openssl/libssl.a ${CMAKE_BINARY_DIR}/openssl/libcrypto.a)
#elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
#elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
#elseif(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
#elseif(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
#elseif(CMAKE_SYSTEM_NAME STREQUAL DragonFly)
#elseif(CMAKE_SYSTEM_NAME STREQUAL SunOS)
#elseif(CMAKE_SYSTEM_NAME STREQUAL AIX)
#elseif(CMAKE_SYSTEM_NAME STREQUAL HP-UX)
#elseif(CMAKE_SYSTEM_NAME STREQUAL IRIX)
#elseif(CMAKE_SYSTEM_NAME STREQUAL OSF)
#elseif(CMAKE_SYSTEM_NAME STREQUAL SCO)
#else()
# panic("Unsupported platform")
endif()
add_dependencies(xfer openssl)
target_include_directories(xfer PUBLIC
${CMAKE_BINARY_DIR}/openssl/include
${CMAKE_SOURCE_DIR}/openssl/include
)
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
target_link_libraries(xfer ws2_32)
endif()
# TODO: For 32-bit systems
# This will only affect the build of xfer. Openssl must be configured through its perl script.
#set_target_properties(xfer PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")