diff --git a/CMakeLists.txt b/CMakeLists.txt index f570192..d4760f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,8 +12,8 @@ option(RSP_ENABLE_ANSI "Enable ANSI output" false) # -------------------------------------------------------------------------------------------------------------- # # Append this package's cmake scripts in module path -list(FIND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" hasModulePath) -if(${hasModulePath} STREQUAL "-1") +list(FIND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" has_cmake_scripts_module_path) +if(has_cmake_scripts_module_path EQUAL -1) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") endif() @@ -48,12 +48,14 @@ project(rsp-cmake-scripts HOMEPAGE_URL "https://github.com/rsps/cmake-scripts" LANGUAGES NONE ) +set("${PROJECT_NAME}_VERSION" "${PROJECT_VERSION}") +set("${PROJECT_NAME}_SEMVER" "${version_SEMVER}") # Ensure parent project has modules and other properties available. -if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) +if(NOT PROJECT_IS_TOP_LEVEL) set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE) - set("${PROJECT_NAME}_VERSION" "${PROJECT_VERSION}" PARENT_SCOPE) - set("${PROJECT_NAME}_SEMVER" "${version_SEMVER}" PARENT_SCOPE) + set("${PROJECT_NAME}_VERSION" "${${PROJECT_NAME}_VERSION}" PARENT_SCOPE) + set("${PROJECT_NAME}_SEMVER" "${${PROJECT_NAME}_SEMVER}" PARENT_SCOPE) endif() # -------------------------------------------------------------------------------------------------------------- # @@ -62,7 +64,7 @@ endif() include("dependencies.cmake") -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) +if(PROJECT_IS_TOP_LEVEL) include("dev-dependencies.cmake") endif() @@ -82,7 +84,7 @@ endif () # Post-dependencies project setup # -------------------------------------------------------------------------------------------------------------- # -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) +if(PROJECT_IS_TOP_LEVEL) include("rsp/debug") include("rsp/logging") endif() diff --git a/dependencies.cmake b/dependencies.cmake index 1909088..c1023d3 100644 --- a/dependencies.cmake +++ b/dependencies.cmake @@ -5,13 +5,13 @@ include_guard() function(install_dependencies) - message(STATUS "Installing Dependencies for ${PROJECT_NAME}") + message(VERBOSE "Installing Dependencies for ${PROJECT_NAME}") # Avoid building tests for dependencies... set(BUILD_TESTING off) # Add dependencies here... - message(STATUS " N/A") + message(VERBOSE " N/A") endfunction() safeguard_properties(CALLBACK "install_dependencies" PROPERTIES BUILD_TESTING) diff --git a/dev-dependencies.cmake b/dev-dependencies.cmake index 53fb1ca..3a190fc 100644 --- a/dev-dependencies.cmake +++ b/dev-dependencies.cmake @@ -8,13 +8,13 @@ include_guard() include("dependencies.cmake") function(install_dev_dependencies) - message(STATUS "Installing Development Dependencies for ${PROJECT_NAME}") + message(VERBOSE "Installing Development Dependencies for ${PROJECT_NAME}") # Avoid building tests for dependencies... set(BUILD_TESTING off) # Add dev-dependencies here... - message(STATUS " N/A") + message(VERBOSE " N/A") endfunction() safeguard_properties(CALLBACK "install_dev_dependencies" PROPERTIES BUILD_TESTING) diff --git a/docs/+current/index.md b/docs/+current/index.md index b56d1aa..1e5a950 100644 --- a/docs/+current/index.md +++ b/docs/+current/index.md @@ -17,4 +17,44 @@ author: RSP Systems A/S ## How to install -_TODO: ...incomplete, please review documentation at a later point_ +### Via CPM + +If you are using [CPM](https://github.com/cpm-cmake/CPM.cmake), then you can install "CMake Scripts" using the following: + +```cmake +set(RSP_CMAKE_SCRIPTS_VERSION "0.1.0") + +CPMAddPackage( + NAME "rsp-cmake-scripts" + VERSION "${RSP_CMAKE_SCRIPTS_VERSION}" + GITHUB_REPOSITORY "rsps/cmake-scripts" +) + +# IMPORTANT: Enable "rsp/*" modules in your project,... +list(APPEND CMAKE_MODULE_PATH "${rsp-cmake-scripts_SOURCE_DIR}/cmake") +``` + +!!! info "`CMAKE_MODULE_PATH`" + At the time of this writing, CPM does not automatically support paths appended to `CMAKE_MODULE_PATH`. + To make use of this package's cmake modules, via CPM, you **MUST** manually append + this package's module path in your top-level `CMakeLists.txt`, as shown in the above install example. + +### Via Fetch Content + +Alternatively, you can also use cmake's [`FetchContent`](https://cmake.org/cmake/help/latest/module/FetchContent.html) module: + +```cmake +set(RSP_CMAKE_SCRIPTS_VERSION "0.1.0") + +include(FetchContent) +FetchContent_Declare( + "rsp-cmake-scripts" + GIT_REPOSITORY "https://github.com/rsps/cmake-scripts" + GIT_TAG "${RSP_CMAKE_SCRIPTS_VERSION}" +) +FetchContent_MakeAvailable("rsp-cmake-scripts") +``` + +!!! note "Note" + "CMake Scripts" depends on [CPM](https://github.com/cpm-cmake/CPM.cmake) for its dependencies. It will + automatically be included, even when you install this project using cmake's `FetchContent` module.