diff --git a/.gitmodules b/.gitmodules index 0741013..78ca73c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,4 +9,4 @@ [submodule "deps/include-what-you-use"] path = deps/include-what-you-use - url = https://beta.devheroes.codes/Serene/include-what-you-use.git \ No newline at end of file + url = https://beta.devheroes.codes/Serene/include-what-you-use.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 384de34..f4d97c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,14 @@ option(SERENE_ENABLE_DOCS "Enable document generation" OFF) option(SERENE_ENABLE_TIDY "Enable clang tidy check" OFF) option(SERENE_DISABLE_CCACHE "Disable automatic ccache integration" OFF) option(SERENE_ENABLE_DEVTOOLS "Enable the devtools build" OFF) +option(SERENE_USE_LIBCXX + "Use libc++ instead of the default (The deafault might be libc++ as well)" + OFF) +set(SERENE_TOOLCHAIN_PATH + "" + CACHE + STRING + "Path to the LLVM build. If empty will use the the default on the platform.") # libserene option(SERENE_SHARED_LIB "Build libserene as a shared library" ON) @@ -88,6 +96,10 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) # Let's nicely support folders in IDEs set_property(GLOBAL PROPERTY USE_FOLDERS ON) + find_package(BDWgc 8.2.0 REQUIRED) + find_program(LLD_PROGRAM REQUIRED NAMES lld) + find_program(MLIRTBLGEN_PROGRAM REQUIRED NAMES mlir-tblgen) + # Setup the basic compiler flags add_compile_options( -Wall @@ -144,6 +156,14 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) #--static ) + if ((SERENE_USE_LIBCXX) AND (NOT (SERENE_TOOLCHAIN_PATH))) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -v") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi") + endif() + + if ((SERENE_USE_LIBCXX) AND (SERENE_TOOLCHAIN_PATH)) + endif() + if (SERENE_USE_COMPILER_RT) add_link_options(-rtlib=compiler-rt -stdlib=libc++ ) endif() @@ -153,10 +173,6 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) set(BUILD_SHARED_LIBS "${SERENE_SHARED_LIB}") endif() - find_package(BDWgc 8.2.0 REQUIRED) - - find_program(LLD_PROGRAM REQUIRED NAMES lld) - find_program(MLIRTBLGEN_PROGRAM REQUIRED NAMES mlir-tblgen) if(SERENE_ENABLE_BUILDID) add_link_options(-Wl,--build-id) diff --git a/builder b/builder index 5b0b601..a4ec7aa 100755 --- a/builder +++ b/builder @@ -103,6 +103,9 @@ export ASAN_OPTIONS LSAN_OPTIONS=suppressions="$ME/.ignore_sanitize" export LSAN_OPTIONS +# shellcheck source=./scripts/deps.sh +source "$ME/scripts/deps.sh" + CMAKEARGS_DEBUG=( "-DCMAKE_BUILD_TYPE=Debug" @@ -110,12 +113,11 @@ CMAKEARGS_DEBUG=( CMAKEARGS=( "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" - "-DCMAKE_EXE_LINKER_FLAGS='-stdlib=libc++' -lc++abi" + "-DSERENE_USE_LIBCXX=ON" + "-DSERENE_TOOLCHAIN_PATH=$LLVM_INSTALL_DIR" "-DSERENE_CCACHE_DIR=$HOME/.ccache" ) -# shellcheck source=./scripts/deps.sh -source "$ME/scripts/deps.sh" # ----------------------------------------------------------------------------- # Initialization @@ -154,7 +156,7 @@ function build-gen() { pushed_build info "Running: " info "cmake -G Ninja ${CMAKEARGS[*]} ${CMAKEARGS_DEBUG[*]}" "$@" "$ME" - cmake -G Ninja "${CMAKEARGS[*]} ${CMAKEARGS_DEBUG[*]}" "$@" "$ME" + cmake -G Ninja "${CMAKEARGS[@]}" "${CMAKEARGS_DEBUG[@]}" "$@" "$ME" popd_build }