|
1 | | -cmake_minimum_required(VERSION 3.15) |
| 1 | +CMAKE_MINIMUM_REQUIRED(VERSION 3.15) |
2 | 2 |
|
3 | 3 | # Set the project name to your project name, my project isn't very descriptive |
4 | | -project(myproject CXX) |
5 | | -include(cmake/StandardProjectSettings.cmake) |
6 | | -include(cmake/PreventInSourceBuilds.cmake) |
| 4 | +PROJECT(myproject CXX) |
| 5 | +INCLUDE(cmake/StandardProjectSettings.cmake) |
| 6 | +INCLUDE(cmake/PreventInSourceBuilds.cmake) |
7 | 7 |
|
8 | | -include(cmake/CodeFormat.cmake) |
| 8 | +INCLUDE(cmake/CodeFormat.cmake) |
9 | 9 |
|
10 | 10 | # Link this 'library' to set the c++ standard / compile-time options requested |
11 | | -add_library(project_options INTERFACE) |
12 | | -target_compile_features(project_options INTERFACE cxx_std_17) |
| 11 | +ADD_LIBRARY(project_options INTERFACE) |
| 12 | +TARGET_COMPILE_FEATURES(project_options INTERFACE cxx_std_17) |
13 | 13 |
|
14 | | -if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") |
15 | | - option(ENABLE_BUILD_WITH_TIME_TRACE "Enable -ftime-trace to generate time tracing .json files on clang" OFF) |
16 | | - if(ENABLE_BUILD_WITH_TIME_TRACE) |
17 | | - target_compile_options(project_options INTERFACE -ftime-trace) |
18 | | - endif() |
19 | | -endif() |
| 14 | +IF(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") |
| 15 | + OPTION(ENABLE_BUILD_WITH_TIME_TRACE "Enable -ftime-trace to generate time tracing .json files on clang" OFF) |
| 16 | + IF(ENABLE_BUILD_WITH_TIME_TRACE) |
| 17 | + TARGET_COMPILE_OPTIONS(project_options INTERFACE -ftime-trace) |
| 18 | + ENDIF() |
| 19 | +ENDIF() |
20 | 20 |
|
21 | 21 | # Link this 'library' to use the warnings specified in CompilerWarnings.cmake |
22 | | -add_library(project_warnings INTERFACE) |
| 22 | +ADD_LIBRARY(project_warnings INTERFACE) |
23 | 23 |
|
24 | 24 | # enable cache system |
25 | | -include(cmake/Cache.cmake) |
| 25 | +INCLUDE(cmake/Cache.cmake) |
26 | 26 |
|
27 | 27 | # standard compiler warnings |
28 | | -include(cmake/CompilerWarnings.cmake) |
29 | | -set_project_warnings(project_warnings) |
| 28 | +INCLUDE(cmake/CompilerWarnings.cmake) |
| 29 | +SET_PROJECT_WARNINGS(project_warnings) |
30 | 30 |
|
31 | 31 | # sanitizer options if supported by compiler |
32 | | -include(cmake/Sanitizers.cmake) |
33 | | -enable_sanitizers(project_options) |
| 32 | +INCLUDE(cmake/Sanitizers.cmake) |
| 33 | +ENABLE_SANITIZERS(project_options) |
34 | 34 |
|
35 | 35 | # enable doxygen |
36 | | -include(cmake/Doxygen.cmake) |
37 | | -enable_doxygen() |
| 36 | +INCLUDE(cmake/Doxygen.cmake) |
| 37 | +ENABLE_DOXYGEN() |
38 | 38 |
|
39 | 39 | # allow for static analysis options |
40 | | -include(cmake/StaticAnalyzers.cmake) |
| 40 | +INCLUDE(cmake/StaticAnalyzers.cmake) |
41 | 41 |
|
42 | | -option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF) |
43 | | -option(ENABLE_TESTING "Enable Test Builds" ON) |
44 | | -option(ENABLE_FUZZING "Enable Fuzzing Builds" OFF) |
| 42 | +OPTION(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF) |
| 43 | +OPTION(ENABLE_TESTING "Enable Test Builds" ON) |
| 44 | +OPTION(ENABLE_FUZZING "Enable Fuzzing Builds" OFF) |
45 | 45 |
|
46 | 46 | # Very basic PCH example |
47 | | -option(ENABLE_PCH "Enable Precompiled Headers" OFF) |
48 | | -if(ENABLE_PCH) |
49 | | - # This sets a global PCH parameter, each project will build its own PCH, which is a good idea if any #define's change |
50 | | - # |
51 | | - # consider breaking this out per project as necessary |
52 | | - target_precompile_headers( |
53 | | - project_options |
54 | | - INTERFACE |
55 | | - <vector> |
56 | | - <string> |
57 | | - <map> |
58 | | - <utility>) |
59 | | -endif() |
| 47 | +OPTION(ENABLE_PCH "Enable Precompiled Headers" OFF) |
| 48 | +IF(ENABLE_PCH) |
| 49 | + # This sets a global PCH parameter, each project will build its own PCH, which is a good idea if any #define's change |
| 50 | + # |
| 51 | + # consider breaking this out per project as necessary |
| 52 | + TARGET_PRECOMPILE_HEADERS( |
| 53 | + project_options |
| 54 | + INTERFACE |
| 55 | + <vector> |
| 56 | + <string> |
| 57 | + <map> |
| 58 | + <utility>) |
| 59 | +ENDIF() |
60 | 60 |
|
61 | 61 | # Set up some extra Conan dependencies based on our needs before loading Conan |
62 | | -set(CONAN_EXTRA_REQUIRES "") |
63 | | -set(CONAN_EXTRA_OPTIONS "") |
| 62 | +SET(CONAN_EXTRA_REQUIRES "") |
| 63 | +SET(CONAN_EXTRA_OPTIONS "") |
64 | 64 |
|
65 | | -include(cmake/Conan.cmake) |
66 | | -run_conan() |
| 65 | +INCLUDE(cmake/Conan.cmake) |
| 66 | +RUN_CONAN() |
67 | 67 |
|
68 | | -if(ENABLE_TESTING) |
69 | | - enable_testing() |
70 | | - message("Building Tests. Be sure to check out test/constexpr_tests for constexpr testing") |
71 | | - add_subdirectory(test) |
72 | | -endif() |
| 68 | +IF(ENABLE_TESTING) |
| 69 | + ENABLE_TESTING() |
| 70 | + MESSAGE("Building Tests. Be sure to check out test/constexpr_tests for constexpr testing") |
| 71 | + ADD_SUBDIRECTORY(test) |
| 72 | +ENDIF() |
73 | 73 |
|
74 | | -if(ENABLE_FUZZING) |
75 | | - message("Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html") |
76 | | - add_subdirectory(fuzz_test) |
77 | | -endif() |
78 | | - |
79 | | -add_subdirectory(src) |
| 74 | +IF(ENABLE_FUZZING) |
| 75 | + MESSAGE("Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html") |
| 76 | + ADD_SUBDIRECTORY(fuzz_test) |
| 77 | +ENDIF() |
80 | 78 |
|
| 79 | +ADD_SUBDIRECTORY(src) |
0 commit comments