From fd7e9db4bc11442cab871e56728882f1288117eb Mon Sep 17 00:00:00 2001 From: Nikola Ducak Date: Fri, 7 Jun 2024 11:40:15 +0200 Subject: [PATCH] build: support preinstalled ftxui and fmt --- CMakeLists.txt | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9ea151..3ef6562 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,18 +25,22 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") include(FetchContent) +set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE) # -------------------------- Fetech ftxui ------------------------------- # -set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE) -FetchContent_Declare( - ftxui - GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui - GIT_TAG v5.0.0) -FetchContent_GetProperties(ftxui) -if(NOT ftxui_POPULATED) - FetchContent_Populate(ftxui) - add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL) +find_package(ftxui 5) +if(NOT ftxui_FOUND) + message(STATUS "ftxui Not found... fetching") + FetchContent_Declare( + ftxui + GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui + GIT_TAG v5.0.0) + FetchContent_GetProperties(ftxui) + if(NOT ftxui_POPULATED) + FetchContent_Populate(ftxui) + add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL) + endif() endif() # --------------------------------- boost -------------------------------- # @@ -62,14 +66,18 @@ find_package(LibGit2 3 REQUIRED) # ------------------------------- Fetch FMT ------------------------------ # -FetchContent_Declare( - fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt - GIT_TAG 9.1.0) -FetchContent_GetProperties(fmt) -if(NOT fmt_POPULATED) - FetchContent_Populate(fmt) - add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR} EXCLUDE_FROM_ALL) +find_package(fmt 9) +if(NOT fmt_FOUND) + message(STATUS "fmt Not found... fetching") + FetchContent_Declare( + fmt + GIT_REPOSITORY https://github.com/fmtlib/fmt + GIT_TAG 9.1.0) + FetchContent_GetProperties(fmt) + if(NOT fmt_POPULATED) + FetchContent_Populate(fmt) + add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR} EXCLUDE_FROM_ALL) + endif() endif() # --------------------------------- tests -------------------------------- #