From c7930b0a06f88d9a6e1545992422b20850474176 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 20 Jul 2021 16:16:07 +0800 Subject: [PATCH] cmake: use string(APPEND ...) to concat strings less repeating this way. Signed-off-by: Kefu Chai --- CMakeLists.txt | 16 ++++++++-------- src/CMakeLists.txt | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb269c0e3e8f..7f0d378889a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,8 @@ if(WIN32) endif() if(MINGW) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-allow-multiple-definition") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-allow-multiple-definition") + string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,-allow-multiple-definition") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-allow-multiple-definition") # By default, cmake generates import libs for executables. The issue is that # for rados and rbd, the executable import lib overrides the library import lib. @@ -120,15 +120,15 @@ if(WITH_STATIC_LIBSTDCXX) message(FATAL_ERROR "Please use GCC to enable WITH_STATIC_LIBSTDCXX") endif() set(static_linker_flags "-static-libstdc++ -static-libgcc") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${static_linker_flags}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${static_linker_flags}") + string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${static_linker_flags}") + string(APPEND CMAKE_EXE_LINKER_FLAGS " ${static_linker_flags}") unset(static_linker_flags) set(GPERFTOOLS_USE_STATIC_LIBS TRUE) endif() include(CheckCxxAtomic) if(NOT HAVE_CXX11_ATOMIC) - set(CMAKE_CXX_STANDARD_LIBRARIES - "${CMAKE_CXX_STANDARD_LIBRARIES} ${LIBATOMIC_LINK_FLAGS}") + string(APPEND CMAKE_CXX_STANDARD_LIBRARIES + " ${LIBATOMIC_LINK_FLAGS}") endif() option(WITH_RDMA "Enable RDMA in async messenger" ON) @@ -566,8 +566,8 @@ if(sanitizers) find_package(Sanitizers REQUIRED ${sanitizers}) add_compile_options(${Sanitizers_COMPILE_OPTIONS}) string(REPLACE ";" " " sanitiers_compile_flags "${Sanitizers_COMPILE_OPTIONS}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${sanitiers_compile_flags}") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${sanitiers_compile_flags}") + string(APPEND CMAKE_EXE_LINKER_FLAGS " ${sanitiers_compile_flags}") + string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${sanitiers_compile_flags}") endif() # Rocksdb diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b72d916d1983..d139ace77e46 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,7 +129,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) # CMAKE_POSITION_INDEPENDENT_CODE is TRUE. if(EXE_LINKER_USE_PIE) if (NOT WITH_OSD_INSTRUMENT_FUNCTIONS AND NOT HAVE_SEASTAR) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -pie") endif() endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) -- 2.47.3