CMake found and NOT found boost simultaneously
CMake found and NOT found boost simultaneously
I am trying to install ismrmrd and following the installation guide for Windows.
In the step cmake-gui.exe my cmake is not finding installed Boost.
cmake-gui.exe
After adding those lines to CMakeLists.txt the result became interesting.
CMakeLists.txt

Any ideas?
UPDATE 8/21
thanks vre and user1234567
Now I changed to boost 1.66 and still no luck.
The new screenshot shows FindBoost is not complain anything now.
But still not any boost found.
UPDATE 8/22
After adding
cmake_policy(SET CMP0074 NEW)
cmake_policy(SET CMP0074 NEW)
and
set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) find_package(Boost REQUIRED system filesystem) include_directories($Boost_INCLUDE_DIRS) target_link_libraries(ismrmrd $Boost_LIBRARIES) into CMakeLists.txt by the suggestion from vre
set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) find_package(Boost REQUIRED system filesystem) include_directories($Boost_INCLUDE_DIRS)
target_link_libraries(ismrmrd $Boost_LIBRARIES)
CMakeLists.txt
The resulting error became this screenshot
set(Boost_ADDITIONAL_VERSIONS 1.68.0 1.68)
For Boost 1.68 you need the lastest CMake master. For your CMake version, 1.67 or older should work. Cf. stackoverflow.com/a/42124857/2799037
– usr1234567
Aug 21 at 22:13
Did you build boost yourself or used a prebuilt version from this site
https://sourceforge.net/projects/boost/files/boost-binaries/ ? They are the maintainers of BOOST and provide binaries for lots of MSVC compilers. To correctly use Boost static libraries you should add set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) find_package(Boost REQUIRED system filesystem) include_directories($Boost_INCLUDE_DIRS) and to link against it target_link_libraries(your_target $Boost_LIBRARIES) to your CMakeLists.txt file.– vre
Aug 22 at 11:19
https://sourceforge.net/projects/boost/files/boost-binaries/
set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) find_package(Boost REQUIRED system filesystem) include_directories($Boost_INCLUDE_DIRS)
target_link_libraries(your_target $Boost_LIBRARIES)
@vre I do download prebuilt version from sourceforge, but I ran
bootstrap.bat and b2.exe variant=debug,release link=static runtime-link=static address-model=64 from link– kaltu
Aug 22 at 14:51
bootstrap.bat
b2.exe variant=debug,release link=static runtime-link=static address-model=64
You are rebuilding boost. But that's not needed if you use the prebuilt package from the sourceforge adress mentioned above. It comes with dynamic and static libraries, release and debug mode built for the named compiler. All that is needed is to reference it correctly in the CMakeLists.txt. What compiler are you using?
– vre
Aug 22 at 15:00
1 Answer
1
As it is to long for comments I try to come up with a recipe:
The commands needed for using Boost header only/static libraries are:
set(Boost_ADDITIONAL_VERSIONS 1.66.0 1.66)
set(BOOST_ROOT "C:/local/boost_1_66_0")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
For using solely header only libraries use
find_package(Boost)
otherwise name the components (libraries) to be used after the COMPONENTS keyword and use
find_package(Boost COMPONENTS <e.g. filesystem system ...>)
if (Boost_FOUND)
include_directories($Boost_INCLUDE_DIRS)
add_definitions( "-DHAS_BOOST" )
endif()
Later you reference the imported targets (libraries) for header only Boost in a call
target_link_libraries(yourproject Boost::boost)
or for named library components in a call
target_link_libraries(yourproject $Boost_LIBRARIES)
Be sure to always delete the CMakeCache.txt file in the build directory when making changes to the CMakeLists.txt regarding Boost and Boost components, as it might cache the values of a previous CMake run.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
You might need to add a variable to your CMakeLists.txt
set(Boost_ADDITIONAL_VERSIONS 1.68.0 1.68)as your CMake release date is older than the release date of your Boost version. FindBoost.cmake only knows Boost versions before its release date not newer ones.– vre
Aug 21 at 18:23