Skip to content

Commit 25cf15c

Browse files
committed
Update README to reflect changes in CMake version and project setup order
- Updated minimum required CMake version from 3.20 to 3.24. - Adjusted the order of commands to ensure proper setup of cpp-library and dependency tracking. - Changed cpp-library version in examples from 4.0.3 to 5.0.0. - Added cpp_library_enable_dependency_tracking() before project() declaration for best practices.
1 parent 9aad344 commit 25cf15c

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,25 @@ If you prefer to set up your project manually, or need to integrate cpp-library
9999
Use `CPMAddPackage` to fetch cpp-library directly in your `CMakeLists.txt`:
100100

101101
```cmake
102-
cmake_minimum_required(VERSION 3.20)
103-
104-
# Project declaration - cpp_library_setup will use this name and detect version from git tags
105-
project(your-library)
102+
cmake_minimum_required(VERSION 3.24)
106103
107-
# Setup CPM
108-
if(PROJECT_IS_TOP_LEVEL AND NOT CPM_SOURCE_CACHE AND NOT DEFINED ENV{CPM_SOURCE_CACHE})
104+
# Setup CPM cache before project()
105+
if(NOT CPM_SOURCE_CACHE AND NOT DEFINED ENV{CPM_SOURCE_CACHE})
109106
set(CPM_SOURCE_CACHE "${CMAKE_SOURCE_DIR}/.cache/cpm" CACHE PATH "CPM source cache")
110-
message(STATUS "Setting cpm cache dir to: ${CPM_SOURCE_CACHE}")
111107
endif()
112108
include(cmake/CPM.cmake)
113109
114-
# Fetch cpp-library via CPM (update to latest version)
115-
CPMAddPackage("gh:stlab/cpp-library@4.0.3") # Check for latest version
110+
# Fetch cpp-library before project()
111+
CPMAddPackage("gh:stlab/cpp-library@5.0.0")
116112
include(${cpp-library_SOURCE_DIR}/cpp-library.cmake)
117113
114+
# Enable dependency tracking before project()
115+
cpp_library_enable_dependency_tracking()
116+
117+
# Now declare project
118+
project(your-library)
119+
120+
# Setup library
118121
cpp_library_setup(
119122
DESCRIPTION "Your library description"
120123
NAMESPACE your_namespace
@@ -131,7 +134,7 @@ cpp_library_setup(
131134

132135
Before using cpp-library, you'll need:
133136

134-
- **CMake 3.20+** - [Download here](https://cmake.org/download/)
137+
- **CMake 3.24+** - [Download here](https://cmake.org/download/)
135138
- **A C++17+ compiler** - GCC 7+, Clang 5+, MSVC 2017+, or Apple Clang 9+
136139

137140
#### Step 1: Install CPM.cmake
@@ -168,7 +171,7 @@ ctest --preset=test
168171
The preferred way to consume a library built with cpp-library is via [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake):
169172

170173
```cmake
171-
cmake_minimum_required(VERSION 3.20)
174+
cmake_minimum_required(VERSION 3.24)
172175
project(my-app)
173176
174177
include(cmake/CPM.cmake)

0 commit comments

Comments
 (0)