Функция myx_cmake_qt_autogen_target_properties

This commit is contained in:
Andrei Astafev 2022-04-07 12:27:02 +03:00
parent c0ee1985f8
commit 26e50c5a03
2 changed files with 30 additions and 1 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(myx-cmake VERSION 0.5.1 LANGUAGES) project(myx-cmake VERSION 0.5.2 LANGUAGES)
include(GNUInstallDirs) include(GNUInstallDirs)
file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake

View File

@ -175,3 +175,32 @@ function(myx_cmake_common_target_properties_post_link target)
endif() endif()
endfunction() endfunction()
function(myx_cmake_qt_autogen_target_properties target)
if(NOT TARGET ${target})
myx_cmake_message_error("MyxCMake: Target ${target} does not exists.")
endif()
get_target_property(_target_type ${target} TYPE)
if(NOT _target_type STREQUAL OBJECT_LIBRARY)
myx_cmake_message_error("MyxCMake: Target ${target} must have type OBJECT ${_target_type}.")
endif()
myx_cmake_common_target_properties(${target})
get_target_property(__sources ${target} SOURCES)
foreach(src IN LISTS __sources)
string(REGEX MATCH ".*/ui_.*\\.h$" __ui ${src})
if(__ui)
target_include_directories(${target} SYSTEM PUBLIC ${Qt5Widgets_INCLUDE_DIRS})
endif()
endforeach()
foreach(src IN LISTS __sources)
string(REGEX MATCH ".*/moc_.*\\.cpp$" __moc ${src})
if(__moc)
target_include_directories(${target} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
endif()
endforeach()
set_target_properties(${target} PROPERTIES CXX_CLANG_TIDY "")
endfunction()