Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ClausKlein committed Jul 11, 2024
1 parent 271323b commit 0a8e6ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 12 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ project(modules_benchmark LANGUAGES CXX)
find_package(OpenSSL REQUIRED)

# Use modules?
option(USE_MODULES "on/off" ON)
unset(USE_MODULES)
unset(HAS_STDLIB_MODULES)

# Always use libc++
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-stdlib=libc++)
add_link_options(-stdlib=libc++)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28.4 AND CMAKE_GENERATOR STREQUAL "Ninja")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.0)
Expand All @@ -21,10 +19,14 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28.4 AND CMAKE_GENERATOR STREQUAL "Ninj
add_compile_options(-fexperimental-library)
add_link_options(-lc++experimental)
add_compile_options(-ftime-trace)
add_compile_options(-stdlib=libc++)
add_link_options(-stdlib=libc++)
if(DEFINED ENV{LLVM_ROOT})
message(STATUS "LLVM_ROOT=$ENV{LLVM_ROOT}")
set(LLVM_LIBC_SOURCE $ENV{LLVM_ROOT}/share/libc++/v1)
set(HAS_STDLIB_MODULES stdlib)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18.0)
set(HAS_STDLIB_MODULES stdlib)
endif()
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0)
set(USE_MODULES TRUE)
Expand All @@ -47,7 +49,11 @@ endif()
if(NOT EXISTS ${LLVM_LIBC_SOURCE})
set(LLVM_LIBC_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/stdlib)
endif()
message(STATUS "LLVM_LIBC_SOURCE=${LLVM_LIBC_SOURCE}")

if(USE_MODULES)
message(STATUS "USE_MODULES=${USE_MODULES}")
message(STATUS "LLVM_LIBC_SOURCE=${LLVM_LIBC_SOURCE}")
endif()

if(PROJECT_IS_TOP_LEVEL)
include(CheckCXXSymbolExists)
Expand Down Expand Up @@ -85,6 +91,7 @@ if(USE_MODULES)

# Build the stdlib module
if(HAS_STDLIB_MODULES)
message(STATUS "HAS_STDLIB_MODULES=${HAS_STDLIB_MODULES}")
add_stdlib_module(${HAS_STDLIB_MODULES})
endif()

Expand Down
6 changes: 4 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ ifeq (${UNAME},Darwin)
export LLVM_ROOT:=$(shell realpath ${LLVM_PREFIX})
export LDFLAGS+=-L${LLVM_ROOT}/lib/c++
export PATH:=${LLVM_ROOT}/bin:${PATH}
else ifeq (${UNAME},Linux)
export LLVM_ROOT:=/usr/lib/llvm-17
endif

export CXXFLAGS:=-std=c++23
export CXX:=clang++-17
export CC:=clang-17
export CXX:=clang++
export CC:=clang

.PHONY: all build install format clean distclean
all: stagedir build
Expand Down

0 comments on commit 0a8e6ab

Please sign in to comment.