In my CMake project I have the following targets:
- LibA library that has a missing function
void foo()
that the user needs to implement when linking with LibA - LibB library which among other implements
foo()
and links to LibA - Proj executable which links to LibB
CMakeLists.txt looks something like this:
add_library(LibA STATIC libA_source.cpp)
add_library(LibB STATIC libB_source.cpp libA_retarget.cpp) #foo() is implemented in retarget
target_link_libraries(LibB LibA)
add_executable(Proj proj_source.cpp)
target_link_libraries(Proj LibB)
If I use VisualStudio as my generator my project builds fine. However if I use MinGW I get linker error that void foo()
is not defined.
Is there something I did fundamentally wrong? In my understanding everything is fine and should work. I have no idea why linker in MinGW cannot find foo()
from LibB.