Skip to content

Commit

Permalink
Tweak CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
ewarchul committed Jul 13, 2024
1 parent 61cf74a commit c75ec24
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CXX="clang++-18"
CC="clang-18"
CXX="g++-14"
CC="gcc-14"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build-*/*
.cache/*
legacy/*
include/cecxx/benchmark/defaults.hpp
data/*
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ project(cecxx
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(Package)
include(config)
include(ProjectConfig)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
Expand Down Expand Up @@ -51,6 +51,8 @@ target_sources(cecxx PUBLIC FILE_SET HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_D
target_compile_options(cecxx PRIVATE ${COMPILE_FLAGS})
target_compile_features(cecxx PRIVATE cxx_std_20)

message(STATUS "The cecxx library is going to be compiled with the following additional flags: ${COMPILE_FLAGS}")

configure_file(defaults.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/cecxx/benchmark/defaults.hpp)
generate_export_header(cecxx)

Expand All @@ -74,5 +76,9 @@ if (WITH_BENCHMARKS)
endif()

if (WITH_TESTS)
add_subdirectory(test)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_subdirectory(test)
else()
message(WARNING "To build tests, use clang compiler. Current CXX compiler: ${CMAKE_CXX_COMPILER}")
endif()
endif(WITH_TESTS)
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ncores := `nproc`

init_build: clean
mkdir -p {{build_dir}}
cd {{build_dir}} && CC={{c_compiler}} CXX={{cxx_compiler}} cmake -DFUZZTEST_FUZZING_MODE=on -DWITH_TESTS=on -DWITH_EXAMPLES=on ..
cd {{build_dir}} && CC={{c_compiler}} CXX={{cxx_compiler}} cmake -DWITH_TESTS=on -DWITH_EXAMPLES=on ..
ln -fs {{build_dir}}/compile_commands.json compile_commands.json

build:
Expand Down
7 changes: 5 additions & 2 deletions cmake/config.cmake → cmake/ProjectConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ option(WITH_BENCHMARKS "Build benchmarks" OFF)
set(BENCHMARK_DATA_STORAGE "${CMAKE_INSTALL_PREFIX}/share/cecxx")

if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(COMPILE_FLAGS -Wall -Wpedantic -Wextra -Wconversion -Wimplicit-fallthrough -Wundef)
set(COMPILE_FLAGS -Wall -Wpedantic -Wextra -Wconversion -Wimplicit-fallthrough -Wundef -Werror)
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14.0)
set(COMPILE_FLAGS ${COMPILE_FLAGS} -Wnrvo)
endif()
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(COMPILE_FLAGS -Wall -Wextra -pedantic -Wconversion -Wundef
-Wdeprecated -Wshadow)
-Wdeprecated -Wshadow -Werror)
endif()
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
set(FUZZTEST_FUZZING_MODE ON)

include(FetchContent)
FetchContent_Declare(
fuzztest
Expand Down

0 comments on commit c75ec24

Please sign in to comment.