From 599f1a53747c544b788fa42529300fff2ac12965 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Mon, 3 Aug 2020 14:45:54 +0200 Subject: CMakeLists.txt improvement Added CONFIGURE_DEPENDS to file GLOB constructs if available --- src/CMakeLists.txt | 12 +++++-- testing/CMakeLists.txt | 98 ++++++-------------------------------------------- 2 files changed, 21 insertions(+), 89 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c99ee9f..cb28911 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,7 +14,11 @@ include_directories( file(MAKE_DIRECTORY ${GENERATED_SRC}) -file(GLOB LANGUAGE_FILES "${CMAKE_CURRENT_LIST_DIR}/translator_??.h") +if (${CMAKE_VERSION} VERSION_EQUAL "3.11.0" OR ${CMAKE_VERSION} VERSION_GREATER "3.11.0") + file(GLOB LANGUAGE_FILES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/translator_??.h") +else() + file(GLOB LANGUAGE_FILES "${CMAKE_CURRENT_LIST_DIR}/translator_??.h") +endif() # instead of increasebuffer.py add_definitions(-DYY_BUF_SIZE=${enlarge_lex_buffers} -DYY_READ_BUF_SIZE=${enlarge_lex_buffers}) @@ -81,7 +85,11 @@ add_custom_command( set_source_files_properties(${GENERATED_SRC}/lang_cfg.h PROPERTIES GENERATED 1) # all resource files -file(GLOB RESOURCES ${CMAKE_SOURCE_DIR}/templates/*/*) +if (${CMAKE_VERSION} VERSION_EQUAL "3.11.0" OR ${CMAKE_VERSION} VERSION_GREATER "3.11.0") + file(GLOB RESOURCES CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/templates/*/*) +else() + file(GLOB RESOURCES ${CMAKE_SOURCE_DIR}/templates/*/*) +endif() # resources.cpp add_custom_command( diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index 75e922a..1851c9f 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -1,98 +1,22 @@ # run all tests sequentially (keep for backward compatibilty) add_custom_target(tests - COMMENT "Running doxygen tests..." - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/testing/runtests.py --doxygen ${PROJECT_BINARY_DIR}/bin/doxygen --inputdir ${CMAKE_SOURCE_DIR}/testing --outputdir ${PROJECT_BINARY_DIR}/testing - DEPENDS doxygen + COMMENT "Running doxygen tests..." + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/testing/runtests.py --doxygen ${PROJECT_BINARY_DIR}/bin/doxygen --inputdir ${CMAKE_SOURCE_DIR}/testing --outputdir ${PROJECT_BINARY_DIR}/testing + DEPENDS doxygen ) -# to update this list run `ls [0-9][0-9][0-9]_*.*` in the testing directory -set(TEST_FILES -001_a.dox -002_addindex.dox -003_anchor.dox -004_arg.dox -005_attention.dox -006_author.dox -007_b.dox -008_brief.c -009_bug.cpp -010_c.dox -011_category.m -012_cite.dox -013_class.h -014_code.dox -015_cond.c -016_copydoc.c -017_copyright.dox -018_def.c -019_defgroup.c -020_only.dox -021_dontinclude.cpp -022_dot.cpp -023_e.dox -024_if.dox -025_example.cpp -026_exception.cpp -027_extends.c -028_formula.c -029_hideinit.c -030_htmlinclude.dox -031_image.dox -032_include.cpp -033_internal.dox -034_internal.dox -035_invariant.c -036_link.c -037_msc.cpp -038_n.dox -039_name.cpp -040_namespace.cpp -041_overload.cpp -042_package.java -043_page.dox -044_section.h -045_refitem.dox -046_related.cpp -047_return.cpp -048_showinit.c -049_snippet.cpp -050_verbatim.dox -051_escape.dox -052_tilde.dox -053_tilde.dox -054_parblock.cpp -055_markdown.md -056_latexinclude.dox -064_castoperator.cpp -065_tilde.dox -066_property_initializer.cs -067_link_varargs.cpp -068_ref_varargs.cpp -069_link_variadic_template.cpp -070_ref_variadic_template.cpp -071_enum_in_anon_ns.cpp -072_using.cpp -073_typed_enum.cpp -074_ref.cpp -075_argmatch.cpp -076_emojis.cpp -077_no_xml_namespace_members_in_file_scope.h -078_xml_namespace_members_in_file_scope.h -079_tableofcontents.dox -080_extract_private_virtual.cpp -081_brief_lists.h -082_decl_def.cpp -083_decl_def.cpp -084_markdown_pre.f90 -085_tooltip.cpp -086_style_tags.h -) +# get the files in the testing directory starting with 3 digits and an underscore +if (${CMAKE_VERSION} VERSION_EQUAL "3.11.0" OR ${CMAKE_VERSION} VERSION_GREATER "3.11.0") + file(GLOB TEST_FILES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/[0-9][0-9][0-9]_*.*") +else() + file(GLOB TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/[0-9][0-9][0-9]_*.*") +endif() foreach(TEST_FILE ${TEST_FILES}) # extract the test name from the file name - string(REGEX REPLACE "^([0-9][0-9][0-9]*.*)\\.[^.]*$" "\\1" TEST_NAME "${TEST_FILE}") + string(REGEX REPLACE "^.*/([0-9][0-9][0-9]*.*)\\.[^.]*$" "\\1" TEST_NAME "${TEST_FILE}") # extract the test id from the file name - string(REGEX REPLACE "^([0-9][0-9][0-9]*).*$" "\\1" TEST_ID "${TEST_FILE}") + string(REGEX REPLACE "^.*/([0-9][0-9][0-9]*).*$" "\\1" TEST_ID "${TEST_FILE}") # add a test target for each test add_test(NAME ${TEST_NAME} COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/testing/runtests.py --id ${TEST_ID} --doxygen $ --inputdir ${CMAKE_SOURCE_DIR}/testing --outputdir ${PROJECT_BINARY_DIR}/testing -- cgit v0.12