aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-10-11 19:00:52 +0000
committerJosh Rahm <rahm@google.com>2022-10-11 19:00:52 +0000
commit21e2e46242033c7aaa6ccfb23e256680816c063c (patch)
treef089522cfb145d6e9c8a86a01d8e454ce5501e20 /cmake
parent179d3ed87b17988f5fe00d8b99f2611a28212be7 (diff)
parent760b399f6c0c6470daa0663752bd22886997f9e6 (diff)
downloadrneovim-floattitle.tar.gz
rneovim-floattitle.tar.bz2
rneovim-floattitle.zip
Merge remote-tracking branch 'upstream/master' into floattitlefloattitle
Diffstat (limited to 'cmake')
-rw-r--r--cmake/GenerateVersion.cmake10
-rw-r--r--cmake/GetCompileFlags.cmake8
-rw-r--r--cmake/RunMsgfmt.cmake9
-rw-r--r--cmake/RunMsgmerge.cmake11
-rw-r--r--cmake/RunTests.cmake4
-rw-r--r--cmake/RunXgettext.cmake14
-rw-r--r--cmake/Util.cmake40
7 files changed, 46 insertions, 50 deletions
diff --git a/cmake/GenerateVersion.cmake b/cmake/GenerateVersion.cmake
index 6118d8cba7..a7a72fe0bb 100644
--- a/cmake/GenerateVersion.cmake
+++ b/cmake/GenerateVersion.cmake
@@ -7,15 +7,11 @@ set(NVIM_VERSION_MEDIUM
"v${NVIM_VERSION_MAJOR}.${NVIM_VERSION_MINOR}.${NVIM_VERSION_PATCH}${NVIM_VERSION_PRERELEASE}")
execute_process(
- COMMAND git describe --first-parent --dirty
+ COMMAND git describe --first-parent --dirty --always
OUTPUT_VARIABLE GIT_TAG
- ERROR_VARIABLE ERR
- RESULT_VARIABLE RES
-)
+ RESULT_VARIABLE RES)
-if(NOT RES EQUAL 0)
- message(STATUS "Git tag extraction failed:\n" " ${GIT_TAG}${ERR}" )
- # This will only be executed once since the file will get generated afterwards.
+if(RES AND NOT RES EQUAL 0)
message(STATUS "Using NVIM_VERSION_MEDIUM: ${NVIM_VERSION_MEDIUM}")
file(WRITE "${OUTPUT}" "${NVIM_VERSION_STRING}")
return()
diff --git a/cmake/GetCompileFlags.cmake b/cmake/GetCompileFlags.cmake
index 49b57f6f75..3b027690f8 100644
--- a/cmake/GetCompileFlags.cmake
+++ b/cmake/GetCompileFlags.cmake
@@ -2,14 +2,6 @@ function(get_compile_flags _compile_flags)
# Create template akin to CMAKE_C_COMPILE_OBJECT.
set(compile_flags "<CMAKE_C_COMPILER> <CFLAGS> <BUILD_TYPE_CFLAGS> <COMPILE_OPTIONS><COMPILE_DEFINITIONS> <INCLUDES>")
- # Get C compiler.
- if(CMAKE_C_COMPILER_ARG1)
- string(REPLACE
- "<CMAKE_C_COMPILER>"
- "<CMAKE_C_COMPILER> ${CMAKE_C_COMPILER_ARG1}"
- compile_flags
- "${compile_flags}")
- endif()
string(REPLACE
"<CMAKE_C_COMPILER>"
"${CMAKE_C_COMPILER}"
diff --git a/cmake/RunMsgfmt.cmake b/cmake/RunMsgfmt.cmake
deleted file mode 100644
index 51606338e0..0000000000
--- a/cmake/RunMsgfmt.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-set(ENV{OLD_PO_FILE_INPUT} yes)
-
-execute_process(
- COMMAND ${MSGFMT_PRG} -o ${MO_FILE} ${PO_FILE}
- ERROR_VARIABLE err
- RESULT_VARIABLE res)
-if(NOT res EQUAL 0)
- message(FATAL_ERROR "msgfmt failed to run correctly: ${err}")
-endif()
diff --git a/cmake/RunMsgmerge.cmake b/cmake/RunMsgmerge.cmake
deleted file mode 100644
index 69e5c7276d..0000000000
--- a/cmake/RunMsgmerge.cmake
+++ /dev/null
@@ -1,11 +0,0 @@
-set(ENV{OLD_PO_FILE_INPUT} yes)
-set(ENV{OLD_PO_FILE_OUTPUT} yes)
-
-execute_process(
- COMMAND ${MSGMERGE_PRG} -q --update --backup=none --sort-by-file
- ${PO_FILE} ${POT_FILE}
- ERROR_VARIABLE err
- RESULT_VARIABLE res)
-if(NOT res EQUAL 0)
- message(FATAL_ERROR "msgmerge failed to run correctly: ${err}")
-endif()
diff --git a/cmake/RunTests.cmake b/cmake/RunTests.cmake
index e07c6dd174..2abe29b54b 100644
--- a/cmake/RunTests.cmake
+++ b/cmake/RunTests.cmake
@@ -2,7 +2,9 @@
set(ENV{LC_ALL} "en_US.UTF-8")
if(POLICY CMP0012)
- # Handle CI=true, without dev warnings.
+ # Avoid policy warning due to CI=true. This is needed even if the main
+ # project has already set this policy as policy settings are reset when using
+ # the cmake script mode (-P).
cmake_policy(SET CMP0012 NEW)
endif()
diff --git a/cmake/RunXgettext.cmake b/cmake/RunXgettext.cmake
deleted file mode 100644
index c9328b151d..0000000000
--- a/cmake/RunXgettext.cmake
+++ /dev/null
@@ -1,14 +0,0 @@
-set(ENV{OLD_PO_FILE_INPUT} yes)
-set(ENV{OLD_PO_FILE_OUTPUT} yes)
-
-list(SORT SOURCES)
-
-execute_process(
- COMMAND ${XGETTEXT_PRG} -o ${POT_FILE} --default-domain=nvim
- --add-comments --keyword=_ --keyword=N_ -D ${SEARCH_DIR}
- ${SOURCES}
- ERROR_VARIABLE err
- RESULT_VARIABLE res)
-if(NOT res EQUAL 0)
- message(FATAL_ERROR "xgettext failed to run correctly: ${err}")
-endif()
diff --git a/cmake/Util.cmake b/cmake/Util.cmake
index b485f4606b..343a729305 100644
--- a/cmake/Util.cmake
+++ b/cmake/Util.cmake
@@ -143,3 +143,43 @@ function(add_glob_targets)
add_custom_target(${ARG_TARGET} DEPENDS ${touch_list})
endfunction()
+
+# Set default build type to Debug. Also limit the list of allowable build types
+# to the ones defined in variable allowableBuildTypes.
+#
+# The correct way to specify build type (for example Release) for
+# single-configuration generators (Make and Ninja) is to run
+#
+# cmake -B build -D CMAKE_BUILD_TYPE=Release
+# cmake --build build
+#
+# while for multi-configuration generators (Visual Studio, Xcode and Ninja
+# Multi-Config) is to run
+#
+# cmake -B build
+# cmake --build build --config Release
+#
+# Passing CMAKE_BUILD_TYPE for multi-config generators will now not only
+# not be used, but also generate a warning for the user.
+function(set_default_buildtype)
+ set(allowableBuildTypes Debug Release MinSizeRel RelWithDebInfo)
+
+ get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(isMultiConfig)
+ set(CMAKE_CONFIGURATION_TYPES ${allowableBuildTypes} PARENT_SCOPE)
+ if(CMAKE_BUILD_TYPE)
+ message(WARNING "CMAKE_BUILD_TYPE specified which is ignored on \
+ multi-configuration generators. Defaulting to Debug build type.")
+ endif()
+ else()
+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${allowableBuildTypes}")
+ if(NOT CMAKE_BUILD_TYPE)
+ message(STATUS "CMAKE_BUILD_TYPE not specified, default is 'Debug'")
+ set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build" FORCE)
+ elseif(NOT CMAKE_BUILD_TYPE IN_LIST allowableBuildTypes)
+ message(FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}")
+ else()
+ message(STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
+ endif()
+ endif()
+endfunction()