Discussion:
[Cmake] use a static library
imho
2003-02-27 11:59:37 UTC
Permalink
Hi,

How do I link a static .a library on linux with cmake?

Thanks
Andy Cedilnik
2003-02-27 13:23:16 UTC
Permalink
Hi,

If you want to create static library:

ADD_LIBRARY(foo STATIC source.c source1.c...)

If you want to link static library to your project:

TARGET_LINK_LIBRARIES(bar foo)

or

TARGET_LINK_LIBRARIES(bar /path/to/foo/libfoo.a)

Andy
Post by imho
Hi,
How do I link a static .a library on linux with cmake?
Thanks
_______________________________________________
Cmake mailing list
http://public.kitware.com/mailman/listinfo/cmake
imho
2003-02-27 13:58:59 UTC
Permalink
thanks, but I still have problems.
I explain :
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.

I've joined my cmakelists and error listing.

Thanks for helping
Post by Andy Cedilnik
Hi,
ADD_LIBRARY(foo STATIC source.c source1.c...)
TARGET_LINK_LIBRARIES(bar foo)
or
TARGET_LINK_LIBRARIES(bar /path/to/foo/libfoo.a)
Andy
Post by imho
Hi,
How do I link a static .a library on linux with cmake?
Thanks
_______________________________________________
Cmake mailing list
http://public.kitware.com/mailman/listinfo/cmake
Brad King
2003-02-27 14:41:25 UTC
Permalink
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

Loading...