Linking libc++ to CMake project on Linux

后端 未结 2 1677
心在旅途
心在旅途 2021-02-13 10:54

I want to use libc++ together with clang on Arch Linux in CMake project. I installed libc++ and added following lines to CMakeLists.txt as said on LLVM site in Linux section of

2条回答
  •  一生所求
    2021-02-13 11:51

    The "proper" way to do this in CMake at the moment, until a specific base feature is added to switch standard libraries that is, is to use a toolchain file.

    In that toolchain file you specify the compiler etc similarly to the other answers here.

    BUT what's great about toolchains is they can be swapped out quickly either on the commandline (using -DCMAKE_TOOLCHAIN_FILE=path/to/file) OR in VSCode with CMakeTools extension installed, and probably other editors too.

    But having to hand code your own toolchain files is yet another obscure chore! No fun!

    Luckily, I stumbled upon this github that maintains a suite of them so you don't have to write them from scratch! Should be a lot less likely to get them wrong.

    https://github.com/ruslo/polly

提交回复
热议问题