I'd like to use the following third party library: https://github.com/Corvusoft/restbed
I'd like to create a folder structure similar to this:
- root
- CMakeLists.txt
- src
- third_party
- restbed
- src
- CMakeLists.txt
- CMakeLists.txt
I've found out that I should use the ExternalProject
CMake module to achieve this but it does not seem that I can do it correctly. For some reason the external lib's (restbed's) source does not appear in my XCode project when I generate it out with the use of the root CMakeLists.txt. This root CMakeLists.txt includes in the third_party
folder's CMakeLists.txt. The third_party
folder's CMakeLists.txt looks like this:
include(ExternalProject)
# CMAKE_CURRENT_LIST_DIR -> third_party folder
set(RESTBED_DIR ${CMAKE_CURRENT_LIST_DIR}/restbed)
ExternalProject_Add(restbed
PREFIX ${RESTBED_DIR}
SOURCE_DIR ${RESTBED_DIR}
CMAKE_ARGS -DBUILD_SSL=NO
DOWNLOAD_COMMAND ""
UPDATE_COMMAND ""
BUILD_COMMAND cmake ..
BINARY_DIR ${RESTBED_DIR}/build
INSTALL_DIR ${RESTBED_DIR}/distribution
INSTALL_COMMAND make install
)
set(RESTBED_INCLUDE_DIR ${RESTBED_DIR}/distribution/include)
set(RESTBED_LIB_DIR ${RESTBED_DIR}/distribution/lib)
add_library(librestbed IMPORTED STATIC)
add_dependencies(librestbed restbed)
After this I'd like to use target_include_dir
and target_link_libraries
to add librestbed
as a dependency to my root project. After this when I build my XCode project nothing happens, the external lib won't get built. What am I doing wrong? I would not like to use the built-in CMake git functionality because I'd like to store my external dependencies as git submodules in the third_party lib. I'd rather not let CMake figure out if it needs to re-download a given dependency. Thanks in advance!