Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F12944885
D3826.id10721.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D3826.id10721.diff
View Options
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
Details
Attached
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)
Attached To
D3826: [CMAKE] Avoid duplicating the compiler/linker flags
Event Timeline
Log In to Comment