From 964ae205a583807127eda75d9876fb6dfda6065c Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 3 Feb 2023 10:53:57 +0100 Subject: [PATCH] build: unbreak building neovim with multi-config generators (#22104) file(GENERATE) has surprising behavior as it doesn't allow different file contents for configurations with the same file name. This results in an error when building neovim with a multi-config generator. Use a workaround for now where we set the build type for multi-config generators to "Unknown". --- cmake.config/CMakeLists.txt | 16 ++++++++-------- ...versiondef-old.h.in => versiondef-multi.h.in} | 4 ++-- cmake.config/versiondef.h.in | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) rename cmake.config/{versiondef-old.h.in => versiondef-multi.h.in} (76%) diff --git a/cmake.config/CMakeLists.txt b/cmake.config/CMakeLists.txt index 872d6a9c62..29d7622c01 100644 --- a/cmake.config/CMakeLists.txt +++ b/cmake.config/CMakeLists.txt @@ -162,15 +162,15 @@ configure_file ( "${PROJECT_BINARY_DIR}/cmake.config/auto/config.h" ) -# Improved :version output on newer cmake versions -if(${CMAKE_VERSION} VERSION_LESS 3.14) - configure_file( - "${PROJECT_SOURCE_DIR}/cmake.config/versiondef-old.h.in" - "${PROJECT_BINARY_DIR}/cmake.config/auto/versiondef.h.gen") +# TODO(dundargoc): the following is a hack to work around the behavior of +# file(GENERATE) for multi-config generators, since it doesn't allow different +# output with the same filename. This should be fixed to be generator +# independent in the future. +get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(isMultiConfig) + configure_file(versiondef-multi.h.in auto/versiondef.h.gen) else() - configure_file( - "${PROJECT_SOURCE_DIR}/cmake.config/versiondef.h.in" - "${PROJECT_BINARY_DIR}/cmake.config/auto/versiondef.h.gen") + configure_file(versiondef.h.in auto/versiondef.h.gen) endif() file(GENERATE OUTPUT "${PROJECT_BINARY_DIR}/cmake.config/auto/versiondef.h" diff --git a/cmake.config/versiondef-old.h.in b/cmake.config/versiondef-multi.h.in similarity index 76% rename from cmake.config/versiondef-old.h.in rename to cmake.config/versiondef-multi.h.in index 2bfd4e0b53..de2d950af7 100644 --- a/cmake.config/versiondef-old.h.in +++ b/cmake.config/versiondef-multi.h.in @@ -15,7 +15,7 @@ #define NVIM_API_LEVEL_COMPAT @NVIM_API_LEVEL_COMPAT@ #define NVIM_API_PRERELEASE @NVIM_API_PRERELEASE@ -#define NVIM_VERSION_CFLAGS "${CMAKE_C_COMPILER} $, > -D$, -D> -I$, -I>" -#define NVIM_VERSION_BUILD_TYPE "$" +#define NVIM_VERSION_CFLAGS "${CMAKE_C_COMPILER} $, > -I$, -I>" +#define NVIM_VERSION_BUILD_TYPE "Unknown" #endif // AUTO_VERSIONDEF_H diff --git a/cmake.config/versiondef.h.in b/cmake.config/versiondef.h.in index 480399142b..2bfd4e0b53 100644 --- a/cmake.config/versiondef.h.in +++ b/cmake.config/versiondef.h.in @@ -15,7 +15,7 @@ #define NVIM_API_LEVEL_COMPAT @NVIM_API_LEVEL_COMPAT@ #define NVIM_API_PRERELEASE @NVIM_API_PRERELEASE@ -#define NVIM_VERSION_CFLAGS "${CMAKE_C_COMPILER} $, > -D$, -D> -I$>, -I>" +#define NVIM_VERSION_CFLAGS "${CMAKE_C_COMPILER} $, > -D$, -D> -I$, -I>" #define NVIM_VERSION_BUILD_TYPE "$" #endif // AUTO_VERSIONDEF_H