diff options
author | Raffi Enficiaud <raffi.enficiaud@mines-paris.org> | 2015-05-29 15:44:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-06-01 13:24:06 (GMT) |
commit | 8444809c47b0c2d6b9b2b57bd62d9a51fc5fa498 (patch) | |
tree | 4e7b0dccb695f5b8086256061e894a75e790faae /Tests/RunCMake/FindMatlab/RunCMakeTest.cmake | |
parent | 5752e558053261bdefc6294d9f13918e1233cd9e (diff) | |
download | CMake-8444809c47b0c2d6b9b2b57bd62d9a51fc5fa498.zip CMake-8444809c47b0c2d6b9b2b57bd62d9a51fc5fa498.tar.gz CMake-8444809c47b0c2d6b9b2b57bd62d9a51fc5fa498.tar.bz2 |
FindMatlab: fix reconfiguration of Matlab_ROOT_DIR
Diffstat (limited to 'Tests/RunCMake/FindMatlab/RunCMakeTest.cmake')
-rw-r--r-- | Tests/RunCMake/FindMatlab/RunCMakeTest.cmake | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake b/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake index 33dbb77..f0eb6b4 100644 --- a/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake @@ -1,3 +1,51 @@ include(RunCMake) run_cmake(MatlabTest1) + +if(RunCMake_GENERATOR MATCHES "Make" AND UNIX) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RerunFindMatlab-build-init) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + message(STATUS "RerunFindMatlab: first configuration to extract real Matlab_ROOT_DIR") + set(RunCMake_TEST_OPTIONS "-Dmatlab_required=REQUIRED") + run_cmake(MatlabTest2) + + message(STATUS "RerunFindMatlab: flushing the variables") + execute_process(COMMAND + ${CMAKE_COMMAND} -L ${RunCMake_TEST_BINARY_DIR} + RESULT_VARIABLE _MatlabTest2_error + OUTPUT_VARIABLE _MatlabTest2_output) + if(NOT _MatlabTest2_error EQUAL 0) + message(FATAL_ERROR "RerunFindMatlab: cannot list the variables ...") + endif() + + string(REGEX MATCH "Matlab_ROOT_DIR.+=([^\r\n]+)" _matched ${_MatlabTest2_output}) + + set(Matlab_ROOT_DIR_correct "${CMAKE_MATCH_1}") + if(Matlab_ROOT_DIR_correct STREQUAL "") + message(FATAL_ERROR "RerunFindMatlab: cannot extract Matlab_ROOT_DIR") + endif() + message(STATUS "RerunFindMatlab: detected correct Matlab_ROOT_DIR=${Matlab_ROOT_DIR_correct}") + + message(STATUS "RerunFindMatlab: change configuration, incorrect Matlab_ROOT_DIR setting") + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RerunFindMatlab-build-second) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + set(RunCMake_TEST_OPTIONS "-DMatlab_ROOT_DIR=/" "-Dmatlab_required=") + run_cmake(MatlabTest2) + + message(STATUS "RerunFindMatlab: fixing configuration with correct Matlab_ROOT_DIR setting") + set(RunCMake_TEST_OPTIONS "-DMatlab_ROOT_DIR=${Matlab_ROOT_DIR_correct}") # required this time? + run_cmake(MatlabTest2) + + # no target on this test + run_cmake_command(MatlabTest2 ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endif() |