diff options
author | Craig Scott <craig.scott@crascit.com> | 2023-04-10 22:05:54 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-04-10 22:06:06 (GMT) |
commit | e245b4df7505f2190dbc1442b7ceb94fc507a40e (patch) | |
tree | 4ec32f0f25d3cfa2c76ee04a7545d4361671a1da /Tests/QtAutogen/MocInterfaceMacroNames/CheckExportTargets.cmake | |
parent | 453cf8a1968081731b667edd01ff942adf1f7bcc (diff) | |
parent | c5c3aff1f5aa36d44f3c639726dd36eedc28f823 (diff) | |
download | CMake-e245b4df7505f2190dbc1442b7ceb94fc507a40e.zip CMake-e245b4df7505f2190dbc1442b7ceb94fc507a40e.tar.gz CMake-e245b4df7505f2190dbc1442b7ceb94fc507a40e.tar.bz2 |
Merge topic 'automoc-macro-names'
c5c3aff1f5 Autogen: Add INTERFACE_AUTOMOC_MACRO_NAMES target property
69cf9700e6 Autogen: Defer setup until Generate step
7cecb6353e cmGeneratorTarget: Factor out EvaluatedTargetProperty infrastructure
2daba01ddf cmGeneratorTarget: Avoid incidental include-what-you-use warning
850b4d990c IWYU: Add mapping for 'std::remove_reference<Defer &>::type'
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8391
Diffstat (limited to 'Tests/QtAutogen/MocInterfaceMacroNames/CheckExportTargets.cmake')
-rw-r--r-- | Tests/QtAutogen/MocInterfaceMacroNames/CheckExportTargets.cmake | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Tests/QtAutogen/MocInterfaceMacroNames/CheckExportTargets.cmake b/Tests/QtAutogen/MocInterfaceMacroNames/CheckExportTargets.cmake new file mode 100644 index 0000000..9db23f6 --- /dev/null +++ b/Tests/QtAutogen/MocInterfaceMacroNames/CheckExportTargets.cmake @@ -0,0 +1,45 @@ + +set(TARGET_NAMES "static_lib" "shared_lib" "interface_lib") +set(static_lib_FOUND "0") +set(shared_lib_FOUND "0") +set(interface_lib_FOUND "0") + +macro(checkExportTargets FOLDER_PATH) + message("Checking folder: ${FOLDER_PATH}") + file(GLOB sources_list LIST_DIRECTORIES true RELATIVE ${FOLDER_PATH} ${FOLDER_PATH}/*) + message("Found files and folders: ${sources_list}") + foreach(source ${sources_list}) + set(SOURCE_ABS "${FOLDER_PATH}/${source}") + if(IS_DIRECTORY ${SOURCE_ABS}) + message("Found subfolder: ${source}") + checkExportTargets(${SOURCE_ABS}) + else() + message("Found file: ${source}") + foreach(TARGET_NAME ${TARGET_NAMES}) + set(TARGETS_FILE "${TARGET_NAME}Targets.cmake") + if(${source} STREQUAL ${TARGETS_FILE}) + message("Found ${TARGETS_FILE} in ${FOLDER_PATH}") + string(TOUPPER ${TARGET_NAME} TARGET_NAME_UPPER) + set(expected_macro "${TARGET_NAME_UPPER}_MACRO") + set(expected_string "INTERFACE_AUTOMOC_MACRO_NAMES \"${expected_macro}\"") + file(READ ${FOLDER_PATH}/${source} contents) + if (NOT contents MATCHES ${expected_string}) + message(FATAL_ERROR "Expected ${expected_string} in ${FOLDER_PATH}/${source}") + else() + message("Found ${expected_string} in ${FOLDER_PATH}/${source}") + set(${TARGET_NAME}_FOUND "1") + endif() + endif() + endforeach() + endif() + endforeach() +endmacro() + +checkExportTargets(${FOLDER_PATH}) + +foreach(TARGET_NAME ${TARGET_NAMES}) + # check if the target found equals the expected value + if(NOT ${TARGET_NAME}_FOUND STREQUAL "1") + message(FATAL_ERROR "Did not find ${TARGET_NAME}Targets.cmake") + endif() +endforeach() |