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 <campbell@blender.org>2022-01-15 08:12:13 +0300
committerCampbell Barton <campbell@blender.org>2022-01-15 08:12:13 +0300
commit18c5d4ccb39d6301892b02d6ffc3cdac85462900 (patch)
tree818bd18200ef4f41aa596bd837833a714e2093ce /build_files
parent9664cc91f338e34de3a4bd826cd62f73885b5149 (diff)
CMake: use LINKER flags instead of CFLAGS for setting the linker
Set the linker using CMAKE_*_LINKER_FLAGS instead of {C/CXX}FLAGS. There is no advantage in using the CFLAGS to set the linker, it has the downside of triggering a full rebuild when changing the linker. Tested building Blender and the bpy.so Python module. Ref D13833 Reviewed by: sergey, brecht
Diffstat (limited to 'build_files')
-rw-r--r--build_files/cmake/platform/platform_unix.cmake19
1 files changed, 13 insertions, 6 deletions
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 4ba3f81fe93..c7637dbee7e 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -671,8 +671,9 @@ if(CMAKE_COMPILER_IS_GNUCC)
COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if("${LD_VERSION}" MATCHES "GNU gold")
- string(APPEND CMAKE_C_FLAGS " -fuse-ld=gold")
- string(APPEND CMAKE_CXX_FLAGS " -fuse-ld=gold")
+ string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=gold")
+ string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=gold")
+ string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=gold")
else()
message(STATUS "GNU gold linker isn't available, using the default system linker.")
endif()
@@ -684,8 +685,9 @@ if(CMAKE_COMPILER_IS_GNUCC)
COMMAND ${CMAKE_C_COMPILER} -fuse-ld=lld -Wl,--version
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if("${LD_VERSION}" MATCHES "LLD")
- string(APPEND CMAKE_C_FLAGS " -fuse-ld=lld")
- string(APPEND CMAKE_CXX_FLAGS " -fuse-ld=lld")
+ string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=lld")
+ string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=lld")
+ string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=lld")
else()
message(STATUS "LLD linker isn't available, using the default system linker.")
endif()
@@ -738,8 +740,9 @@ if(CMAKE_COMPILER_IS_GNUCC)
if(WITH_LINKER_MOLD)
# GCC will search for `ld` in this directory first.
- string(APPEND CMAKE_CXX_FLAGS " -B \"${MOLD_BIN_DIR}\"")
- string(APPEND CMAKE_C_FLAGS " -B \"${MOLD_BIN_DIR}\"")
+ string(APPEND CMAKE_EXE_LINKER_FLAGS " -B \"${MOLD_BIN_DIR}\"")
+ string(APPEND CMAKE_SHARED_LINKER_FLAGS " -B \"${MOLD_BIN_DIR}\"")
+ string(APPEND CMAKE_MODULE_LINKER_FLAGS " -B \"${MOLD_BIN_DIR}\"")
endif()
unset(MOLD_BIN)
unset(MOLD_BIN_DIR)
@@ -758,8 +761,12 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
else()
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
string(APPEND CMAKE_EXE_LINKER_FLAGS " --ld-path=\"${MOLD_BIN}\"")
+ string(APPEND CMAKE_SHARED_LINKER_FLAGS " --ld-path=\"${MOLD_BIN}\"")
+ string(APPEND CMAKE_MODULE_LINKER_FLAGS " --ld-path=\"${MOLD_BIN}\"")
else()
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=\"${MOLD_BIN}\"")
+ string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=\"${MOLD_BIN}\"")
+ string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=\"${MOLD_BIN}\"")
endif()
endif()
endif()