@@ -41,10 +41,13 @@ string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen_minor_
4141set (EIGEN_MINOR_VERSION "${CMAKE_MATCH_1} " )
4242set (EIGEN_VERSION_NUMBER ${EIGEN_WORLD_VERSION} .${EIGEN_MAJOR_VERSION} .${EIGEN_MINOR_VERSION} )
4343
44- # if the mercurial program is absent, this will leave the EIGEN_HG_CHANGESET string empty,
45- # but won't stop CMake.
46- execute_process (COMMAND hg tip -R ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE EIGEN_HGTIP_OUTPUT)
47- execute_process (COMMAND hg branch -R ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE EIGEN_BRANCH_OUTPUT)
44+ # if we are not in a mercurial clone
45+ if (IS_DIRECTORY ${CMAKE_SOURCE_DIR} /.hg)
46+ # if the mercurial program is absent or this will leave the EIGEN_HG_CHANGESET string empty,
47+ # but won't stop CMake.
48+ execute_process (COMMAND hg tip -R ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE EIGEN_HGTIP_OUTPUT)
49+ execute_process (COMMAND hg branch -R ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE EIGEN_BRANCH_OUTPUT)
50+ endif ()
4851
4952# if this is the default (aka development) branch, extract the mercurial changeset number from the hg tip output...
5053if (EIGEN_BRANCH_OUTPUT MATCHES "default" )
@@ -64,6 +67,33 @@ include(GNUInstallDirs)
6467
6568set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} /cmake)
6669
70+
71+ option (EIGEN_TEST_CXX11 "Enable testing with C++11 and C++11 features (e.g. Tensor module)." OFF )
72+
73+
74+ macro (ei_add_cxx_compiler_flag FLAG)
75+ string (REGEX REPLACE "-" "" SFLAG1 ${FLAG} )
76+ string (REGEX REPLACE "\\ +" "p" SFLAG ${SFLAG1} )
77+ check_cxx_compiler_flag(${FLAG} COMPILER_SUPPORT_${SFLAG} )
78+ if (COMPILER_SUPPORT_${SFLAG} )
79+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG} " )
80+ endif ()
81+ endmacro (ei_add_cxx_compiler_flag)
82+
83+ check_cxx_compiler_flag("-std=c++11" EIGEN_COMPILER_SUPPORT_CPP11)
84+
85+ if (EIGEN_TEST_CXX11)
86+ set (CMAKE_CXX_STANDARD 11)
87+ set (CMAKE_CXX_EXTENSIONS OFF )
88+ if (EIGEN_COMPILER_SUPPORT_CPP11)
89+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
90+ endif ()
91+ else ()
92+ #set(CMAKE_CXX_STANDARD 03)
93+ #set(CMAKE_CXX_EXTENSIONS OFF)
94+ ei_add_cxx_compiler_flag("-std=c++03" )
95+ endif ()
96+
6797#############################################################################
6898# find how to link to the standard libraries #
6999#############################################################################
@@ -115,15 +145,6 @@ endif()
115145
116146set (EIGEN_TEST_MAX_SIZE "320" CACHE STRING "Maximal matrix/vector size, default is 320" )
117147
118- macro (ei_add_cxx_compiler_flag FLAG)
119- string (REGEX REPLACE "-" "" SFLAG1 ${FLAG} )
120- string (REGEX REPLACE "\\ +" "p" SFLAG ${SFLAG1} )
121- check_cxx_compiler_flag(${FLAG} COMPILER_SUPPORT_${SFLAG} )
122- if (COMPILER_SUPPORT_${SFLAG} )
123- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG} " )
124- endif ()
125- endmacro (ei_add_cxx_compiler_flag)
126-
127148if (NOT MSVC )
128149 # We assume that other compilers are partly compatible with GNUCC
129150
@@ -359,8 +380,6 @@ if(EIGEN_TEST_NO_EXCEPTIONS)
359380 message (STATUS "Disabling exceptions in tests/examples" )
360381endif ()
361382
362- option (EIGEN_TEST_CXX11 "Enable testing with C++11 and C++11 features (e.g. Tensor module)." OFF )
363-
364383set (EIGEN_CUDA_COMPUTE_ARCH 30 CACHE STRING "The CUDA compute architecture level to target when compiling CUDA code" )
365384
366385include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
@@ -416,16 +435,15 @@ add_subdirectory(Eigen)
416435
417436add_subdirectory (doc EXCLUDE_FROM_ALL )
418437
419- include (EigenConfigureTesting)
420-
421- # fixme, not sure this line is still needed:
422- enable_testing () # must be called from the root CMakeLists, see man page
438+ option (BUILD_TESTING "Enable creation of Eigen tests." ON )
439+ if (BUILD_TESTING)
440+ include (EigenConfigureTesting)
423441
424-
425- if (EIGEN_LEAVE_TEST_IN_ALL_TARGET)
426- add_subdirectory ( test ) # can't do EXCLUDE_FROM_ALL here, breaks CTest
427- else ( )
428- add_subdirectory ( test EXCLUDE_FROM_ALL )
442+ if (EIGEN_LEAVE_TEST_IN_ALL_TARGET)
443+ add_subdirectory ( test ) # can't do EXCLUDE_FROM_ALL here, breaks CTest
444+ else ()
445+ add_subdirectory ( test EXCLUDE_FROM_ALL )
446+ endif ( )
429447endif ()
430448
431449if (EIGEN_LEAVE_TEST_IN_ALL_TARGET)
@@ -461,7 +479,9 @@ endif(NOT WIN32)
461479
462480configure_file (scripts/cdashtesting.cmake.in cdashtesting.cmake @ONLY)
463481
464- ei_testing_print_summary()
482+ if (BUILD_TESTING)
483+ ei_testing_print_summary()
484+ endif ()
465485
466486message (STATUS "" )
467487message (STATUS "Configured Eigen ${EIGEN_VERSION_NUMBER} " )
0 commit comments