diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-08-19 10:17:20 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-08-19 10:18:02 +0300 |
commit | 0b677ae93c4084eefae60d77f7b89432abbaae07 (patch) | |
tree | ba08220a49621521086e630fe28fadc15eed5a02 | |
parent | 516bd619ccf71baee06ef1dae1ff1ea9e677ef9c (diff) | |
download | libatomic_ops-0b677ae93c4084eefae60d77f7b89432abbaae07.tar.gz |
Set default build type to RelWithDebInfo (CMake)
This enforces -O2 -g options passed to the compiler (in case of the
gcc or clang compiler), matching that of the configure-based build.
* CMakeLists.txt [!CMAKE_BUILD_TYPE && !CMAKE_CONFIGURATION_TYPES]
(CMAKE_BUILD_TYPE): Set to RelWithDebInfo; set property (listing all
possible values).
* CMakeLists.txt [enable_assertions]: Add -UNDEBUG compile option; add
comment.
-rw-r--r-- | CMakeLists.txt | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 938847e..d782280 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,15 @@ option(enable_docs "Build and install documentation" ON) option(enable_gpl "Build atomic_ops_gpl library" ON) option(install_headers "Install header and pkg-config metadata files" ON) +# Override the default build type to RelWithDebInfo (this instructs cmake to +# pass -O2 -g -DNDEBUG options to the compiler). +if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE + STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY + STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel") +endif() + # Convert VER_INFO values to [SO]VERSION ones. if (BUILD_SHARED_LIBS) # atomic_ops: @@ -94,7 +103,10 @@ else() add_definitions("-DAO_NO_PTHREADS") endif() -if (NOT enable_assertions) +if (enable_assertions) + # In case NDEBUG macro is defined e.g. by cmake -DCMAKE_BUILD_TYPE=Release. + add_compile_options("-UNDEBUG") +else() # Define to disable assertion checking. add_definitions("-DNDEBUG") endif() |