-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
92 lines (73 loc) · 2.93 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
cmake_minimum_required( VERSION 3.12...3.12 )
if( ${CMAKE_VERSION} VERSION_LESS 3.12 )
cmake_policy( VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} )
endif()
project(
base-util-driver
VERSION 1.0
DESCRIPTION "C++ Base [Utilities]"
LANGUAGES CXX
)
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )
# === ccache ======================================================
find_program( CCACHE_PROGRAM ccache )
if( CCACHE_PROGRAM )
set( CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" )
#message( STATUS "ccache found: ${CCACHE_PROGRAM}" )
else()
message( STATUS "ccache not found." )
endif()
set( THREADS_PREFER_PTHREAD_FLAG ON )
find_package( Threads REQUIRED )
# === build type ==================================================
set( default_build_type "Debug" )
if( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
message( STATUS "Setting build type to '${default_build_type}'." )
set( CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE )
# Set the possible values of build type for cmake-gui
set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "RelWithDebInfo")
endif()
message( STATUS "Build type: ${CMAKE_BUILD_TYPE}" )
# === subdirectories ==============================================
add_subdirectory( src )
add_subdirectory( app )
add_subdirectory( test )
# === external dependencies =======================================
# We don't want this variable set when we import the externs be-
# cause it will cause trouble; it may be enabled from the pre-
# vious CMake run because we do enable tests us.
set( BUILD_TESTING OFF )
# ... add_subdirectory's here...
set( BUILD_TESTING ON ) # Catch2 will actually do this as well.
add_subdirectory( extern/Catch2 EXCLUDE_FROM_ALL )
# === custom targets ==============================================
# Should also automatically add a dependency on the binary.
add_custom_target( run
COMMAND main
WORKING_DIRECTORY ../
USES_TERMINAL )
add_custom_target( test
COMMAND run-tests
WORKING_DIRECTORY ../../
USES_TERMINAL )
# === clang-tools =================================================
if( USE_CLANG_TIDY )
find_program( CLANG_TIDY_EXE NAMES "clang-tidy" )
if( NOT CLANG_TIDY_EXE )
message( FATAL_ERROR "clang-tidy not found." )
endif()
set( DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-quiet" )
set_target_properties( base-util PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}" )
endif()
if( USE_IWYU )
find_program( IWYU_EXE NAMES "include-what-you-use" )
if( NOT IWYU_EXE )
message( FATAL_ERROR "include-what-you-use requested, but not found." )
endif()
get_filename_component( REAL_IWYU_EXE "${IWYU_EXE}" REALPATH )
set_target_properties( base-util PROPERTIES
CXX_INCLUDE_WHAT_YOU_USE "${REAL_IWYU_EXE}" )
endif()