mirror of
https://github.com/neovim/neovim.git
synced 2025-10-16 14:56:08 +00:00
build: use custom command to create single versiondef (#22290)
When using a multi config generator, CMake generates an output file for each configuration when using file(GENERATE). When the contents of the file for each configuration are different, CMake fails. Instead, create separate files for each configuration and add a build time step to copy the configuration specific file to the generic path "auto/versiondef.h" which is included at build time.
This commit is contained in:
@@ -466,6 +466,15 @@ add_custom_target(update_version_stamp
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/GenerateVersion.cmake
|
||||
BYPRODUCTS ${NVIM_VERSION_GIT_H})
|
||||
|
||||
set(NVIM_VERSION_DEF_H ${PROJECT_BINARY_DIR}/cmake.config/auto/versiondef.h)
|
||||
add_custom_command(
|
||||
OUTPUT "${NVIM_VERSION_DEF_H}"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-E copy
|
||||
"${PROJECT_BINARY_DIR}/cmake.config/auto/versiondef-$<CONFIG>.h"
|
||||
"${NVIM_VERSION_DEF_H}"
|
||||
DEPENDS "${PROJECT_BINARY_DIR}/cmake.config/auto/versiondef-$<CONFIG>.h")
|
||||
|
||||
# NVIM_GENERATED_FOR_HEADERS: generated headers to be included in headers
|
||||
# NVIM_GENERATED_FOR_SOURCES: generated headers to be included in sources
|
||||
# NVIM_GENERATED_SOURCES: generated source files
|
||||
@@ -503,7 +512,7 @@ foreach(sfile ${NVIM_SOURCES}
|
||||
set(depends "${HEADER_GENERATOR}" "${sfile}")
|
||||
if("${f}" STREQUAL "version.c")
|
||||
# Ensure auto/versiondef_git.h exists after "make clean".
|
||||
list(APPEND depends update_version_stamp "${NVIM_VERSION_GIT_H}")
|
||||
list(APPEND depends update_version_stamp "${NVIM_VERSION_GIT_H}" "${NVIM_VERSION_DEF_H}")
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT "${gf_c_h}" "${gf_h_h}"
|
||||
|
Reference in New Issue
Block a user