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