From bbe650c89d0396a0846225d1f73b2641b040a0cb Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Thu, 10 Oct 2024 21:36:12 +0700 Subject: [PATCH] feat: rename `CDEPS_ROOT` variable to `CDEPS_DIR` Signed-off-by: Alfi Maulana --- cmake/CDeps.cmake | 78 +++++++++++++++--------------- test/test_build.cmake | 2 +- test/test_build_generator.cmake | 2 +- test/test_build_options.cmake | 2 +- test/test_build_type.cmake | 2 +- test/test_download.cmake | 2 +- test/test_download_submodule.cmake | 2 +- test/test_download_version.cmake | 2 +- test/test_install.cmake | 2 +- 9 files changed, 47 insertions(+), 47 deletions(-) diff --git a/cmake/CDeps.cmake b/cmake/CDeps.cmake index 92aa307..3601397 100644 --- a/cmake/CDeps.cmake +++ b/cmake/CDeps.cmake @@ -20,12 +20,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# This variable contains the version of the included `CDeps.cmake` module. +# This variable specifies the version of the included `CDeps.cmake` module. set(CDEPS_VERSION 0.1.0) -# This variable contains the root directory for storing external packages. -if(NOT DEFINED CDEPS_ROOT) - set(CDEPS_ROOT "${CMAKE_SOURCE_DIR}/.cdeps") +# This variable specifies the directory used by CDeps to store packages. +if(NOT DEFINED CDEPS_DIR) + set(CDEPS_DIR ${CMAKE_SOURCE_DIR}/.cdeps) endif() # Downloads the source files of an external package. @@ -52,15 +52,15 @@ function(cdeps_download_package NAME URL REF) endif() # Check if the lock file is valid; redownload the source files if it isn't. - if(EXISTS ${CDEPS_ROOT}/${NAME}/src.lock) - file(READ ${CDEPS_ROOT}/${NAME}/src.lock LOCK) + if(EXISTS ${CDEPS_DIR}/${NAME}/src.lock) + file(READ ${CDEPS_DIR}/${NAME}/src.lock LOCK) if(LOCK STREQUAL SOURCE_LOCK) message(STATUS "CDeps: Using existing ${NAME} source files") - set(${NAME}_SOURCE_DIR ${CDEPS_ROOT}/${NAME}/src PARENT_SCOPE) + set(${NAME}_SOURCE_DIR ${CDEPS_DIR}/${NAME}/src PARENT_SCOPE) return() else() - file(REMOVE ${CDEPS_ROOT}/${NAME}/src.lock) - file(REMOVE_RECURSE ${CDEPS_ROOT}/${NAME}/src) + file(REMOVE ${CDEPS_DIR}/${NAME}/src.lock) + file(REMOVE_RECURSE ${CDEPS_DIR}/${NAME}/src) endif() endif() @@ -80,18 +80,18 @@ function(cdeps_download_package NAME URL REF) message(STATUS "CDeps: Downloading ${NAME} from ${GIT_URL} at ${REF}") execute_process( COMMAND "${GIT_EXECUTABLE}" clone ${CLONE_OPTS} https://${URL}.git - ${CDEPS_ROOT}/${NAME}/src + ${CDEPS_DIR}/${NAME}/src ERROR_VARIABLE ERR RESULT_VARIABLE RES OUTPUT_QUIET) if(NOT "${RES}" EQUAL 0) - file(REMOVE_RECURSE ${CDEPS_ROOT}/${NAME}/src) + file(REMOVE_RECURSE ${CDEPS_DIR}/${NAME}/src) message(FATAL_ERROR "CDeps: Failed to download ${NAME}: ${ERR}") return() endif() - file(WRITE ${CDEPS_ROOT}/${NAME}/src.lock "${SOURCE_LOCK}") - set(${NAME}_SOURCE_DIR ${CDEPS_ROOT}/${NAME}/src PARENT_SCOPE) + file(WRITE ${CDEPS_DIR}/${NAME}/src.lock "${SOURCE_LOCK}") + set(${NAME}_SOURCE_DIR ${CDEPS_DIR}/${NAME}/src PARENT_SCOPE) endfunction() # Builds an external package. @@ -135,12 +135,12 @@ function(cdeps_build_package NAME) list(APPEND ARG_OPTIONS CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() - if(NOT EXISTS ${CDEPS_ROOT}/${NAME}/src.lock) + if(NOT EXISTS ${CDEPS_DIR}/${NAME}/src.lock) message(FATAL_ERROR "CDeps: ${NAME} must be downloaded before building") return() endif() - file(READ ${CDEPS_ROOT}/${NAME}/src.lock SOURCE_LOCK) + file(READ ${CDEPS_DIR}/${NAME}/src.lock SOURCE_LOCK) set(BUILD_LOCK "${SOURCE_LOCK}") if(DEFINED ARG_GENERATOR) string(APPEND BUILD_LOCK " GENERATOR ${ARG_GENERATOR}") @@ -150,15 +150,15 @@ function(cdeps_build_package NAME) endif() # Check if the lock file is valid; rebuild the package if it isn't. - if(EXISTS ${CDEPS_ROOT}/${NAME}/build.lock) - file(READ ${CDEPS_ROOT}/${NAME}/build.lock LOCK) + if(EXISTS ${CDEPS_DIR}/${NAME}/build.lock) + file(READ ${CDEPS_DIR}/${NAME}/build.lock LOCK) if(LOCK STREQUAL BUILD_LOCK) message(STATUS "CDeps: Using existing ${NAME} build") - set(${NAME}_BUILD_DIR ${CDEPS_ROOT}/${NAME}/build PARENT_SCOPE) + set(${NAME}_BUILD_DIR ${CDEPS_DIR}/${NAME}/build PARENT_SCOPE) return() else() - file(REMOVE ${CDEPS_ROOT}/${NAME}/build.lock) - file(REMOVE_RECURSE ${CDEPS_ROOT}/${NAME}/build) + file(REMOVE ${CDEPS_DIR}/${NAME}/build.lock) + file(REMOVE_RECURSE ${CDEPS_DIR}/${NAME}/build) endif() endif() @@ -170,31 +170,31 @@ function(cdeps_build_package NAME) list(APPEND CONFIGURE_ARGS -D "${OPTION}") endforeach() execute_process( - COMMAND "${CMAKE_COMMAND}" -B ${CDEPS_ROOT}/${NAME}/build ${CONFIGURE_ARGS} - ${CDEPS_ROOT}/${NAME}/src + COMMAND "${CMAKE_COMMAND}" -B ${CDEPS_DIR}/${NAME}/build ${CONFIGURE_ARGS} + ${CDEPS_DIR}/${NAME}/src ERROR_VARIABLE ERR RESULT_VARIABLE RES OUTPUT_QUIET) if(NOT "${RES}" EQUAL 0) - file(REMOVE_RECURSE ${CDEPS_ROOT}/${NAME}/build) + file(REMOVE_RECURSE ${CDEPS_DIR}/${NAME}/build) message(FATAL_ERROR "CDeps: Failed to configure ${NAME}: ${ERR}") return() endif() message(STATUS "CDeps: Building ${NAME}") execute_process( - COMMAND "${CMAKE_COMMAND}" --build ${CDEPS_ROOT}/${NAME}/build + COMMAND "${CMAKE_COMMAND}" --build ${CDEPS_DIR}/${NAME}/build ERROR_VARIABLE ERR RESULT_VARIABLE RES OUTPUT_QUIET) if(NOT "${RES}" EQUAL 0) - file(REMOVE_RECURSE ${CDEPS_ROOT}/${NAME}/build) + file(REMOVE_RECURSE ${CDEPS_DIR}/${NAME}/build) message(FATAL_ERROR "CDeps: Failed to build ${NAME}: ${ERR}") return() endif() - file(WRITE ${CDEPS_ROOT}/${NAME}/build.lock "${BUILD_LOCK}") - set(${NAME}_BUILD_DIR ${CDEPS_ROOT}/${NAME}/build PARENT_SCOPE) + file(WRITE ${CDEPS_DIR}/${NAME}/build.lock "${BUILD_LOCK}") + set(${NAME}_BUILD_DIR ${CDEPS_DIR}/${NAME}/build PARENT_SCOPE) endfunction() # Installs an external package. @@ -208,40 +208,40 @@ endfunction() # This function outputs the `_INSTALL_DIR` variable, which contains the # path to the installed external package. function(cdeps_install_package NAME) - if(NOT EXISTS ${CDEPS_ROOT}/${NAME}/build.lock) + if(NOT EXISTS ${CDEPS_DIR}/${NAME}/build.lock) message(FATAL_ERROR "CDeps: ${NAME} must be built before installation") return() endif() - file(READ ${CDEPS_ROOT}/${NAME}/build.lock BUILD_LOCK) + file(READ ${CDEPS_DIR}/${NAME}/build.lock BUILD_LOCK) set(INSTALL_LOCK "${BUILD_LOCK}") # Check if the lock file is valid; reinstall the package if it isn't. - if(EXISTS ${CDEPS_ROOT}/${NAME}/install.lock) - file(READ ${CDEPS_ROOT}/${NAME}/install.lock LOCK) + if(EXISTS ${CDEPS_DIR}/${NAME}/install.lock) + file(READ ${CDEPS_DIR}/${NAME}/install.lock LOCK) if(LOCK STREQUAL INSTALL_LOCK) message(STATUS "CDeps: Using existing ${NAME} installation") - set(${NAME}_INSTALL_DIR ${CDEPS_ROOT}/${NAME}/install PARENT_SCOPE) + set(${NAME}_INSTALL_DIR ${CDEPS_DIR}/${NAME}/install PARENT_SCOPE) return() else() - file(REMOVE ${CDEPS_ROOT}/${NAME}/install.lock) - file(REMOVE_RECURSE ${CDEPS_ROOT}/${NAME}/install) + file(REMOVE ${CDEPS_DIR}/${NAME}/install.lock) + file(REMOVE_RECURSE ${CDEPS_DIR}/${NAME}/install) endif() endif() message(STATUS "CDeps: Installing ${NAME}") execute_process( - COMMAND "${CMAKE_COMMAND}" --install ${CDEPS_ROOT}/${NAME}/build - --prefix ${CDEPS_ROOT}/${NAME}/install + COMMAND "${CMAKE_COMMAND}" --install ${CDEPS_DIR}/${NAME}/build + --prefix ${CDEPS_DIR}/${NAME}/install ERROR_VARIABLE ERR RESULT_VARIABLE RES OUTPUT_QUIET) if(NOT "${RES}" EQUAL 0) - file(REMOVE_RECURSE ${CDEPS_ROOT}/${NAME}/install) + file(REMOVE_RECURSE ${CDEPS_DIR}/${NAME}/install) message(FATAL_ERROR "CDeps: Failed to install ${NAME}: ${ERR}") return() endif() - file(WRITE ${CDEPS_ROOT}/${NAME}/install.lock "${INSTALL_LOCK}") - set(${NAME}_INSTALL_DIR ${CDEPS_ROOT}/${NAME}/install PARENT_SCOPE) + file(WRITE ${CDEPS_DIR}/${NAME}/install.lock "${INSTALL_LOCK}") + set(${NAME}_INSTALL_DIR ${CDEPS_DIR}/${NAME}/install PARENT_SCOPE) endfunction() diff --git a/test/test_build.cmake b/test/test_build.cmake index af25d8f..ecbb629 100644 --- a/test/test_build.cmake +++ b/test/test_build.cmake @@ -4,7 +4,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../cmake/CDeps.cmake) set(CMAKE_GENERATOR "Unix Makefiles") -set(CDEPS_ROOT .cdeps) +set(CDEPS_DIR .cdeps) file(REMOVE_RECURSE .cdeps) section("it should fail to build a package " diff --git a/test/test_build_generator.cmake b/test/test_build_generator.cmake index 35ae66c..39fe41b 100644 --- a/test/test_build_generator.cmake +++ b/test/test_build_generator.cmake @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.21) include(${CMAKE_CURRENT_LIST_DIR}/../cmake/CDeps.cmake) -set(CDEPS_ROOT .cdeps) +set(CDEPS_DIR .cdeps) file(REMOVE_RECURSE .cdeps) file(WRITE .cdeps/pkg/src/CMakeLists.txt diff --git a/test/test_build_options.cmake b/test/test_build_options.cmake index 164f558..87a5ee5 100644 --- a/test/test_build_options.cmake +++ b/test/test_build_options.cmake @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.21) include(${CMAKE_CURRENT_LIST_DIR}/../cmake/CDeps.cmake) -set(CDEPS_ROOT .cdeps) +set(CDEPS_DIR .cdeps) file(REMOVE_RECURSE .cdeps) file(WRITE .cdeps/pkg/src/CMakeLists.txt diff --git a/test/test_build_type.cmake b/test/test_build_type.cmake index 525ea92..11e8e49 100644 --- a/test/test_build_type.cmake +++ b/test/test_build_type.cmake @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.21) include(${CMAKE_CURRENT_LIST_DIR}/../cmake/CDeps.cmake) -set(CDEPS_ROOT .cdeps) +set(CDEPS_DIR .cdeps) file(REMOVE_RECURSE .cdeps) file(WRITE .cdeps/pkg/src/CMakeLists.txt diff --git a/test/test_download.cmake b/test/test_download.cmake index a845daf..a5fdbd0 100644 --- a/test/test_download.cmake +++ b/test/test_download.cmake @@ -2,7 +2,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../cmake/CDeps.cmake) find_package(Git REQUIRED QUIET) -set(CDEPS_ROOT .cdeps) +set(CDEPS_DIR .cdeps) file(REMOVE_RECURSE .cdeps) section("it should download a package") diff --git a/test/test_download_submodule.cmake b/test/test_download_submodule.cmake index bb9a36c..853889d 100644 --- a/test/test_download_submodule.cmake +++ b/test/test_download_submodule.cmake @@ -2,7 +2,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../cmake/CDeps.cmake) find_package(Git REQUIRED QUIET) -set(CDEPS_ROOT .cdeps) +set(CDEPS_DIR .cdeps) file(REMOVE_RECURSE .cdeps) section("it should download a package without submodules") diff --git a/test/test_download_version.cmake b/test/test_download_version.cmake index 2b8f73d..347c634 100644 --- a/test/test_download_version.cmake +++ b/test/test_download_version.cmake @@ -2,7 +2,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../cmake/CDeps.cmake) find_package(Git REQUIRED QUIET) -set(CDEPS_ROOT .cdeps) +set(CDEPS_DIR .cdeps) file(REMOVE_RECURSE .cdeps) section("it should download a package with a specific version") diff --git a/test/test_install.cmake b/test/test_install.cmake index 3181017..be88de3 100644 --- a/test/test_install.cmake +++ b/test/test_install.cmake @@ -4,7 +4,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../cmake/CDeps.cmake) set(CMAKE_GENERATOR "Unix Makefiles") -set(CDEPS_ROOT .cdeps) +set(CDEPS_DIR .cdeps) file(REMOVE_RECURSE .cdeps) section("it should fail to install a package "