-
-
Notifications
You must be signed in to change notification settings - Fork 567
/
Copy pathCMakeLists.txt
116 lines (105 loc) · 3.49 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
file(GLOB_RECURSE CC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
if(BUILD_SHARED_LIBS)
set(LIBKIND SHARED)
else()
set(LIBKIND STATIC)
endif()
# source files
if(WIN32)
set(ASM_FILES co/context/context_x64.asm)
if(MSVC)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ASM_FILES co/context/context_x86.asm)
endif()
set_property(SOURCE ${ASM_FILES} PROPERTY LANGUAGE ASM_MASM)
else()
set(ASM_FILES co/context/context.S)
endif()
add_library(co ${LIBKIND}
${CC_FILES}
${ASM_FILES}
log/StackWalker.cpp
co/detours/creatwth.cpp
co/detours/detours.cpp
co/detours/image.cpp
co/detours/modules.cpp
co/detours/disasm.cpp
)
else()
add_library(co ${LIBKIND}
${CC_FILES}
co/context/context.S
)
endif()
if(WITH_LIBCURL)
find_package(OpenSSL 1.1.0 REQUIRED)
find_package(ZLIB REQUIRED)
find_package(CURL REQUIRED)
if(CURL_FOUND)
message(STATUS "found openssl, include: ${OPENSSL_INCLUDE_DIR}, lib: ${OPENSSL_LIBRARIES}")
message(STATUS "found zlib ${ZLIB_VERSION_STRING}, include: ${ZLIB_INCLUDE_DIR}, lib: ${ZLIB_LIBRARIES}")
message(STATUS "found libcurl ${CURL_VERSION_STRING}, include: ${CURL_INCLUDE_DIR}, lib: ${CURL_LIBRARIES}")
target_compile_definitions(co PRIVATE HAS_OPENSSL)
target_compile_definitions(co PRIVATE HAS_LIBCURL)
target_include_directories(co PRIVATE ${CURL_INCLUDE_DIR})
target_include_directories(co PRIVATE ${OPENSSL_INCLUDE_DIR})
target_include_directories(co PRIVATE ${ZLIB_INCLUDE_DIR})
target_link_libraries(co PRIVATE ${CURL_LIBRARIES})
target_link_libraries(co PRIVATE ${ZLIB_LIBRARIES})
target_link_libraries(co PRIVATE ${OPENSSL_LIBRARIES})
endif()
elseif(WITH_OPENSSL)
find_package(OpenSSL 1.1.0 REQUIRED)
if(OPENSSL_FOUND)
message(STATUS "found openssl, include: ${OPENSSL_INCLUDE_DIR}, lib: ${OPENSSL_LIBRARIES}")
target_compile_definitions(co PRIVATE HAS_OPENSSL)
target_include_directories(co PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(co PRIVATE ${OPENSSL_LIBRARIES})
endif()
endif()
if(FPIC)
if(NOT MSVC)
target_compile_options(co PRIVATE -fPIC)
endif()
endif()
if(WIN32)
if(MSVC)
if(BUILD_SHARED_LIBS)
target_compile_definitions(co PRIVATE BUILDING_CO_DLL)
set(USING_CO_DLL 1)
else()
set(USING_CO_DLL 0)
endif()
configure_file(
"${PROJECT_SOURCE_DIR}/include/co/config.h.in"
"${PROJECT_SOURCE_DIR}/include/co/config.h"
)
endif()
target_compile_definitions(co PRIVATE WIN32_LEAN_AND_MEAN)
target_compile_definitions(co PRIVATE _WINSOCK_DEPRECATED_NO_WARNINGS)
if(NOT MSVC)
target_link_libraries(co PUBLIC ws2_32)
endif()
else()
include(CheckIncludeFiles)
include(CheckIncludeFileCXX)
check_include_files(backtrace.h HAS_BACKTRACE)
check_include_file_cxx(cxxabi.h HAS_CXXABI)
if(HAS_BACKTRACE)
target_compile_definitions(co PRIVATE HAS_BACKTRACE_H)
target_link_libraries(co PUBLIC backtrace)
endif()
if(HAS_CXXABI)
target_compile_definitions(co PRIVATE HAS_CXXABI_H)
endif()
if(NOT ANDROID)
target_link_libraries(co PUBLIC pthread)
target_link_libraries(co PRIVATE dl)
endif()
endif()
install(
TARGETS co
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)