diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ae9fd4305a02d99ea2d8e3454cafe2a5b6e71f6..9ce9fcf1ec4fa6c2986b4921302ba3e65ba9342e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ ########################################################################### -# CMakeLists.txt file for building BornAgain framework +# top-level CMakeLists.txt for building BornAgain ############################################################################ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) @@ -58,4 +58,3 @@ add_subdirectory(cmake) # trick to print the message # packaging include(BornAgainCPack) - diff --git a/Tests/FunctionalTests/CMakeLists.txt b/Tests/FunctionalTests/CMakeLists.txt index 165e483a253a00157b7bada5159ad58989638d0c..100040b532df419afa1d35e7b7797fa8a07993c5 100644 --- a/Tests/FunctionalTests/CMakeLists.txt +++ b/Tests/FunctionalTests/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################ -# CMakeLists.txt file for running functional tests +# FunctionalTests/CMakeLists.txt (called from top-level CMakeLists.txt) ############################################################################ enable_testing() @@ -9,15 +9,22 @@ include(CTestCustom) add_custom_target(check ${CMAKE_CTEST_COMMAND}) # export CTEST_OUTPUT_ON_FAILURE=ON will give some output on failure -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Tests/ReferenceData/BornAgain ${CMAKE_BINARY_DIR}/Tests/ReferenceData/BornAgain) -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Tests/FunctionalTests/TestPyCore ${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyCore) -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Tests/FunctionalTests/TestPyFit ${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyFit) +execute_process( COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_SOURCE_DIR}/Tests/ReferenceData/BornAgain + ${CMAKE_BINARY_DIR}/Tests/ReferenceData/BornAgain ) +execute_process( COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_SOURCE_DIR}/Tests/FunctionalTests/TestPyCore + ${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyCore ) +execute_process( COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_SOURCE_DIR}/Tests/FunctionalTests/TestPyFit + ${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyFit ) #file(COPY ${CMAKE_SOURCE_DIR}/Tests/FunctionalTests/TestPyFit DESTINATION ${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyFit) #COPY_IF_DIFFERENT( ${CMAKE_SOURCE_DIR}/Tests/FunctionalTests/TestPyFit ${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyFit ${SRC_FILES} IncludeTargets "Includes") add_subdirectory(TestCore) add_subdirectory(TestFit) + if(BORNAGAIN_PYTHON) add_subdirectory(TestPyCore) add_subdirectory(TestPyFit) @@ -26,4 +33,3 @@ endif() if(BORNAGAIN_GUI) add_subdirectory(TestGUI) endif() - diff --git a/Tests/FunctionalTests/TestCore/CMakeLists.txt b/Tests/FunctionalTests/TestCore/CMakeLists.txt index eea0a082924c67fdb2899e7016b300fa1db9ab3e..683fe0f17b0f4f9d98af3c1c5a4f5afab4c2daad 100644 --- a/Tests/FunctionalTests/TestCore/CMakeLists.txt +++ b/Tests/FunctionalTests/TestCore/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################ -# CMakeLists.txt file for building TestCore functional tests +# FunctionalTests/TestCore/CMakeLists.txt ############################################################################ include_directories( @@ -63,17 +63,17 @@ set(list_of_tests ) -# Adding executables. -get_list_of_executables_from_list_of_tests("${list_of_tests}" ${list_of_executables}) +# Adding executables (using macros defined in BornAgainMacros.cmake): +GET_LIST_OF_EXECUTABLES_FROM_LIST_OF_TESTS("${list_of_tests}" ${list_of_executables}) foreach(test_exe_name ${list_of_executables}) - BORNAGAIN_EXECUTABLE(${test_exe_name} LOCATIONS ${test_exe_name} EXCLUDE_FROM_ALL LIBRARIES ${BornAgainCore_LIBRARY}) + BORNAGAIN_EXECUTABLE( + ${test_exe_name} LOCATIONS ${test_exe_name} + EXCLUDE_FROM_ALL LIBRARIES ${BornAgainCore_LIBRARY} + ) endforeach() -# Adding tests +# Adding tests (using macros defined in BornAgainMacros.cmake): foreach(_test ${list_of_tests}) - get_test_name_and_argument(${_test} ${test_exe_name} ${test_argument}) + GET_TEST_NAME_AND_ARGUMENT(${_test} ${test_exe_name} ${test_argument}) BORNAGAIN_ADD_TEST(${_test} ${test_exe_name} TEST_ARGUMENTS ${test_argument}) endforeach() - - - diff --git a/cmake/modules/BornAgainMacros.cmake b/cmake/modules/BornAgainMacros.cmake index 35e8f54ba0ecec6d913327d84823b6b1b82025f6..961f2cc828a5b438be55cad7d620f1f3252678fb 100644 --- a/cmake/modules/BornAgainMacros.cmake +++ b/cmake/modules/BornAgainMacros.cmake @@ -1,13 +1,14 @@ -# --- Collection of scripts for BornAgain CMake infrastructure +############################################################################ +# Collection of macros/functions for BornAgain CMake infrastructure +############################################################################ # Returns the list of unique executables from the list of functional tests # Usage: -# set(list_of_tests "exe1/arg1" "exe1/arg2" "exe1/arg3" "exe2" "exe4/arg1") -# get_list_of_executables_from_list_of_tests("${list_of_tests}" ${list_of_executables}) -# +# set(list_of_tests "exe1/arg1" "exe1/arg2" "exe1/arg3" "exe2" "exe4/arg1") +# get_list_of_executables_from_list_of_tests("${list_of_tests}" ${list_of_executables}) # Result: -# list_of_executables will be "exe1;exe2;exe3;exe4" +# list_of_executables will be "exe1;exe2;exe3;exe4" macro(get_list_of_executables_from_list_of_tests list_of_tests) foreach(_test ${list_of_tests}) string(REPLACE "/" ";" test_info ${_test}) @@ -21,10 +22,11 @@ endmacro() # Parse string containing test info into test name and test argument # Usage: -# set(test_string "CoreSuite/CylindersAndPrisms") -# get_test_name_and_argument(${test_string} ${test_exe_name} ${test_argument}) -# -# Result: test_exe_name will be "CoreSuite", test_argument will be CylindersAndPrisms +# set(test_string "CoreSuite/CylindersAndPrisms") +# get_test_name_and_argument(${test_string} ${test_exe_name} ${test_argument}) +# Result: +# test_exe_name will be "CoreSuite", +# test_argument will be CylindersAndPrisms macro(get_test_name_and_argument _test_string) unset(_test_exe_name) @@ -51,7 +53,7 @@ function(BORNAGAIN_EXECUTABLE executable) file(GLOB source_files ${ARG_LOCATIONS}/*.cpp) # making executable - if(${ARG_EXCLUDE_FROM_ALL}) + if(${ARG_EXCLUDE_FROM_ALL}) add_executable(${executable} EXCLUDE_FROM_ALL ${source_files} ) else() add_executable(${executable} ${ARG_UNPARSED_ARGUMENTS} ) @@ -59,7 +61,7 @@ function(BORNAGAIN_EXECUTABLE executable) # linking libraries from the list foreach(_libname ${ARG_LIBRARIES}) include_directories(${${_libname}_INCLUDE_DIRS}) - target_link_libraries(${executable} ${_libname}) + target_link_libraries(${executable} ${_libname}) endforeach() endfunction() @@ -211,10 +213,3 @@ print(s.get_config_var('LDVERSION') or s.get_config_var('VERSION')); # set(ALT_PYTHON_VERSION_STRING ${ALT_PYTHON_VERSION_STRING} PARENT_SCOPE) # set(ALT_PYTHON_INCLUDE_DIRS ${ALT_PYTHON_INCLUDE_DIRS} PARENT_SCOPE) endfunction() - - - - - - -