-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·94 lines (69 loc) · 2.56 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
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -stdlib=libc++") #enable if build with clang
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -std=c++20 -stdlib=libc++ -lc++abi") #enable if build with clang
cmake_minimum_required(VERSION 3.17)
project(project VERSION 1.0.0
DESCRIPTION project
LANGUAGES CXX
)
cmake_policy(SET CMP0015 NEW)
########## enable cache system
include(cmake/Cache.cmake)
########## link against the libs to apply the configurations to the target
# compiler warnings
set(PROJECT_WARNINGS project_warning)
add_library(${PROJECT_WARNINGS} INTERFACE)
include(cmake/CompilerWarnings.cmake)
set_project_warnings(${PROJECT_WARNINGS})
# compiler options
set(PROJECT_OPTIONS project_options)
add_library(${PROJECT_OPTIONS} INTERFACE)
target_compile_features(${PROJECT_OPTIONS} INTERFACE cxx_std_20)
# target_precompile_headers(${PROJECT_OPTIONS} INTERFACE
# )
# include(cmake/Sanitizers.cmake)
# enable_sanitizers(${PROJECT_OPTIONS})
# allow for static analysis options
#include(cmake/StaticAnalyzers.cmake)
######## conan setup
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
set(TARGET_NAME project)
add_executable(${TARGET_NAME})
# remove this if you want to use more threads
target_compile_definitions(${TARGET_NAME} PUBLIC BOOST_ASIO_DISABLE_THREADS)
######## add sub dir
add_subdirectory(src)
####### link
target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(${TARGET_NAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(${TARGET_NAME} PRIVATE
${PROJECT_WARNINGS}
${PROJECT_OPTIONS}
CONAN_PKG::imgui-sfml
CONAN_PKG::boost
)
####### create executable
OPTION(BUILD_TESTS "enable tests" OFF)
IF(BUILD_TESTS)
enable_testing()
add_subdirectory(test)
ENDIF(BUILD_TESTS)
# add main after add_subdirectory(test) so we can take the sources from ${TARGET_NAME} and dont have to remove main.cxx from that list
target_sources(${TARGET_NAME} PRIVATE
"main.cxx"
)
if (CMAKE_BINARY_DIR)
target_compile_definitions(${TARGET_NAME} PRIVATE PATH_TO_BINARY="${CMAKE_BINARY_DIR}")
endif()
####### include what you use
#find_program(iwyu_path NAMES include-what-you-use iwyu)
#set_property(TARGET ${TARGET_NAME} PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})
#print all variables used in cmake
# get_cmake_property(_variableNames VARIABLES)
# list (SORT _variableNames)
# foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
# endforeach()