Добавлена функция myx_cmake_common_target_properties_post

This commit is contained in:
Andrei Astafev 2021-12-21 12:50:01 +03:00
parent de837bf115
commit ea38edfdc4

View File

@ -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()