diff --git a/CMLibCommonTargetProperties.cmake b/CMLibCommonTargetProperties.cmake index 592476a..f52d18c 100644 --- a/CMLibCommonTargetProperties.cmake +++ b/CMLibCommonTargetProperties.cmake @@ -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 $ @@ -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)