Is there are proper way to find a library (via FindPackage()
) which was built with ExternalProject_Add()
?
The problem is that CMake cannot find the library at CMake-time because the external library gets build at compile time. I know that it is possible to combine these two CMake function when building the library and the project in a superbuild but I want to use it in a normal CMake project.
In fact I would like to build VTK 6 with ExternalProject_Add
and find it with FindPackage
all inside my CMake project.
there is a way to do this. but it´s kind of hackish. you basically add a custom target, that reruns cmake during build.
you will have to try this in a small test project, to decide if it works for you
this seems to work well for mingw makefiles / eclipse makefile projects. vs will request to reload all projects after first build.
You can force a build using the build_external_project function below.
It works by generating a simple helper project inside the build tree and then calling the cmake configuration and the cmake build on the helper.
Customize at will for the actual ExternalProject_add command.
Note that the trailing arguments are used to pass CMAKE_ARGS. Furthur enhancements are left as an exercise to the reader :-)