Closed opelx closed 3 years ago
....
CPMAddPackage(
NAME SPIRIT
GITHUB_REPOSITORY boostorg/spirit
GIT_TAG boost-1.76.0
OPTIONS
"BUILD_TESTING OFF"
)
...
Thank you for your fast answer. This gave me the hint into the right direction. The CMake relevant part is:
option(DEVELOPER_EXTERNAL_BOOST_SPIRIT "boost.spirit" ON)
mark_as_advanced(DEVELOPER_EXTERNAL_BOOST_SPIRIT)
if(DEVELOPER_EXTERNAL_BOOST_SPIRIT)
CPMAddPackage(
NAME external-boost-spirit
GITHUB_REPOSITORY boostorg/spirit
GIT_TAG boost-1.76.0
OPTIONS "BUILD_TESTING OFF"
)
message(STATUS "boost_spirit_ADDED = ${boost_spirit_ADDED}")
if(boost_spirit_SOURCE_DIR)
add_custom_target(external-boost-spirit)
set(EXTERNAL_BOOST_SPIRIT_INCLUDE_DIR ${boost_spirit_SOURCE_DIR}/include)
else()
message(FATAL_ERROR "Failure in external Boost's optional module 'Spirit'")
endif()
message(STATUS "EXTERNAL_BOOST_SPIRIT_INCLUDE_DIR = ${EXTERNAL_BOOST_SPIRIT_INCLUDE_DIR}")
endif()
option(DEVELOPER_EXTERNAL_BOOST_TEST "boost.test" ON)
mark_as_advanced(DEVELOPER_EXTERNAL_BOOST_TEST)
if(DEVELOPER_EXTERNAL_BOOST_TEST)
CPMAddPackage(
NAME external-boost-test
GITHUB_REPOSITORY boostorg/test
GIT_TAG boost-1.76.0
OPTIONS "BUILD_TESTING OFF"
)
message(STATUS "boost_test_ADDED = ${boost_test_ADDED}")
if(boost_test_SOURCE_DIR)
add_custom_target(external-boost-test)
set(EXTERNAL_BOOST_TEST_INCLUDE_DIR ${boost_test_SOURCE_DIR}/include)
else()
message(FATAL_ERROR "Failure in external Boost's optional module 'Test'")
endif()
message(STATUS "EXTERNAL_BOOST_TEST_INCLUDE_DIR = ${EXTERNAL_BOOST_TEST_INCLUDE_DIR}")
endif()
and with
> cmake .
-- CPM: adding package external-boost-spirit@ (boost-1.76.0)
-- boost_spirit_ADDED =
-- EXTERNAL_BOOST_SPIRIT_INCLUDE_DIR = D:/<project>/build/_deps/external-boost-spirit-src/include
-- CPM: adding package external-boost-test@ (boost-1.76.0)
-- boost_test_ADDED =
CMake Error at cmake/external_optional.cmake:56 (message):
Failure in external Boost's optional module 'Test'
Call Stack (most recent call first):
CMakeLists.txt:40 (include)
the CMakeCache.txt still contains only:
//Value Computed by CMake
boost_spirit_BINARY_DIR:STATIC=D:/<project>/build/_deps/external-boost-spirit-build
//Value Computed by CMake
boost_spirit_SOURCE_DIR:STATIC=D:/<project>/build/_deps/external-boost-spirit-src
so there is no boost_spirit_ADDED - or even the vars for Boost test 'boosttest'
I restarted several time with removed build directory and new cmake call without success. CMake is:
> cmake --version
cmake version 3.19.6
The project structure is:
{ROOT]/CMakeLists.txt:
...
list(APPEND
CMAKE_MODULE_PATH
${PROJECT_SOURCE_DIR}/cmake
${PROJECT_SOURCE_DIR}/cmake/module
)
...
# [cpm-cmake/CPM.cmake](https://github.com/cpm-cmake/CPM.cmake)
include(cmake/module/CPM.cmake) # FixMe full path
...
include(external_optional)
...
{ROOT]/cmake/module/CPM.cmake:
see top of posting
So, what could go be wrong here. For some reasons I have to explicit use the path to CPM.cmake, even if it should be in the module PATH.
This repository Boost Test not have support to CMake. Therefore, you cannot send options to it as you can with Boost Spirit.
Replace the called to Boost Test with this:
CPMAddPackage(
NAME external-boost-test
GITHUB_REPOSITORY boostorg/test
GIT_TAG boost-1.76.0
)
Thanks for your help!
Hi,
I try to import boost spirit modular package. Boost Spirit is a header only library and I don't want to build the tests.
Three attempts using CPM.cmake fail:
Using short form:
completes, but doesn't set_ADDED
CMakeCache contains only:
Next approach:
run into errors:
using with 'name':
again with errors:
The suggested "gh:Orphis/boost-cmake" repos doesn't seem to get update for 3 years and sticks with boost 1.67.0.
So, how to cope with those modules? CPM is from today's master.