[Cmake] use a static library

Brad King brad.king at kitware.com
Thu Feb 27 09:41:25 EST 2003


> I work on a project who needs itk, vtk and qt. We have something working
> on windows, and I try to compile it on linux, but we use Kuebler's
> vtk_qt library, so I need to build this for linux first. That's what
> I've done (making a libvtk_qt.a ) but now I still have linking problems.

The cmake file provided on Kuebler's page seems out of date.  There are
much newer cmake conventions that work better.  If you are including the
vtk_qt sources in your project, then you can just use a single cmake
listfile to build both the library and your project, or even just include
the library's sources directly in your project.  Something like this
should get you started (this is untested, and just off the top of my
head):

CMAKE_MINIMUM_REQUIRED(VERSION 1.6)
PROJECT(MyProject)

FIND_PACKAGE(Qt)
FIND_PACKAGE(VTK)

IF(VTK_FOUND)
  INCLUDE(${VTK_USE_FILE})
ENDIF(VTK_FOUND)

IF(QT_INCLUDE_DIR)
  INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
ENDIF(QT_INCLUDE_DIR)

SET(MyProject_SRCS
  # List vtk_qt's sources here.
  # List your sources here.
)

SET(MyProject_MOC_SRCS
  # List vtk_qt's moc headers here.
  # List your moc headers here.
)

IF(QT_WRAP_CPP)
  QT_WRAP_CPP(myProject vtk_qt_SRCS vtk_qt_MOC_SRCS)
ENDIF(QT_WRAP_CPP)

ADD_EXECUTABLE(myProject vtk_qt_SRCS)
TARGET_LINK_LIBRARIES(myProject vtkRendering ${QT_QT_LIBRARY})

-Brad




More information about the CMake mailing list