[Cmake] Specifying static or dynamic linking of external libraries?
Thomas Deschamps
tdeschamps at lbl.gov
Wed Oct 23 13:12:12 EDT 2002
Bill,
I now remember when I was using this command INCLUDE
(${CMAKE_ROOT}/Modules/FindVTK.cmake). Thank you for the tip.
It works nicely, but there are still two problems:
1) Not very important: we still need to directly provide the full name
/usr/local/libvtkIO.a instead of vtkIO, otherwise the link is made
against shared lib, and both libraries types co-exist.
2) I cannot configure anymore the compilation (CC,CXX, any flag, etc...)
even whith cmake -i, or ccmake. Everything is taken from UseVTK.cmake
and no more accessible via the command line interactive cmake. It just
ask me wether I want to use built or installed version of VTK.
But if I want to use different compiling options than the one used for VTK?
Is there a mechanism to modify it through cmake -i? Or should I include
it in the CMakeList.txt?
Thomas
William A. Hoffman wrote:
> OK, I see the problem, you should see the Examples directory in VTK.
> (Examples/Tutorial/Step1/Cxx)
>
> You want something like this:
>
> PROJECT(calWidgets)
>
> # ask cmake to find VTK
> INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)
> IF (USE_VTK_FILE)
> INCLUDE(${USE_VTK_FILE})
> ENDIF (USE_VTK_FILE)
>
> # create a variable with your sources
> SET(Project_sources
> myImagePlaneWidget.cxx
> myImageViewer.cxx )
>
> # create your library from the sources
> ADD_LIBRARY(calWidgets STATIC ${Project_sources})
> # create an executable using test.cxx
> ADD_EXECUTABLE(testImagePlaneWidget test.cxx)
> # now link calWidgets and any libraries that you directly use out of VTK:
> TARGET_LINK_LIBRARIES(testImagePlaneWidget calWidgets vtkHybrid
> vtkRendering vtkIO)
>
> As long as the VTK you point cmake at is built static, things should
> work well.
> cmake will pull in all the extra libraries used by vtkHybrid
> vtkRendering and vtkIO.
>
> CMake is just doing what you told it to do. It is linking all the
> libraries in the order that
> you gave them to it. Since you did not use the UseVTK.cmake file,
> cmake does
> not know about the extra libraries needed by VTK.
>
> -Bill
More information about the CMake
mailing list