Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CMAKE_LINKER_TYPE in CMake 3.29+ #94

Open
rdong8 opened this issue Aug 21, 2024 · 2 comments
Open

Use CMAKE_LINKER_TYPE in CMake 3.29+ #94

rdong8 opened this issue Aug 21, 2024 · 2 comments

Comments

@rdong8
Copy link

rdong8 commented Aug 21, 2024

The proper way to set the linker in CMake 3.29+ is with this new variable. The example from the bottom of this page suggests something like this (target specific):

set_property(TARGET "${project_name}" PROPERTY LINKER_TYPE "MOLD")

or globally:

set(CMAKE_LINKER_TYPE "MOLD")
@benjamin051000
Copy link

What happens if you don't have mold installed? Could it be guarded by checking which mold?

@rdong8
Copy link
Author

rdong8 commented Oct 5, 2024

I think the default error is clear enough:

cmake -S . -B build -G "Ninja Multi-Config" -DCMAKE_CXX_COMPILER=clang++
-- The C compiler identification is GNU 14.2.1
-- The CXX compiler identification is Clang 18.1.8
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- INTERFACE_LINKER_TYPE for target 'config' is:
-- INTERFACE_LINKER_TYPE for target 'lib' is:
-- INTERFACE_LINKER_TYPE for target 'app' is:
-- Configuring done (0.7s)
CMake Error in CMakeLists.txt:
  LINKER_TYPE 'SOLD' is unknown or not supported by this toolchain.

There is already some error checking for this that could also be adapted to work with the new setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants