diff options
author | Brad King <brad.king@kitware.com> | 2023-03-31 12:08:51 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-03-31 12:09:06 (GMT) |
commit | 17e6b2bdcae4d7ea98b4738a9a0fe72396d28eb5 (patch) | |
tree | 67799349942985af373f0914dea7a844db9d2526 /Tests/RunCMake/Autogen/MocPredefs.cmake | |
parent | fb37de96a096d4b6813b62265a37aea25137b919 (diff) | |
parent | 429a452705f5a3b7f9a46833aca6560393659cc2 (diff) | |
download | CMake-17e6b2bdcae4d7ea98b4738a9a0fe72396d28eb5.zip CMake-17e6b2bdcae4d7ea98b4738a9a0fe72396d28eb5.tar.gz CMake-17e6b2bdcae4d7ea98b4738a9a0fe72396d28eb5.tar.bz2 |
Merge topic 'automoc-cxx-standard'
429a452705 Autogen: Add target's C++ standard to moc_predef.h
21f812e57c Autogen: Split creation and setup of custom targets into separate steps
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8359
Diffstat (limited to 'Tests/RunCMake/Autogen/MocPredefs.cmake')
-rw-r--r-- | Tests/RunCMake/Autogen/MocPredefs.cmake | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Tests/RunCMake/Autogen/MocPredefs.cmake b/Tests/RunCMake/Autogen/MocPredefs.cmake new file mode 100644 index 0000000..7a89bb5 --- /dev/null +++ b/Tests/RunCMake/Autogen/MocPredefs.cmake @@ -0,0 +1,40 @@ +cmake_policy(SET CMP0129 NEW) +enable_language(CXX) + +find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_EXTENSIONS OFF) + +add_library(MocPredefs MocPredefs.cxx) + +if(NOT DEFINED CMAKE_CXX_COMPILER_PREDEFINES_COMMAND) + return() +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL "LCC" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "1.26") + return() +endif() + +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) + set(moc_predefs_h "moc_predefs_$<CONFIG>.h") + set(check_dir "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>") +else() + set(moc_predefs_h "moc_predefs.h") + set(check_dir "${CMAKE_CURRENT_BINARY_DIR}") +endif() + +add_custom_command(TARGET MocPredefs POST_BUILD VERBATIM COMMAND + ${CMAKE_COMMAND} + -Din=${CMAKE_CURRENT_BINARY_DIR}/MocPredefs_autogen/${moc_predefs_h} + -Dout=${check_dir}/check_predefs.h + -P${CMAKE_CURRENT_SOURCE_DIR}/MocPredefs-prefix.cmake + ) + +add_executable(MocPredefs-check MocPredefs-check.cxx) +target_include_directories(MocPredefs-check PRIVATE ${check_dir}) +add_dependencies(MocPredefs-check MocPredefs) + +add_custom_target(MocPredefs-run-check ALL VERBATIM COMMAND MocPredefs-check) |