From 4b3a5f691687b3ab8a2ea591ebaedcd38032400c Mon Sep 17 00:00:00 2001 From: Edwin van Leeuwen Date: Sat, 3 Dec 2022 16:03:01 +0000 Subject: build: Fix build on arch --- CMakeLists.txt | 55 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cab78f..9e129c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,17 +19,13 @@ if (NOT pugixml_FOUND) FetchContent_MakeAvailable(pugixml) endif() -find_library(CPR cpr) +find_package(cpr) -set(CPR_LIBS cpr) - -if (NOT CPR) - set(CPR_FORCE_USE_SYSTEM_CURL ON) +if (NOT cpr_FOUND) FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git - GIT_TAG 1.7.2) + GIT_TAG 871ed52d350214a034f6ef8a3b8f51c5ce1bd400) FetchContent_MakeAvailable(cpr) - set(CPR_LIBS cpr::cpr) endif() find_package(nlohmann_json) @@ -61,6 +57,7 @@ if (NOT ftxui_FOUND) FetchContent_Populate(ftxui) add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL) endif() + FetchContent_MakeAvailable(ftxui) endif() @@ -90,6 +87,8 @@ find_package(Threads REQUIRED) # main set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) +# As always with cmake we need special repeating of thingies. You would think this is automatically set by CMAKE_CXX_STANDARD, but they love to use the compiler specific flag, which then confuses lsp, because it uses a different compiler. 1-0 for having to manually repeat versus automating things to be sensible. Luckily I don't work in a field based around automating things, otherwise this would be humiliating +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20") # Set a default build type if none was specified set(default_build_type "Release") @@ -113,14 +112,48 @@ set (SOURCES src/main.cpp) # Setup executable add_executable(${TARGET} ${SOURCES}) +file(GLOB_RECURSE + FOUND_HEADERS + src/*.hpp +) + +target_precompile_headers(${TARGET} + PRIVATE + + + + + + + + + + + + + + + + + + + + + + + + +) + target_include_directories(${TARGET} PRIVATE src/ + PRIVATE src/rttt/ PRIVATE test/include/ ) target_link_libraries(${TARGET} PRIVATE ${CURL_LIBRARIES} - PRIVATE ${CPR_LIBS} + PRIVATE cpr::cpr PRIVATE nlohmann_json::nlohmann_json PRIVATE Threads::Threads PRIVATE pugixml::pugixml @@ -141,8 +174,7 @@ target_link_libraries(rttt-send # General options target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wpedantic -Werror) -install(TARGETS ${TARGET} RUNTIME DESTINATION bin) -install(TARGETS rttt-send RUNTIME DESTINATION bin) +install(TARGETS ${TARGET} rttt-send RUNTIME DESTINATION bin) # Test files FILE(GLOB TESTFILES test/catch_*.cpp) @@ -154,6 +186,7 @@ foreach(TESTFILE ${TESTFILES}) else() add_executable(${NAME} EXCLUDE_FROM_ALL ${TESTFILE}) endif() + target_precompile_headers(${NAME} REUSE_FROM ${TARGET}) target_include_directories(${NAME} PRIVATE . test/include/ @@ -161,7 +194,7 @@ foreach(TESTFILE ${TESTFILES}) ) target_link_libraries(${NAME} PRIVATE ${CURL_LIBRARIES} - ${CPR_LIBS} + cpr::cpr nlohmann_json::nlohmann_json Threads::Threads pugixml::pugixml -- cgit v1.2.3