From 7b046ce5a86e5eaffef1c3151d87931b80b84861 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 19 Feb 2013 22:58:35 +0100 Subject: [PATCH 1/6] Quote output correctly --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 886da0e3..e7761cc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -242,7 +242,7 @@ opm_compile_satellites (opm-core tests "" "^test_([^/]*)$") add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS tests - COMMENT Checking if library is functional + COMMENT "Checking if library is functional" VERBATIM ) From b53e39ada505243ce279762628f14c67a6efe2ae Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 19 Feb 2013 23:00:01 +0100 Subject: [PATCH 2/6] Remove copied data files on distclean --- cmake/Modules/OpmDistClean.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/Modules/OpmDistClean.cmake b/cmake/Modules/OpmDistClean.cmake index 8d09c42f..35c02549 100644 --- a/cmake/Modules/OpmDistClean.cmake +++ b/cmake/Modules/OpmDistClean.cmake @@ -32,6 +32,7 @@ macro (opm_dist_clean opm) ${tutorial_DEBUG} install_manifest.txt ${${opm}_STYLESHEET_COPIED} + ${tests_INPUT_FILES} ) # only remove these files if they were actually copied if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) From abf418f2bdbeae0806ee58b41eec4f718c36723e Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 19 Feb 2013 23:04:37 +0100 Subject: [PATCH 3/6] Use provided filenames instead of hardcoded list --- cmake/Modules/OpmSatellites.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/OpmSatellites.cmake b/cmake/Modules/OpmSatellites.cmake index 12389c74..e8e6347a 100644 --- a/cmake/Modules/OpmSatellites.cmake +++ b/cmake/Modules/OpmSatellites.cmake @@ -85,7 +85,7 @@ endmacro (opm_compile_satellites opm prefix) # # provides these output variables: # -# ${satellite_INPUT_FILES} List of all files that are copied +# ${satellite}_INPUT_FILES List of all files that are copied # ${satellite}_DATAFILES Name of target which copies these files # # Example: @@ -100,7 +100,7 @@ macro (opm_data satellite target files) # provide datafiles as inputs for the tests, by copying them # to a tests/ directory in the output tree (if different) set (${satellite}_INPUT_FILES) - file (GLOB ${satellite}_DATA "tests/*.xml") + file (GLOB ${satellite}_DATA ${files}) if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) foreach (input_datafile IN LISTS ${satellite}_DATA) file (RELATIVE_PATH rel_datafile "${PROJECT_SOURCE_DIR}" ${input_datafile}) From ebc0be26aac40832e9452f540ea3bf7e4a100da2 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 19 Feb 2013 23:28:44 +0100 Subject: [PATCH 4/6] Make sure that datafiles are copied when tests are made That way, if someone runs `make test`, the datafiles will be there if the testing programs are there, and the tests won't fail (because of that). --- cmake/Modules/OpmSatellites.cmake | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/OpmSatellites.cmake b/cmake/Modules/OpmSatellites.cmake index e8e6347a..e29b2296 100644 --- a/cmake/Modules/OpmSatellites.cmake +++ b/cmake/Modules/OpmSatellites.cmake @@ -39,13 +39,21 @@ # opm_compile_satellites (opm-core test "" "^test_([^/]*)$") # macro (opm_compile_satellites opm satellite excl_all test_regexp) + # if we are going to build the tests always, then make sure that + # the datafiles are present too + if (NOT (${excl_all} MATCHES "EXCLUDE_ALL")) + set (_incl_all "ALL") + else (NOT (${excl_all} MATCHES "EXCLUDE_ALL")) + set (_incl_all "") + endif (NOT (${excl_all} MATCHES "EXCLUDE_ALL")) + # if a set of datafiles has been setup, pull those in if (${satellite}_DATAFILES) - add_custom_target (${satellite} DEPENDS ${${satellite}_DATAFILES}) + add_custom_target (${satellite} ${_incl_all} DEPENDS ${${satellite}_DATAFILES}) else (${satellite}_DATAFILES) - add_custom_target (${satellite}) + add_custom_target (${satellite} ${_incl_all}) endif (${satellite}_DATAFILES) - + # compile each of these separately foreach (_sat_FILE IN LISTS ${satellite}_SOURCES) get_filename_component (_sat_NAME "${_sat_FILE}" NAME_WE) From fa01a6fed134d8de5771727ab51482b549a8898e Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 20 Feb 2013 00:12:38 +0100 Subject: [PATCH 5/6] Change directory with test driver for older CMakes The WORKING_DIRECTORY property wasn't added until 2.8.4; for versions earlier than that we provide a work-around. On newer versions we set the property since some other components may use it. --- cmake/Modules/OpmSatellites.cmake | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cmake/Modules/OpmSatellites.cmake b/cmake/Modules/OpmSatellites.cmake index e29b2296..28336552 100644 --- a/cmake/Modules/OpmSatellites.cmake +++ b/cmake/Modules/OpmSatellites.cmake @@ -79,11 +79,18 @@ macro (opm_compile_satellites opm satellite excl_all test_regexp) if (NOT ${test_regexp} STREQUAL "") string (REGEX REPLACE "${test_regexp}" "\\1" _sat_FANCY "${_sat_NAME}") get_target_property (_sat_LOC ${_sat_NAME} LOCATION) - add_test (${_sat_FANCY} ${_sat_LOC}) - # run the test in the directory where the data files are - set_tests_properties (${_sat_FANCY} PROPERTIES - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${${satellite}_DIR} - ) + if (CMAKE_VERSION VERSION_LESS "2.8.4") + add_test ( + NAME ${_sat_FANCY} + COMMAND ${CMAKE_COMMAND} -E chdir "${PROJECT_BINARY_DIR}/${${satellite}_DIR}" ${_sat_LOC} + ) + else (CMAKE_VERSION VERSION_LESS "2.8.4") + add_test (${_sat_FANCY} ${_sat_LOC}) + # run the test in the directory where the data files are + set_tests_properties (${_sat_FANCY} PROPERTIES + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${${satellite}_DIR} + ) + endif (CMAKE_VERSION VERSION_LESS "2.8.4") endif(NOT ${test_regexp} STREQUAL "") endforeach (_sat_FILE) endmacro (opm_compile_satellites opm prefix) From e1488bbca76dfdbbf28c2653b7d5bd97f43b3309 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 20 Feb 2013 13:23:27 +0100 Subject: [PATCH 6/6] Fix dependencies between test programs and datafiles Apparently, DEPENDS can only be used between file-level dependencies and not target-level dependencies. add_dependencies must be used for that. --- cmake/Modules/OpmSatellites.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/OpmSatellites.cmake b/cmake/Modules/OpmSatellites.cmake index 28336552..19ed7d14 100644 --- a/cmake/Modules/OpmSatellites.cmake +++ b/cmake/Modules/OpmSatellites.cmake @@ -48,10 +48,9 @@ macro (opm_compile_satellites opm satellite excl_all test_regexp) endif (NOT (${excl_all} MATCHES "EXCLUDE_ALL")) # if a set of datafiles has been setup, pull those in + add_custom_target (${satellite} ${_incl_all}) if (${satellite}_DATAFILES) - add_custom_target (${satellite} ${_incl_all} DEPENDS ${${satellite}_DATAFILES}) - else (${satellite}_DATAFILES) - add_custom_target (${satellite} ${_incl_all}) + add_dependencies (${satellite} ${${satellite}_DATAFILES}) endif (${satellite}_DATAFILES) # compile each of these separately