In my project I have a dependency "A" that has another library dependency "B", I'm trying to download and install the dependency B before A in order to clear the conflict. I'm using Externalproject_add
, FetchContent_Declare
and install
, but it fails.
for an example
I got a CMakeList.txt like:
FetchContent_Declare( libpng
GIT_REPOSITORY https://github.com/glennrp/libpng.git
GIT_TAG master
UPDATE_DISCONNECTED TRUE
STEP_TARGETS update
)
FetchContent_GetProperties(libpng)
if (NOT libpng_POPULATED)
FetchContent_Populate(libpng)
add_subdirectory("${libpng_SOURCE_DIR}" ${libpng_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
The CMakeList.txt of this libpng has the line find_package(ZLIB REQUIRED)
, at this point I could download and install manually the zlib, but since I'm developing a library I would like my code to take care of this dependency. Also I cannot modify the CMakeList.txt of libpng. So, I have this code but it continues to fail.
FetchContent_Declare( zlib
GIT_REPOSITORY https://github.com/zlib-ng/zlib-ng.git
GIT_TAG develop
UPDATE_DISCONNECTED TRUE
STEP_TARGETS update
)
FetchContent_GetProperties(zlib)
if (NOT zlib_POPULATED)
FetchContent_Populate(zlib)
add_subdirectory("${zlib_SOURCE_DIR}" ${zlib_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
install(TARGETS zlib)
I'm still starting with CMake and I continuous learning but it's hard to find proper examples.
So, How can I install a external project in order to make it available for find_package?