C++QED  v2 Milestone 10
a framework for simulating open quantum dynamics
CMakeLists.cmake
1 # Copyright Raimar Sandner 2012–2014. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt)
2 
3 #! \ingroup Main
4 #! \file
5 #! \brief %CMake file for the C++QED testing suite.
6 #!
7 #! The file has the following structure:
8 
9 project(testing)
10 
11 # Please avoid any special characters in test names (+,^,.,etc.)
12 # The ctest command might interpret them as regular expressions
13 
14 
15 #! \file
16 #! <!--#########################################################-->
17 #! ### Configuration of the test suite
18 #! <!--#########################################################-->
19 #!
20 #! Find the Python interpreter and add the targets `check_fast` and `ckeck` (c.f. \ref testsuite_running).
21 #! Also defines helper macros.
22 
23 include(${core_BINARY_DIR}/CPPQEDConfig.cmake)
24 include(${CPPQED_USE})
25 
26 find_package(Scipy)
27 
28 if(NOT ( PYTHONINTERP_FOUND AND NUMPY_FOUND AND SCIPY_FOUND ) )
29  message(WARNING "Disabling testsuite, not all Python components are available")
30  return()
31 endif()
32 
33 if(NOT COMPILE_SCRIPTS)
34  message(WARNING "Disabling testsuite, scripts are not compiled.")
35  return()
36 endif()
37 
38 configure_file(testdriver.conf.in testdriver.conf)
39 configure_file(${CMAKE_SOURCE_DIR}/helperscripts/check_push.sh.in ${CMAKE_BINARY_DIR}/check_push.sh @ONLY)
40 
41 #! \file
42 #! <!--#########################################################-->
43 #! ### Convenience custom targets
44 #! <!--#########################################################-->
45 #!
46 
47 if(NOT XCODE)
48  add_custom_target(check_fast DEPENDS check_compilefail check_run check_continue check_boost testdriver.conf.in)
49  add_custom_target(check DEPENDS check_fast check_compile check_cpypyqed)
50  add_custom_target(check_full DEPENDS check_physics check)
51  add_custom_target(check_push COMMAND ${CMAKE_BINARY_DIR}/check_push.sh)
52 endif()
53 
54 #! \name Project options
55 #! @{
56 
57 #! Number of parallel test jobs for the test suite, default 1.
58 set(TEST_PARALLEL 1 CACHE STRING "Number of parallel test jobs for the test suite.")
59 set_property(CACHE TEST_PARALLEL PROPERTY STRINGS 1 2 3 4 5 6 7 8 9 10)
60 set(CTEST_J "-j${TEST_PARALLEL}")
61 #! Switch verbose test output.
62 option(TEST_VERBOSE "Verbose output in test suite." Off)
63 #! @}
64 if(TEST_VERBOSE)
65  set(CTEST_V "-V")
66 endif()
67 
68 #! \brief Initialize a sub-directory of the test suite.
69 #! \ingroup Helpers
70 #! \param dir The sub-directory name.
71 #! \return `TESTSCRIPT` - set to the command by which to call the Python test driver.
72 #!
73 #! This macro adds the target `check_${dir}` and makes it depend on any target passed as argument after `dir`.
74 #! This target runs all tests in the current sub-directory.
75 #! It also sets the variable `TESTSCRIPT`, which holds the full path to the python test driver and already
76 #! adds some command line parameters: the configuration files and the build configuration.
77 macro(testdir dir)
78  set(TESTSDEPEND cpypyqed ${ARGN})
79  if(NOT XCODE)
80  add_custom_target(check_${dir}
81  COMMAND ${CMAKE_CTEST_COMMAND} ${CTEST_V} ${CTEST_J}
82  DEPENDS ${TESTSDEPEND}
83  )
84  endif()
85  set(TESTSCRIPT ${testing_SOURCE_DIR}/testdriver.py ${testing_BINARY_DIR}/testdriver.conf ${CMAKE_CURRENT_LIST_DIR}/testdriver.conf --configuration=$<CONFIGURATION>)
86 endmacro()
87 
88 #! \brief Declare a new test.
89 #! \ingroup Helpers
90 #! \param name Name of the test. Avoid any special characters (+,\,$ etc), which might be mis-interpreted in a regular expression.
91 #! \return `TESTNAME` - holds the name of the test.
92 #!
93 #! Besides setting `TESTNAME`, this macro adds a new target `name` which runs the specific test alone.
94 macro(declaretest name)
95  set(TESTNAME ${name})
96  if(NOT XCODE)
97  add_custom_target(${name} COMMAND ${CMAKE_CTEST_COMMAND} ${CTEST_V} -R "^${name}$" DEPENDS ${TESTSDEPEND})
98  endif()
99 endmacro()
100 
101 #! \file
102 #! <!--#########################################################-->
103 #! ### Adding all sub-directories to the test suite
104 #! <!--#########################################################-->
105 #!
106 
107 add_subdirectory(run)
108 add_subdirectory(continue)
109 add_subdirectory(compile)
110 add_subdirectory(compilefail)
111 add_subdirectory(boost)
112 add_subdirectory(cpypyqed)
113 add_subdirectory(physics)