diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bf8a5a6b7..06b2ebf2f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.6) +cmake_minimum_required(VERSION 3.11) project(mlpack C CXX) include(CMake/CheckHash.cmake) @@ -7,7 +7,6 @@ include(CMake/ConfigureCrossCompile.cmake) include(CMake/CheckAtomic.cmake) # First, define all the compilation options. -# We default to debugging mode for developers. option(DEBUG "Compile with debugging information." OFF) option(PROFILE "Compile with profiling information." OFF) option(ARMA_EXTRA_DEBUG "Compile with extra Armadillo debugging symbols." OFF) @@ -27,6 +26,14 @@ set(ARMADILLO_VERSION "10.8") set(ENSMALLEN_VERSION "2.10.0") set(CEREAL_VERSION "1.1.2") +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + +if (PROFILE) + message(WARNING "The PROFILE option is deprecated and will be removed in mlpack 5.0.0; specify -DCMAKE_CXX_FLAGS=\"-pg\" instead!") +endif() + # Consider using ccache find_program(CCACHE_PROGRAM ccache) if(CCACHE_PROGRAM) @@ -230,10 +237,13 @@ endif() # Debugging CFLAGS. Turn optimizations off; turn debugging symbols on. set (BFD_DL_AVAILABLE "NO") if (DEBUG) + message(WARNING "The DEBUG option is deprecated and will be removed in mlpack 5.0.0; specify CMAKE_BUILD_TYPE as \"Debug\" instead!") +endif () + +if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR DEBUG) if (NOT MSVC) add_definitions(-DDEBUG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -ftemplate-backtrace-limit=0") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g -O0") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-backtrace-limit=0") endif() # mlpack uses it's own mlpack::backtrace class based on Binary File Descriptor @@ -252,19 +262,6 @@ if (DEBUG) message(WARNING "No libBFD and/or libDL has been found!") endif() endif() -else() - add_definitions(-DNDEBUG) - if (NOT MSVC) - if (NOT CMAKE_CROSSCOMPILING) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -O3") - else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") - endif() - else () - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O3") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /O3") - endif () endif() # Profiling CFLAGS. Turn profiling information on. diff --git a/HISTORY.md b/HISTORY.md index 8f6f2cec39..a3ae7c13de 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,7 +6,8 @@ _????-??-??_ * Fix command-line duplicate output bug when loading matrices for some bindings (#3838). - + * Use `CMAKE_BUILD_TYPE` to specify build type instead of DEBUG and PROFILE options (#3865). + * Add `MLPACK_NO_STD_MUTEX` to allow disabling `std::mutex` (#3868). ## mlpack 4.5.1 diff --git a/doc/user/build_windows.md b/doc/user/build_windows.md index 823711ec38..afa6760443 100644 --- a/doc/user/build_windows.md +++ b/doc/user/build_windows.md @@ -139,7 +139,7 @@ compiler and Windows SDK are installed correctly. - Run cmake: ``` -cmake -G "Visual Studio 16 2019" -A x64 -DBLAS_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DLAPACK_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DARMADILLO_INCLUDE_DIR="C:/mlpack/armadillo/include" -DARMADILLO_LIBRARY:FILEPATH="C:/mlpack/armadillo/build/Debug/armadillo.lib" -DDEBUG=OFF -DPROFILE=OFF .. +cmake -G "Visual Studio 16 2019" -A x64 -DBLAS_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DLAPACK_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DARMADILLO_INCLUDE_DIR="C:/mlpack/armadillo/include" -DARMADILLO_LIBRARY:FILEPATH="C:/mlpack/armadillo/build/Debug/armadillo.lib" .. ``` *Note*: CMake will attempt to automatically download the ensmallen dependency. diff --git a/doc/user/install.md b/doc/user/install.md index 8adaddc506..f87c670009 100644 --- a/doc/user/install.md +++ b/doc/user/install.md @@ -187,15 +187,13 @@ The following options can be used when configuring mlpack. | ***Option*** | ***Description*** | ***Default*** | |--------------|-------------------|---------------| | ***General configuration*** ||| +| `-DCMAKE_BUILD_TYPE="build type"` | Specify the build configuration: `"Debug"`, `"Release"`, `"RelWithDebInfo"`, `"MinSizeRel"`. See the [CMake documentation](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html#variable:CMAKE_BUILD_TYPE). | `"Release"`| | `-DDOWNLOAD_DEPENDENCIES=ON` | Download all dependencies that are not found on the system. | `OFF` | -| `-DDEBUG=ON` | Compile with debugging symbols. | `OFF` | -| `-DPROFILE=ON` | Compile with profiling symbols. | `OFF` | | `-DARMA_EXTRA_DEBUG=ON` | Emit extra Armadillo debugging output (warning: *very* verbose). | `OFF` | | `-DTEST_VERBOSE=ON` | Emit verbose output when running tests. | `OFF` | | `-DBUILD_TESTS=ON` | Build `mlpack_test`. | `OFF` | | `-DUSE_OPENMP=ON` | Use OpenMP for parallelization. | `ON` | -| `-DUSE_PRECOMPILED_HEADERS=OFF` | Disable precompiled headers during build. | -`OFF` | +| `-DUSE_PRECOMPILED_HEADERS=OFF` | Disable precompiled headers during build. | `OFF` | |--------------|-------------------|---------------| | ***Dependency locations*** ||| | `-DARMADILLO_INCLUDE_DIR=/path/to/arma/include/` | Path containing `armadillo` header file. ||