Skip to content

Commit

Permalink
Add support to use cmake package configuration file from boost (#154)
Browse files Browse the repository at this point in the history
* Fix path in cmake config modul of boost

* Remove boost config module in hunter

* Increment package id

* Add Boost_USE_STATIC_LIBS in examples....

* Fix boost iostream example...

* Fix example, add Boost_USE_STATIC_LIBS

* Add workaround in example to fix test on travis

* If an older boost version is used... use BoostConfig from hunter

* Try to fix windows test builds

* Add FindBoost.cmake again,

It is needed, even when you set CONFIG in find_package! See BoostConfig
line 51 in hunter.
The original FindBoost from cmake add for example in iostream regex as
required dependency but this is an optional dependency ....

* Fix iOS build, set install target

* Split build and install target on iOS build

* Enable boost debug

* Use Boost::boost because example is build also with older versions

* Comment out fix, needs impovement

* Fix mingw/boost 1.64 test build

* Fix vs builds

* Cleanup boost thread test build

* Fix boost system test on windows

* Improve boost log test

* Set Boost_USE_STATIC_LIBS when not HUNTER_BUILD_SHARED_LIBS

* Get cmake args for Boost

* Fix use boost static libs in windows

* Introduced USE_CONFIG_FROM_BOOST

* use boost config if not boost version less then 1.72

* If boost version should be 1.72 or greater

* if not BOOST_BUILD_DYNAMIC_VSRUNTIME use boost static runtime

* Fix some review findings

* Increase PACKAGE_INTERNAL_DEPS_ID

* Create boost config from boost if USE_CONFIG_FROM_BOOST is set

* Use only some examples to use config from boost

* Fix boost log example

* Add USE_CONFIG_FROM_BOOST hint in boost doc
  • Loading branch information
Bjoe authored Mar 13, 2020
1 parent 4c13dd0 commit ef5bfcd
Show file tree
Hide file tree
Showing 79 changed files with 636 additions and 51 deletions.
2 changes: 1 addition & 1 deletion cmake/projects/Boost/atomic/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
atomic
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/chrono/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
chrono
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/context/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
context
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/contract/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
contract
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/coroutine/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
coroutine
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/date_time/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
date_time
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/exception/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
exception
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/fiber/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
fiber
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/filesystem/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
filesystem
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/graph/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
graph
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/graph_parallel/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
graph_parallel
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
25 changes: 24 additions & 1 deletion cmake/projects/Boost/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,27 @@ endif()

hunter_pick_scheme(DEFAULT url_sha1_boost)
hunter_cacheable(Boost)
hunter_download(PACKAGE_NAME Boost PACKAGE_INTERNAL_DEPS_ID "47")
hunter_download(PACKAGE_NAME Boost PACKAGE_INTERNAL_DEPS_ID "48")


if(NOT HUNTER_Boost_VERSION VERSION_LESS 1.72.0)
hunter_get_cmake_args(PACKAGE Boost OUT boost_cmake_args)
string(FIND "${boost_cmake_args}" "BUILD_SHARED_LIBS=ON" boost_shared)
string(FIND "${boost_cmake_args}" "USE_CONFIG_FROM_BOOST=ON" use_boost_config)
string(FIND "${boost_cmake_args}" "BOOST_BUILD_DYNAMIC_VSRUNTIME=NO" boost_static_runtime)
if(use_boost_config GREATER -1)
if(boost_shared LESS 0)
option(Boost_USE_STATIC_LIBS "Use of the static libraries" ON)
else()
option(Boost_USE_STATIC_LIBS "Use of the static libraries" OFF)
endif()

if(MSVC)
if(boost_static_runtime LESS 0)
option(Boost_USE_STATIC_RUNTIME "Use libraries linked statically to the C++ runtime" OFF)
else()
option(Boost_USE_STATIC_RUNTIME "Use libraries linked statically to the C++ runtime" ON)
endif()
endif()
endif()
endif()
2 changes: 1 addition & 1 deletion cmake/projects/Boost/hunter.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
boost_component
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/iostreams/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
iostreams
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/locale/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
locale
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/log/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
log
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/math/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
math
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/mpi/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
mpi
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/program_options/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
program_options
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/python/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
python
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/random/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
random
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/regex/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
regex
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
11 changes: 4 additions & 7 deletions cmake/projects/Boost/schemes/url_sha1_boost.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ configure_file(


set(pass_boost_no_cmake_config )
if (@HUNTER_Boost_VERSION@ VERSION_GREATER_EQUAL 1.72.0)
if (@HUNTER_Boost_VERSION@ VERSION_GREATER_EQUAL 1.72.0 AND NOT USE_CONFIG_FROM_BOOST)
set(pass_boost_no_cmake_config --no-cmake-config)
endif()

Expand Down Expand Up @@ -154,11 +154,6 @@ ExternalProject_Add(
"@HUNTER_SELF@/scripts/try-copy-license.cmake"

# ineffective on older Boost than 1.72.0 as we resort on --no-cmake-config
COMMAND
"@CMAKE_COMMAND@"
"-Dinstalldir=@HUNTER_PACKAGE_INSTALL_PREFIX@"
-P
"@HUNTER_SELF@/scripts/clean-boost-configs.cmake"

LOG_CONFIGURE ${log_build}
LOG_BUILD ${log_build}
Expand All @@ -170,4 +165,6 @@ set(HUNTER_SELF "@HUNTER_SELF@")
set(HUNTER_PACKAGE_INSTALL_PREFIX "@HUNTER_PACKAGE_INSTALL_PREFIX@")
set(HUNTER_Boost_VERSION "@HUNTER_Boost_VERSION@")

hunter_install_boost_config()
if(NOT USE_CONFIG_FROM_BOOST OR HUNTER_Boost_VERSION VERSION_LESS 1.72.0)
hunter_install_boost_config()
endif()
18 changes: 14 additions & 4 deletions cmake/projects/Boost/schemes/url_sha1_boost_ios_library.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ set(
--user-config="${boost_user_jam}"
)

if (@HUNTER_Boost_VERSION@ VERSION_GREATER_EQUAL 1.72.0)
if (@HUNTER_Boost_VERSION@ VERSION_GREATER_EQUAL 1.72.0 AND NOT USE_CONFIG_FROM_BOOST)
list(APPEND build_opts --no-cmake-config )
endif()

Expand Down Expand Up @@ -220,7 +220,11 @@ if(has_iphoneos)
BUILD_IN_SOURCE
1
INSTALL_COMMAND
""
./b2
-d0
${build_opts_iphoneos}
install
"--prefix=@HUNTER_PACKAGE_INSTALL_PREFIX@"
)
else()
# Add dummy target
Expand Down Expand Up @@ -273,7 +277,11 @@ if(has_isim)
BUILD_IN_SOURCE
1
INSTALL_COMMAND
""
./b2
-d0
${build_opts_iphonesimulator}
install
"--prefix=@HUNTER_PACKAGE_INSTALL_PREFIX@"
)
else()
# Add dummy target
Expand Down Expand Up @@ -376,4 +384,6 @@ set(HUNTER_SELF "@HUNTER_SELF@")
set(HUNTER_PACKAGE_INSTALL_PREFIX "@HUNTER_PACKAGE_INSTALL_PREFIX@")
set(HUNTER_Boost_VERSION "@HUNTER_Boost_VERSION@")

hunter_install_boost_config()
if(NOT USE_CONFIG_FROM_BOOST OR HUNTER_Boost_VERSION VERSION_LESS 1.72.0)
hunter_install_boost_config()
endif()
13 changes: 9 additions & 4 deletions cmake/projects/Boost/schemes/url_sha1_boost_library.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ if(has_toolset_version)
endif()

set(boost_user_jam "@HUNTER_PACKAGE_BUILD_DIR@/boost.user.jam")
# TODO file(TO_NATIVE_PATH "${boost_user_jam}" boost_user_jam_native_path)
# Escape --user-config=C:\projects\hunter-tdmm2\_testing\Hunter\_Base\5398c9d\30f4075\2d24521\Build\Boost\__filesystem\Build\boost.user.jam
# Error -> Invalid character escape '\p'.
set(
build_opts
-a
Expand All @@ -230,7 +233,7 @@ set(
--with-@HUNTER_PACKAGE_COMPONENT@
)

if (@HUNTER_Boost_VERSION@ VERSION_GREATER_EQUAL 1.72.0)
if (@HUNTER_Boost_VERSION@ VERSION_GREATER_EQUAL 1.72.0 AND NOT USE_CONFIG_FROM_BOOST)
list(APPEND build_opts --no-cmake-config )
endif()

Expand Down Expand Up @@ -533,8 +536,8 @@ ExternalProject_Add(
${b2_cmd}
-d0
${build_opts}
stage # install only libraries, headers installed in `url_sha1_boost`
"--stagedir=@HUNTER_PACKAGE_INSTALL_PREFIX@"
install
"--prefix=@HUNTER_PACKAGE_INSTALL_PREFIX@"
--ignore-site-config # Ignore Gentoo specific optimization "none" in site config that only the patched bjam of Gentoo can understand.
LOG_CONFIGURE ${log_build}
LOG_BUILD ${log_build}
Expand All @@ -546,4 +549,6 @@ set(HUNTER_SELF "@HUNTER_SELF@")
set(HUNTER_PACKAGE_INSTALL_PREFIX "@HUNTER_PACKAGE_INSTALL_PREFIX@")
set(HUNTER_Boost_VERSION "@HUNTER_Boost_VERSION@")

hunter_install_boost_config()
if(NOT USE_CONFIG_FROM_BOOST OR HUNTER_Boost_VERSION VERSION_LESS 1.72.0)
hunter_install_boost_config()
endif()
2 changes: 1 addition & 1 deletion cmake/projects/Boost/serialization/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
serialization
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/signals/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
signals
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/stacktrace/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
stacktrace
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/system/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
system
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/test/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
test
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/thread/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
thread
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/timer/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
timer
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/wave/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
wave
PACKAGE_INTERNAL_DEPS_ID "47"
PACKAGE_INTERNAL_DEPS_ID "48"
)
9 changes: 9 additions & 0 deletions docs/packages/pkg/Boost.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ config file (``boost/config/user.hpp``):
#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#define BOOST_MPL_LIMIT_LIST_SIZE 3
- Option ``USE_CONFIG_FROM_BOOST=ON`` use the package configuration file provided
by the boost project.
Since boost version 1.70.0, the boost project provide a well maintained package
configuration file for use with find_package's config mode.
See the difference between following example:
- `Boost-log <https://github.com/cpp-pm/hunter/blob/master/examples/Boost-log/CMakeLists.txt>`__
- `Boost-log-usingBoostConfig <https://github.com/cpp-pm/hunter/blob/master/examples/Boost-log-usingBoostConfig/CMakeLists.txt>`__


Python
------

Expand Down
23 changes: 23 additions & 0 deletions examples/Boost-chrono-1-64/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2013, Ruslan Baratov
# All rights reserved.

cmake_minimum_required(VERSION 3.0)

# Emulate HunterGate:
# * https://github.com/hunter-packages/gate
include("../common.cmake")

project(download-boost)

hunter_add_package(Boost COMPONENTS system chrono)
find_package(Boost CONFIG REQUIRED system chrono)

add_executable(foo foo.cpp)
target_link_libraries(
foo
PUBLIC
Boost::chrono
Boost::system # Should be last
# Boost 1.66.0, Linux, Clang with -stdlib=libstdc++:
# * https://travis-ci.org/ingenue/hunter/jobs/318140468#L2651
)
6 changes: 6 additions & 0 deletions examples/Boost-chrono-1-64/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <boost/chrono/system_clocks.hpp>

int main() {
boost::chrono::system_clock::now();
return 0;
}
Loading

0 comments on commit ef5bfcd

Please sign in to comment.