I'm trying to download, build and link external libraries using ExternalProject_Add(). Currently I'm trying to import Volk library https://github.com/zeux/volk with it. I got to the point, where I can download and build the library without any problem, but I can't link to it, because the library isn't downloaded and built yet (throws an ninja error). Before ExternalProject_Add() I used find_package(). It worked great, but it was processed at configuration stage and I don't have access to the library files until build stage. The Volk library also has dependecy on Vulkan and I have no idea on how to provide Vulkan lib files to it. It was all done automatically using the VolkConfig.cmake script.
My current code for the ExternalProject_Add():
ExternalProject_Add(
VolkDownload
GIT_REPOSITORY https://github.com/zeux/volk.git
GIT_TAG b3bc21e584f97400b6884cb2a541a56c6a5ddba3
PREFIX ${PROJECT_SOURCE_DIR}/External/VolkDownload
CONFIGURE_COMMAND cmake ../VolkDownload -DVOLK_INSTALL=ON
BUILD_COMMAND cmake --build . --config Release
INSTALL_COMMAND cmake --install . --prefix ../../install
)
Externalproject_Get_Property(VolkDownload binary_dir)
set(VOLK_INCLUDE_DIR ${binary_dir}/../install/include)
set(VOLK_LIB_DIR ${binary_dir}/../install/lib)
add_library(volk STATIC IMPORTED)
set_target_properties(volk PROPERTIES IMPORTED_LOCATION ${VOLK_LIB_DIR}/volk.lib)
add_dependencies(volk VolkDownload)
add_library(testLib SHARED ${SRC_FILES})
add_dependencies(testLib volk)
target_include_directories(testLib PRIVATE ${VOLK_INCLUDE_DIR})
target_link_libraries(testLib volk)
The error I get:
[build] ninja: error: 'VolkDownload/src/install/lib/volk.lib', needed by 'bin/testLib.dll', missing and no known rule to make it
My question is how can I properly download and build the external libraries (in this case Volk) using ExternalProject_Add() and how to properly create library targets, which I can easily link to?