From 62c5ee32ee77b2b9a198474f91246159829cde85 Mon Sep 17 00:00:00 2001 From: LSuper <120311070@qq.com> Date: Sat, 26 Apr 2025 23:38:27 +0800 Subject: [PATCH 1/2] feat: use CPM instead of FetchContent --- CMakeLists.txt | 11 +++++++++++ src/CMakeLists.txt | 39 +++++++++++++++++---------------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c6d44a..97b60aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,17 @@ elseif(UNIX AND NOT APPLE) add_compile_definitions(LINUX_OS) endif() +# download CPM.cmake +set(CPM_VERSION 0.40.8) +set(CPM_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_VERSION}.cmake") + +if(NOT (EXISTS ${CPM_LOCATION})) + message(STATUS "Downloading CPM.cmake") + file(DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_VERSION}/CPM.cmake ${CPM_LOCATION}) +endif() + +include(${CPM_LOCATION}) + add_subdirectory(src) if (BUILD_TEST) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f1bb49e..5cb8556 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -136,33 +136,28 @@ if (WIN32) # Install dlls in the same directory as the executable on Windows set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src) endif () - -include(FetchContent) -FetchContent_Declare(spdlog - URL https://github.com/gabime/spdlog/archive/refs/tags/v1.15.2.zip +CPMAddPackage( + NAME spdlog + GITHUB_REPOSITORY gabime/spdlog + VERSION 1.15.2) + +CPMAddPackage( + NAME json + VERSION 3.11.3 + # The git repo is incredibly large, so we download the archived include directory + URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz ) -FetchContent_Declare(json - URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz) - -FetchContent_Declare(cpr - GIT_REPOSITORY https://github.com/libcpr/cpr.git - GIT_TAG 96cd60913124f2a9a17f9d814f3db11d62ef3ae0) - -FetchContent_Declare(SingleApplication - URL https://github.com/itay-grudev/SingleApplication/archive/refs/tags/v3.5.2.tar.gz) - -FetchContent_Declare(mio - GIT_REPOSITORY https://github.com/vimpunk/mio.git - GIT_TAG 8b6b7d878c89e81614d05edca7936de41ccdd2da +CPMAddPackage( + NAME SingleApplication + VERSION 3.5.2 + URL https://github.com/itay-grudev/SingleApplication/archive/refs/tags/v3.5.2.tar.gz ) -FetchContent_Declare(magic_enum - GIT_REPOSITORY https://github.com/Neargye/magic_enum.git - GIT_TAG v0.9.7 -) +CPMAddPackage("gh:libcpr/cpr#96cd60913124f2a9a17f9d814f3db11d62ef3ae0") +CPMAddPackage("gh:vimpunk/mio#8b6b7d878c89e81614d05edca7936de41ccdd2da") +CPMAddPackage("gh:Neargye/magic_enum@0.9.7") -FetchContent_MakeAvailable(spdlog json cpr SingleApplication mio magic_enum) set(MIO_INCLUDE_DIR ${mio_SOURCE_DIR}/single_include) include_directories(${MIO_INCLUDE_DIR}) From 13cd7fda6a0288dbcc3a61349ccfb16b0b527fe3 Mon Sep 17 00:00:00 2001 From: L-Super <40905056+L-Super@users.noreply.github.com> Date: Thu, 26 Jun 2025 11:02:09 +0800 Subject: [PATCH 2/2] feat: upgrade cpm to v0.42.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97b60aa..dd4b669 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ elseif(UNIX AND NOT APPLE) endif() # download CPM.cmake -set(CPM_VERSION 0.40.8) +set(CPM_VERSION 0.42.0) set(CPM_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_VERSION}.cmake") if(NOT (EXISTS ${CPM_LOCATION}))