Skip to content

Add how to install guide #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

# -------------------------------------------------------------------------------------------------------------- #
Expand All @@ -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()

Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions dev-dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
42 changes: 41 additions & 1 deletion docs/+current/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.