[mlpack-git] master: Add FORCE_CXX11 option to work around deficiencies in CMake. (a2d45eb)
gitdub at mlpack.org
gitdub at mlpack.org
Wed Oct 5 10:19:45 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/ebdb5abeaa3fd621a06ae663862bb72df76d2b40...a2d45ebc93d175602500df8136d54328399e40a8
>---------------------------------------------------------------
commit a2d45ebc93d175602500df8136d54328399e40a8
Author: Ryan Curtin <ryan at ratml.org>
Date: Wed Oct 5 10:19:45 2016 -0400
Add FORCE_CXX11 option to work around deficiencies in CMake.
This is meant to address #796.
>---------------------------------------------------------------
a2d45ebc93d175602500df8136d54328399e40a8
CMakeLists.txt | 38 +++++++++++++++++++++++---------------
src/mlpack/CMakeLists.txt | 5 -----
2 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0f18c3..eb25187 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,21 +1,6 @@
cmake_minimum_required(VERSION 2.8.5)
project(mlpack C CXX)
-# Ensure that we have a C++11 compiler. In newer versions of CMake, this is
-# done with target_compile_features() when the mlpack library target is added in
-# src/mlpack/CMakeLists.txt.
-if (${CMAKE_MAJOR_VERSION} LESS 3 OR
- (${CMAKE_MAJOR_VERSION} EQUAL 3 AND ${CMAKE_MINOR_VERSION} LESS 1))
- # Older versions of CMake do not support target_compile_features(), so we have
- # to use something kind of hacky.
- include(CMake/CXX11.cmake)
- check_for_cxx11_compiler(HAS_CXX11)
- if(NOT HAS_CXX11)
- message(FATAL_ERROR "No C++11 compiler available!")
- endif()
- enable_cxx11()
-endif()
-
# First, define all the compilation options.
# We default to debugging mode for developers.
option(DEBUG "Compile with debugging information." OFF)
@@ -31,8 +16,31 @@ option(BUILD_WITH_COVERAGE
"Build with support for code coverage tools (gcc only)." OFF)
option(MATHJAX
"Use MathJax for HTML Doxygen output (disabled by default)." OFF)
+option(FORCE_CXX11
+ "Don't check that the compiler supports C++11, just assume it. Make sure \
+ to specify any necessary flag to enable C++11 as part of CXXFLAGS." OFF)
enable_testing()
+# Ensure that we have a C++11 compiler. In newer versions of CMake, this is
+# done with target_compile_features() when the mlpack library target is added in
+# src/mlpack/CMakeLists.txt.
+if ((${CMAKE_MAJOR_VERSION} LESS 3 OR
+ (${CMAKE_MAJOR_VERSION} EQUAL 3 AND ${CMAKE_MINOR_VERSION} LESS 1))
+ AND NOT FORCE_CXX11)
+ # Older versions of CMake do not support target_compile_features(), so we have
+ # to use something kind of hacky.
+ include(CMake/CXX11.cmake)
+ check_for_cxx11_compiler(HAS_CXX11)
+ if(NOT HAS_CXX11)
+ message(FATAL_ERROR "No C++11 compiler available!")
+ endif()
+ enable_cxx11()
+elseif (NOT FORCE_CXX11)
+ # Use the newer C++11 checks.
+ include(../../CMake/NewCXX11.cmake)
+endif ()
+
+
# Include modules in the CMake directory.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake")
diff --git a/src/mlpack/CMakeLists.txt b/src/mlpack/CMakeLists.txt
index 82663a1..cc9008b 100644
--- a/src/mlpack/CMakeLists.txt
+++ b/src/mlpack/CMakeLists.txt
@@ -23,11 +23,6 @@ endif ()
# are set in the root CMakeLists.txt.
add_library(mlpack ${MLPACK_SRCS})
-if (NOT (${CMAKE_MAJOR_VERSION} LESS 3 OR
- (${CMAKE_MAJOR_VERSION} EQUAL 3 AND ${CMAKE_MINOR_VERSION} LESS 1)))
- include(../../CMake/NewCXX11.cmake)
-endif ()
-
# Generate export symbols for Windows, instead of adding __declspec(dllimport)
# and __declspec(dllexport) everywhere. However, those modifiers are still
# necessary for global variables (of which there are a few in mlpack).
More information about the mlpack-git
mailing list