I was trying to include an external library in my project using the following:
ExternalProject_Add(
http_server_dl
GIT_REPOSITORY "https://github.com/av4625/http_server.git"
GIT_TAG "beast"
GIT_SHALLOW TRUE
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target http_server
TEST_COMMAND ""
INSTALL_COMMAND ""
BUILD_BYPRODUCTS "<BINARY_DIR>/src/libhttp_server.a"
)
ExternalProject_Get_Property(http_server_dl SOURCE_DIR BINARY_DIR)
add_library(http_server IMPORTED STATIC GLOBAL)
add_dependencies(http_server http_server_dl)
file(MAKE_DIRECTORY ${SOURCE_DIR}/src)
set_target_properties(http_server PROPERTIES
IMPORTED_LOCATION ${BINARY_DIR}/src/libhttp_server.a
INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/src)
This seems to work ok but the external library depends on boost
. It uses conan
to build boost
and I can see this happening when the external project build step is happening.
When I try to do:
#include <server.hpp>
in one of my files I get this warning:
fatal error: 'boost/noncopyable.hpp' file not found
#include <boost/noncopyable.hpp>
server.hpp
does use that boost
file.
In the library that I include server.hpp
I have done:
add_library(<my_lib> library_file.cpp)
target_link_libraries(<my_lib> PRIVATE http_server)
How do I fix this so everything is bundled into the http_server
library?