From ef5bfcddba2d702755c0402bb39d20f0c70d61a3 Mon Sep 17 00:00:00 2001 From: Joerg-Christian Boehme Date: Fri, 13 Mar 2020 14:26:10 +0100 Subject: [PATCH] Add support to use cmake package configuration file from boost (#154) * 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 --- cmake/projects/Boost/atomic/hunter.cmake | 2 +- cmake/projects/Boost/chrono/hunter.cmake | 2 +- cmake/projects/Boost/context/hunter.cmake | 2 +- cmake/projects/Boost/contract/hunter.cmake | 2 +- cmake/projects/Boost/coroutine/hunter.cmake | 2 +- cmake/projects/Boost/date_time/hunter.cmake | 2 +- cmake/projects/Boost/exception/hunter.cmake | 2 +- cmake/projects/Boost/fiber/hunter.cmake | 2 +- cmake/projects/Boost/filesystem/hunter.cmake | 2 +- cmake/projects/Boost/graph/hunter.cmake | 2 +- .../Boost/graph_parallel/hunter.cmake | 2 +- cmake/projects/Boost/hunter.cmake | 25 ++++++- cmake/projects/Boost/hunter.cmake.in | 2 +- cmake/projects/Boost/iostreams/hunter.cmake | 2 +- cmake/projects/Boost/locale/hunter.cmake | 2 +- cmake/projects/Boost/log/hunter.cmake | 2 +- cmake/projects/Boost/math/hunter.cmake | 2 +- cmake/projects/Boost/mpi/hunter.cmake | 2 +- .../Boost/program_options/hunter.cmake | 2 +- cmake/projects/Boost/python/hunter.cmake | 2 +- cmake/projects/Boost/random/hunter.cmake | 2 +- cmake/projects/Boost/regex/hunter.cmake | 2 +- .../Boost/schemes/url_sha1_boost.cmake.in | 11 ++-- .../url_sha1_boost_ios_library.cmake.in | 18 +++-- .../schemes/url_sha1_boost_library.cmake.in | 13 ++-- .../projects/Boost/serialization/hunter.cmake | 2 +- cmake/projects/Boost/signals/hunter.cmake | 2 +- cmake/projects/Boost/stacktrace/hunter.cmake | 2 +- cmake/projects/Boost/system/hunter.cmake | 2 +- cmake/projects/Boost/test/hunter.cmake | 2 +- cmake/projects/Boost/thread/hunter.cmake | 2 +- cmake/projects/Boost/timer/hunter.cmake | 2 +- cmake/projects/Boost/wave/hunter.cmake | 2 +- docs/packages/pkg/Boost.rst | 9 +++ examples/Boost-chrono-1-64/CMakeLists.txt | 23 +++++++ examples/Boost-chrono-1-64/foo.cpp | 6 ++ .../CMakeLists.txt | 23 +++++++ .../Boost-chrono-useBoostConfig/config.cmake | 4 ++ examples/Boost-chrono-useBoostConfig/foo.cpp | 6 ++ examples/Boost-chrono/CMakeLists.txt | 2 + examples/Boost-contract/CMakeLists.txt | 2 + examples/Boost-fiber/CMakeLists.txt | 2 + examples/Boost-filesystem-1-64/CMakeLists.txt | 60 +++++++++++++++++ examples/Boost-filesystem-1-64/foo.cpp | 7 ++ .../Boost-filesystem-1-64/foo_android.cpp | 21 ++++++ examples/Boost-filesystem-shared/config.cmake | 2 +- .../CMakeLists.txt | 66 +++++++++++++++++++ .../config.cmake | 4 ++ .../Boost-filesystem-useBoostConfig/foo.cpp | 7 ++ .../foo_android.cpp | 21 ++++++ examples/Boost-filesystem/CMakeLists.txt | 2 + .../CMakeLists.txt | 23 +++++++ .../config.cmake | 4 ++ .../Boost-iostreams-useBoostConfig/foo.cpp | 66 +++++++++++++++++++ examples/Boost-iostreams/CMakeLists.txt | 2 + examples/Boost-log-shared/CMakeLists.txt | 2 + .../Boost-log-useBoostConfig/CMakeLists.txt | 19 ++++++ .../Boost-log-useBoostConfig/config.cmake | 4 ++ examples/Boost-log-useBoostConfig/foo.cpp | 12 ++++ examples/Boost-log/CMakeLists.txt | 17 ++++- examples/Boost-log/foo.cpp | 10 ++- examples/Boost-math/CMakeLists.txt | 2 + examples/Boost-program-options/CMakeLists.txt | 2 + examples/Boost-python-numpy/CMakeLists.txt | 2 + examples/Boost-python/CMakeLists.txt | 2 + examples/Boost-random/CMakeLists.txt | 2 + examples/Boost-serialization/CMakeLists.txt | 2 + examples/Boost-stacktrace/CMakeLists.txt | 2 + examples/Boost-system-1-66/CMakeLists.txt | 2 + examples/Boost-system/CMakeLists.txt | 2 + examples/Boost-test/CMakeLists.txt | 2 + examples/Boost-thread-1-64/CMakeLists.txt | 16 +++++ examples/Boost-thread-1-64/foo.cpp | 36 ++++++++++ examples/Boost-thread/CMakeLists.txt | 2 + examples/Boost-useBoostConfig/CMakeLists.txt | 48 ++++++++++++++ examples/Boost-useBoostConfig/config.cmake | 4 ++ examples/Boost-useBoostConfig/foo.cpp | 4 ++ examples/Boost-uuid/CMakeLists.txt | 2 + examples/Boost/CMakeLists.txt | 4 +- 79 files changed, 636 insertions(+), 51 deletions(-) create mode 100644 examples/Boost-chrono-1-64/CMakeLists.txt create mode 100644 examples/Boost-chrono-1-64/foo.cpp create mode 100644 examples/Boost-chrono-useBoostConfig/CMakeLists.txt create mode 100644 examples/Boost-chrono-useBoostConfig/config.cmake create mode 100644 examples/Boost-chrono-useBoostConfig/foo.cpp create mode 100644 examples/Boost-filesystem-1-64/CMakeLists.txt create mode 100644 examples/Boost-filesystem-1-64/foo.cpp create mode 100644 examples/Boost-filesystem-1-64/foo_android.cpp create mode 100644 examples/Boost-filesystem-useBoostConfig/CMakeLists.txt create mode 100644 examples/Boost-filesystem-useBoostConfig/config.cmake create mode 100644 examples/Boost-filesystem-useBoostConfig/foo.cpp create mode 100644 examples/Boost-filesystem-useBoostConfig/foo_android.cpp create mode 100644 examples/Boost-iostreams-useBoostConfig/CMakeLists.txt create mode 100644 examples/Boost-iostreams-useBoostConfig/config.cmake create mode 100644 examples/Boost-iostreams-useBoostConfig/foo.cpp create mode 100644 examples/Boost-log-useBoostConfig/CMakeLists.txt create mode 100644 examples/Boost-log-useBoostConfig/config.cmake create mode 100644 examples/Boost-log-useBoostConfig/foo.cpp create mode 100644 examples/Boost-thread-1-64/CMakeLists.txt create mode 100644 examples/Boost-thread-1-64/foo.cpp create mode 100644 examples/Boost-useBoostConfig/CMakeLists.txt create mode 100644 examples/Boost-useBoostConfig/config.cmake create mode 100644 examples/Boost-useBoostConfig/foo.cpp diff --git a/cmake/projects/Boost/atomic/hunter.cmake b/cmake/projects/Boost/atomic/hunter.cmake index 950d1eda24..ffe9b97b04 100644 --- a/cmake/projects/Boost/atomic/hunter.cmake +++ b/cmake/projects/Boost/atomic/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT atomic - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/chrono/hunter.cmake b/cmake/projects/Boost/chrono/hunter.cmake index f5769f2ad1..1dfe5444dd 100644 --- a/cmake/projects/Boost/chrono/hunter.cmake +++ b/cmake/projects/Boost/chrono/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT chrono - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/context/hunter.cmake b/cmake/projects/Boost/context/hunter.cmake index 629d56dbea..f3198d656f 100644 --- a/cmake/projects/Boost/context/hunter.cmake +++ b/cmake/projects/Boost/context/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT context - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/contract/hunter.cmake b/cmake/projects/Boost/contract/hunter.cmake index ff4ce5ded9..431ae5926a 100644 --- a/cmake/projects/Boost/contract/hunter.cmake +++ b/cmake/projects/Boost/contract/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT contract - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/coroutine/hunter.cmake b/cmake/projects/Boost/coroutine/hunter.cmake index 60c7250b6d..7217543a4d 100644 --- a/cmake/projects/Boost/coroutine/hunter.cmake +++ b/cmake/projects/Boost/coroutine/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT coroutine - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/date_time/hunter.cmake b/cmake/projects/Boost/date_time/hunter.cmake index 7aa3a724f0..37b7b76091 100644 --- a/cmake/projects/Boost/date_time/hunter.cmake +++ b/cmake/projects/Boost/date_time/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT date_time - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/exception/hunter.cmake b/cmake/projects/Boost/exception/hunter.cmake index 0f6ac454c2..df61a6be94 100644 --- a/cmake/projects/Boost/exception/hunter.cmake +++ b/cmake/projects/Boost/exception/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT exception - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/fiber/hunter.cmake b/cmake/projects/Boost/fiber/hunter.cmake index efd1c651ff..3c63f88c0d 100644 --- a/cmake/projects/Boost/fiber/hunter.cmake +++ b/cmake/projects/Boost/fiber/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT fiber - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/filesystem/hunter.cmake b/cmake/projects/Boost/filesystem/hunter.cmake index 7b36f6e898..3eba982f4c 100644 --- a/cmake/projects/Boost/filesystem/hunter.cmake +++ b/cmake/projects/Boost/filesystem/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT filesystem - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/graph/hunter.cmake b/cmake/projects/Boost/graph/hunter.cmake index f030cc13ca..7afa55e61d 100644 --- a/cmake/projects/Boost/graph/hunter.cmake +++ b/cmake/projects/Boost/graph/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT graph - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/graph_parallel/hunter.cmake b/cmake/projects/Boost/graph_parallel/hunter.cmake index b00be6c538..d42a72e6b4 100644 --- a/cmake/projects/Boost/graph_parallel/hunter.cmake +++ b/cmake/projects/Boost/graph_parallel/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT graph_parallel - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/hunter.cmake b/cmake/projects/Boost/hunter.cmake index b16598f2fc..dce69a67fd 100644 --- a/cmake/projects/Boost/hunter.cmake +++ b/cmake/projects/Boost/hunter.cmake @@ -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() \ No newline at end of file diff --git a/cmake/projects/Boost/hunter.cmake.in b/cmake/projects/Boost/hunter.cmake.in index 08da145184..602e6a1142 100644 --- a/cmake/projects/Boost/hunter.cmake.in +++ b/cmake/projects/Boost/hunter.cmake.in @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT boost_component - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/iostreams/hunter.cmake b/cmake/projects/Boost/iostreams/hunter.cmake index 8d415ed0b8..5fb3eb8cb1 100644 --- a/cmake/projects/Boost/iostreams/hunter.cmake +++ b/cmake/projects/Boost/iostreams/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT iostreams - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/locale/hunter.cmake b/cmake/projects/Boost/locale/hunter.cmake index 829671090a..7a98c3e927 100644 --- a/cmake/projects/Boost/locale/hunter.cmake +++ b/cmake/projects/Boost/locale/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT locale - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/log/hunter.cmake b/cmake/projects/Boost/log/hunter.cmake index b1a2706fd7..d5916f092b 100644 --- a/cmake/projects/Boost/log/hunter.cmake +++ b/cmake/projects/Boost/log/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT log - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/math/hunter.cmake b/cmake/projects/Boost/math/hunter.cmake index b93ecb4e67..bb703e1993 100644 --- a/cmake/projects/Boost/math/hunter.cmake +++ b/cmake/projects/Boost/math/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT math - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/mpi/hunter.cmake b/cmake/projects/Boost/mpi/hunter.cmake index bd2967a152..023a7999b5 100644 --- a/cmake/projects/Boost/mpi/hunter.cmake +++ b/cmake/projects/Boost/mpi/hunter.cmake @@ -26,5 +26,5 @@ hunter_download( Boost PACKAGE_COMPONENT mpi - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/program_options/hunter.cmake b/cmake/projects/Boost/program_options/hunter.cmake index 948249d811..625c00affc 100644 --- a/cmake/projects/Boost/program_options/hunter.cmake +++ b/cmake/projects/Boost/program_options/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT program_options - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/python/hunter.cmake b/cmake/projects/Boost/python/hunter.cmake index d4735fafc2..76448ce7c3 100644 --- a/cmake/projects/Boost/python/hunter.cmake +++ b/cmake/projects/Boost/python/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT python - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/random/hunter.cmake b/cmake/projects/Boost/random/hunter.cmake index a3d474d83c..a8773af2c2 100644 --- a/cmake/projects/Boost/random/hunter.cmake +++ b/cmake/projects/Boost/random/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT random - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/regex/hunter.cmake b/cmake/projects/Boost/regex/hunter.cmake index 402bb6c3df..22cff29e3f 100644 --- a/cmake/projects/Boost/regex/hunter.cmake +++ b/cmake/projects/Boost/regex/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT regex - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/schemes/url_sha1_boost.cmake.in b/cmake/projects/Boost/schemes/url_sha1_boost.cmake.in index 9a589c2694..9d9cab6e4d 100644 --- a/cmake/projects/Boost/schemes/url_sha1_boost.cmake.in +++ b/cmake/projects/Boost/schemes/url_sha1_boost.cmake.in @@ -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() @@ -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} @@ -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() diff --git a/cmake/projects/Boost/schemes/url_sha1_boost_ios_library.cmake.in b/cmake/projects/Boost/schemes/url_sha1_boost_ios_library.cmake.in index 9ae5ad025d..a7fce1a634 100644 --- a/cmake/projects/Boost/schemes/url_sha1_boost_ios_library.cmake.in +++ b/cmake/projects/Boost/schemes/url_sha1_boost_ios_library.cmake.in @@ -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() @@ -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 @@ -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 @@ -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() diff --git a/cmake/projects/Boost/schemes/url_sha1_boost_library.cmake.in b/cmake/projects/Boost/schemes/url_sha1_boost_library.cmake.in index d9e04dca3e..a950038bd3 100644 --- a/cmake/projects/Boost/schemes/url_sha1_boost_library.cmake.in +++ b/cmake/projects/Boost/schemes/url_sha1_boost_library.cmake.in @@ -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 @@ -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() @@ -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} @@ -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() diff --git a/cmake/projects/Boost/serialization/hunter.cmake b/cmake/projects/Boost/serialization/hunter.cmake index 93d9eb58bc..b87adad2fc 100644 --- a/cmake/projects/Boost/serialization/hunter.cmake +++ b/cmake/projects/Boost/serialization/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT serialization - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/signals/hunter.cmake b/cmake/projects/Boost/signals/hunter.cmake index a3d9654faf..21a98f910c 100644 --- a/cmake/projects/Boost/signals/hunter.cmake +++ b/cmake/projects/Boost/signals/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT signals - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/stacktrace/hunter.cmake b/cmake/projects/Boost/stacktrace/hunter.cmake index b75d11533d..29252182a4 100644 --- a/cmake/projects/Boost/stacktrace/hunter.cmake +++ b/cmake/projects/Boost/stacktrace/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT stacktrace - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/system/hunter.cmake b/cmake/projects/Boost/system/hunter.cmake index ebe480c074..f4a5ddace0 100644 --- a/cmake/projects/Boost/system/hunter.cmake +++ b/cmake/projects/Boost/system/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT system - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/test/hunter.cmake b/cmake/projects/Boost/test/hunter.cmake index d563576c97..6614f40d61 100644 --- a/cmake/projects/Boost/test/hunter.cmake +++ b/cmake/projects/Boost/test/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT test - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/thread/hunter.cmake b/cmake/projects/Boost/thread/hunter.cmake index 7304cdf496..a57239b86f 100644 --- a/cmake/projects/Boost/thread/hunter.cmake +++ b/cmake/projects/Boost/thread/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT thread - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/timer/hunter.cmake b/cmake/projects/Boost/timer/hunter.cmake index df900b45fb..4807b1304f 100644 --- a/cmake/projects/Boost/timer/hunter.cmake +++ b/cmake/projects/Boost/timer/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT timer - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/cmake/projects/Boost/wave/hunter.cmake b/cmake/projects/Boost/wave/hunter.cmake index ebe4a0a7bc..50fd90894e 100644 --- a/cmake/projects/Boost/wave/hunter.cmake +++ b/cmake/projects/Boost/wave/hunter.cmake @@ -18,5 +18,5 @@ hunter_download( Boost PACKAGE_COMPONENT wave - PACKAGE_INTERNAL_DEPS_ID "47" + PACKAGE_INTERNAL_DEPS_ID "48" ) diff --git a/docs/packages/pkg/Boost.rst b/docs/packages/pkg/Boost.rst index f4477bd5bb..b1c637acd6 100644 --- a/docs/packages/pkg/Boost.rst +++ b/docs/packages/pkg/Boost.rst @@ -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 `__ + - `Boost-log-usingBoostConfig `__ + + Python ------ diff --git a/examples/Boost-chrono-1-64/CMakeLists.txt b/examples/Boost-chrono-1-64/CMakeLists.txt new file mode 100644 index 0000000000..9b5a8dadd5 --- /dev/null +++ b/examples/Boost-chrono-1-64/CMakeLists.txt @@ -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 +) diff --git a/examples/Boost-chrono-1-64/foo.cpp b/examples/Boost-chrono-1-64/foo.cpp new file mode 100644 index 0000000000..33c0516210 --- /dev/null +++ b/examples/Boost-chrono-1-64/foo.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + boost::chrono::system_clock::now(); + return 0; +} diff --git a/examples/Boost-chrono-useBoostConfig/CMakeLists.txt b/examples/Boost-chrono-useBoostConfig/CMakeLists.txt new file mode 100644 index 0000000000..6ba8ec001b --- /dev/null +++ b/examples/Boost-chrono-useBoostConfig/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (c) 2013, Ruslan Baratov +# All rights reserved. + +cmake_minimum_required(VERSION 3.0) + +set(Boost_DEBUG ON CACHE BOOLEAN "") +set(TESTING_CONFIG_OPT FILEPATH ${CMAKE_CURRENT_LIST_DIR}/config.cmake) + +# Emulate HunterGate: +# * https://github.com/hunter-packages/gate +include("../common.cmake") + +project(download-boost) + +hunter_add_package(Boost COMPONENTS chrono) +find_package(Boost CONFIG REQUIRED chrono) + +add_executable(foo foo.cpp) +target_link_libraries( + foo + PUBLIC + Boost::chrono +) diff --git a/examples/Boost-chrono-useBoostConfig/config.cmake b/examples/Boost-chrono-useBoostConfig/config.cmake new file mode 100644 index 0000000000..9daa4a1d95 --- /dev/null +++ b/examples/Boost-chrono-useBoostConfig/config.cmake @@ -0,0 +1,4 @@ +hunter_config(Boost + VERSION ${HUNTER_Boost_VERSION} + CMAKE_ARGS USE_CONFIG_FROM_BOOST=ON +) diff --git a/examples/Boost-chrono-useBoostConfig/foo.cpp b/examples/Boost-chrono-useBoostConfig/foo.cpp new file mode 100644 index 0000000000..33c0516210 --- /dev/null +++ b/examples/Boost-chrono-useBoostConfig/foo.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + boost::chrono::system_clock::now(); + return 0; +} diff --git a/examples/Boost-chrono/CMakeLists.txt b/examples/Boost-chrono/CMakeLists.txt index 9b5a8dadd5..8152a6e319 100644 --- a/examples/Boost-chrono/CMakeLists.txt +++ b/examples/Boost-chrono/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-contract/CMakeLists.txt b/examples/Boost-contract/CMakeLists.txt index 4ddcf58906..c70258414d 100644 --- a/examples/Boost-contract/CMakeLists.txt +++ b/examples/Boost-contract/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-fiber/CMakeLists.txt b/examples/Boost-fiber/CMakeLists.txt index 2f6fe07035..401f7332d8 100644 --- a/examples/Boost-fiber/CMakeLists.txt +++ b/examples/Boost-fiber/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-filesystem-1-64/CMakeLists.txt b/examples/Boost-filesystem-1-64/CMakeLists.txt new file mode 100644 index 0000000000..6339e56979 --- /dev/null +++ b/examples/Boost-filesystem-1-64/CMakeLists.txt @@ -0,0 +1,60 @@ +# Copyright (c) 2013-2015, 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) + +# download boost +hunter_add_package(Boost COMPONENTS system filesystem) + +# now boost can be used +find_package(Boost CONFIG REQUIRED system filesystem) + +if(ANDROID) + string(COMPARE EQUAL "${CMAKE_ANDROID_NDK}" "" is_empty) + if(is_empty) + message(FATAL_ERROR "CMAKE_ANDROID_NDK is empty") + endif() + add_library( + foo + SHARED + foo_android.cpp + "${CMAKE_ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c" + ) +else() + add_executable(foo foo.cpp) +endif() + +target_link_libraries(foo Boost::system Boost::filesystem) + +if(ANDROID) + target_link_libraries(foo log android) + target_include_directories( + foo PUBLIC "${CMAKE_ANDROID_NDK}/sources/android/native_app_glue" + ) + + if(NOT "$ENV{TRAVIS}") + # Travis CI failed builds: + # * https://travis-ci.org/ingenue/hunter/jobs/106905844 + # * https://travis-ci.org/ingenue/hunter/jobs/106905851 + hunter_add_package(Android-Apk) + list(APPEND CMAKE_MODULE_PATH "${ANDROID-APK_ROOT}") + include(AndroidApk) + + hunter_add_package(Android-SDK) + message("Path to `android`: ${ANDROID-SDK_ROOT}/android-sdk/tools/android") + message("Path to `emulator`: ${ANDROID-SDK_ROOT}/android-sdk/tools/emulator") + message("Path to `adb`: ${ANDROID-SDK_ROOT}/android-sdk/platform-tools/adb") + + android_create_apk( + BASE_TARGET foo + LAUNCH_TARGET foo-launch + DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/apk" + ) + endif() +endif() diff --git a/examples/Boost-filesystem-1-64/foo.cpp b/examples/Boost-filesystem-1-64/foo.cpp new file mode 100644 index 0000000000..13f5f90676 --- /dev/null +++ b/examples/Boost-filesystem-1-64/foo.cpp @@ -0,0 +1,7 @@ +#include +#include // std::cout + +int main() { + namespace fs = boost::filesystem; + std::cout << "Current path: " << fs::current_path() << std::endl; +} diff --git a/examples/Boost-filesystem-1-64/foo_android.cpp b/examples/Boost-filesystem-1-64/foo_android.cpp new file mode 100644 index 0000000000..b86604683d --- /dev/null +++ b/examples/Boost-filesystem-1-64/foo_android.cpp @@ -0,0 +1,21 @@ +// Copyright (c) 2015, Ruslan Baratov +// All rights reserved. + +#include + +#include +#include + +void android_main(struct android_app* state) { + app_dummy(); // Make sure glue isn't stripped + + namespace fs = boost::filesystem; + + __android_log_print( + ANDROID_LOG_INFO, + "BoostFilesystemExample", + fs::current_path().c_str() + ); + + ANativeActivity_finish(state->activity); +} diff --git a/examples/Boost-filesystem-shared/config.cmake b/examples/Boost-filesystem-shared/config.cmake index 0bf7053a2f..f9ab533253 100644 --- a/examples/Boost-filesystem-shared/config.cmake +++ b/examples/Boost-filesystem-shared/config.cmake @@ -1,4 +1,4 @@ hunter_config(Boost VERSION ${HUNTER_Boost_VERSION} - CMAKE_ARGS BUILD_SHARED_LIBS=ON + CMAKE_ARGS BUILD_SHARED_LIBS=ON USE_CONFIG_FROM_BOOST=ON ) diff --git a/examples/Boost-filesystem-useBoostConfig/CMakeLists.txt b/examples/Boost-filesystem-useBoostConfig/CMakeLists.txt new file mode 100644 index 0000000000..9bb5b74ced --- /dev/null +++ b/examples/Boost-filesystem-useBoostConfig/CMakeLists.txt @@ -0,0 +1,66 @@ +# Copyright (c) 2013-2015, Ruslan Baratov +# All rights reserved. + +cmake_minimum_required(VERSION 3.0) + +set(Boost_DEBUG ON CACHE BOOLEAN "") +set(TESTING_CONFIG_OPT FILEPATH ${CMAKE_CURRENT_LIST_DIR}/config.cmake) + +# Emulate HunterGate: +# * https://github.com/hunter-packages/gate +include("../common.cmake") + +project(download-boost) + +# download boost +hunter_add_package(Boost COMPONENTS filesystem) + +# now boost can be used +find_package(Boost CONFIG REQUIRED filesystem) + +if(ANDROID) + string(COMPARE EQUAL "${CMAKE_ANDROID_NDK}" "" is_empty) + if(is_empty) + message(FATAL_ERROR "CMAKE_ANDROID_NDK is empty") + endif() + add_library( + foo + SHARED + foo_android.cpp + "${CMAKE_ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c" + ) +else() + add_executable(foo foo.cpp) +endif() + +target_link_libraries( + foo + Boost::filesystem +) + +if(ANDROID) + target_link_libraries(foo log android) + target_include_directories( + foo PUBLIC "${CMAKE_ANDROID_NDK}/sources/android/native_app_glue" + ) + + if(NOT "$ENV{TRAVIS}") + # Travis CI failed builds: + # * https://travis-ci.org/ingenue/hunter/jobs/106905844 + # * https://travis-ci.org/ingenue/hunter/jobs/106905851 + hunter_add_package(Android-Apk) + list(APPEND CMAKE_MODULE_PATH "${ANDROID-APK_ROOT}") + include(AndroidApk) + + hunter_add_package(Android-SDK) + message("Path to `android`: ${ANDROID-SDK_ROOT}/android-sdk/tools/android") + message("Path to `emulator`: ${ANDROID-SDK_ROOT}/android-sdk/tools/emulator") + message("Path to `adb`: ${ANDROID-SDK_ROOT}/android-sdk/platform-tools/adb") + + android_create_apk( + BASE_TARGET foo + LAUNCH_TARGET foo-launch + DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/apk" + ) + endif() +endif() diff --git a/examples/Boost-filesystem-useBoostConfig/config.cmake b/examples/Boost-filesystem-useBoostConfig/config.cmake new file mode 100644 index 0000000000..9daa4a1d95 --- /dev/null +++ b/examples/Boost-filesystem-useBoostConfig/config.cmake @@ -0,0 +1,4 @@ +hunter_config(Boost + VERSION ${HUNTER_Boost_VERSION} + CMAKE_ARGS USE_CONFIG_FROM_BOOST=ON +) diff --git a/examples/Boost-filesystem-useBoostConfig/foo.cpp b/examples/Boost-filesystem-useBoostConfig/foo.cpp new file mode 100644 index 0000000000..13f5f90676 --- /dev/null +++ b/examples/Boost-filesystem-useBoostConfig/foo.cpp @@ -0,0 +1,7 @@ +#include +#include // std::cout + +int main() { + namespace fs = boost::filesystem; + std::cout << "Current path: " << fs::current_path() << std::endl; +} diff --git a/examples/Boost-filesystem-useBoostConfig/foo_android.cpp b/examples/Boost-filesystem-useBoostConfig/foo_android.cpp new file mode 100644 index 0000000000..b86604683d --- /dev/null +++ b/examples/Boost-filesystem-useBoostConfig/foo_android.cpp @@ -0,0 +1,21 @@ +// Copyright (c) 2015, Ruslan Baratov +// All rights reserved. + +#include + +#include +#include + +void android_main(struct android_app* state) { + app_dummy(); // Make sure glue isn't stripped + + namespace fs = boost::filesystem; + + __android_log_print( + ANDROID_LOG_INFO, + "BoostFilesystemExample", + fs::current_path().c_str() + ); + + ANativeActivity_finish(state->activity); +} diff --git a/examples/Boost-filesystem/CMakeLists.txt b/examples/Boost-filesystem/CMakeLists.txt index 95c1113116..1ae09d42a0 100644 --- a/examples/Boost-filesystem/CMakeLists.txt +++ b/examples/Boost-filesystem/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-iostreams-useBoostConfig/CMakeLists.txt b/examples/Boost-iostreams-useBoostConfig/CMakeLists.txt new file mode 100644 index 0000000000..f817e0c1ee --- /dev/null +++ b/examples/Boost-iostreams-useBoostConfig/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (c) 2015, Aaditya Kalsi +# All rights reserved. + +cmake_minimum_required(VERSION 3.0) + +set(Boost_DEBUG ON CACHE BOOLEAN "") +set(TESTING_CONFIG_OPT FILEPATH ${CMAKE_CURRENT_LIST_DIR}/config.cmake) + +# Emulate HunterGate: +# * https://github.com/hunter-packages/gate +include("../common.cmake") + +project(boost_iostreams) + +hunter_add_package(Boost COMPONENTS iostreams serialization) +# If you use boost/iostreams/filter/gzip.hpp then you should add ZLIB +find_package(ZLIB CONFIG REQUIRED) +# If you use boost/iostreams/filter/bzip2.hpp then you should add BZip2 +find_package(BZip2 CONFIG REQUIRED) +find_package(Boost CONFIG REQUIRED iostreams serialization) + +add_executable(foo foo.cpp) +target_link_libraries(foo PUBLIC Boost::iostreams Boost::serialization ZLIB::zlib BZip2::bz2) diff --git a/examples/Boost-iostreams-useBoostConfig/config.cmake b/examples/Boost-iostreams-useBoostConfig/config.cmake new file mode 100644 index 0000000000..9daa4a1d95 --- /dev/null +++ b/examples/Boost-iostreams-useBoostConfig/config.cmake @@ -0,0 +1,4 @@ +hunter_config(Boost + VERSION ${HUNTER_Boost_VERSION} + CMAKE_ARGS USE_CONFIG_FROM_BOOST=ON +) diff --git a/examples/Boost-iostreams-useBoostConfig/foo.cpp b/examples/Boost-iostreams-useBoostConfig/foo.cpp new file mode 100644 index 0000000000..f49eb2a8fb --- /dev/null +++ b/examples/Boost-iostreams-useBoostConfig/foo.cpp @@ -0,0 +1,66 @@ +// Copyright (c) 2015, David Hirvonen +// All rights reserved. + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +struct Record +{ + Record() {} + Record(int age, const std::string &name) : age(age), name(name) {} + + int age; + std::string name; + + // Boost serialization: + //friend class boost::serialization::access; + template void serialize(Archive & ar, const unsigned int version) + { + ar & age; + ar & name; + } +}; + +int main(int argc, char **argv) +{ + std::string filename = "/tmp/record.dat"; + + typedef boost::iostreams::zlib_compressor Compressor; + typedef boost::iostreams::zlib_decompressor Decompressor; + + { // Dump the record: + Record record(1, "kermit"); + std::ofstream ofs(filename, std::ios_base::out | std::ios_base::binary); + if(ofs) + { + boost::iostreams::filtering_stream buffer; + buffer.push(Compressor()); + buffer.push(ofs); + boost::archive::binary_oarchive oa(buffer); + oa << record; + } + } + + { // Load the record + Record record; + std::ifstream ifs(filename, std::ios_base::in | std::ios_base::binary); + if(ifs) + { + boost::iostreams::filtering_streambuf buffer; + buffer.push(Decompressor()); + buffer.push(ifs); + boost::archive::binary_iarchive ia(buffer); // (ifs); + ia >> record; + } + } +} + diff --git a/examples/Boost-iostreams/CMakeLists.txt b/examples/Boost-iostreams/CMakeLists.txt index f6e7051bb4..8edd8b2399 100644 --- a/examples/Boost-iostreams/CMakeLists.txt +++ b/examples/Boost-iostreams/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-log-shared/CMakeLists.txt b/examples/Boost-log-shared/CMakeLists.txt index a1227604b5..82b3df15b1 100644 --- a/examples/Boost-log-shared/CMakeLists.txt +++ b/examples/Boost-log-shared/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate set(TESTING_CONFIG_OPT FILEPATH ${CMAKE_CURRENT_LIST_DIR}/config.cmake) #set BUILD_SHARED_LIBS=ON diff --git a/examples/Boost-log-useBoostConfig/CMakeLists.txt b/examples/Boost-log-useBoostConfig/CMakeLists.txt new file mode 100644 index 0000000000..82bfb43ee5 --- /dev/null +++ b/examples/Boost-log-useBoostConfig/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright (c) 2013-2017, Ruslan Baratov +# All rights reserved. + +cmake_minimum_required(VERSION 3.0) + +set(Boost_DEBUG ON CACHE BOOLEAN "") +set(TESTING_CONFIG_OPT FILEPATH ${CMAKE_CURRENT_LIST_DIR}/config.cmake) + +# Emulate HunterGate: +# * https://github.com/hunter-packages/gate +include("../common.cmake") + +project(download-boost) + +hunter_add_package(Boost COMPONENTS log) +find_package(Boost CONFIG REQUIRED log) + +add_executable(foo foo.cpp) +target_link_libraries(foo PUBLIC Boost::log) diff --git a/examples/Boost-log-useBoostConfig/config.cmake b/examples/Boost-log-useBoostConfig/config.cmake new file mode 100644 index 0000000000..9daa4a1d95 --- /dev/null +++ b/examples/Boost-log-useBoostConfig/config.cmake @@ -0,0 +1,4 @@ +hunter_config(Boost + VERSION ${HUNTER_Boost_VERSION} + CMAKE_ARGS USE_CONFIG_FROM_BOOST=ON +) diff --git a/examples/Boost-log-useBoostConfig/foo.cpp b/examples/Boost-log-useBoostConfig/foo.cpp new file mode 100644 index 0000000000..1f56b3f693 --- /dev/null +++ b/examples/Boost-log-useBoostConfig/foo.cpp @@ -0,0 +1,12 @@ +#include + +int main() { + BOOST_LOG_TRIVIAL(trace) << "A trace severity message"; + BOOST_LOG_TRIVIAL(debug) << "A debug severity message"; + BOOST_LOG_TRIVIAL(info) << "An informational severity message"; + BOOST_LOG_TRIVIAL(warning) << "A warning severity message"; + BOOST_LOG_TRIVIAL(error) << "An error severity message"; + BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message"; + + return 0; +} diff --git a/examples/Boost-log/CMakeLists.txt b/examples/Boost-log/CMakeLists.txt index 35550d4219..49874c456f 100644 --- a/examples/Boost-log/CMakeLists.txt +++ b/examples/Boost-log/CMakeLists.txt @@ -3,14 +3,25 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") project(download-boost) -hunter_add_package(Boost COMPONENTS log) -find_package(Boost CONFIG REQUIRED log) +hunter_add_package(Boost COMPONENTS log filesystem system chrono thread regex date_time atomic) +find_package(Boost CONFIG REQUIRED log filesystem system chrono thread regex date_time atomic) add_executable(foo foo.cpp) -target_link_libraries(foo PUBLIC Boost::log) +target_link_libraries(foo PUBLIC Boost::log + Boost::filesystem + Boost::chrono + Boost::thread + Boost::regex + Boost::date_time + Boost::atomic + Boost::system + Boost::boost +) diff --git a/examples/Boost-log/foo.cpp b/examples/Boost-log/foo.cpp index 75cfa01846..1f56b3f693 100644 --- a/examples/Boost-log/foo.cpp +++ b/examples/Boost-log/foo.cpp @@ -1,4 +1,12 @@ -#include +#include int main() { + BOOST_LOG_TRIVIAL(trace) << "A trace severity message"; + BOOST_LOG_TRIVIAL(debug) << "A debug severity message"; + BOOST_LOG_TRIVIAL(info) << "An informational severity message"; + BOOST_LOG_TRIVIAL(warning) << "A warning severity message"; + BOOST_LOG_TRIVIAL(error) << "An error severity message"; + BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message"; + + return 0; } diff --git a/examples/Boost-math/CMakeLists.txt b/examples/Boost-math/CMakeLists.txt index 843235678c..fd4340f8e6 100644 --- a/examples/Boost-math/CMakeLists.txt +++ b/examples/Boost-math/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-program-options/CMakeLists.txt b/examples/Boost-program-options/CMakeLists.txt index f9a68b8db7..c8375c594e 100644 --- a/examples/Boost-program-options/CMakeLists.txt +++ b/examples/Boost-program-options/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-python-numpy/CMakeLists.txt b/examples/Boost-python-numpy/CMakeLists.txt index e82eacd728..df502caa30 100644 --- a/examples/Boost-python-numpy/CMakeLists.txt +++ b/examples/Boost-python-numpy/CMakeLists.txt @@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 3.12) option(HUNTER_BUILD_SHARED_LIBS "..." ON) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Configure: set(PYTHON_VERSION 3.5) set(TESTING_CONFIG_OPT FILEPATH "${CMAKE_CURRENT_LIST_DIR}/config.cmake") diff --git a/examples/Boost-python/CMakeLists.txt b/examples/Boost-python/CMakeLists.txt index 85b3d6e26c..dd439a790a 100644 --- a/examples/Boost-python/CMakeLists.txt +++ b/examples/Boost-python/CMakeLists.txt @@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 3.2) option(HUNTER_BUILD_SHARED_LIBS "..." ON) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Configure: set(PYTHON_VERSION 3.5) set(TESTING_CONFIG_OPT FILEPATH "${CMAKE_CURRENT_LIST_DIR}/config.cmake") diff --git a/examples/Boost-random/CMakeLists.txt b/examples/Boost-random/CMakeLists.txt index 7721d532e9..70b56b530a 100644 --- a/examples/Boost-random/CMakeLists.txt +++ b/examples/Boost-random/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-serialization/CMakeLists.txt b/examples/Boost-serialization/CMakeLists.txt index 6fe52a0bfa..e73204d557 100644 --- a/examples/Boost-serialization/CMakeLists.txt +++ b/examples/Boost-serialization/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-stacktrace/CMakeLists.txt b/examples/Boost-stacktrace/CMakeLists.txt index 27720d5424..0bcace8efe 100644 --- a/examples/Boost-stacktrace/CMakeLists.txt +++ b/examples/Boost-stacktrace/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.2) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-system-1-66/CMakeLists.txt b/examples/Boost-system-1-66/CMakeLists.txt index 5d3cfe9f2c..dfb9c11ef6 100644 --- a/examples/Boost-system-1-66/CMakeLists.txt +++ b/examples/Boost-system-1-66/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + set(TESTING_CONFIG_OPT FILEPATH ${CMAKE_CURRENT_LIST_DIR}/config.cmake) # Emulate HunterGate: diff --git a/examples/Boost-system/CMakeLists.txt b/examples/Boost-system/CMakeLists.txt index a383233257..2e125023bf 100644 --- a/examples/Boost-system/CMakeLists.txt +++ b/examples/Boost-system/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-test/CMakeLists.txt b/examples/Boost-test/CMakeLists.txt index eea8628343..3fa14ce10d 100644 --- a/examples/Boost-test/CMakeLists.txt +++ b/examples/Boost-test/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-thread-1-64/CMakeLists.txt b/examples/Boost-thread-1-64/CMakeLists.txt new file mode 100644 index 0000000000..cdb4d19a80 --- /dev/null +++ b/examples/Boost-thread-1-64/CMakeLists.txt @@ -0,0 +1,16 @@ +# 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 thread) +find_package(Boost CONFIG REQUIRED system thread) + +add_executable(foo foo.cpp) +target_link_libraries(foo PUBLIC Boost::system Boost::thread) diff --git a/examples/Boost-thread-1-64/foo.cpp b/examples/Boost-thread-1-64/foo.cpp new file mode 100644 index 0000000000..811dcb8b0b --- /dev/null +++ b/examples/Boost-thread-1-64/foo.cpp @@ -0,0 +1,36 @@ +#ifndef BOOST_THREAD_PROVIDES_FUTURE +#define BOOST_THREAD_PROVIDES_FUTURE +#endif +// #ifndef BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION +// #define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION +// #endif +// #ifndef BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY +// #define BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY +// #endif + + +#include +#include + + +int calculate_the_answer_to_life_the_universe_and_everything() +{ + return 42; +} + + + +int main() { + boost::packaged_task pt(calculate_the_answer_to_life_the_universe_and_everything); + boost:: future fi=pt.get_future(); + + boost::thread task(boost::move(pt)); // launch task on a thread + + fi.wait(); // wait for it to finish + + assert(fi.is_ready()); + assert(fi.has_value()); + assert(!fi.has_exception()); + assert(fi.get_state()==boost::future_state::ready); + assert(fi.get()==42); +} diff --git a/examples/Boost-thread/CMakeLists.txt b/examples/Boost-thread/CMakeLists.txt index cdb4d19a80..0595070c47 100644 --- a/examples/Boost-thread/CMakeLists.txt +++ b/examples/Boost-thread/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost-useBoostConfig/CMakeLists.txt b/examples/Boost-useBoostConfig/CMakeLists.txt new file mode 100644 index 0000000000..b261ad51d3 --- /dev/null +++ b/examples/Boost-useBoostConfig/CMakeLists.txt @@ -0,0 +1,48 @@ +# Copyright (c) 2013, Ruslan Baratov +# All rights reserved. + +cmake_minimum_required(VERSION 3.0) + +set(Boost_DEBUG ON CACHE BOOLEAN "") +set(TESTING_CONFIG_OPT FILEPATH ${CMAKE_CURRENT_LIST_DIR}/config.cmake) + +# Emulate HunterGate: +# * https://github.com/hunter-packages/gate +include("../common.cmake") + +project(download-boost) + +hunter_add_package(Boost) +find_package(Boost CONFIG REQUIRED) + +add_executable(foo foo.cpp) +target_link_libraries(foo PUBLIC Boost::headers) # Since boost 1.70 you should use Boost::headers as target + +set(project_license "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt") +file( + WRITE + "${project_license}" + "Some info about this project license.\n\n" +) + +string(COMPARE EQUAL "${Boost_LICENSES}" "" is_empty) +if(is_empty) + message(FATAL_ERROR "No licenses") +endif() + +file(APPEND "${project_license}" "== 3rd party licenses ==\n\n") + +foreach(x ${Boost_LICENSES}) + file(READ "${x}" content) + get_filename_component(license_name "${x}" NAME) + file(APPEND "${project_license}" "== Boost (${license_name}) ==\n\n") + file(APPEND "${project_license}" "${content}") +endforeach() + +message("Project license: ${project_license}") + +file(GLOB_RECURSE boost_configs "${BOOST_ROOT}/*/BoostConfig.cmake") +list(LENGTH boost_configs len) +if(NOT len EQUAL "1") + message(FATAL_ERROR "More than one *Config: ${boost_configs}") +endif() diff --git a/examples/Boost-useBoostConfig/config.cmake b/examples/Boost-useBoostConfig/config.cmake new file mode 100644 index 0000000000..9daa4a1d95 --- /dev/null +++ b/examples/Boost-useBoostConfig/config.cmake @@ -0,0 +1,4 @@ +hunter_config(Boost + VERSION ${HUNTER_Boost_VERSION} + CMAKE_ARGS USE_CONFIG_FROM_BOOST=ON +) diff --git a/examples/Boost-useBoostConfig/foo.cpp b/examples/Boost-useBoostConfig/foo.cpp new file mode 100644 index 0000000000..28f9a77ef2 --- /dev/null +++ b/examples/Boost-useBoostConfig/foo.cpp @@ -0,0 +1,4 @@ +#include + +int main() { +} diff --git a/examples/Boost-uuid/CMakeLists.txt b/examples/Boost-uuid/CMakeLists.txt index 64c41f30c3..fb131a17dc 100644 --- a/examples/Boost-uuid/CMakeLists.txt +++ b/examples/Boost-uuid/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") diff --git a/examples/Boost/CMakeLists.txt b/examples/Boost/CMakeLists.txt index d1f6c5e0b7..4b30e30889 100644 --- a/examples/Boost/CMakeLists.txt +++ b/examples/Boost/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) +set(Boost_DEBUG ON CACHE BOOLEAN "") + # Emulate HunterGate: # * https://github.com/hunter-packages/gate include("../common.cmake") @@ -13,7 +15,7 @@ hunter_add_package(Boost) find_package(Boost CONFIG REQUIRED) add_executable(foo foo.cpp) -target_link_libraries(foo PUBLIC Boost::boost) +target_link_libraries(foo PUBLIC Boost::boost) # Since boost 1.70 you should use Boost::headers as target set(project_license "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt") file(