@@ -7,8 +7,32 @@ set(_opts)
77
88# --- boilerplate follows
99message (STATUS "CMake ${CMAKE_VERSION} " )
10- if (CMAKE_VERSION VERSION_LESS 3.14)
11- message (FATAL_ERROR "Please update CMake >= 3.14" )
10+ if (CMAKE_VERSION VERSION_LESS 3.15)
11+ message (FATAL_ERROR "Please update CMake >= 3.15" )
12+ endif ()
13+
14+ # CTEST_CMAKE_GENERATOR must always be defined
15+ if (NOT DEFINED CTEST_CMAKE_GENERATOR AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.17)
16+ find_program (_gen NAMES ninja ninja-build samu)
17+ if (_gen)
18+ execute_process (COMMAND ${_gen} --version
19+ OUTPUT_VARIABLE _ninja_version
20+ OUTPUT_STRIP_TRAILING_WHITESPACE
21+ RESULT_VARIABLE _gen_ok
22+ TIMEOUT 10)
23+ if (_gen_ok EQUAL 0 AND _ninja_version VERSION_GREATER_EQUAL 1.10)
24+ set (CTEST_CMAKE_GENERATOR "Ninja" )
25+ endif ()
26+ endif (_gen)
27+ endif ()
28+ if (NOT DEFINED CTEST_CMAKE_GENERATOR)
29+ if (WIN32 )
30+ set (CTEST_CMAKE_GENERATOR "MinGW Makefiles" )
31+ set (CTEST_BUILD_FLAGS -j) # not --parallel as this goes to generator directly
32+ else ()
33+ set (CTEST_CMAKE_GENERATOR "Unix Makefiles" )
34+ set (CTEST_BUILD_FLAGS -j) # not --parallel as this goes to generator directly
35+ endif ()
1236endif ()
1337
1438# site is OS name
@@ -21,24 +45,6 @@ include(ProcessorCount)
2145ProcessorCount(Ncpu)
2246message (STATUS "${Ncpu} CPU cores detected" )
2347
24- # test name is Fortran compiler in FC
25- # Note: ctest scripts cannot read cache variables like CMAKE_Fortran_COMPILER
26- if (DEFINED ENV{FC})
27- set (FC $ENV{FC} )
28- set (CTEST_BUILD_NAME ${FC} )
29-
30- if (NOT DEFINED ENV{CC})
31- # use same compiler for C and Fortran, which CMake might not do itself
32- if (FC STREQUAL ifort)
33- if (WIN32 )
34- set (ENV{CC} icl)
35- else ()
36- set (ENV{CC} icc)
37- endif ()
38- endif ()
39- endif ()
40- endif ()
41-
4248if (NOT DEFINED CTEST_BUILD_CONFIGURATION)
4349 set (CTEST_BUILD_CONFIGURATION "Release" )
4450endif ()
@@ -48,20 +54,6 @@ if(NOT DEFINED CTEST_BINARY_DIRECTORY)
4854 set (CTEST_BINARY_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} /build )
4955endif ()
5056
51- # CTEST_CMAKE_GENERATOR must be defined in any case here.
52- if (NOT DEFINED CTEST_CMAKE_GENERATOR)
53- find_program (_gen NAMES ninja ninja-build samu)
54- if (_gen)
55- set (CTEST_CMAKE_GENERATOR "Ninja" )
56- elseif (WIN32 )
57- set (CTEST_CMAKE_GENERATOR "MinGW Makefiles" )
58- set (CTEST_BUILD_FLAGS -j) # not --parallel as this goes to generator directly
59- else ()
60- set (CTEST_CMAKE_GENERATOR "Unix Makefiles" )
61- set (CTEST_BUILD_FLAGS -j) # not --parallel as this goes to generator directly
62- endif ()
63- endif ()
64-
6557# -- build and test
6658ctest_start ("Experimental" ${CTEST_SOURCE_DIRECTORY} ${CTEST_BINARY_DIRECTORY} )
6759
0 commit comments