Hello,

Consider the following case where:
- I want to export/import my library named mylib
- This library depends on OpenCV that is also exported

According to http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#creating-packages
the CMakeLists.txt of my library is simpilar to:

project(mylib)
find_package(OpenCV)
add_library(mylib foo.c foo.h)
target_link_libraries(mylib ${OpenCV_LIBS})
...
export(EXPORT mylibTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/mylibTargets.cmake")
...

Now the CMakeLists of an other project that uses mylib will be like :

project(test)
find_package(mylib)
add_executable(test test.c)
target_link_libraries(test mylib)

During the build of this project the linker complains that OpenCV libraries are not found

Linking C executable test
"/Applications/CMake 3.0.0.app/Contents/bin/cmake" -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1 /usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/test.dir/test.c.o -o test -lopencv_videostab -lopencv_video ...
ld: library not found for -lopencv_videostab

The problem comes from mylibTargets.cmake where I have:

set_target_properties(mylib PROPERTIES
IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG "opencv_videostab;opencv_video;..."
  IMPORTED_LOCATION_NOCONFIG "/tmp/build/libmylib.dylib"
  IMPORTED_SONAME_NOCONFIG "/tmp/build/libmylib.3.dylib"
  )

while I wanted to have the full path to OpenCV libraries (ie /tmp/OpenCV/lib/libopencv_videostab.2.4.10.dylib ...

Is there a proper way to include OpenCV dependencies during the export of my library ?

Fabien
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to