-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
67 lines (59 loc) · 1.97 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
cmake_minimum_required(VERSION 3.12)
enable_testing()
project(future_demo)
# link libraries
set(LINK_LIBRARIES
gtest
)
# boost
find_package(Boost 1.71.0 REQUIRED COMPONENTS system thread)
message("Boost ${Boost_FOUND} version:${Boost_VERSION}.")
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
add_definitions(
-DBOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
-DBOOST_THREAD_PROVIDES_EXECUTORS
-DBOOST_THREAD_USES_MOVE)
#language standard
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_STANDARD 17)
message("using C++17 standard...")
else()
set(CMAKE_CXX_STANDARD 11)
message("using C++11 standard...")
endif()
# 3rd party
OPTION(COMPILE_WITH_3RD_PARTY "Compile with 3rd party libraries." OFF)
if(COMPILE_WITH_3RD_PARTY)
message("using 3rd party libraries...")
add_subdirectory(3rd_party/googletest)
add_subdirectory(3rd_party/abseil-cpp)
list(APPEND LINK_LIBRARIES absl::flat_hash_map)
else()
include_directories(
/usr/local/include
)
link_directories(
/usr/local/lib
)
list(APPEND LINK_LIBRARIES -labsl_bad_variant_access)
endif()
######## compiler options #######
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
else()
list(APPEND LINK_LIBRARIES pthread)
if(CMAKE_COMPILE_IS_GUNCXX)
set(CMAKE_CXX_FLAGS "--coverage")
elseif(CMAKE_GENERATOR STREQUAL Xcode)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
else()
set(CMAKE_CXX_FLAGS "-fprofile-instr-generate -fcoverage-mapping")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
################################
include_directories(${CMAKE_SOURCE_DIR})
add_executable(${PROJECT_NAME} tests/future_test.cc)
target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARIES} ${Boost_LIBRARIES})