mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge 'CMake: Prepare for releases.'
This commit is contained in:
commit
a2b8d7cdba
100
CMakeLists.txt
100
CMakeLists.txt
@ -38,31 +38,36 @@ 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
|
||||
include(GetGitRevisionDescription)
|
||||
file(TO_NATIVE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git GIT_DIR)
|
||||
get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
|
||||
if(NOT NVIM_VERSION_COMMIT)
|
||||
set(NVIM_VERSION_COMMIT "?")
|
||||
endif()
|
||||
set(NVIM_VERSION_MAJOR 0)
|
||||
set(NVIM_VERSION_MINOR 0)
|
||||
set(NVIM_VERSION_PATCH 0)
|
||||
set(NVIM_VERSION_PRERELEASE "-alpha")
|
||||
# TODO(justinmk): UTC time would be nice here #1071
|
||||
git_timestamp(GIT_TIMESTAMP)
|
||||
# TODO(justinmk): do not set this for "release" builds #1071
|
||||
if(GIT_TIMESTAMP)
|
||||
set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}")
|
||||
|
||||
file(TO_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git FORCED_GIT_DIR)
|
||||
include(GetGitRevisionDescription)
|
||||
if(NVIM_VERSION_PRERELEASE)
|
||||
get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
|
||||
|
||||
# TODO(justinmk): UTC time would be nice here #1071
|
||||
git_timestamp(GIT_TIMESTAMP)
|
||||
if(GIT_TIMESTAMP)
|
||||
set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}")
|
||||
endif()
|
||||
else()
|
||||
# If possible, get the Git tag for the current revision.
|
||||
git_get_exact_tag(NVIM_VERSION_COMMIT)
|
||||
set(NVIM_VERSION_BUILD "")
|
||||
endif()
|
||||
|
||||
set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
|
||||
# NVIM_VERSION_CFLAGS set further below.
|
||||
|
||||
@ -74,6 +79,57 @@ if(CMAKE_C_FLAGS_RELEASE MATCHES "-O3")
|
||||
string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
endif()
|
||||
|
||||
# Disable logging for release-type builds.
|
||||
if(NOT CMAKE_C_FLAGS_RELEASE MATCHES DDISABLE_LOG)
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDISABLE_LOG")
|
||||
endif()
|
||||
if(NOT CMAKE_C_FLAGS_MINSIZEREL MATCHES DDISABLE_LOG)
|
||||
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DDISABLE_LOG")
|
||||
endif()
|
||||
if(NOT CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DDISABLE_LOG)
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDISABLE_LOG")
|
||||
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 +233,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()
|
||||
|
@ -42,7 +42,13 @@ set(__get_git_revision_description YES)
|
||||
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
function(get_git_dir _gitdir)
|
||||
# check GIT_DIR in environment first
|
||||
# check FORCED_GIT_DIR first
|
||||
if(FORCED_GIT_DIR)
|
||||
set(${_gitdir} ${FORCED_GIT_DIR} PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# check GIT_DIR in environment
|
||||
set(GIT_DIR $ENV{GIT_DIR})
|
||||
if(NOT GIT_DIR)
|
||||
set(GIT_PARENT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define NVIM_VERSION_PATCH @NVIM_VERSION_PATCH@
|
||||
#define NVIM_VERSION_PRERELEASE "@NVIM_VERSION_PRERELEASE@"
|
||||
#define NVIM_VERSION_BUILD "@NVIM_VERSION_BUILD@"
|
||||
#define NVIM_VERSION_COMMIT "@NVIM_VERSION_COMMIT@"
|
||||
#cmakedefine NVIM_VERSION_COMMIT "@NVIM_VERSION_COMMIT@"
|
||||
#define NVIM_VERSION_CFLAGS "@NVIM_VERSION_CFLAGS@"
|
||||
#define NVIM_VERSION_BUILD_TYPE "@NVIM_VERSION_BUILD_TYPE@"
|
||||
|
||||
|
@ -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.
|
||||
#
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define ELOGN(...)
|
||||
|
||||
// Logging is disabled if NDEBUG or DISABLE_LOG is defined.
|
||||
#ifdef NDEBUG
|
||||
#if !defined(DISABLE_LOG) && defined(NDEBUG)
|
||||
# define DISABLE_LOG
|
||||
#endif
|
||||
|
||||
|
@ -36,7 +36,9 @@ char *Version = VIM_VERSION_SHORT;
|
||||
char *longVersion = NVIM_VERSION_LONG;
|
||||
char *longVersionWithDate = NVIM_VERSION_LONG " (compiled " __DATE__ " " __TIME__ ")";
|
||||
char *mediumVersion = NVIM_VERSION_MEDIUM;
|
||||
#ifdef NVIM_VERSION_COMMIT
|
||||
char *version_commit = "Commit: " NVIM_VERSION_COMMIT;
|
||||
#endif
|
||||
char *version_buildtype = "Build type: " NVIM_VERSION_BUILD_TYPE;
|
||||
char *version_cflags = "Compilation: " NVIM_VERSION_CFLAGS;
|
||||
|
||||
@ -1024,7 +1026,9 @@ void list_version(void)
|
||||
// When adding features here, don't forget to update the list of
|
||||
// internal variables in eval.c!
|
||||
MSG(longVersionWithDate);
|
||||
#ifdef NVIM_VERSION_COMMIT
|
||||
MSG(version_commit);
|
||||
#endif
|
||||
MSG(version_buildtype);
|
||||
MSG(version_cflags);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user