merge with organizing targets

This commit is contained in:
Bechir
2024-03-08 13:28:34 +01:00
parent 47d381d299
commit 146d2aed19
7 changed files with 44 additions and 69 deletions

View File

@ -7,6 +7,9 @@ project(aare
LANGUAGES C CXX
)
add_library(aare_compiler_flags INTERFACE)
target_compile_features(aare_compiler_flags INTERFACE cxx_std_17)
cmake_policy(SET CMP0135 NEW)
cmake_policy(SET CMP0079 NEW)
@ -14,56 +17,30 @@ include(GNUInstallDirs)
include(FetchContent)
option(AARE_USE_SANITIZER "Sanitizers for debugging" ON)
option(AARE_USE_WARNINGS "Eable warnings" ON)
option(AARE_PYTHON_BINDINGS "Build python bindings" ON)
option(AARE_TESTS "Build tests" OFF)
option(AARE_EXAMPLES "Build examples" OFF)
#TODO! Should this be on the top level or move it down to the component
#that needs it?
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json
GIT_TAG v3.11.3
)
FetchContent_MakeAvailable(json)
option(AARE_TESTS "Build tests" ON)
option(AARE_EXAMPLES "Build examples" ON)
option(AARE_DEBUG "Compile in debug mode" ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(fmt 6 REQUIRED)
if (AARE_DEBUG)
target_compile_options(aare_compiler_flags INTERFACE -Og -ggdb3 -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC)
else()
target_compile_options(aare_compiler_flags INTERFACE -O3)
endif()
# set(CMAKE_BUILD_TYPE "Debug")
# if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# set(OPTIMIZATION_FLAGS "-Og -ggdb3 -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC")
# else()
# set(OPTIMIZATION_FLAGS "-O3")
# endif()
# set(OPTIONAL_FLAGS "")
# if(DISABLE_WARNINGS)
# set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow -Wformat=2 -Wold-style-cast -Wnon-virtual-dtor -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Woverloaded-virtual -Winline")
# endif()
# if(USE_SANITIZER)
# set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch -fdiagnostics-show-template-tree -fsanitize=address,undefined,pointer-compare -fno-sanitize-recover -D_FORTIFY_SOURCE=2 -fstack-protector -fno-omit-frame-pointer ")
# endif()
# set(SUPPRESSED_WARNINGS "-Wno-return-type")
# set(CMAKE_CXX_FLAGS "${OPTIMIZATION_FLAGS} ${SUPPRESSED_WARNINGS}")
if(AARE_USE_WARNINGS)
target_compile_options(aare_compiler_flags INTERFACE -Wall -Wextra -pedantic -Wshadow )
endif()
if(AARE_BUILD_TESTS)
add_subdirectory(tests)
endif()
add_subdirectory(core)
add_subdirectory(file_io)