diff --git a/README.md b/README.md index 8455eba..df938a7 100644 --- a/README.md +++ b/README.md @@ -29,12 +29,16 @@ add_executable(my-parser my-parser.cpp) target_link_libraries(cpm-test LarsParser) ``` +# Update packages + +To update packages, run cmake with the additional option `-DCPM_RESET=ON`. To keep the project working offline after the update, set `-DCPM_RESET=OFF` afterwards. + # Installation To add CPM to your current project, copy the scripts in the `cmake` directory into you current project project. The command below will perform this automatically. ```bash -wget -qO- https://github.com/TheLartians/CPM/releases/download/v0.2/cmake.zip | bsdtar -xvf- +wget -qO- https://github.com/TheLartians/CPM/releases/download/v0.3/cmake.zip | bsdtar -xvf- ``` # Limitations diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 38e2342..7a551b0 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -2,10 +2,13 @@ set(_CPM_Dir "${CMAKE_CURRENT_LIST_DIR}") include(CMakeParseArguments) include(${_CPM_Dir}/DownloadProject.cmake) - -function(CPMHasPackage) -endfunction() +option(CPM_RESET "reset CPM" OFF) + +if(${CPM_RESET}) + message(STATUS "CPM: resetting packages") + set(CPM_PACKAGES "" CACHE INTERNAL "CPM Packages") +endif() function(CPMAddPackage) set(options QUIET) @@ -16,6 +19,7 @@ function(CPMAddPackage) VERSION GIT_TAG BINARY_DIR + UPDATE_DISCONNECTED ) set(multiValueArgs "") @@ -30,6 +34,15 @@ function(CPMAddPackage) set(CPM_ARGS_BINARY_DIR ${CMAKE_BINARY_DIR}/CPM-projects/${CPM_ARGS_NAME}) endif() + if (NOT CPM_ARGS_UPDATE_DISCONNECTED) + if (${CPM_RESET}) + set(CPM_ARGS_UPDATE_DISCONNECTED OFF) + else() + set(CPM_ARGS_UPDATE_DISCONNECTED ON) + endif() + endif() + + if (NOT CPM_PROJECT_DIR) set(CPM_PROJECT_DIR "${CPM_ARGS_BINARY_DIR}") endif() diff --git a/cmake/CPMProject.CMakeLists.cmake.in b/cmake/CPMProject.CMakeLists.cmake.in index 3bf475f..5f413c7 100644 --- a/cmake/CPMProject.CMakeLists.cmake.in +++ b/cmake/CPMProject.CMakeLists.cmake.in @@ -17,7 +17,7 @@ else() PROJ @CPM_ARGS_NAME@ GIT_REPOSITORY @CPM_ARGS_GIT_REPOSITORY@ GIT_TAG @CPM_ARGS_GIT_TAG@ - UPDATE_DISCONNECTED 1 + UPDATE_DISCONNECTED @CPM_ARGS_UPDATE_DISCONNECTED@ GIT_SHALLOW 1 PREFIX @CPM_ARGS_BINARY_DIR@/dl QUIET diff --git a/tests/complex/CMakeLists.txt b/tests/complex/CMakeLists.txt index de9ce3b..8454572 100644 --- a/tests/complex/CMakeLists.txt +++ b/tests/complex/CMakeLists.txt @@ -7,7 +7,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CPM.cmake) CPMAddPackage( NAME LHC GIT_REPOSITORY https://github.com/TheLartians/LHC.git - VERSION 0.3 + VERSION 0.4 ) CPMAddPackage(