diff options
author | Edwin van Leeuwen <edwinvanl@tuta.io> | 2022-12-03 16:03:27 +0000 |
---|---|---|
committer | Edwin van Leeuwen <edwinvanl@tuta.io> | 2022-12-03 16:03:27 +0000 |
commit | 0a84ecf19fb7b4ecfb45a5938f0c226dc32bf7f7 (patch) | |
tree | 0c7bf57e0468f410686befd24f9fa06ded9d5e0a | |
parent | 380c36ff02cc1fb7b4b78f4bebff14f32a6f0443 (diff) | |
parent | 08f9ff25ca6c4412faf0830cad20660547e3bfa5 (diff) |
build fix
-rw-r--r-- | CMakeLists.txt | 55 |
1 files 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 + <chrono> + <cpr/cpr.h> + <deque> + <fmt/format.h> + <list> + <map> + <memory> + <nlohmann/json.hpp> + <optional> + <pugixml.hpp> + <queue> + <random> + <ranges> + <regex> + <stack> + <string> + <variant> + <vector> + <ftxui/component/captured_mouse.hpp> + <ftxui/component/component.hpp> + <ftxui/component/screen_interactive.hpp> + <ftxui/dom/elements.hpp> + <ftxui/dom/flexbox_config.hpp> + <zmq.hpp> +) + 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 |