Skip to content

Commit 1f51e73

Browse files
authored
Merge pull request #15 from rsps/add-how-to-install-guide
Add how to install guide
2 parents 43febe9 + 5d4829d commit 1f51e73

File tree

4 files changed

+54
-12
lines changed

4 files changed

+54
-12
lines changed

CMakeLists.txt

+9-7
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ option(RSP_ENABLE_ANSI "Enable ANSI output" false)
1212
# -------------------------------------------------------------------------------------------------------------- #
1313

1414
# Append this package's cmake scripts in module path
15-
list(FIND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" hasModulePath)
16-
if(${hasModulePath} STREQUAL "-1")
15+
list(FIND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" has_cmake_scripts_module_path)
16+
if(has_cmake_scripts_module_path EQUAL -1)
1717
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1818
endif()
1919

@@ -48,12 +48,14 @@ project(rsp-cmake-scripts
4848
HOMEPAGE_URL "https://github.com/rsps/cmake-scripts"
4949
LANGUAGES NONE
5050
)
51+
set("${PROJECT_NAME}_VERSION" "${PROJECT_VERSION}")
52+
set("${PROJECT_NAME}_SEMVER" "${version_SEMVER}")
5153

5254
# Ensure parent project has modules and other properties available.
53-
if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
55+
if(NOT PROJECT_IS_TOP_LEVEL)
5456
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
55-
set("${PROJECT_NAME}_VERSION" "${PROJECT_VERSION}" PARENT_SCOPE)
56-
set("${PROJECT_NAME}_SEMVER" "${version_SEMVER}" PARENT_SCOPE)
57+
set("${PROJECT_NAME}_VERSION" "${${PROJECT_NAME}_VERSION}" PARENT_SCOPE)
58+
set("${PROJECT_NAME}_SEMVER" "${${PROJECT_NAME}_SEMVER}" PARENT_SCOPE)
5759
endif()
5860

5961
# -------------------------------------------------------------------------------------------------------------- #
@@ -62,7 +64,7 @@ endif()
6264

6365
include("dependencies.cmake")
6466

65-
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
67+
if(PROJECT_IS_TOP_LEVEL)
6668
include("dev-dependencies.cmake")
6769
endif()
6870

@@ -82,7 +84,7 @@ endif ()
8284
# Post-dependencies project setup
8385
# -------------------------------------------------------------------------------------------------------------- #
8486

85-
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
87+
if(PROJECT_IS_TOP_LEVEL)
8688
include("rsp/debug")
8789
include("rsp/logging")
8890
endif()

dependencies.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
include_guard()
66

77
function(install_dependencies)
8-
message(STATUS "Installing Dependencies for ${PROJECT_NAME}")
8+
message(VERBOSE "Installing Dependencies for ${PROJECT_NAME}")
99

1010
# Avoid building tests for dependencies...
1111
set(BUILD_TESTING off)
1212

1313
# Add dependencies here...
14-
message(STATUS " N/A")
14+
message(VERBOSE " N/A")
1515

1616
endfunction()
1717
safeguard_properties(CALLBACK "install_dependencies" PROPERTIES BUILD_TESTING)

dev-dependencies.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ include_guard()
88
include("dependencies.cmake")
99

1010
function(install_dev_dependencies)
11-
message(STATUS "Installing Development Dependencies for ${PROJECT_NAME}")
11+
message(VERBOSE "Installing Development Dependencies for ${PROJECT_NAME}")
1212

1313
# Avoid building tests for dependencies...
1414
set(BUILD_TESTING off)
1515

1616
# Add dev-dependencies here...
17-
message(STATUS " N/A")
17+
message(VERBOSE " N/A")
1818

1919
endfunction()
2020
safeguard_properties(CALLBACK "install_dev_dependencies" PROPERTIES BUILD_TESTING)

docs/+current/index.md

+41-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,44 @@ author: RSP Systems A/S
1717

1818
## How to install
1919

20-
_TODO: ...incomplete, please review documentation at a later point_
20+
### Via CPM
21+
22+
If you are using [CPM](https://github.com/cpm-cmake/CPM.cmake), then you can install "CMake Scripts" using the following:
23+
24+
```cmake
25+
set(RSP_CMAKE_SCRIPTS_VERSION "0.1.0")
26+
27+
CPMAddPackage(
28+
NAME "rsp-cmake-scripts"
29+
VERSION "${RSP_CMAKE_SCRIPTS_VERSION}"
30+
GITHUB_REPOSITORY "rsps/cmake-scripts"
31+
)
32+
33+
# IMPORTANT: Enable "rsp/*" modules in your project,...
34+
list(APPEND CMAKE_MODULE_PATH "${rsp-cmake-scripts_SOURCE_DIR}/cmake")
35+
```
36+
37+
!!! info "`CMAKE_MODULE_PATH`"
38+
At the time of this writing, CPM does not automatically support paths appended to `CMAKE_MODULE_PATH`.
39+
To make use of this package's cmake modules, via CPM, you **MUST** manually append
40+
this package's module path in your top-level `CMakeLists.txt`, as shown in the above install example.
41+
42+
### Via Fetch Content
43+
44+
Alternatively, you can also use cmake's [`FetchContent`](https://cmake.org/cmake/help/latest/module/FetchContent.html) module:
45+
46+
```cmake
47+
set(RSP_CMAKE_SCRIPTS_VERSION "0.1.0")
48+
49+
include(FetchContent)
50+
FetchContent_Declare(
51+
"rsp-cmake-scripts"
52+
GIT_REPOSITORY "https://github.com/rsps/cmake-scripts"
53+
GIT_TAG "${RSP_CMAKE_SCRIPTS_VERSION}"
54+
)
55+
FetchContent_MakeAvailable("rsp-cmake-scripts")
56+
```
57+
58+
!!! note "Note"
59+
"CMake Scripts" depends on [CPM](https://github.com/cpm-cmake/CPM.cmake) for its dependencies. It will
60+
automatically be included, even when you install this project using cmake's `FetchContent` module.

0 commit comments

Comments
 (0)