From 26e50c5a03b50846a5b741ddf0b7c4eb6bb103a4 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Thu, 7 Apr 2022 12:27:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20my?= =?UTF-8?q?x=5Fcmake=5Fqt=5Fautogen=5Ftarget=5Fproperties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- .../MyxCMakeCommonTargetProperties.cmake | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 533298a..6630af1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.0) -project(myx-cmake VERSION 0.5.1 LANGUAGES) +project(myx-cmake VERSION 0.5.2 LANGUAGES) include(GNUInstallDirs) file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake diff --git a/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake b/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake index 43df47a..eae8a71 100644 --- a/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake +++ b/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake @@ -175,3 +175,32 @@ function(myx_cmake_common_target_properties_post_link target) endif() 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() +