Skip to content

Instantly share code, notes, and snippets.

@Trass3r
Created April 23, 2024 11:06
Show Gist options
  • Save Trass3r/56eabcd6eda6fb23d65507926174ae7f to your computer and use it in GitHub Desktop.
Save Trass3r/56eabcd6eda6fb23d65507926174ae7f to your computer and use it in GitHub Desktop.
PCH
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOGEN_ORIGIN_DEPENDS OFF)
set(CMAKE_GLOBAL_AUTOGEN_TARGET ON)
set(CMAKE_UNITY_BUILD OFF CACHE BOOL "")
set(CMAKE_UNITY_BUILD_BATCH_SIZE 4)
add_compile_options("$<$<CONFIG:Debug>:-Og;-fno-omit-frame-pointer>" -fvisibility-inlines-hidden) # -ftime-trace) # ;-gsplit-dwarf
link_libraries(debug -Wl,--gdb-index)
link_libraries(debug -Wl,--gc-sections)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
target_compile_definitions(${TARGET} PRIVATE CATCH_CONFIG_FAST_COMPILE=1)
target_compile_options(${TARGET} PRIVATE -O0)
if(0)
file(TOUCH ${CMAKE_BINARY_DIR}/pch_obj.cpp)
add_library(${TARGET}_pch STATIC ${CMAKE_BINARY_DIR}/pch_obj.cpp)
target_compile_options(${TARGET}_pch PRIVATE -fpch-instantiate-templates)
target_compile_options(${TARGET}_pch PRIVATE -fpch-codegen $<$<CONFIG:Debug>:-fpch-debuginfo>)
target_precompile_headers(${TARGET}_pch PRIVATE <QSignalSpy> <NLogging> <catch2/catch.hpp> <trompeloeil.hpp> <msc/types/Enum.h> <set>) # set comes from DetectionFeatures
target_compile_options(${TARGET}_pch PRIVATE -ffunction-sections -fdata-sections)
target_link_libraries(${TARGET}_pch INTERFACE -Wl,--gc-sections)
target_precompile_headers(${TARGET} REUSE_FROM ${TARGET}_pch)
target_link_libraries(${TARGET} PRIVATE ${TARGET}_pch)
else()
target_compile_options(${TARGET} PRIVATE -fpch-instantiate-templates)
target_precompile_headers(${TARGET} PRIVATE <QSignalSpy> <NLogging> <catch2/catch.hpp> <trompeloeil.hpp> <msc/types/Enum.h> <set>) # set comes from DetectionFeatures
endif()
#target_compile_options(${TARGET} PRIVATE -ftime-trace)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment