avoid unnecessary `validateCFG-*` targets in CMake (#4166)

This commit is contained in:
Oliver Stöneberg 2022-06-03 23:07:28 +02:00 committed by GitHub
parent ee072b11cd
commit 9e8d5d1b2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -25,12 +25,15 @@ file(GLOB cfgs "cfg/*.cfg")
file(GLOB platforms "platforms/*.xml") file(GLOB platforms "platforms/*.xml")
if (LIBXML2_XMLLINT_EXECUTABLE) if (LIBXML2_XMLLINT_EXECUTABLE)
add_custom_target(validateCFG ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_SOURCE_DIR}/cfg/cppcheck-cfg.rng) add_custom_target(validateCFG DEPENDS validateCFG-cmd)
add_custom_command(OUTPUT validateCFG-cmd
COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_SOURCE_DIR}/cfg/cppcheck-cfg.rng)
foreach(cfg ${cfgs}) foreach(cfg ${cfgs})
get_filename_component(cfgname ${cfg} NAME_WE) add_custom_command(OUTPUT validateCFG-cmd APPEND
add_custom_target(validateCFG-${cfgname} ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/cfg/cppcheck-cfg.rng ${cfg}) COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/cfg/cppcheck-cfg.rng ${cfg})
add_dependencies(validateCFG validateCFG-${cfgname})
endforeach() endforeach()
# this is a symbolic name for a build rule and not an output file
set_source_files_properties(validateCFG-cmd PROPERTIES SYMBOLIC "true")
add_custom_target(errorlist-xml $<TARGET_FILE:cppcheck> --errorlist > ${CMAKE_BINARY_DIR}/errorlist.xml add_custom_target(errorlist-xml $<TARGET_FILE:cppcheck> --errorlist > ${CMAKE_BINARY_DIR}/errorlist.xml
DEPENDS cppcheck) DEPENDS cppcheck)