Project Hierarchy
- Main CMakeLists.txt
- App CMakeLists.txt
- LibA CMakeLists.txt
Details
Main CMakeLists.txt
...
add_subdirectory(LibA)
add_subdirectory(App)
...
App CMakeLists.txt
...
find_package(LibA REQUIRED)
...
Problem
find_package(LibA REQUIRED)
in App CMakeLists.txt doesn’t always succeed, cases:
- As a Visual Studio 2019 cmake proejct it works
- As a Qt Creator project it fails
- When configure and generate with cmake-gui it fails
Question
I’m using Qt Creator now, what’s the best way for find_package
to work?
Here is a workaround but not good enough: CMake find_package dependency on subproject - Stack Overflow
I think there is no universal way:
- For a lib with add_subdirectory,
target_link
is enough. - For an external lib, an additional
find_package
is needed.
Right?