Позиционно-независимый код для приложений

This commit is contained in:
Andrei Astafev 2019-02-21 13:42:38 +03:00
parent 489f0cce72
commit 428dc84cfd

View File

@ -8,6 +8,10 @@ function(common_target_properties Name)
set(__visibility INTERFACE)
endif()
target_compile_features(${Name} ${__visibility} ${COMMON_CXX_FEATURES})
get_target_property(_targetType ${Name} TYPE)
if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_CXX_COMPILE_OPTIONS_PIE)
target_compile_options(${Name} PUBLIC "${CMAKE_CXX_COMPILE_OPTIONS_PIE}")
endif()
target_include_directories(
${Name}
PUBLIC $<INSTALL_INTERFACE:include>
@ -19,8 +23,9 @@ function(common_target_properties Name)
endif()
if(NOT __interface)
if(TARGET Qt5::Core)
target_compile_options(${Name}
PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
if (_targetType STREQUAL "EXECUTABLE")
target_compile_options(${Name} PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
endif()
set_target_properties(${Name} PROPERTIES AUTOMOC TRUE AUTORCC TRUE)
endif()
if(TARGET Qt5::Widgets)