New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boost 1.70's cmake config makes cmake stop looking where I tell it to #12
Comments
|
More info in case it helps… I'm testing with a cmake_minimum_required( VERSION 3.7 )
project( cmake-boost-problems )
find_package( Boost 1.68.0 REQUIRED program_options )
add_executable( example_exe example_exe.cpp )
target_link_libraries( example_exe Boost::program_options )…and a C++ file like this: #include <iostream>
#include <boost/program_options.hpp>
using ::boost::program_options::notify;
using ::boost::program_options::options_description;
using ::boost::program_options::parse_command_line;
using ::boost::program_options::store;
using ::boost::program_options::value;
using ::boost::program_options::variables_map;
using ::std::cout;
int main(int ac, char **av) {
::std::cout << "Hello world\n";
// Declare the supported options.
options_description desc("Allowed options");
desc.add_options()("help", "produce help message")(
"compression", value<int>(), "set compression level");
variables_map vm;
store(parse_command_line(ac, av, desc), vm);
notify(vm);
if (vm.count("help")) {
cout << desc << "\n";
return 1;
}
if (vm.count("compression")) {
cout << "Compression level was set to " << vm["compression"].as<int>()
<< ".\n";
} else {
cout << "Compression level was not set.\n";
}
}I'm using program_options so that I get obvious link errors on attempts to link against the wrong Boost (GCC+libstc++ / Clang+libc++). I'm using invocations like: /some/specific/cmake -Bcmbi-clang -DBOOST_ROOT=/opt/obscure/boost_1_70_0_clang_c++14_build -H. -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_CXX_FLAGS=-stdlib=libc++
/some/specific/cmake -Bcmbi-gcc -DBOOST_ROOT=/opt/obscure/boost_1_70_0_gcc_c++14_build -H. -DCMAKE_BUILD_TYPE=RELEASEI'm using |
|
If you want to disable the use of BoostConfig (installed by 1.70), set For this specific use case, you may consider building and installing Boost with |
|
Thanks very much for your very quick and very helpful response. I think your explanation is much clearer than the ones in the documentation to which you linked - even after you've highlighted the relevant sections, I can barely make out the solution to my problem from it. I feel like many people are likely to hit this sort of issue and will, like me, waste a lot of time wondering what they've done wrong. Is there some way we could try to mitigate this? Could the config mode detect when From my experiments, I think I'm finding that:
Is that correct? Is it possible to make both work via both? Thanks very much for all your work on this really important area. It's much appreciated. |
|
For reference (potentially for other people that may stumble across this issue), I'm finding these toolchain files (
set( Boost_NO_BOOST_CMAKE ON )
set( BOOST_ROOT /opt/boost_1_68_0_clang_c++14_build )
set( CMAKE_BUILD_TYPE RELEASE )
set( CMAKE_C_COMPILER /usr/bin/clang )
set( CMAKE_CXX_COMPILER /usr/bin/clang++ )
set( CMAKE_CXX_FLAGS -stdlib=libc++ )
set( ENV{Boost_DIR} /opt/boost_1_70_0_clang_c++14_build )
set( CMAKE_BUILD_TYPE RELEASE )
set( CMAKE_C_COMPILER /usr/bin/clang )
set( CMAKE_CXX_COMPILER /usr/bin/clang++ )
set( CMAKE_CXX_FLAGS -stdlib=libc++ )
set( Boost_NO_BOOST_CMAKE ON )
set( BOOST_ROOT /opt/boost_1_68_0_gcc_c++14_build )
set( CMAKE_BUILD_TYPE RELEASE )
set( ENV{Boost_DIR} /opt/boost_1_70_0_gcc_c++14_build )
set( CMAKE_BUILD_TYPE RELEASE ) |
|
I think that There is also the option of using This is all CMake behavior, we have no control over it. |
|
No control, that is, apart from filing issues against CMake. :-) https://gitlab.kitware.com/cmake/cmake/issues?scope=all&utf8=%E2%9C%93&state=opened&search=boost |
|
So my current understanding is:
Does that sound about right? To me, this story, even if only rougly accurate is a recipe for much confusion and frustration. I'm happy to raise issues against CMake if that might help but I'm unclear about what can be plausibly fixed. In particular, what are issues in |
|
To confuse matters further, Since |
|
I suppose that |
You could also add the path you would otherwise set in a The only side-effect is, that if you do not restore the former value of Then again you could always use the |
|
Dang even with this great help after 4 hours I still cannot get my Centos7 gcc 8.2 static build of Boost 1.72 to be found from CMake 3.15. Arrrgghh! Update: I had to set via shell environment variable It also worked via the ENV trick in the toolchain file. |
Boost 1.70's cmake config makes
cmakestop looking where I tell it to in two ways:cmakethe location of the Boost I wanted to use with either aBOOST_ROOTenvironment variable or a-DBOOST_ROOT=[...]command line flag but with 1.70.0, the latter option has stopped working./opt/,cmakeuses that one instead of the Boost (either 1.68 or 1.70) in another location that I explicitly request (via either aBOOST_ROOTenvironment variable or a-DBOOST_ROOT=[...]command line flag). Even if I have two Boost 1.70 directories in/opt/,cmakechooses which one to use itself, disregarding my explicit choice.I have seen these issues with
cmake-3.12.1-Linux-x86_64andcmake-3.15.0-rc3-Linux-x86_64.Apologies: I'm not sure whether this issue should be raised here or against
FindBoost.cmakeon https://gitlab.kitware.com/cmake — I'm guessing here because the problem appears to be associated with a change in the Boost version not the CMake version. Sorry if that's incorrect.The text was updated successfully, but these errors were encountered: