diff --git a/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake b/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake index 631b98d..3315a2a 100644 --- a/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake +++ b/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake @@ -61,9 +61,6 @@ function(myx_cmake_common_target_properties target) if(CMAKE_CXX_COMPILE_OPTIONS_PIE) target_compile_options(${target} PUBLIC ${CMAKE_CXX_COMPILE_OPTIONS_PIE}) endif() - if(CMAKE_CXX_COMPILER_IS_GCC AND MYX_CMAKE_CODE_COVERAGE) - myx_cmake_code_coverage(${target}) - endif() install(TARGETS ${target} COMPONENT main RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() @@ -102,15 +99,6 @@ function(myx_cmake_common_target_properties target) endif() endif() - # cmake-format: off - if(COMMAND cotire) - set_property(TARGET ${target} - PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER ${MYX_CMAKE_PRECOMPILED_HEADERS}) - set_property(TARGET ${target} - PROPERTY COTIRE_ADD_UNITY_BUILD ${MYX_CMAKE_UNITY_BUILD}) - endif() - # cmake-format: on - if(CMAKE_BUILD_TYPE STREQUAL Profile) target_compile_definitions(${target} ${__visibility} PROFILE) elseif(CMAKE_BUILD_TYPE STREQUAL Debug) @@ -164,3 +152,28 @@ function(myx_cmake_common_target_properties target) add_dependencies(${target} myx-cmake-symlinks-to-project-directories) endif() endfunction() + +function(myx_cmake_common_target_properties_post target) + if(NOT TARGET ${target}) + message(FATAL_ERROR "MyxCMake: Target ${target} does not exists.") + return() + endif() + get_target_property(_target_type ${target} TYPE) + + # cmake-format: off + if(COMMAND cotire) + set_property(TARGET ${target} + PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER ${MYX_CMAKE_PRECOMPILED_HEADERS}) + set_property(TARGET ${target} + PROPERTY COTIRE_ADD_UNITY_BUILD ${MYX_CMAKE_UNITY_BUILD}) + endif() + # cmake-format: on + + if(NOT _target_type STREQUAL INTERFACE_LIBRARY) + if(CMAKE_CXX_COMPILER_IS_GCC AND MYX_CMAKE_CODE_COVERAGE) + myx_cmake_code_coverage(${target}) + endif() + add_sanitizers(${target}) + endif() +endfunction() +