From ed1a0785822e73b910b18a7920be9f58fda67ba8 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Tue, 24 Oct 2023 13:02:56 +0200 Subject: [PATCH] LLVMExtra: Dynamically pick a C++ standard version. --- deps/LLVMExtra/CMakeLists.txt | 6 +++++- deps/build_local.jl | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/deps/LLVMExtra/CMakeLists.txt b/deps/LLVMExtra/CMakeLists.txt index 9abcd992..1b9d0198 100644 --- a/deps/LLVMExtra/CMakeLists.txt +++ b/deps/LLVMExtra/CMakeLists.txt @@ -13,7 +13,11 @@ LANGUAGES C ) -set(CMAKE_CXX_STANDARD 17) +if(NOT DEFINED CXX_STANDARD) + set(CXX_STANDARD 17) +endif() +set(CMAKE_CXX_STANDARD ${CXX_STANDARD}) + set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/deps/build_local.jl b/deps/build_local.jl index 032d3619..ca993b94 100644 --- a/deps/build_local.jl +++ b/deps/build_local.jl @@ -45,10 +45,17 @@ else end LLVM_DIR = joinpath(LLVM.artifact_dir, "lib", "cmake", "llvm") +# LLVM 16 requires C++17 +cxx_standard = if Base.libllvm_version >= v"16" + "17" +else + "14" +end + # build and install @info "Building" source_dir scratch_dir build_dir LLVM_DIR cmake() do cmake_path - config_opts = `-DLLVM_ROOT=$(LLVM_DIR) -DCMAKE_INSTALL_PREFIX=$(scratch_dir)` + config_opts = `-DLLVM_ROOT=$(LLVM_DIR) -DCXX_STANDARD=$(cxx_standard) -DCMAKE_INSTALL_PREFIX=$(scratch_dir)` if Sys.iswindows() # prevent picking up MSVC config_opts = `$config_opts -G "MSYS Makefiles"`