Page MenuHomePhabricator

D3826.id10721.diff
No OneTemporary

D3826.id10721.diff

diff --git a/cmake/modules/AddCompilerFlags.cmake b/cmake/modules/AddCompilerFlags.cmake
--- a/cmake/modules/AddCompilerFlags.cmake
+++ b/cmake/modules/AddCompilerFlags.cmake
@@ -18,9 +18,13 @@
function(add_compiler_flags_to_var TARGET LANGUAGE)
foreach(f ${ARGN})
- check_compiler_flag(FLAG_IS_SUPPORTED ${LANGUAGE} ${f})
- if(${FLAG_IS_SUPPORTED})
- string(APPEND ${TARGET} " ${f}")
+ # If the flag is already set, avoid duplicating it
+ string(FIND "${${TARGET}}" "${f}" FLAG_POSITION)
+ if(${FLAG_POSITION} LESS 0)
+ check_compiler_flag(FLAG_IS_SUPPORTED ${LANGUAGE} ${f})
+ if(${FLAG_IS_SUPPORTED})
+ string(APPEND ${TARGET} " ${f}")
+ endif()
endif()
endforeach()
set(${TARGET} ${${TARGET}} PARENT_SCOPE)
@@ -105,7 +109,12 @@
# Save the current linker flags
set(SAVE_CMAKE_EXE_LINKERFLAGS ${CMAKE_EXE_LINKER_FLAGS})
- string(APPEND CMAKE_EXE_LINKER_FLAGS " ${f}")
+
+ # If the flag is already set, avoid duplicating it
+ string(FIND "${CMAKE_EXE_LINKER_FLAGS}" "${f}" FLAG_POSITION)
+ if(${FLAG_POSITION} LESS 0)
+ string(APPEND CMAKE_EXE_LINKER_FLAGS " ${f}")
+ endif()
# CHECK_CXX_COMPILER_FLAG calls CHECK_CXX_SOURCE_COMPILES which in turn
# calls try_compile, so it will check our flag

File Metadata

Mime Type
text/plain
Expires
Thu, Feb 6, 15:52 (16 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5082449
Default Alt Text
D3826.id10721.diff (1 KB)

Event Timeline