Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake can't find IMPORTED library

Tags:

cmake

In foo/CMakeLists.txt, based on this and this, I have the following

SET (EXTERNAL_LIB_ROOT "../../external_libs/")

ADD_LIBRARY (avcodec-debug STATIC IMPORTED)

SET_PROPERTY (
    TARGET avcodec-debug PROPERTY IMPORTED_LOCATION
    ${EXTERNAL_LIB_ROOT}/libavcodec-0.8.10.a)

In bar/CMakeLists.txt I have this:

# old way uses system libraries
#TARGET_LINK_LIBRARIES (bar avformat avcodec avutil)

# new way uses local debug builds
TARGET_LINK_LIBRARIES (bar avformat avcodec-debug avutil)

When I run make I get

/usr/bin/ld: cannot find -lavcodec-debug

If I revert to the old way, build, touch foo/CMakeLists.txt and rebuild, CMake's configuration output indicates that avcodec-debug is being found by the build system.

So why can't I add it as a dependency?

like image 242
spraff Avatar asked May 09 '14 13:05

spraff


1 Answers

As it mentioned above by Angew the visibility for imported library differs, though you can extend it using GLOBAL modifier. It might be enough for you to modify add_library call next way:

ADD_LIBRARY(avcodec-debug STATIC IMPORTED GLOBAL)
like image 140
Boris Lyubimov Avatar answered Sep 29 '22 00:09

Boris Lyubimov