Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Respect CMAKE_EXE_LINKER_FLAGS/CMAKE_SHARED_LINKER_FLAGS flags set vi…
…a CLI

In case of Clang, we were always overriding the above mentioned flags
and hence cmake args were ignored (resuliting in link errors)
  • Loading branch information
pramodk committed Jun 22, 2022
commit bbed7dcbeee876de74941b8b123b3c2cf28d0874
4 changes: 2 additions & 2 deletions CMake/config/CompilerFlagsHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
# Force same ld behavior as when called from gcc --as-needed forces the linker to check whether
# a dynamic library mentioned in the command line is actually needed by the objects being
# linked. Symbols needed in shared objects are already linked when building that library.
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_EXE_LINKER_FLAGS}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use https://cmake.org/cmake/help/latest/command/string.html#append to avoid repeating the variable name, I think, but no big deal.

set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_SHARED_LINKER_FLAGS}")

# rest of the world
else()
Expand Down