File tree Expand file tree Collapse file tree 4 files changed +22
-53
lines changed
Expand file tree Collapse file tree 4 files changed +22
-53
lines changed Original file line number Diff line number Diff line change 1+ @PACKAGE_INIT@
2+
3+ include ("${CMAKE_CURRENT_LIST_DIR} /${PROJECT_NAME} Targets.cmake" )
Original file line number Diff line number Diff line change 1- # Link Time Optimization (LTO)
2- add_library (lto INTERFACE )
3-
4- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" )
5- target_compile_options (lto INTERFACE -flto)
6- target_link_options (lto INTERFACE -flto)
7- else ()
8- message (WARNING "LTO not configured for compiler: ${CMAKE_CXX_COMPILER_ID} " )
9- endif ()
10-
11- # Function to apply lto
121function (enable_lto target )
132 if (CMAKE_INTERPROCEDURAL_OPTIMIZATION)
14- target_link_libraries ( ${target} PRIVATE lto )
15- message (STATUS "✅ Enabled LTO for target: ${target} " )
3+ set_property ( TARGET ${target} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE )
4+ message (STATUS "🔧 \t Enabled LTO for target ${target} " )
165 endif ()
176endfunction ()
Original file line number Diff line number Diff line change 1- # Enable AddressSanitizer + UndefinedBehaviorSanitizer only for "Sanitize" build type
21if (CMAKE_BUILD_TYPE STREQUAL "Sanitize" )
32 set (SANITIZER_FLAGS
43 -fsanitize=address
54 -fsanitize=undefined
65 -O1
76 -g
87 )
9-
10- add_library (sanitizers INTERFACE )
11- target_compile_options (sanitizers INTERFACE ${SANITIZER_FLAGS} )
12- target_link_options (sanitizers INTERFACE ${SANITIZER_FLAGS} )
13- message (STATUS "✅ Sanitize build enabled with flags: ${SANITIZER_FLAGS} " )
8+ message (STATUS "✅\t Sanitize build enabled with flags: ${SANITIZER_FLAGS} " )
149endif ()
1510
1611function (enable_sanitizers target )
17- if (TARGET sanitizers )
18- target_link_libraries (${target} PRIVATE sanitizers )
19- message (STATUS "✅ Enabled sanitizers for target ${target} " )
12+ if (CMAKE_BUILD_TYPE STREQUAL "Sanitize" )
13+ target_compile_options (${target} PRIVATE ${SANITIZER_FLAGS} )
14+ message (STATUS "✅\t Enabled sanitizers for target ${target} " )
2015 endif ()
2116endfunction ()
Original file line number Diff line number Diff line change 1- # Standard warnings
2- add_library (warnings INTERFACE )
3-
4- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" )
5- target_compile_options (warnings INTERFACE
6- -Wall
7- -Wextra
8- -Wpedantic
9- -Wconversion
10- -Wsign-conversion
11- )
12- else ()
13- message (WARNING "Warnings not configured for compiler: ${CMAKE_CXX_COMPILER_ID} " )
14- endif ()
15-
16- # Warnings as errors
17- add_library (strict_warnings INTERFACE )
18-
19- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" )
20- target_compile_options (strict_warnings INTERFACE -Werror)
21- target_link_libraries (strict_warnings INTERFACE warnings)
22- else ()
23- message (WARNING "Strict warnings not configured for compiler: ${CMAKE_CXX_COMPILER_ID} " )
24- endif ()
25-
26- # Function to apply warnings
271function (enable_warnings target )
28- target_link_libraries (${target} PRIVATE warnings)
29- message (STATUS "⚠️ Enabled warnings for target ${target} " )
2+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" )
3+ target_compile_options (${target} PRIVATE
4+ -Wall
5+ -Wextra
6+ -Wpedantic
7+ -Wconversion
8+ -Wsign-conversion
9+ )
10+ message (STATUS "⚠️\t Enabled warnings for target ${target} " )
11+ endif ()
3012endfunction ()
3113
32- # Function to apply warnings as errors (aka strict warnings)
3314function (enable_strict_warnings target )
34- target_link_libraries (${target} PRIVATE strict_warnings)
35- message (STATUS "⚠️ Enabled warnings as errors for target ${target} " )
15+ enable_warnings(${target} )
16+ target_compile_options (${target} PRIVATE -Werror)
17+ message (STATUS "🚨\t Warnings treated as errors for target ${target} " )
3618endfunction ()
You can’t perform that action at this time.
0 commit comments