aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Walch <florian@fwalch.com>2015-09-28 12:14:38 +0200
committerFlorian Walch <florian@fwalch.com>2015-11-01 15:41:36 +0100
commit87e5a4131666e44354f280538cbc6bbe52225092 (patch)
treef8138925b61e40ad277ae2f662d6d5ad7c4b025d
parent2e4baa9ae475e1ea01c5e15a440933b4814f0637 (diff)
downloadrneovim-87e5a4131666e44354f280538cbc6bbe52225092.tar.gz
rneovim-87e5a4131666e44354f280538cbc6bbe52225092.tar.bz2
rneovim-87e5a4131666e44354f280538cbc6bbe52225092.zip
CMake: Add custom Dev build type.
Introduce new build type Dev that replaces RelWithDebInfo for development builds off master and has optimizations, debug info, and logging enabled. Keep assertions enabled for RelWithDebInfo.
-rw-r--r--CMakeLists.txt62
-rw-r--r--contrib/local.mk.example11
2 files changed, 50 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3db32f1966..dcc5edb52a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,12 +38,12 @@ endif()
# Set available build types for CMake GUIs.
# A different build type can still be set by -DCMAKE_BUILD_TYPE=...
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
- STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
+ STRINGS "Debug" "Dev" "Release" "MinSizeRel" "RelWithDebInfo")
# Set default build type.
if(NOT CMAKE_BUILD_TYPE)
- message(STATUS "CMAKE_BUILD_TYPE not given; setting to 'RelWithDebInfo'.")
- set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)
+ message(STATUS "CMAKE_BUILD_TYPE not given, defaulting to 'Dev'.")
+ set(CMAKE_BUILD_TYPE "Dev" CACHE STRING "Choose the type of build." FORCE)
endif()
# Version tokens
@@ -74,6 +74,46 @@ if(CMAKE_C_FLAGS_RELEASE MATCHES "-O3")
string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
endif()
+# Enable assertions for RelWithDebInfo.
+if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG)
+ string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
+endif()
+
+# Set build flags for custom Dev build type.
+# -DNDEBUG purposely omitted because we want assertions.
+if(MSVC)
+ SET(CMAKE_C_FLAGS_DEV ""
+ CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds."
+ FORCE)
+else()
+ if(CMAKE_COMPILER_IS_GNUCC)
+ check_c_compiler_flag(-Og HAS_OG_FLAG)
+ else()
+ set(HAS_OG_FLAG 0)
+ endif()
+
+ if(HAS_OG_FLAG)
+ set(CMAKE_C_FLAGS_DEV "-Og -g"
+ CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds."
+ FORCE)
+ else()
+ set(CMAKE_C_FLAGS_DEV "-O2 -g"
+ CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds."
+ FORCE)
+ endif()
+endif()
+SET(CMAKE_EXE_LINKER_FLAGS_DEV ""
+ CACHE STRING "Flags used for linking binaries during development (optimized, but with debug info and logging) builds."
+ FORCE)
+SET(CMAKE_SHARED_LINKER_FLAGS_DEV ""
+ CACHE STRING "Flags used by the shared libraries linker during development (optimized, but with debug info and logging) builds."
+ FORCE)
+
+MARK_AS_ADVANCED(
+ CMAKE_C_FLAGS_DEV
+ CMAKE_EXE_LINKER_FLAGS_DEV
+ CMAKE_SHARED_LINKER_FLAGS_DEV)
+
# Enable -Wconversion.
if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion")
@@ -177,22 +217,6 @@ if(TRAVIS_CI_BUILD)
add_definitions(-Werror)
endif()
-if(CMAKE_COMPILER_IS_GNUCC)
- check_c_compiler_flag(-Og HAS_OG_FLAG)
-else()
- set(HAS_OG_FLAG 0)
-endif()
-
-# Set custom build flags for RelWithDebInfo.
-# -DNDEBUG purposely omitted because we want assertions.
-if(HAS_OG_FLAG)
- set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Og -g"
- CACHE STRING "Flags used by the compiler during release builds with debug info." FORCE)
-elseif(NOT MSVC)
- set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g"
- CACHE STRING "Flags used by the compiler during release builds with debug info." FORCE)
-endif()
-
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(DEBUG 1)
else()
diff --git a/contrib/local.mk.example b/contrib/local.mk.example
index 4e7b01a39f..22aac4fda7 100644
--- a/contrib/local.mk.example
+++ b/contrib/local.mk.example
@@ -13,16 +13,19 @@
# Sets the build type; defaults to Debug. Valid values:
#
-# - Debug: Disables optimizations (-O0), enables debug information.
+# - Debug: Disables optimizations (-O0), enables debug information and logging.
#
-# - RelWithDebInfo: Enables all optimizations that do not interfere with
+# - Dev: Enables all optimizations that do not interfere with
# debugging (-Og if available, -O2 and -g if not).
-# Enables debug information.
+# Enables debug information and logging.
+#
+# - RelWithDebInfo: Enables optimizations (-O2) and debug information.
+# Disables logging.
#
# - MinSizeRel: Enables all -O2 optimization that do not typically
# increase code size, and performs further optimizations
# designed to reduce code size (-Os).
-# Disables debug information.
+# Disables debug information and logging.
#
# - Release: Same as RelWithDebInfo, but disables debug information.
#