diff options
author | Brad King <brad.king@kitware.com> | 2020-12-17 18:22:28 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-12-17 18:22:40 (GMT) |
commit | 6d7621baeaaf4e19322480484b33f9ca95e6c75e (patch) | |
tree | b2edc5d55d789617f7378ce2d6efe330845effe9 /Tests | |
parent | 215bd0e72b48b2fb2b8e62a53765a60064d7b4b0 (diff) | |
parent | 20e4db4a6671ef2c39863d08fc5513848c1a07b6 (diff) | |
download | CMake-6d7621baeaaf4e19322480484b33f9ca95e6c75e.zip CMake-6d7621baeaaf4e19322480484b33f9ca95e6c75e.tar.gz CMake-6d7621baeaaf4e19322480484b33f9ca95e6c75e.tar.bz2 |
Merge topic 'qt-autogen-per-config'
20e4db4a66 cmGeneratorTarget: Make GetConfigCommonSourceFiles Xcode-specific
92d7b456e5 Autogen: Add support for per-config sources
3ffebbaefb Tests/QtAutogen: Forward build configuration in multi-config generators
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5624
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt | 13 | ||||
-rw-r--r-- | Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt | 8 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/CMakeLists.txt | 12 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/CfgDebug.cpp | 5 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/CfgDebug.hpp | 15 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/CfgOther.cpp | 5 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/CfgOther.hpp | 15 | ||||
-rw-r--r-- | Tests/QtAutogen/MocOnly/main.cpp | 8 | ||||
-rw-r--r-- | Tests/QtAutogen/TestMacros.cmake | 10 | ||||
-rw-r--r-- | Tests/RunCMake/NinjaMultiConfig/Qt5.cmake | 3 |
10 files changed, 86 insertions, 8 deletions
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt b/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt index d9fc2b0..17855ff 100644 --- a/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt +++ b/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt @@ -2,6 +2,15 @@ cmake_minimum_required(VERSION 3.11) project(AutogenOriginDependsOff) include("../AutogenCoreTest.cmake") +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +# XXX(xcode-per-cfg-src): Enable multi-config code path for Xcode +# when the Xcode generator supports per-config sources. +if(_isMultiConfig AND NOT CMAKE_GENERATOR STREQUAL "Xcode") + set(mocs_compilation_cpp "mocs_compilation_$<CONFIG>.cpp") +else() + set(mocs_compilation_cpp "mocs_compilation.cpp") +endif() + set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) set(CBD ${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CSD}) @@ -19,7 +28,7 @@ add_custom_command ( add_custom_target ( a_mc COMMAND ${CMAKE_COMMAND} -E sleep 2 COMMAND ${CMAKE_COMMAND} - "-DMCF=${CBD}/a_qt_autogen/mocs_compilation.cpp" + "-DMCF=${CBD}/a_qt_autogen/${mocs_compilation_cpp}" "-DCF_IN=${CSD}/a_mc.hpp.in" "-DCF_OUT=${CBD}/a_mc.hpp" -P ${CSD}/configure_content.cmake @@ -51,7 +60,7 @@ add_custom_command ( DEPENDS b_qt_autogen COMMAND ${CMAKE_COMMAND} -E sleep 2 COMMAND ${CMAKE_COMMAND} - "-DMCF=${CBD}/b_qt_autogen/mocs_compilation.cpp" + "-DMCF=${CBD}/b_qt_autogen/${mocs_compilation_cpp}" "-DCF_IN=${CSD}/b_mc.cpp.in" "-DCF_OUT=${CBD}/b_mc.cpp" -P ${CSD}/configure_content.cmake diff --git a/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt index 81fd8db..e95c626 100644 --- a/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt +++ b/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt @@ -13,10 +13,10 @@ include("../AutogenCoreTest.cmake") set(GAT_SDIR "${CMAKE_CURRENT_SOURCE_DIR}/GAT") set(GAT_BDIR "${CMAKE_CURRENT_BINARY_DIR}/GAT") # Files -set(MCA "sda/sda_autogen/mocs_compilation.cpp") -set(MCB "sdb/sdb_autogen/mocs_compilation.cpp") -set(MCC "sdc/sdc_autogen/mocs_compilation.cpp") -set(MCG "gat_autogen/mocs_compilation.cpp") +set(MCA "sda/sda_autogen/mocs_compilation*.cpp") +set(MCB "sdb/sdb_autogen/mocs_compilation*.cpp") +set(MCC "sdc/sdc_autogen/mocs_compilation*.cpp") +set(MCG "gat_autogen/mocs_compilation*.cpp") set(DRA "sda/sda_autogen/*qrc_data.cpp") set(DRB "sdb/sdb_autogen/*qrc_data.cpp") diff --git a/Tests/QtAutogen/MocOnly/CMakeLists.txt b/Tests/QtAutogen/MocOnly/CMakeLists.txt index e109154..f4fde58 100644 --- a/Tests/QtAutogen/MocOnly/CMakeLists.txt +++ b/Tests/QtAutogen/MocOnly/CMakeLists.txt @@ -11,6 +11,18 @@ add_executable(mocOnly IncA.cpp IncB.cpp ) +# XXX(xcode-per-cfg-src): Drop the NO_PER_CONFIG_SOURCES exclusion +# when the Xcode generator supports per-config sources. +if(NOT NO_PER_CONFIG_SOURCES) + target_sources(mocOnly PRIVATE + "$<$<CONFIG:Debug>:${CMAKE_CURRENT_SOURCE_DIR}/CfgDebug.cpp>" + "$<$<NOT:$<CONFIG:Debug>>:${CMAKE_CURRENT_SOURCE_DIR}/CfgOther.cpp>" + ) + target_compile_definitions(mocOnly PRIVATE + "$<$<CONFIG:Debug>:HAVE_CFG_DEBUG>" + "$<$<NOT:$<CONFIG:Debug>>:HAVE_CFG_OTHER>" + ) +endif() set_property(TARGET mocOnly PROPERTY AUTOMOC ON) target_link_libraries(mocOnly ${QT_LIBRARIES}) # Add compile definitions with unusual characters diff --git a/Tests/QtAutogen/MocOnly/CfgDebug.cpp b/Tests/QtAutogen/MocOnly/CfgDebug.cpp new file mode 100644 index 0000000..07ca3fb --- /dev/null +++ b/Tests/QtAutogen/MocOnly/CfgDebug.cpp @@ -0,0 +1,5 @@ +#include "CfgDebug.hpp" + +CfgDebug::CfgDebug() +{ +} diff --git a/Tests/QtAutogen/MocOnly/CfgDebug.hpp b/Tests/QtAutogen/MocOnly/CfgDebug.hpp new file mode 100644 index 0000000..3cd90a4 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/CfgDebug.hpp @@ -0,0 +1,15 @@ +#ifndef CFGDEBUG_HPP +#define CFGDEBUG_HPP + +#include <QObject> + +/* clang-format off */ +class CfgDebug : public QObject +{ + Q_OBJECT +public: + CfgDebug(); +}; +/* clang-format on */ + +#endif diff --git a/Tests/QtAutogen/MocOnly/CfgOther.cpp b/Tests/QtAutogen/MocOnly/CfgOther.cpp new file mode 100644 index 0000000..0ccd433 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/CfgOther.cpp @@ -0,0 +1,5 @@ +#include "CfgOther.hpp" + +CfgOther::CfgOther() +{ +} diff --git a/Tests/QtAutogen/MocOnly/CfgOther.hpp b/Tests/QtAutogen/MocOnly/CfgOther.hpp new file mode 100644 index 0000000..7cacd52 --- /dev/null +++ b/Tests/QtAutogen/MocOnly/CfgOther.hpp @@ -0,0 +1,15 @@ +#ifndef CFGOTHER_HPP +#define CFGOTHER_HPP + +#include <QObject> + +/* clang-format off */ +class CfgOther : public QObject +{ + Q_OBJECT +public: + CfgOther(); +}; +/* clang-format on */ + +#endif diff --git a/Tests/QtAutogen/MocOnly/main.cpp b/Tests/QtAutogen/MocOnly/main.cpp index ec8da21..6c0f6f2 100644 --- a/Tests/QtAutogen/MocOnly/main.cpp +++ b/Tests/QtAutogen/MocOnly/main.cpp @@ -5,6 +5,14 @@ #include "StyleA.hpp" #include "StyleB.hpp" +#ifdef HAVE_CFG_DEBUG +# include "CfgDebug.hpp" +#endif + +#ifdef HAVE_CFG_OTHER +# include "CfgOther.hpp" +#endif + int main(int argv, char** args) { StyleA styleA; diff --git a/Tests/QtAutogen/TestMacros.cmake b/Tests/QtAutogen/TestMacros.cmake index 0e27188..1024996 100644 --- a/Tests/QtAutogen/TestMacros.cmake +++ b/Tests/QtAutogen/TestMacros.cmake @@ -1,12 +1,19 @@ # Autogen build options set(Autogen_BUILD_OPTIONS "-DQT_TEST_VERSION=${QT_TEST_VERSION}") -if(NOT _isMultiConfig) # Set in Tests/CMakeLists.txt +if(_isMultiConfig) # Set in Tests/CMakeLists.txt + list(APPEND Autogen_CTEST_OPTIONS --build-config $<CONFIGURATION>) +else() list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_BUILD_TYPE=$<CONFIGURATION>") endif() list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_AUTOGEN_VERBOSE=1" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" ) +# XXX(xcode-per-cfg-src): Drop the NO_PER_CONFIG_SOURCES exclusion +# when the Xcode generator supports per-config sources. +if(CMAKE_GENERATOR STREQUAL "Xcode") + list(APPEND Autogen_BUILD_OPTIONS -DNO_PER_CONFIG_SOURCES=1) +endif() # A macro to add a QtAutogen test macro(ADD_AUTOGEN_TEST NAME) @@ -30,6 +37,7 @@ macro(ADD_AUTOGEN_TEST NAME) "${_BuildDir}" ${build_generator_args} --build-project ${NAME} + ${Autogen_CTEST_OPTIONS} --build-exe-dir "${_BuildDir}" --force-new-ctest-process --build-options ${build_options} ${Autogen_BUILD_OPTIONS} diff --git a/Tests/RunCMake/NinjaMultiConfig/Qt5.cmake b/Tests/RunCMake/NinjaMultiConfig/Qt5.cmake index 3a1c7f5..578256a 100644 --- a/Tests/RunCMake/NinjaMultiConfig/Qt5.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/Qt5.cmake @@ -16,12 +16,13 @@ if(Qt5Core_VERSION VERSION_GREATER_EQUAL "5.15.0") set(moc_writes_depfiles 1) endif() -set(autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/mocs_compilation.cpp") +set(autogen_files) if(moc_writes_depfiles) list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/deps") list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/timestamp") endif() foreach(c IN LISTS CMAKE_CONFIGURATION_TYPES) + list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/mocs_compilation_${c}.cpp") list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp") if(moc_writes_depfiles) list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp.d") |