build: Search for files instead off explicitly giving CMake file list and enable color diagnostics

This commit is contained in:
:^) 2024-11-24 04:04:52 +01:00
parent 3426c801c9
commit 48bfda760d
Signed by: etenie
GPG Key ID: 02B622C4DE405C2B
1 changed files with 12 additions and 15 deletions

View File

@ -1,16 +1,16 @@
cmake_minimum_required(VERSION 3.30) cmake_minimum_required(VERSION 3.30)
project(nutri) project(nutri)
set(CMAKE_CXX_STANDARD 26) set(CMAKE_CXX_STANDARD 26)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1) set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
add_compile_options(-fdiagnostics-color=always) set(CMAKE_COLOR_DIAGNOSTICS 1)
find_program(MOLD_LINKER mold) find_program(MOLD_LINKER mold)
if (MOLD_LINKER) if(MOLD_LINKER)
add_link_options(-fuse-ld=mold) add_link_options(-fuse-ld=mold)
endif() endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release") if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
add_compile_options(-O3 -march=native) add_compile_options(-O3 -march=native)
@ -20,10 +20,10 @@ endif()
include(FetchContent) include(FetchContent)
find_package(ctre QUIET) find_package(ctre QUIET)
if (NOT ctre_FOUND) if(NOT ctre_FOUND)
FetchContent_Declare( FetchContent_Declare(
ctre ctre
GIT_REPOSITORY https://github.com/hanickadot/compile-time-regular-expressions.git GIT_REPOSITORY https://github.com/hanickadot/compile-time-regular-expressions.git
GIT_TAG v3.9.0 GIT_TAG v3.9.0
GIT_SHALLOW TRUE GIT_SHALLOW TRUE
) )
@ -31,10 +31,10 @@ if (NOT ctre_FOUND)
endif() endif()
find_package(cpr QUIET) find_package(cpr QUIET)
if (NOT cpr_FOUND) if(NOT cpr_FOUND)
FetchContent_Declare( FetchContent_Declare(
cpr cpr
GIT_REPOSITORY https://github.com/libcpr/cpr.git GIT_REPOSITORY https://github.com/libcpr/cpr.git
GIT_TAG 1.11.0 GIT_TAG 1.11.0
GIT_SHALLOW TRUE GIT_SHALLOW TRUE
) )
@ -42,7 +42,7 @@ if (NOT cpr_FOUND)
endif() endif()
find_package(glaze QUIET) find_package(glaze QUIET)
if (NOT glaze_FOUND) if(NOT glaze_FOUND)
FetchContent_Declare( FetchContent_Declare(
glaze glaze
GIT_REPOSITORY https://github.com/stephenberry/glaze.git GIT_REPOSITORY https://github.com/stephenberry/glaze.git
@ -52,13 +52,10 @@ if (NOT glaze_FOUND)
FetchContent_MakeAvailable(glaze) FetchContent_MakeAvailable(glaze)
endif() endif()
add_executable( file(GLOB_RECURSE SOURCES
nutri ${CMAKE_SOURCE_DIR}/src/*.cpp
src/main.cpp ${CMAKE_SOURCE_DIR}/src/*.hpp
src/ArgParser.hpp
src/Helpers/Utility.cpp
src/Helpers/Utility.hpp
src/Helpers/WolframAlpha.hpp
) )
add_executable(nutri ${SOURCES})
target_link_libraries(nutri PRIVATE cpr::cpr ctre::ctre glaze::glaze) target_link_libraries(nutri PRIVATE cpr::cpr ctre::ctre glaze::glaze)