diff --git a/CMake/CXX11.cmake b/CMake/CXX11.cmake deleted file mode 100644 index ac2ca53139..0000000000 --- a/CMake/CXX11.cmake +++ /dev/null @@ -1,48 +0,0 @@ -# This is cloned from -# https://github.com/nitroshare/CXX11-CMake-Macros -# until C++11 support finally hits CMake stable (should be 3.1, I think). - -# Copyright (c) 2013 Nathan Osman - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -# Determines whether or not the compiler supports C++11 -macro(check_for_cxx11_compiler _VAR) - message(STATUS "Checking for C++11 compiler") - set(${_VAR}) - if((MSVC AND (MSVC14)) OR - (CMAKE_COMPILER_IS_GNUCXX AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.6) OR - (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.1) OR - (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 12.0)) - set(${_VAR} 1) - message(STATUS "Checking for C++11 compiler - available") - else() - message(STATUS "Checking for C++11 compiler - unavailable") - endif() -endmacro() - -# Sets the appropriate flag to enable C++11 support -macro(enable_cxx11) - if(CMAKE_COMPILER_IS_GNUCXX OR - CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR - CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - endif() -endmacro() - diff --git a/CMake/FindPythonModule.cmake b/CMake/FindPythonModule.cmake index 60fd7a9f55..73a0b3e180 100644 --- a/CMake/FindPythonModule.cmake +++ b/CMake/FindPythonModule.cmake @@ -20,7 +20,7 @@ function(find_python_module module) endif () # A module's location is usually a directory, but for binary modules # it's a .so file. - execute_process(COMMAND "${PYTHON}" "-c" + execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" "import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))" RESULT_VARIABLE _${module}_status OUTPUT_VARIABLE _${module}_location @@ -28,7 +28,7 @@ function(find_python_module module) if (NOT _${module}_status) # Now we have to check the version. if (VERSION_REQ) - execute_process(COMMAND "${PYTHON}" "-c" + execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" "import ${module}; from distutils.version import StrictVersion; print(StrictVersion(${module}.__version__) >= StrictVersion('${VERSION_REQ}'));" RESULT_VARIABLE _version_status OUTPUT_VARIABLE _version_compare diff --git a/CMakeLists.txt b/CMakeLists.txt index ea42a24c60..0149693e62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.10) +cmake_minimum_required(VERSION 3.3.2) project(mlpack C CXX) include(CMake/cotire.cmake) @@ -31,27 +31,9 @@ if (WIN32) message(WARNING "By default Python bindings are not compiled for Windows because they are not known to work. Set BUILD_PYTHON_BINDINGS to ON if you want them built.") endif() -# 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() -else() - # set required standard to c++11 - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED ON) -endif () -# Otherwise, we may have to set the C++11 mode after the mlpack target is -# defined. +# Set required standard to c++11 +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) # Include modules in the CMake directory. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake") diff --git a/HISTORY.md b/HISTORY.md index 2e0728f347..c2f530f2d2 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +### mlpack 3.0.4 +###### ????-??-?? + * Bump minimum CMake version to 3.3.2. + + * CMake fixes for Ninja generator by Marc Espie. + ### mlpack 3.0.3 ###### 2018-07-27 * Fix Visual Studio compilation issue (#1443). diff --git a/README.md b/README.md index 3f39ae086f..5c525312aa 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ mlpack has the following dependencies: Armadillo >= 6.500.0 Boost (program_options, math_c99, unit_test_framework, serialization, spirit) - CMake >= 2.8.5 + CMake >= 3.3.2 All of those should be available in your distribution's package manager. If not, you will have to compile each of them by hand. See the documentation for diff --git a/src/mlpack/bindings/python/CMakeLists.txt b/src/mlpack/bindings/python/CMakeLists.txt index 4823c00457..f5f8cf94cc 100644 --- a/src/mlpack/bindings/python/CMakeLists.txt +++ b/src/mlpack/bindings/python/CMakeLists.txt @@ -15,11 +15,11 @@ endif () # Generate Python setuptools file. # We can probably use FindPythonInterp when we require CMake 3.0. -find_program(PYTHON "python" REQUIRED) -if (NOT PYTHON) +find_package(PythonInterp REQUIRED) +if (NOT PYTHON_EXECUTABLE) not_found_return("Python not found; not building Python bindings.") else () - message(STATUS "Found Python: ${PYTHON}") + message(STATUS "Found Python: ${PYTHON_EXECUTABLE}") endif () # Import find_python_module. @@ -135,14 +135,14 @@ endif () # Install any dependencies via setuptools automatically. add_custom_command(TARGET python_copy POST_BUILD - COMMAND ${CMAKE_COMMAND} -E env NO_BUILD=1 ${PYTHON} + COMMAND ${CMAKE_COMMAND} -E env NO_BUILD=1 ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py build WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/) # Then do the actual build. add_custom_command(TARGET python POST_BUILD - COMMAND ${PYTHON} ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py - build_ext + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py build_ext DEPENDS mlpack/arma_numpy.pxd mlpack/arma_numpy.pyx mlpack/arma.pxd @@ -155,19 +155,19 @@ add_custom_command(TARGET python POST_BUILD # Copy the built artifacts, so that it is also an in-place build. add_custom_command(TARGET python POST_BUILD - COMMAND ${PYTHON} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/copy_artifacts.py WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/) add_dependencies(python python_copy) # Configure installation script file. -execute_process(COMMAND ${PYTHON} +execute_process(COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/print_python_version.py" "${CMAKE_INSTALL_PREFIX}" OUTPUT_VARIABLE NEW_PYTHONPATH) install(CODE "set(ENV{PYTHONPATH} ${NEW_PYTHONPATH})") install(CODE "execute_process(COMMAND mkdir -p $ENV{DESTDIR}${NEW_PYTHONPATH})") -install(CODE "execute_process(COMMAND ${PYTHON} +install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} \"${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py\" install --prefix=${CMAKE_INSTALL_PREFIX} --root=$ENV{DESTDIR} WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/\")") @@ -207,7 +207,8 @@ if (BUILD_PYTHON_BINDINGS) # enforce it here. Although this will always be rebuilt, that's okay because # distutils will determine whether or not it *actually* needs to be rebuilt. add_custom_target(build_pyx_${name} - ${PYTHON} ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py + ${PYTHON_EXECUTABLE} + ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py build_ext --module=${name}.pyx DEPENDS generate_pyx_${name} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/ @@ -227,8 +228,8 @@ endmacro () # Add a test. if (BUILD_PYTHON_BINDINGS) add_test(NAME python_bindings_test - COMMAND ${PYTHON} ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py - test + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py test WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/) set_tests_properties(python_bindings_test PROPERTIES ENVIRONMENT "NO_BUILD=1;LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_BINARY_DIR}/lib/") diff --git a/src/mlpack/methods/adaboost/CMakeLists.txt b/src/mlpack/methods/adaboost/CMakeLists.txt index 5505f057fb..583131ad45 100644 --- a/src/mlpack/methods/adaboost/CMakeLists.txt +++ b/src/mlpack/methods/adaboost/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 2.8) - # Define the files we need to compile. # Anything not in this list will not be compiled into mlpack. set(SOURCES diff --git a/src/mlpack/methods/decision_stump/CMakeLists.txt b/src/mlpack/methods/decision_stump/CMakeLists.txt index e9d9c04c1a..26042b4435 100644 --- a/src/mlpack/methods/decision_stump/CMakeLists.txt +++ b/src/mlpack/methods/decision_stump/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 2.8) - # Define the files we need to compile. # Anything not in this list will not be compiled into mlpack. set(SOURCES diff --git a/src/mlpack/methods/decision_tree/CMakeLists.txt b/src/mlpack/methods/decision_tree/CMakeLists.txt index 448e4d62ee..25598133b7 100644 --- a/src/mlpack/methods/decision_tree/CMakeLists.txt +++ b/src/mlpack/methods/decision_tree/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 2.8) - # Define the files we need to compile. # Anything not in this list will not be compiled into mlpack. set(SOURCES diff --git a/src/mlpack/methods/perceptron/CMakeLists.txt b/src/mlpack/methods/perceptron/CMakeLists.txt index f0b4afc596..8e6763464d 100644 --- a/src/mlpack/methods/perceptron/CMakeLists.txt +++ b/src/mlpack/methods/perceptron/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 2.8) - # Define the files we need to compile. # Anything not in this list will not be compiled into mlpack. set(SOURCES diff --git a/src/mlpack/methods/random_forest/CMakeLists.txt b/src/mlpack/methods/random_forest/CMakeLists.txt index 3ac70de8a8..bfc6121ad6 100644 --- a/src/mlpack/methods/random_forest/CMakeLists.txt +++ b/src/mlpack/methods/random_forest/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 2.8) - # Define the files we need to compile. # Anything not in this list will not be compiled into mlpack. set(SOURCES