2019-02-16 10:10:12 +00:00
|
|
|
set(COMMON_CXX_FEATURES cxx_alias_templates cxx_nullptr cxx_override)
|
2019-02-12 16:31:17 +00:00
|
|
|
|
|
|
|
function(common_target_properties Name)
|
|
|
|
get_target_property(__type ${Name} TYPE)
|
|
|
|
set(__visibility PUBLIC)
|
|
|
|
if(__type STREQUAL INTERFACE_LIBRARY)
|
|
|
|
set(__interface 1)
|
|
|
|
set(__visibility INTERFACE)
|
|
|
|
endif()
|
|
|
|
target_compile_features(${Name} ${__visibility} ${COMMON_CXX_FEATURES})
|
2019-02-21 10:42:38 +00:00
|
|
|
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()
|
2019-02-16 10:10:12 +00:00
|
|
|
target_include_directories(
|
|
|
|
${Name}
|
|
|
|
PUBLIC $<INSTALL_INTERFACE:include>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
|
2019-02-12 16:31:17 +00:00
|
|
|
if(APPLE)
|
|
|
|
target_compile_definitions(${Name} ${__visibility} Darwin)
|
|
|
|
endif()
|
|
|
|
if(NOT __interface)
|
|
|
|
if(TARGET Qt5::Core)
|
2019-02-21 10:42:38 +00:00
|
|
|
if (_targetType STREQUAL "EXECUTABLE")
|
|
|
|
target_compile_options(${Name} PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
|
|
|
|
endif()
|
2019-02-12 16:31:17 +00:00
|
|
|
set_target_properties(${Name} PROPERTIES AUTOMOC TRUE AUTORCC TRUE)
|
|
|
|
endif()
|
|
|
|
if(TARGET Qt5::Widgets)
|
|
|
|
set_target_properties(${Name} PROPERTIES AUTOUIC TRUE)
|
2019-05-31 12:15:52 +00:00
|
|
|
# if(CMAKE_VERSION VERSION_LESS 3.7.99)
|
|
|
|
# target_include_directories(
|
|
|
|
# ${Name}
|
|
|
|
# PUBLIC
|
|
|
|
# $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${Name}_autogen/include>
|
|
|
|
# )
|
|
|
|
# endif()
|
2019-02-12 16:31:17 +00:00
|
|
|
endif()
|
|
|
|
if(CMAKE_CXX_COMPILER_IS_GCC AND NOT APPLE)
|
|
|
|
set_target_properties(${Name} PROPERTIES LINK_FLAGS "-Wl,--no-as-needed")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endfunction()
|
|
|
|
|