Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-11-06 09:11:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-11-06 09:26:29 +0300
commit9762a0992b3b15f63c7c45f752ae9eafd1b17daa (patch)
treeeaa21a40b857e107a2784a93245d25a9b048b746 /source/creator
parent9a7da1242d9f44a085b8b0d0bab989f4eb945270 (diff)
CMake: configue_file() to pass strings for build-info
Using configue_file(..) would have avoided the breakage from 1daa3c3f0a1cfd, caused by buildinfo not properly escaping quotes. Rely on CMake to escaping strings instead using configure_file().
Diffstat (limited to 'source/creator')
-rw-r--r--source/creator/CMakeLists.txt55
1 files changed, 28 insertions, 27 deletions
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 95af663d53e..7f4f8d47688 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -153,45 +153,46 @@ if(WITH_BUILDINFO)
# --------------------------------------------------------------------------
# These defines could all be moved into the header below
- set(BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}")
- set(BUILDINFO_CXXFLAGS "${CMAKE_CXX_FLAGS}")
- set(BUILDINFO_LINKFLAGS "${PLATFORM_LINKFLAGS}")
+ # Write strings into a separate header since we can escape C-strings
+ # in a way that's not practical when passing defines.
+ set(BUILD_PLATFORM "${CMAKE_SYSTEM_NAME}")
+ set(BUILD_TYPE "${CMAKE_BUILD_TYPE}")
+ set(BUILD_CFLAGS "${CMAKE_C_FLAGS}")
+ set(BUILD_CXXFLAGS "${CMAKE_CXX_FLAGS}")
+ set(BUILD_LINKFLAGS "${PLATFORM_LINKFLAGS}")
+ set(BUILD_SYSTEM "CMake")
if(WITH_COMPILER_SHORT_FILE_MACRO)
- # Needed because currently including quotes isn't supported.
- # Besides this it's not necessary to include path information
+ # It's not necessary to include path information
# about the system building Blender in the executable.
- string(REPLACE "${PLATFORM_CFLAGS_FMACRO_PREFIX_MAP}" " " BUILDINFO_CFLAGS "${BUILDINFO_CFLAGS}")
- string(REPLACE "${PLATFORM_CFLAGS_FMACRO_PREFIX_MAP}" " " BUILDINFO_CXXFLAGS "${BUILDINFO_CXXFLAGS}")
+ string(REPLACE "${PLATFORM_CFLAGS_FMACRO_PREFIX_MAP}" " " BUILD_CFLAGS "${BUILD_CFLAGS}")
+ string(REPLACE "${PLATFORM_CFLAGS_FMACRO_PREFIX_MAP}" " " BUILD_CXXFLAGS "${BUILD_CXXFLAGS}")
endif()
- string(REPLACE " " "\ " BUILDINFO_CFLAGS "${BUILDINFO_CFLAGS}")
- string(REPLACE " " "\ " BUILDINFO_CXXFLAGS "${BUILDINFO_CXXFLAGS}")
- string(REPLACE " " "\ " BUILDINFO_LINKFLAGS "${BUILDINFO_LINKFLAGS}")
-
- add_definitions(
- # # define in header now, else these get out of date on rebuilds.
- # -DBUILD_DATE="${BUILD_DATE}"
- # -DBUILD_TIME="${BUILD_TIME}"
- # -DBUILD_COMMIT_TIMESTAMP="${BUILD_COMMIT_TIMESTAMP}"
- # -DBUILD_COMMIT_TIME="${BUILD_COMMIT_TIME}"
- # -DBUILD_COMMIT_DATE="${BUILD_COMMIT_DATE}"
- # -DBUILD_HASH="${BUILD_HASH}"
- # -DBUILD_BRANCH="${BUILD_BRANCH}"
- -DWITH_BUILDINFO_HEADER # alternative to lines above
- -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
- -DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
- -DBUILD_CFLAGS="${BUILDINFO_CFLAGS}"
- -DBUILD_CXXFLAGS="${BUILDINFO_CXXFLAGS}"
- -DBUILD_LINKFLAGS="${BUILDINFO_LINKFLAGS}"
- -DBUILD_SYSTEM="CMake"
+ # Use `configure_file` instead of definitions since properly
+ # escaping the multiple command line arguments which themselves
+ # contain strings and spaces becomes overly error-prone & complicated.
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/build_files/cmake/buildinfo_static.h.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/buildinfo_static.h"
+ ESCAPE_QUOTES
+ @ONLY
)
+ unset(BUILD_PLATFORM)
+ unset(BUILD_TYPE)
+ unset(BUILD_CFLAGS)
+ unset(BUILD_CXXFLAGS)
+ unset(BUILD_LINKFLAGS)
+ unset(BUILD_SYSTEM)
+
# --------------------------------------------------------------------------
# write header for values that change each build
# note, generaed file is in build dir's source/creator
# except when used as an include path.
+ add_definitions(-DWITH_BUILDINFO_HEADER)
+
# include the output directory, where the buildinfo.h file is generated
include_directories(${CMAKE_CURRENT_BINARY_DIR})