I have the following directory layout:
main_folder + static_lib1 + executable
- Both static_lib1 and executable have full CMakeLists so that they can be built independently.
- The executable depends on static_lib1. It uses
find_package()
to search for "static_lib1". - The main folder contains CMakeLists, which includes both static_lib1 and "executable" via
add_subdirectory
to conveniently build the entire project in one go.
Everything works fine if I manually create "static_lib1" and then the "executable". But when I start CMakeLists from the main folder, I get an error because find_package
cannot find library files from 'static_lib1' that have not been created yet.
How can I resolve this by keeping the CMakeLists files separate (i.e. not including the static_lib CMakeLists from the executable CMakeLists)?
source share