forked from owent/libcopp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
55 lines (44 loc) · 2.1 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
cmake_minimum_required(VERSION 3.3.0)
project(libcopp)
########################################################################
# CMake 模块 (递归包含模块, 带颜色输出模块, 平台检测模块)
set (PROJECT_CMAKE_MODULE_DIR "${CMAKE_CURRENT_LIST_DIR}/project/cmake")
include("${PROJECT_CMAKE_MODULE_DIR}/ProjectBuildOption.cmake")
include("${PROJECT_CMAKE_MODULE_DIR}/IncludeDirectoryRecurse.cmake")
include("${PROJECT_CMAKE_MODULE_DIR}/EchoWithColor.cmake")
include("${PROJECT_CMAKE_MODULE_DIR}/FindPlatform.cmake")
include("${PROJECT_CMAKE_MODULE_DIR}/ProjectTools.cmake")
#####################################################################
# 导入编译器和编译选项配置
include("${PROJECT_CMAKE_MODULE_DIR}/CompilerOption.cmake")
include("${PROJECT_CMAKE_MODULE_DIR}/TargetOption.cmake")
EchoWithColor(COLOR GREEN "-- Build Type: ${CMAKE_BUILD_TYPE}")
########################################################################
# 导入项目配置
## 导入所有 macro 定义
include_macro_recurse(${CMAKE_CURRENT_LIST_DIR})
# feature detect
include(WriteCompilerDetectionHeader)
if (NOT EXISTS "${PROJECT_ROOT_INC_DIR}/libcopp/utils/config")
file(MAKE_DIRECTORY "${PROJECT_ROOT_INC_DIR}/libcopp/utils/config")
endif()
# generate check header
write_compiler_detection_header(
FILE "${PROJECT_ROOT_INC_DIR}/libcopp/utils/config/compiler_features.h"
PREFIX UTIL_CONFIG
COMPILERS GNU Clang AppleClang MSVC
FEATURES cxx_auto_type cxx_constexpr cxx_decltype cxx_decltype_auto cxx_defaulted_functions cxx_deleted_functions cxx_final cxx_override cxx_range_for cxx_noexcept cxx_nullptr cxx_rvalue_references cxx_static_assert cxx_thread_local cxx_variadic_templates cxx_lambdas
)
configure_file(
"${PROJECT_ROOT_INC_DIR}/libcopp/utils/config/build_feature.h.in"
"${PROJECT_ROOT_INC_DIR}/libcopp/utils/config/build_feature.h"
@ONLY
)
## 导入所有工程项目
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/src")
if(PROJECT_ENABLE_SAMPLE)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/sample")
endif()
if(PROJECT_ENABLE_UNITTEST)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/test")
endif()