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

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