[CMake] link issue with 2 statics lib->what's wrong in my cmake project
Bill Hoffman
bill.hoffman at kitware.com
Tue Mar 16 17:49:46 EDT 2010
AKHRES Nader wrote:
> Hello CMake community,
>
> I've two libs A and B where B depends on A.
> Then I have my final exe which depends on A and B.
> When I generate exe project for gcc or mingw, I get undefined reference
> errors from B.
> This doesn't happen with visual c++.
>
> Here are my cmake files organization, with relevant content between
> bracket:
>
> root
> |--myAlib
> |--------CMakeLists.txt [ADD_LIBRARY(A STATIC sources)]
> |--myBlib
> |--------CMakeLists.txt [INCLUDE_DIRECTORIES(myAlib/src) ADD_LIBRARY(B
> STATIC src)]
target_link_libraries(B A) # add this
> |--myExe
> |--------CMakeLists.txt [ADD_EXECUTABLE(exename src)
> TARGET_LINK_LIBRARIES(exename B) ] # you can remove A from here
> |--CMakeLists.txt [ADD_SUBDIRECTORY(myAlib) ADD_SUBDIRECTORY(myBlib)
> ADD_SUBDIRECTORY(myExe)]
>
>
> Maybe it's something obvious I've forgotten...
>
More information about the CMake
mailing list