Use Debug and Release variables from CMake (#3865)
* Use Debug and Release variables from CMake Signed-off-by: Omar Shrit <omar@avontech.fr> * Bring back the debug option Signed-off-by: Omar Shrit <omar@avontech.fr> * Remove automatically set options Signed-off-by: Omar Shrit <omar@avontech.fr> * Document the new option and remove the deprecated ones Signed-off-by: Omar Shrit <omar@avontech.fr> * Fix missing endif () Signed-off-by: Omar Shrit <omar@avontech.fr> * Fix the history, typo and docs Signed-off-by: Omar Shrit <omar@avontech.fr> --------- Signed-off-by: Omar Shrit <omar@avontech.fr>
This commit is contained in:
+14
-17
@@ -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.
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
+2
-4
@@ -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. ||
|
||||
|
||||
Reference in New Issue
Block a user