[CMake] can not import target external lib before being build

Stéphane Ancelot sancelot at numalliance.com
Thu Sep 12 03:54:55 EDT 2019


Hi,

I am using this cmake snippet in order to build an external library


# ------ QGLViewer ----------
set(QGLVIEWER_FILES 
${CMAKE_BINARY_DIR}/libQGLViewer-2.7.1/QGLViewer/qglviewer.h)

get_target_property (QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)

add_custom_command(OUTPUT ${QGLVIEWER_FILES}
   COMMAND  tar xzf 
"${CMAKE_CURRENT_SOURCE_DIR}/libQGLViewer-2.7.1.tar.gz" --strip 1
   COMMAND ${QT_QMAKE_EXECUTABLE} -o QMakefile
   COMMAND make -f QMakefile
#  COMMAND ${CMAKE_COMMAND} -E touch ${LIBFOO_TAR_HEADERS}
   WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/libQGLViewer-2.7.1"
   DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libQGLViewer-2.7.1.tar.gz"
   COMMENT "Unpacking libQGLViewer-2.7.1.tar.gz"
   VERBATIM
)

add_custom_target(qglviewer_untar DEPENDS ${QGLVIEWER_FILES})

add_library(qglviewer SHARED IMPORTED)
add_dependencies(qglviewer qglviewer_untar)

# link qglviewer
set_target_properties(qglviewer PROPERTIES
                       IMPORTED_LOCATION 
"${CMAKE_CURRENT_BINARY_DIR}/libQGLViewer-2.7.1/QGLViewer/libQGLViewer-qt5.so"
                       INTERFACE_INCLUDE_DIRECTORIES 
"${CMAKE_CURRENT_BINARY_DIR}/libQGLViewer-2.7.1")


Unfortunately, cmake replies with the next error when configuring :


CMake Error in API_COLLISION/CMakeLists.txt:
   Imported target "qglviewer" includes non-existent path

"/tmp/OK/BASE_SILFAX_SAFETY/build/API_COLLISION/libQGLViewer-2.7.1"

   in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

   * The path was deleted, renamed, or moved to another location.

   * An install or uninstall procedure did not complete successfully.

   * The installation package was faulty and references files it does not
   provide.



CMake Error in API_COLLISION/CMakeLists.txt:
   Imported target "qglviewer" includes non-existent path

"/tmp/OK/BASE_SILFAX_SAFETY/build/API_COLLISION/libQGLViewer-2.7.1"

   in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

   * The path was deleted, renamed, or moved to another location.

   * An install or uninstall procedure did not complete successfully.

   * The installation package was faulty and references files it does not
   provide.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190912/b0a858d1/attachment.html>


More information about the CMake mailing list