diff --git a/App/CMakeLists.txt b/App/CMakeLists.txt index 9851ba7417cdb50d021d5f6ce61db6669435a9c2..96b948d2e33abfde2b5b03b9c037d9fe15e2faf3 100644 --- a/App/CMakeLists.txt +++ b/App/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################ -# CMakeLists.txt file for building BornAgain/App executalbe +# CMakeLists.txt file for building BornAgain/App executable ############################################################################ cmake_minimum_required(VERSION 2.8 FATAL_ERROR) diff --git a/CMakeLists.txt b/CMakeLists.txt index 320b2382a32cb3a9e956ed47b4b0440782babb95..5f13d3f90cc6bb79d0cab0380c0eed1138aefa79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,15 +15,16 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) #--- Including macros --- include(BornAgainMacros) include(SearchInstalledSoftware) -include(CMakeMacroParseArguments) #--- Recurse into the given subdirectories --- add_subdirectory(Core) add_subdirectory(ThirdParty/gtest) -add_subdirectory(Tests/UnitTests/TestCore) if(ROOT_FOUND) add_subdirectory(Fit) add_subdirectory(App) endif() +# functional tests (cmake; make check) +add_subdirectory(Tests/FunctionalTests) + diff --git a/Tests/FunctionalTests/CMakeLists.txt b/Tests/FunctionalTests/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..93cebe943987a0363b57a5051689938921d7c86a --- /dev/null +++ b/Tests/FunctionalTests/CMakeLists.txt @@ -0,0 +1,11 @@ +############################################################################ +# CMakeLists.txt file for running functional tests +############################################################################ + +enable_testing() +add_custom_target(check ${CMAKE_CTEST_COMMAND} -V) + +#add_subdirectory(TestCore) +add_subdirectory(TestFit) + + diff --git a/Tests/FunctionalTests/TestCore/CMakeLists.txt b/Tests/FunctionalTests/TestCore/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..65dc73a724042bd3efd419fa1a596bc1bd7c5fff --- /dev/null +++ b/Tests/FunctionalTests/TestCore/CMakeLists.txt @@ -0,0 +1,26 @@ +############################################################################ +# CMakeLists.txt file for building TestCore functional tests +############################################################################ + +set(CMAKE_CXX_FLAGS "-DSTANDALONE") + +set(list_of_tests + "IsGISAXS01" + "IsGISAXS02" + "IsGISAXS03" + "IsGISAXS04" + "IsGISAXS06" + "IsGISAXS07" + "IsGISAXS08" + "IsGISAXS09" + "IsGISAXS10" + "IsGISAXS11" + "IsGISAXS15" + "MesoCrystal1" +) + +foreach(_test ${list_of_tests}) + BORNAGAIN_EXECUTABLE(${_test} LOCATIONS ${_test} EXCLUDE_FROM_ALL LIBRARIES ${BornAgainCore_LIBRARY}) + BORNAGAIN_ADD_TEST(${_test}) +endforeach() + diff --git a/Tests/FunctionalTests/TestFit/CMakeLists.txt b/Tests/FunctionalTests/TestFit/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..034dea5db27c952af0b096d4dc5d668487b71eb8 --- /dev/null +++ b/Tests/FunctionalTests/TestFit/CMakeLists.txt @@ -0,0 +1,15 @@ +############################################################################ +# CMakeLists.txt file for building TestFit functional tests +############################################################################ + +set(CMAKE_CXX_FLAGS "-DSTANDALONE") + +set(list_of_tests + "TestFit01" + "TestFit02" +) + +foreach(_test ${list_of_tests}) + BORNAGAIN_EXECUTABLE(${_test} LOCATIONS ${_test} EXCLUDE_FROM_ALL LIBRARIES ${BornAgainCore_LIBRARY} ${BornAgainFit_LIBRARY}) + BORNAGAIN_ADD_TEST(${_test}) +endforeach() diff --git a/Tests/UnitTests/TestCore/CMakeLists.txt b/Tests/UnitTests/TestCore/CMakeLists.txt index 05d99722f948fdf99d742f1fa8c2718dc2b694a2..21c210a051b546b42f3879c1ddd32e9279b15e92 100644 --- a/Tests/UnitTests/TestCore/CMakeLists.txt +++ b/Tests/UnitTests/TestCore/CMakeLists.txt @@ -2,9 +2,7 @@ # CMakeLists.txt file for building BornAgain framework ############################################################################ -cmake_minimum_required(VERSION 2.8 FATAL_ERROR) - -enable_testing(true) +enable_testing() add_executable( TestCore main.cpp ) diff --git a/cmake/modules/BornAgainMacros.cmake b/cmake/modules/BornAgainMacros.cmake index 124682219a410baefd62f79cb59f3ea9bc8b7100..e27ac6f942d88f15b978debae69538228d2cf865 100644 --- a/cmake/modules/BornAgainMacros.cmake +++ b/cmake/modules/BornAgainMacros.cmake @@ -27,94 +27,34 @@ else() endif() -#--------------------------------------------------------------------------------------------------- -# BORNAGAIN_USE_PACKAGE( package ) -#--------------------------------------------------------------------------------------------------- -# macro( BORNAGAIN_USE_PACKAGE package ) -# if( EXISTS ${CMAKE_SOURCE_DIR}/${package}/CMakeLists.txt) -# set(_use_packages ${_use_packages} ${package}) -# include_directories( ${CMAKE_SOURCE_DIR}/${package}/inc ) -# set_property(GLOBAL APPEND PROPERTY ROOT_BUILDTREE_PACKAGES ${package}) -# file(READ ${CMAKE_SOURCE_DIR}/${package}/CMakeLists.txt file_contents) -# string( REGEX MATCHALL "ROOT_USE_PACKAGE[ ]*[(][ ]*([^ )])+" vars ${file_contents}) -# foreach( var ${vars}) -# string(REGEX REPLACE "ROOT_USE_PACKAGE[ ]*[(][ ]*([^ )])" "\\1" p ${var}) -# #---avoid calling the same one at the same directory level --------------------------------- -# list(FIND _use_packages ${p} _done) -# if(_done EQUAL -1) -# ROOT_USE_PACKAGE(${p}) -# endif() -# endforeach() -# else() -# #find_package(${package}) -# #GET_PROPERTY(parent DIRECTORY PROPERTY PARENT_DIRECTORY) -# #if(parent) -# #set(${package}_environment ${${package}_environment} PARENT_SCOPE) -# #else() -# # set(${package}_environment ${${package}_environment} ) -# #endif() -# include_directories( ${${package}_INCLUDE_DIRS} ) -# link_directories( ${${package}_LIBRARY_DIRS} ) -# endif() -# endmacro() -# -# -# function(ROOT_GENERATE_DICTIONARY dictionary) -# message("QQQQ 1.1") -# PARSE_ARGUMENTS(ARG "LINKDEF;OPTIONS" "" ${ARGN}) -# #---Get the list of header files------------------------- -# set(headerfiles) -# foreach(fp ${ARG_DEFAULT_ARGS}) -# file(GLOB files inc/${fp}) -# if(files) -# foreach(f ${files}) -# if(NOT f MATCHES LinkDef) -# set(headerfiles ${headerfiles} ${f}) -# endif() -# endforeach() -# else() -# set(headerfiles ${headerfiles} ${fp}) -# endif() -# endforeach() -# string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/inc/" "" rheaderfiles "${headerfiles}") -# #---Get the list of include directories------------------ -# get_directory_property(incdirs INCLUDE_DIRECTORIES) -# if(CMAKE_PROJECT_NAME STREQUAL ROOT) -# set(includedirs -I${CMAKE_CURRENT_SOURCE_DIR}/inc -# -I${CMAKE_BINARY_DIR}/include -# -I${CMAKE_SOURCE_DIR}/cint/cint/include -# -I${CMAKE_SOURCE_DIR}/cint/cint/stl -# -I${CMAKE_SOURCE_DIR}/cint/cint/lib) -# else() -# set(includedirs -I${CMAKE_CURRENT_SOURCE_DIR}/inc) -# endif() -# foreach( d ${incdirs}) -# set(includedirs ${includedirs} -I${d}) -# endforeach() -# #---Get the list of definitions--------------------------- -# get_directory_property(defs COMPILE_DEFINITIONS) -# foreach( d ${defs}) -# if(NOT d MATCHES "=") -# set(definitions ${definitions} -D${d}) -# endif() -# endforeach() -# #---Get LinkDef.h file------------------------------------ -# foreach( f ${ARG_LINKDEF}) -# if( IS_ABSOLUTE ${f}) -# set(_linkdef ${_linkdef} ${f}) -# else() -# if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) -# set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) -# else() -# set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/${f}) -# endif() -# endif() -# endforeach() -# message("QQQQ 1.2 a) ${ARG_OPTIONS} b) ${ARG_LINKDEF} c) ${rootcint_cmd}") -# #---call rootcint------------------------------------------ -# add_custom_command(OUTPUT ${dictionary}.cxx ${dictionary}.h -# COMMAND ${rootcint_cmd} -cint -f ${dictionary}.cxx -# -c ${ARG_OPTIONS} ${definitions} ${includedirs} ${rheaderfiles} ${_linkdef} -# DEPENDS ${headerfiles} ${_linkdef} ${ROOTCINTDEP}) -# endfunction() -# + +# ----------------------------------------------------------------------------- +# add executable (ARG, options, one_value_keyword, multi_value_keywoard arguments (aka ${ARG_UNPARSED_ARGUMENTS}) +# ----------------------------------------------------------------------------- +function(BORNAGAIN_EXECUTABLE executable) + CMAKE_PARSE_ARGUMENTS(ARG "EXCLUDE_FROM_ALL" "" "LIBRARIES;LOCATIONS" "" ${ARGN}) + # retrieving source list + file(GLOB source_files ${ARG_LOCATIONS}/*.cpp) + + # making executable + if(${ARG_EXCLUDE_FROM_ALL}) + add_executable(${executable} EXCLUDE_FROM_ALL ${source_files} ) + else() + add_executable(${executable} ${ARG_UNPARSED_ARGUMENTS} ) + endif() + # linking libraries from the list + foreach(_libname ${ARG_LIBRARIES}) + include_directories(${${_libname}_INCLUDE_DIRS}) + target_link_libraries(${executable} ${_libname}) + endforeach() +endfunction() + + +# ----------------------------------------------------------------------------- +# add cmake test +# ----------------------------------------------------------------------------- +function(BORNAGAIN_ADD_TEST test) + add_test( ${test} ${test} ) # TestName ExeName + add_dependencies(check ${test}) +endfunction() + diff --git a/cmake/modules/CMakeMacroParseArguments.cmake b/cmake/modules/CMakeMacroParseArguments.cmake deleted file mode 100644 index 4cea370b83580f4cdddd6aaf91b2ddf0c40774d5..0000000000000000000000000000000000000000 --- a/cmake/modules/CMakeMacroParseArguments.cmake +++ /dev/null @@ -1,90 +0,0 @@ -# This file defines the following macro for developers needing to parse -# arguments passed to a CMake macro using names. -# -# PARSE_ARGUMENTS - parse arguments supplied to a macro -# -# The PARSE_ARGUMENTS macro will take the arguments of another macro and define -# several variables. The first argument to PARSE_ARGUMENTS is a prefix to put -# on all variables it creates. The second argument is a list of names, and the -# third argument is a list of options. Both of these lists should be quoted. -# The rest of PARSE_ARGUMENTS are arguments from another macro to be parsed. -# -# PARSE_ARGUMENTS(prefix arg_names options arg1 arg2...) -# -# For each item in options, PARSE_ARGUMENTS will create a variable with that -# name, prefixed with prefix_. So, for example, if prefix is MY_MACRO and -# options is OPTION1;OPTION2, then PARSE_ARGUMENTS will create the variables -# MY_MACRO_OPTION1 and MY_MACRO_OPTION2. These variables will be set to true -# if the option exists in the command line or false otherwise. -# -# For each item in arg_names, PARSE_ARGUMENTS will create a variable with that -# name, prefixed with prefix_. Each variable will be filled with the arguments -# that occur after the given arg_name is encountered up to the next arg_name -# or the end of the arguments. All options are removed from these lists. -# PARSE_ARGUMENTS also creates a prefix_DEFAULT_ARGS variable containing the -# list of all arguments up to the first arg_name encountered. -# -# Here is a simple, albeit impractical, example of using PARSE_ARGUMENTS that -# demonstrates its behavior. -# -# SET(arguments -# hello OPTION3 world -# LIST3 foo bar -# OPTION2 -# LIST1 fuz baz -# ) -# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments}) -# -# PARSE_ARGUMENTS creates 7 variables and sets them as follows: -# -# * ARG_DEFAULT_ARGS: hello;world -# * ARG_LIST1: fuz;baz -# * ARG_LIST2: -# * ARG_LIST3: foo;bar -# * ARG_OPTION1: FALSE -# * ARG_OPTION2: TRUE -# * ARG_OPTION3: TRUE -# -# If you don't have any options, use an empty string in its place. -# -# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "" ${arguments}) -# -# Likewise if you have no lists. -# -# PARSE_ARGUMENTS(ARG "" "OPTION1;OPTION2;OPTION3" ${arguments}) -# -# -# Code and description copied from: -# http://www.cmake.org/Wiki/CMakeMacroParseArguments - -MACRO(PARSE_ARGUMENTS prefix arg_names option_names) - SET(DEFAULT_ARGS) - FOREACH(arg_name ${arg_names}) - SET(${prefix}_${arg_name}) - ENDFOREACH(arg_name) - FOREACH(option ${option_names}) - SET(${prefix}_${option} FALSE) - ENDFOREACH(option) - - SET(current_arg_name DEFAULT_ARGS) - SET(current_arg_list) - FOREACH(arg ${ARGN}) - SET(larg_names ${arg_names}) - LIST(FIND larg_names "${arg}" is_arg_name) - IF (is_arg_name GREATER -1) - SET(${prefix}_${current_arg_name} ${current_arg_list}) - SET(current_arg_name ${arg}) - SET(current_arg_list) - ELSE (is_arg_name GREATER -1) - SET(loption_names ${option_names}) - LIST(FIND loption_names "${arg}" is_option) - IF (is_option GREATER -1) - SET(${prefix}_${arg} TRUE) - ELSE (is_option GREATER -1) - SET(current_arg_list ${current_arg_list} ${arg}) - ENDIF (is_option GREATER -1) - ENDIF (is_arg_name GREATER -1) - ENDFOREACH(arg) - SET(${prefix}_${current_arg_name} ${current_arg_list}) -ENDMACRO(PARSE_ARGUMENTS) - diff --git a/cmake/modules/FindROOT.cmake b/cmake/modules/FindROOT.cmake index 9260ec78077f29b48e5f2349d75cbef01ae539bc..856a322fe5af86c5e683a263b1b29d7b686904b0 100644 --- a/cmake/modules/FindROOT.cmake +++ b/cmake/modules/FindROOT.cmake @@ -59,10 +59,8 @@ find_package(GCCXML) # LINKDEF linkdef1 ... # OPTIONS opt1...) function(ROOT_GENERATE_DICTIONARY dictionary) - message("AAAAAAAA 1.1") CMAKE_PARSE_ARGUMENTS(ARG "" "" "LINKDEF;OPTIONS" "" ${ARGN}) #---Get the list of header files------------------------- - message("AAAAAAAA 1.2") set(headerfiles) foreach(fp ${ARG_UNPARSED_ARGUMENTS}) file(GLOB files ${fp}) @@ -96,7 +94,6 @@ function(ROOT_GENERATE_DICTIONARY dictionary) endif() endforeach() #---call rootcint------------------------------------------ - message("W ${ROOTCINT_EXECUTABLE} ${dictionary}.cxx ${linkdefs}") add_custom_command(OUTPUT ${dictionary}.cxx ${dictionary}.h COMMAND ${ROOTCINT_EXECUTABLE} -cint -f ${dictionary}.cxx -c ${ARG_OPTIONS} ${includedirs} ${headerfiles} ${linkdefs}