Skip to content

Commit 5acd3ed

Browse files
committed
Adding support for installing the library and simplifying versioning.
1 parent 092a709 commit 5acd3ed

4 files changed

Lines changed: 53 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
cmake_minimum_required(VERSION 3.20)
2-
project(stlab-copy-on-write)
2+
project(stlab-copy-on-write
3+
VERSION 1.0.2
4+
DESCRIPTION "Copy-on-write wrapper for any type"
5+
)
36

47
# Enable testing for this project
58
include(CTest)
@@ -65,6 +68,42 @@ target_include_directories(stlab-copy-on-write
6568
$<INSTALL_INTERFACE:include>
6669
)
6770

71+
# Generate and install CMake config files
72+
include(CMakePackageConfigHelpers)
73+
write_basic_package_version_file(
74+
"${CMAKE_CURRENT_BINARY_DIR}/stlab-copy-on-write-config-version.cmake"
75+
VERSION ${PROJECT_VERSION}
76+
COMPATIBILITY SameMajorVersion
77+
)
78+
79+
configure_package_config_file(
80+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/stlab-copy-on-write-config.cmake.in"
81+
"${CMAKE_CURRENT_BINARY_DIR}/stlab-copy-on-write-config.cmake"
82+
INSTALL_DESTINATION lib/cmake/stlab-copy-on-write
83+
)
84+
85+
# Installation rules
86+
install(TARGETS stlab-copy-on-write
87+
EXPORT stlab-copy-on-write-targets
88+
INCLUDES DESTINATION include
89+
)
90+
91+
install(DIRECTORY include/
92+
DESTINATION include
93+
)
94+
95+
install(EXPORT stlab-copy-on-write-targets
96+
FILE stlab-copy-on-write-targets.cmake
97+
NAMESPACE stlab::
98+
DESTINATION lib/cmake/stlab-copy-on-write
99+
)
100+
101+
install(FILES
102+
"${CMAKE_CURRENT_BINARY_DIR}/stlab-copy-on-write-config.cmake"
103+
"${CMAKE_CURRENT_BINARY_DIR}/stlab-copy-on-write-config-version.cmake"
104+
DESTINATION lib/cmake/stlab-copy-on-write
105+
)
106+
68107
# Function to add a test executable with all necessary setup
69108
function(add_test_executable NAME)
70109
add_executable(${NAME} test/${NAME}.cpp)
@@ -111,7 +150,7 @@ if(BUILD_DOCS)
111150
# Set variables for Doxyfile template
112151
set(PROJECT_NAME "stlab::copy_on_write")
113152
set(PROJECT_BRIEF "Copy-on-write wrapper for any type")
114-
set(PROJECT_VERSION "1.0.0")
153+
set(PROJECT_VERSION "${PROJECT_VERSION}")
115154
set(INPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
116155
set(OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
117156
set(AWESOME_CSS_PATH "${AWESOME_CSS_DIR}")

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ Copy-on-write wrapper for any type.
1818
**Online Documentation:**
1919
The latest documentation is automatically built and deployed to [GitHub Pages](https://stlab.github.io/copy-on-write/) on every push to the main branch.
2020

21+
**Version Management:**
22+
The project version is maintained in a single location in the `project()` command at the top of `CMakeLists.txt`. When creating a new release:
23+
1. Update the version in `project(stlab-copy-on-write VERSION X.Y.Z)`
24+
2. The version will automatically propagate to:
25+
- CMake package configuration
26+
- Doxygen documentation
27+
- GitHub release
28+
2129
`stlab::copy_on_write<T>` is a smart pointer that implements copy-on-write semantics. It allows multiple instances to share the same underlying data until one of them needs to modify it, at which point a copy is made. This can provide significant performance benefits when dealing with expensive-to-copy objects that are frequently copied but rarely modified.
2230

2331
## Features
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@PACKAGE_INIT@
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/stlab-copy-on-write-targets.cmake")
4+
check_required_components(stlab-copy-on-write)

include/stlab/copy_on_write.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
This file contains the complete implementation of stlab::copy_on_write, a thread-safe
1313
copy-on-write wrapper for any type that models Regular. The implementation uses atomic
1414
reference counting and provides lazy copying semantics.
15-
16-
@author Adobe Systems
17-
@version 1.0.0
18-
@date 2013-2024
1915
*/
2016

2117
#ifndef STLAB_COPY_ON_WRITE_HPP

0 commit comments

Comments
 (0)