According to this bugreport, install(TARGETS)
command flow accepts only targets created within the same directory.
So you need either move the add_library()
call into the top-level directory, or split install(TARGETS)
call into per-target ones, and move each of them into the corresponding subdirectory.
Since CMake 3.13 install(TARGETS)
can work even with targets created in other directories.
install(TARGETS)
can install targets that were created in other directories. When using such cross-directory install rules, runningmake install
(or similar) from a subdirectory will not guarantee that targets from other directories are up-to-date.