I included a Boost-Header file to my test project using CMakeLists.txt. My some.cpp can include this header without any error, but i'm not able to run since the header file relies obviously on other Boost headers and its not finding the required files. The location of my files is in cpp folder and the boost files are in (C:\boost) a subdirectory:
..\src\main\cpp\boost\RequiredHeader.hpp.
For the include files in the "RequiredHeader" the compiler is looking at:
..\src\main\cpp\boost\boost\AnotherHeader.hpp.
CMakeLists.txt (Boost-part)
# ADD BOOST
message("Import Boost...\n")
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_INCLUDE_DIRS C:/boost_1_64_0/boost)
find_package(Boost 1.64.0)
if(Boost_FOUND)
message("Boost found! Link libraries...\n")
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(myDependantLib ${Boost_LIBRARIES})
endif()
Your help is highly appreciated!
Updated question:
How to tell CMake where my Boost header files are, since it still is not finding the right location, with BOOST_ROOT set?
Updated CMakeLists.txt
# ADD BOOST
message("Add boost...\n")
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_ROOT C:/boost_1_64_0)
set(BOOST_INCLUDE_DIR C:/boost_1_64_0/boost)
FIND_PACKAGE(Boost 1.64.0 COMPONENTS foreach REQUIRED)
if(Boost_FOUND)
message("Boost found! Link libraries...\n")
target_link_libraries(calculator LINK_PUBLIC ${Boost_LIBRARIES})
endif()
find_packge(Boost)
should set it for you? - TsyvarevUnable to find the requested Boost libraries. Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers
I tried setting those directories, but wasn't successful... - int ermedi_8I tried setting those directories, but wasn't successful.
- Show what have you tried. And do not replace actual Boost header name with "RequiredHeader". - TsyvarevBOOST_INCLUDEDIR
variable, notBOOST_INCLUDE_DIR
. By settingBoost_DEBUG
variable to 1 (or any non-false value) you may get additional information about searching Boost. - Tsyvarev