Issue
I am building a C++ project for most platforms and would like to upgrade the standard to c++20. Currently, the main problem preventing this upgrade is macOS yelling at me because 10.12
does not support c++20 libraries (eg. filesystem
)
I managed to build from source and link without issues, but now I want to integrate it with our CMake.
cmake -G Ninja -S runtimes -B build \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 \
-DCMAKE_BUILD_TYPE=Release \
-DLIBCXX_ENABLE_STATIC=ON \
-DLIBCXX_ENABLE_SHARED=OFF \
-DLIBCXXABI_ENABLE_STATIC=ON \
-DLIBCXXABI_ENABLE_SHARED=OFF \
-DLIBUNWIND_ENABLE_STATIC=ON \
-DLIBUNWIND_ENABLE_SHARED=OFF \
-DLIBCXX_HERMETIC_STATIC_LIBRARY=ON \
-DCMAKE_INSTALL_PREFIX=$LLVM_INSTALL_DIR
I built directly from the runtimes
CMakeLists, which does not generate any config.cmake or so.
Bundling the sources and linking with the targets like this:
include(FetchContent)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12")
set(LLVM_ENABLE_RUNTIMES "libcxx;libcxxabi;libunwind" CACHE INTERNAL "")
set(LIBCXX_ENABLE_STATIC ON CACHE INTERNAL "")
set(LIBCXX_ENABLE_SHARED OFF CACHE INTERNAL "")
set(LIBCXXABI_ENABLE_STATIC ON CACHE INTERNAL "")
set(LIBCXXABI_ENABLE_SHARED OFF CACHE INTERNAL "")
set(LIBUNWIND_ENABLE_STATIC ON CACHE INTERNAL "")
set(LIBUNWIND_ENABLE_SHARED OFF CACHE INTERNAL "")
fetchcontent_declare(
llvm
URL https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-16.0.6.tar.gz
SOURCE_SUBDIR runtimes)
fetchcontent_makeavailable(llvm)
target_link_libraries(test PRIVATE cxx_static cxxabi_static unwind_static)
target_compile_options(test PRIVATE -fvisibility=hidden)
works but in productioon, the libraries are prebuilt and downloaded from a server.
Is there any way to link with the targets in a modern way? ie. getting LLVM to export a config.cmake or so?
I can't find a Find module either and I'd like to avoid writing one myself if possible.
Solution
Well, I ended up writing a FindLLVMRuntimes module myself. It's not pretty but it works.
I would still like to know if there are cleaner / more portable alternatives.
Answered By - jacky la mouette Answer Checked By - Robin (WPSolving Admin)