Skip to content

Commit b818565

Browse files
committed
fix version 1.88.0.beta1 handling
fix version 1.88.0.beta1 handling updated docs updated year of copyright updated version to 3.7.2
1 parent 4718d3a commit b818565

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14...3.22)
44

55
# ---- Project ----
66

7-
set(AddBoost.cmake_VERSION 3.7.1)
7+
set(AddBoost.cmake_VERSION 3.7.2)
88

99
option(${PROJECT_NAME}_INSTALL "Install the script at local system?" NO)
1010

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Arni
3+
Copyright (c) 2025 Arniiiii [email protected]
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Find or download Boost from CMake.
44

5-
Versions tested: from 1.79.0 upto 1.87.0 .
5+
Versions tested: from 1.79.0 upto 1.88.0.beta1 .
66

77
## Examples
88

@@ -11,18 +11,18 @@ Versions tested: from 1.79.0 upto 1.87.0 .
1111
## How to use:
1212

1313
1. Add [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake?tab=readme-ov-file#adding-cpm) in your project.
14-
2. Download `AddBoost.CMake` via CPM:
14+
2. Download `AddBoost.CMake` via CPM: (or install AddBoost.cmake system-wide, check [Features section](#features) of the document)
1515

1616
```cmake
1717
CPMAddPackage(
1818
NAME AddBoost.CMake
19-
GIT_TAG 3.3
19+
GIT_TAG 3.7.2
2020
GITHUB_REPOSITORY Arniiiii/AddBoost.cmake
2121
)
2222
```
23-
3. Use the `add_boost` macro. Notice *NOT* wrapping variables like TRY_BOOST_VERSION and so on in `${}` when sending arguments to the macro
23+
3. Use the `add_boost` macro. Notice *NOT* wrapping variables like TRY_BOOST_VERSION and so on in `"${}"` when sending arguments to the macro
2424
```cmake
25-
set(TRY_BOOST_VERSION "1.86.0")
25+
set(TRY_BOOST_VERSION "1.88.0.beta1")
2626
set(BOOST_MY_OPTIONS "BOOST_ENABLE_PYTHON ON;")
2727
set(BOOST_NOT_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED "thread;system")
2828
set(BOOST_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED "asio;beast;uuid;container;cobalt")
@@ -62,7 +62,7 @@ packageProject(
6262
6363
```
6464

65-
## Features:
65+
## Features
6666

6767
- [x] Finds local Boost ( you can set `-DCPM_USE_LOCAL_PACKAGES=1` for "looking for local Boost. if failed: download" mode. Set `-DCPM_LOCAL_PACKAGES_ONLY=1` to only look for installed Boost and emit error if failed to find)
6868
- [x] Downloads boost, if `-DCPM_USE_LOCAL_PACKAGES=1` and there's installed Boost with lower version than needed or if installed Boost doesn't exist on the system or if `-DCPM_DOWNLOAD_ALL=1` is set.
@@ -76,8 +76,11 @@ packageProject(
7676
- [x] If you want, you can link Boost libs yourself, since the code is macro, not a function: copy and paste some last parts of the main CMakeLists.txt of the project and adjust for yourself.
7777
- [x] You can link Boost libs automagically to multiple targets just by adding them to the end of the `add_boost(...)` macro.
7878
- [x] You can use `ADDBOOSTCMAKE_LINK_TYPE` to override default behaviour of linking: if target is INTERFACE, use INTERFACE, if else: PUBLIC
79+
- [x] Correctly handles attempts to get beta versions like `boost-1.88.0.beta1`, since `find_package` considers such version as incorrect, but we understand what you mean ^_^
80+
- [x] You can install the AddBoost.cmake on your SYSTEM !!! Use `-DAddBoost.cmake_INSTALL=ON` command line option and enjoy! And yes, it supports versioning!
7981
- [ ] Internally, this uses my fork of CPM with better logging handling. Waiting until PRs for CPM are going to be reviewed...
80-
- [x] You can install it as a utility module. Use `AddBoost.cmake_INSTALL` option at configuring and use `find_package(AddBoost.cmake)`
82+
- [ ] Cannot check existence of header only components of installed Boost, since it relies on functionality of `find_package(Boost ${VERSION} ${COMPONENTS})`. Therefore, set version of Boost you need so that it have the library.
83+
- [x] You can install it as a utility module. Use `AddBoost.cmake_INSTALL` option at configuring and use `find_package(AddBoost.cmake)`
8184
- [x] You can apply your patches to Boost. Before calling the ~~function~~ macro `add_boost(...)`, define variable `BOOST_ADD_MY_PATCHES` to be a path to folder in which there's `*.patch` in such layout:
8285
```
8386
patches/

cmake/AddBoost.cmake/AddBoost.cmakeConfig.cmake.in

+13-9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ macro(add_boost TRY_BOOST_VERSION BOOST_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED
5454
set(boost_is_old TRUE)
5555
endif()
5656

57+
if("${${TRY_BOOST_VERSION}}" MATCHES "\\.beta1")
58+
string(REGEX REPLACE "\\.beta." "" boost_find_package_version "${${TRY_BOOST_VERSION}}")
59+
else()
60+
set(boost_find_package_version "${${TRY_BOOST_VERSION}}")
61+
endif()
62+
5763
set(patches_for_boost "")
5864

5965
file(GLOB global_patches_for_boost CONFIGURE_DEPENDS
@@ -104,31 +110,31 @@ macro(add_boost TRY_BOOST_VERSION BOOST_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED
104110
if(DEFINED BOOST_USE_MY_BOOST_DIRECTORY)
105111
CPMAddPackage(
106112
NAME Boost
107-
VERSION ${${TRY_BOOST_VERSION}}
113+
VERSION "${boost_find_package_version}"
108114
SOURCE_DIR ${BOOST_USE_MY_BOOST_DIRECTORY} PATCHES ${patches_for_boost}
109115
FIND_PACKAGE_ARGUMENTS "COMPONENTS ${ESCAPED_BOOST_NOT_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED}"
110116
OPTIONS "BOOST_ENABLE_CMAKE ON;BOOST_SKIP_INSTALL_RULES OFF;${BOOST_MY_OPTIONS}"
111117
)
112118
elseif(patches_for_boost AND NOT boost_is_old) # is it 1.80.0 < x < 1.84.0
113119
CPMAddPackage(
114120
NAME Boost
115-
VERSION ${${TRY_BOOST_VERSION}}
121+
VERSION "${boost_find_package_version}"
116122
URL ${BOOST_URL} PATCHES ${patches_for_boost}
117123
FIND_PACKAGE_ARGUMENTS "COMPONENTS ${ESCAPED_BOOST_NOT_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED}"
118124
OPTIONS "BOOST_ENABLE_CMAKE ON;BOOST_SKIP_INSTALL_RULES OFF;${BOOST_MY_OPTIONS}"
119125
)
120126
elseif(NOT boost_is_old) # is it 1.85.0+ ?
121127
CPMAddPackage(
122128
NAME Boost
123-
VERSION ${${TRY_BOOST_VERSION}}
129+
VERSION "${boost_find_package_version}"
124130
URL ${BOOST_URL}
125131
FIND_PACKAGE_ARGUMENTS "COMPONENTS ${ESCAPED_BOOST_NOT_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED}"
126132
OPTIONS "BOOST_ENABLE_CMAKE ON;BOOST_SKIP_INSTALL_RULES OFF;${BOOST_MY_OPTIONS}"
127133
)
128134
else() # is it <1.80.0 ?
129135
CPMAddPackage(
130136
NAME Boost
131-
VERSION ${${TRY_BOOST_VERSION}}
137+
VERSION "${boost_find_package_version}"
132138
GIT_REPOSITORY "https://github.com/boostorg/boost"
133139
GIT_TAG "boost-${${TRY_BOOST_VERSION}}" PATCHES ${patches_for_boost}
134140
FIND_PACKAGE_ARGUMENTS "COMPONENTS ${ESCAPED_BOOST_NOT_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED}"
@@ -170,10 +176,8 @@ macro(add_boost TRY_BOOST_VERSION BOOST_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED
170176
endforeach()
171177
endforeach()
172178
if(Boost_LOCAL STREQUAL "YES")
173-
set(ADDBOOSTCMAKE_PACKAGEPROJECT_INSTALL_TARGETS
174-
"Boost ${${TRY_BOOST_VERSION}} REQUIRED"
175-
)
176-
foreach(dep ${${BOOST_NOT_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED}})
179+
set(ADDBOOSTCMAKE_PACKAGEPROJECT_INSTALL_TARGETS "Boost ${boost_find_package_version} REQUIRED")
180+
foreach(dep ${${BOOST_NOT_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED}})
177181
string(APPEND ADDBOOSTCMAKE_PACKAGEPROJECT_INSTALL_TARGETS " ${dep}")
178182
endforeach()
179183
else()
@@ -183,7 +187,7 @@ macro(add_boost TRY_BOOST_VERSION BOOST_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED
183187
)
184188
foreach(dep ${BOOST_ALL_DEPENDENCIES})
185189
string(APPEND ADDBOOSTCMAKE_PACKAGEPROJECT_INSTALL_TARGETS
186-
"boost_${dep} ${${TRY_BOOST_VERSION}};"
190+
"boost_${dep} ${boost_find_package_version};"
187191
)
188192
endforeach()
189193
string(LENGTH "${ADDBOOSTCMAKE_PACKAGEPROJECT_INSTALL_TARGETS}"

0 commit comments

Comments
 (0)