I’m working on 2 cmake projects.
Project A creates a shared lib that depends on OpenMP.
find_package(OpenMP REQUIRED)
add_library(lib_a SHARED file_a.cpp)
target_link_libraries(lib_a OpenMP::OpenMP_CXX)
And project B uses the above library.
Note that project B itself does not depend on OpenMP.
find_package(project_a REQUIRED)
add_library(lib_b SHARED file_b.cpp)
target_link_libraries(lib_b project_a::lib_a)
I can compile project A without issues.
When compiling project B I get the error:
Target "lib_b" links to target "OpenMP::OpenMP_CXX" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?
I can compile project B without issues if I add find_package(OpenMP REQUIRED)
to its CMakeLists.txt.
But since project B itself doesn’t depend on OpenMP I shouldn’t need to do this, right??
I’m guessing I’m missing some step in project A’s cmake?
How can I fix this without having to find OpenMP in project B?