I am trying to use the pre-compiled boost from silverglint. For some reason, the build system is not able to locate source files [these files are present in src/main/cpp/boost/]
.../app/src/main/cpp/boost/thread.hpp:13:10: fatal error: 'boost/thread/thread.hpp' file not found
Following is the relevant content of my CMakeLists.txt:
add_library(boost SHARED IMPORTED)
set_property(TARGET boost PROPERTY IMPORTED_LOCATION
${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/arm64-v8a/libboost_thread.so
)
include_directories(
src/main/cpp/boost/
)
I suspect this is error is due to misconfigured path. Any help in resolving this error is appreciated.
If the file is included at the path:
boost/thread/thread.hpp
and the file is actually located here:
src/main/cpp/boost/thread/thread.hpp
I believe the included directory should be:
include_directories(
src/main/cpp
)
As commented, it is best practice to use absolute paths when including directories in CMake. Also, prefer the target-specific target_include_directories()
command whenever possible, to prevent the pollution of the global include directories space:
target_include_directories(YourTarget PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp
)
FWIW, the idiomatic way to import Boost libraries into your project is described in this answer, and is a much cleaner approach.