Search code examples
visual-studio-2012cmakegdcm

Is there a way to specify all the GDCM libraries in CMakeList at once?


This may be a very basic question, but I am unable to find the answer.

I just installed GDCM library on my Windows 7 workstation and compiled it with CMake and later built the generated solution using VS2012 Express. However, I'm unsure about which GDCM libraries to include in the CMakeLists and I was wondering if there was an easier way to specify all the libraries at once.(like VTK_LIBRARIES for VTK). I tried GDCM_LIBRARIES and that doesn't return a value, neither does GDCM. Specifically, I am looking to replace:

TARGET_LINK_LIBRARIES(TestvtkGDCMImageReader vtkgdcm gdcmMSFF gdcmDSED gdcm2vtk)

with something more general.


Solution

  • Typically, GDCM_LIBRARIES would be defined by the use file that you include after finding the GDCM package in CMake; however, it isn't currently set. You might just do it yourself by setting a variable with all of the GDCM library names.

    For example, from looking at the libraries included in the 2.4.0 Windows binary distribution, I could do this in my CMakeLists.txt:

    set( GDCM_LIBRARIES
        gdcmDICT gdcmDSED gdcmIOD gdcmMEXD gdcmMSFF gdcmcharls gdcmexpat gdcmgetopt
        gdcmjpeg12 gdcmjpeg16 gdcmjpeg8 gdcmopenjpeg gdcmzlib
    # since you built the vtk component, you might also include them here
        vtkgdcm gdcm2vtk
    )
    
    # then you can replace your line with this
    target_link_libraries( TestvtkGDCMImageReader ${GDCM_LIBRARIES} )
    

    Check out where the GDCM dlls you built are installed to see that you get all of the libraries.