@Fabian188 I posted the CMakeLists.txt files above so you can see what I’m doing.
The External_Project_Add() simply downloads, patches, configures, builds, and installs what is built to a intermediate location. Then, the install() function is what is referenced when performing a ninja install or cmake --install ., which copies files from the intermediate location to the desired system location. With ninja package, CPack copies files from the intermediate location to the _CPack_Packages/Linux/.../<target> directory and the package is created as specified by the install() function. It’s the install() function that CMake uses to generate the <target>/cmake_install.cmake file. The install_manifest_<target>.txt file is created when a install is performed, either by ninja install, cmake --install . or ninja package.
The add_dependencies(${PROJECT_NAME} zlib), in the openssl CMakeLists.txt, adds a build time dependency on zlib. But this build time dependency doesn’t perform an install from the intermediate location to the system location with ninja install or cmake --install ..
I might get to understand your problem and what actually happens.
I did not understand that there is actually an install to the project directory already…
It is like Craig wrote: you need to do it yourself.
You could do it, as I wrote, by installing the dependency to the system and building your main project from the then-system files (I would not do it).
Or you require a double install. The first is from the external project itself and for the second you do manually add the files to be installed to the main project via install(). Otherwise the main project ninja install does not know about these files. Or you make use of the manifest_install.txt from the dependency build directory.
The second step (calling install() with the artefacts) you can do as an post-install-step for the dependency.