Skip to content

Commit c60ca61

Browse files
committed
Add -ftime-trace and UNITY build support options
1 parent 2338ae4 commit c60ca61

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ include(cmake/StandardProjectSettings.cmake)
88
add_library(project_options INTERFACE)
99
target_compile_features(project_options INTERFACE cxx_std_17)
1010

11+
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
12+
option(ENABLE_BUILD_WITH_TIME_TRACE "Enable -ftime-trace to generate time tracing .json files on clang" OFF)
13+
if (ENABLE_BUILD_WITH_TIME_TRACE)
14+
add_compile_definitions(project_options INTERFACE -ftime-trace)
15+
endif()
16+
endif()
17+
1118
# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
1219
add_library(project_warnings INTERFACE)
1320

@@ -35,7 +42,7 @@ if (ENABLE_PCH)
3542
# This sets a global PCH parameter, each project will build its own PCH, which
3643
# is a good idea if any #define's change
3744
#
38-
#
45+
# consider breaking this out per project as necessary
3946
target_precompile_headers(project_options INTERFACE <vector> <string> <map> <utility>)
4047
endif()
4148

@@ -81,3 +88,12 @@ endif()
8188

8289

8390
add_subdirectory(src)
91+
92+
93+
option(ENABLE_UNITY "Enable Unity builds of projects" OFF)
94+
if (ENABLE_UNITY)
95+
# Add for any project you want to apply unity builds for
96+
set_target_properties(intro PROPERTIES UNITY_BUILD ON)
97+
endif()
98+
99+

cmake/StaticAnalyzers.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ if(ENABLE_CLANG_TIDY)
2222
endif()
2323

2424
if(ENABLE_INCLUDE_WHAT_YOU_USE)
25-
find_program(INCLUDEWHATYOUUSE include-what-you-use)
26-
if(INCLUDEWHATYOUUSE)
27-
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${INCLUDEWHATYOUUSE})
25+
find_program(INCLUDE_WHAT_YOU_USE include-what-you-use)
26+
if(INCLUDE_WHAT_YOU_USE)
27+
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${INCLUDE_WHAT_YOU_USE})
2828
else()
2929
message(SEND_ERROR "include-what-you-use requested but executable not found")
3030
endif()

0 commit comments

Comments
 (0)