-
-
Notifications
You must be signed in to change notification settings - Fork 567
/
Copy pathCMakeLists.txt
65 lines (50 loc) · 1.61 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
cmake_minimum_required(VERSION 3.10)
project(co)
if(MSVC)
enable_language(C CXX ASM_MASM)
else()
enable_language(C CXX ASM)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/bin)
if(MSVC)
add_compile_options(/W4 /fp:fast /EHsc)
add_link_options(/SAFESEH:NO)
else()
add_compile_options(-Wall -O2 -g -Wno-sign-compare -Wno-class-memaccess -Wno-strict-aliasing)
if(APPLE)
add_compile_options(-fno-pie)
endif()
endif()
# build with libcurl (openssl & zlib also required)
option(WITH_LIBCURL "build with libcurl" OFF)
# build with openssl 1.1.0+
option(WITH_OPENSSL "build with openssl" OFF)
# build with -fPIC
option(FPIC "build with -fPIC" OFF)
# build all projects (libco, gen, test, unitest)
option(BUILD_ALL "Build all projects" OFF)
# vs runtime, use MT
if(MSVC)
option(STATIC_VS_CRT "use /MT or /MTd" ON)
if(STATIC_VS_CRT)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif()
endif()
include_directories(include)
add_subdirectory(src)
if(BUILD_ALL)
add_subdirectory(gen)
add_subdirectory(unitest)
add_subdirectory(test)
endif()
install(
DIRECTORY include/co
DESTINATION include
)