Skip to content
Snippets Groups Projects
Commit 21df6cde authored by Markus Blatt's avatar Markus Blatt
Browse files

Finally cmake to build the test during make test, that is on demand.

Now make test works in all directories.

[[Imported from SVN: r6679]]
parent a4f9acfa
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,9 @@ cmake_minimum_required(VERSION 2.8)
# make sure our own modules are found
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
# set the script dir for the macros.
set(DUNE_COMMON_SCRIPT_DIR "${CMAKE_SOURCE_DIR}/cmake/scripts")
#include the dune macros
include(DuneMacros)
......@@ -21,3 +24,5 @@ add_subdirectory("cmake/scripts")
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project()
include(CPack)
test_dep()
MACRO(test_dep)
execute_process(COMMAND ${CMAKE_COMMAND} -D RELPATH=${CMAKE_SOURCE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/scripts/FindFiles.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE _res ERROR_VARIABLE _dirs)
foreach(_dir ${_dirs})
string(REGEX REPLACE "([^ \t\n]+)[ \n\t]*$" "\\1" _dir ${_dir})
set_property(DIRECTORY ${_dir} PROPERTY TEST_INCLUDE_FILE ${CMAKE_BINARY_DIR}/${_dir}/BuildTests.cmake)
endforeach(_dir ${_dirs})
ENDMACRO(test_dep)
MACRO(get_directory_test_target _target _dir)
string(REPLACE "${CMAKE_BINARY_DIR}" "" _relative_dir "${_dir}")
string(REPLACE "/" "_" ${_target} "${_relative_dir}")
ENDMACRO(get_directory_test_target _target _dir)
MACRO(add_directory_test_target _target)
get_directory_test_target(${_target} "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_target(${${_target}})
configure_file(${DUNE_COMMON_SCRIPT_DIR}/BuildTests.cmake.in BuildTests.cmake @ONLY)
ENDMACRO(add_directory_test_target)
......@@ -6,17 +6,14 @@
# This really sucks!
# Therefore currently make build_tests has to be called
# before make test.
add_custom_target(build_tests DEPENDS ${TESTPROGS})
# mimic make check of the autotools
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS build_tests)
# enable testing before adding the subdirectories.
# Thus we can add the tests in the subdirectories
# where they actually are.
enable_testing()
#add_custom_target(build_test)
set_property(TEST APPEND PROPERTY DEPENDS build_tests)
#activate CTest
include(CTest)
#include our macros
include(DuneTestMacros)
MACRO(get_directory_test_target _target _dir)
message("$_dir")
string(REPLACE "@CMAKE_BINARY_DIR@" "" _relative_dir "${_dir}")
message("$_relative_dir")
string(REPLACE "/" "_" ${_target} "${_relative_dir}")
message("target=${${_target}}")
ENDMACRO(get_directory_test_target _target _dir)
get_directory_test_target(_build_test_target "@CMAKE_CURRENT_BINARY_DIR@")
message("binary_dir=@CMAKE_CURRENT_BINARY_DIR@")
execute_process(COMMAND @CMAKE_COMMAND@ --build @CMAKE_BINARY_DIR@
--target ${_build_test_target})
\ No newline at end of file
file(GLOB modules *.cmake)
install(FILES ${modules} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/scripts)
install(FILES ${modules} ${CMAKE_CURRENT_SOURCE_DIR}/BuildTests.cmake.in DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/scripts)
file(GLOB_RECURSE makefiles RELATIVE ${RELPATH} "CMakeLists.txt")
foreach(_file ${makefiles})
string(REGEX MATCH ".*test" _testdir ${_file})
if(_testdir)
list(APPEND _makefiles ${_testdir})
endif(_testdir)
endforeach(_file ${_makefiles})
message("${_makefiles}")
set(MPITESTPROGS indicestest indexsettest syncertest selectiontest)
add_directory_test_target(_test_target)
# We do not want want to build the tests during make all,
# but just build them on demand
add_dependencies(build_tests ${MPITESTPROGS})
add_dependencies(${_test_target} ${MPITESTPROGS})
add_executable("indexsettest" indexsettest.cc)
target_link_libraries("indexsettest" "dunecommon" ${CMAKE_THREAD_LIBS_INIT} ${})
......
......@@ -65,7 +65,8 @@ set(TESTPROGS ${TESTS} ${FAILTESTS})
# We do not want want to build the tests during make all,
# but just build them on demand
add_dependencies(build_tests ${TESTPROGS})
add_directory_test_target(_test_target)
add_dependencies(${_test_target} ${TESTPROGS})
# Add the executables needed for the tests
add_executable("arraylisttest" arraylisttest.cc)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment