[CMake] Questions on CMAKE_CONFIGURATION_TYPES

Michael Schildt michael.schildt at ifn-magdeburg.de
Thu Mar 25 10:53:52 EDT 2010


>
> On Thu, Mar 25, 2010 at 12:51 PM, Michael Schildt
> <michael.schildt at ifn-magdeburg.de <http://www.cmake.org/mailman/listinfo/cmake>> wrote:
> >>/
> />>/ On Wed, Mar 24, 2010 at 2:10 PM, John Drescher <drescherjm at gmail.com
> />>/ <http://www.cmake.org/mailman/listinfo/cmake>> wrote:
> />>/ >/ On Wed, Mar 24, 2010 at 1:42 PM, Michael Schildt
> />>/ />/ <michael.schildt at ifn-magdeburg.de
> />>/ <http://www.cmake.org/mailman/listinfo/cmake>> wrote:
> />>/ />>/ Hello,
> />>/ />>/
> />>/ />>/ I use GDCM libaries in one project. Unfurtunally, i couldn't find a
> />>/ findGDCM
> />>/ />>/ module and i'm not experienced enough to write one. I have seen that
> />>/ GDCM is
> />>/ />>/ used in ITK, so there must be a module like this. GDCM is using cmake
> />>/ too,
> />>/ />>/ so inclusion should be easy. But i have problems to link the correkt
> />>/ library
> />>/ />>/ version depending on the configuration type.
> />>/ />>/
> />>/ />>/ IF(WIN32)
> />>/ />>/  INCLUDE_DIRECTORIES(C:/Programme/GDCM\ 2.0/include/gdcm-2.0)
> />>/ />>/  IF(CMAKE_BUILD_TYPE MATCHES "Debug")
> />>/ />>/   LINK_DIRECTORIES("C:/Program Files/GDCM/bin/Debug")
> />>/ />>/  ELSE(CMAKE_BUILD_TYPE MATCHES "Debug")
> />>/ />>/   LINK_DIRECTORIES("C:/Program Files/GDCM/bin/Release")
> />>/ />>/  ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug")
> />>/ />>/  SET(GDCM_LIBRARIES gdcmcharls.lib gdcmCommon.lib gdcmDICT.lib
> />>/ gdcmDSED.lib
> />>/ />>/ gdcmexpat.lib gdcmgetopt.lib gdcmIOD.lib gdcmjpeg8.lib gdcmjpeg12.lib
> />>/ />>/ gdcmjpeg16.lib gdcmMSFF.lib gdcmopenjpeg.lib gdcmzlib.lib)
> />>/ />>/ ELSE(WIN32)
> />>/ />>/   # Linux
> />>/ />>/   INCLUDE_DIRECTORIES(/usr/include/gdcm-2.0)
> />>/ />>/   SET(GDCM_LIBRARIES gdcmCommon gdcmDICT gdcmDSED gdcmIOD gdcmjpeg8
> />>/ />>/ gdcmjpeg12 gdcmjpeg16 gdcmMSFF)
> />>/ />>/ ENDIF(WIN32)
> />>/ />>/
> />>/ />>/ He always includes the Relase Directory. What is a solution for this
> />>/ issue?
> />>/ />>/
> />>/ />/
> />>/ />/ Build GDCM from source and it will have the necessary finders. Do not
> />>/ />/ INSTALL. Then the usual in your CMakeLists.txt file. Here is an
> />>/ />/ example.
> />>/ />/
> />>/ />/ CMakeLists.txt
> />>/ />/ cmake_minimum_required(VERSION 2.6)
> />>/ />/
> />>/ />/        PROJECT(GDCMImageViewer)
> />>/ />/
> />>/ />/        FIND_PACKAGE(VTK REQUIRED)
> />>/ />/        INCLUDE(${VTK_USE_FILE})
> />>/ />/
> />>/ />/        FIND_PACKAGE(GDCM REQUIRED)
> />>/ />/        INCLUDE(${GDCM_USE_FILE})
> />>/ />/
> />>/ />/        INCLUDE_DIRECTORIES(
> />>/ />/         ${GDCM_SOURCE_DIR}/Utilities/VTK
> />>/ />/        )
> />>/ />/
> />>/ />/        IF(WIN32 AND NOT CYGWIN)
> />>/ />/                ADD_SUBDIRECTORY(getopt)
> />>/ />/                INCLUDE_DIRECTORIES(getopt)
> />>/ />/        ENDIF(WIN32 AND NOT CYGWIN)
> />>/ />/
> />>/ />/        ADD_EXECUTABLE(GDCMImageViewer gdcmviewer.cxx)
> />>/ />/        TARGET_LINK_LIBRARIES(GDCMImageViewer vtkHybrid vtkInfovis
> />>/ vtkWidgets
> />>/ />/ vtkgdcm getopt)
> />>/ />/
> />>/ />/
> />>/ /
> />>/ BTW when cmake-gui complains it can not find GDCM point it to the
> />>/ place where you built gdcm. Also make sure you build all
> />>/ configurations of GDCM that you want in the same build tree. That is
> />>/ why I said do not install. Since install will try to put the binaries
> />>/ in the same folder and since they are named the same it will cause
> />>/ problems.
> />>/
> />>/
> />>/ John
> />>/
> />/
> />/ Hi,
> />/
> />/ thanks for the useful hints, cmake finds the package now. But unfurtunally,
> />/ it does not link the library and therefore i get a lot of unresolved
> />/ dependency from gdcm. i replaced my stuff with
> />/
> />/ FIND_PACKAGE(GDCM REQUIRED)
> />/ INCLUDE(${GDCM_USE_FILE})
> />/
> />/ and tested the typical variables
> />/
> />/ MESSAGE(STATUS "Cmake GDCM: using GDCM includes at: ${GDCM_INCLUDE_DIR}")
> />/ MESSAGE(STATUS "Cmake GDCM: using GDCM libraries: ${GDCM_LIBRARIES}")
> />/ MESSAGE(STATUS "Cmake GDCM: using GDCM libraries: ${GDCM_LIBRARY}")
> />/
> />/ but the are all empty? How can i find out, what is defined by GDCM?
> /
> `cmake --help-module` parses system installed Find*.cmake file,
> however it does not parse *Config.cmake file. You have to look into
> GDCMConfig.cmake and such to understand.
>
> Anyway, there is no generic "GDCM_LIBRARIES", you have to specify
> explicitely the name of the desired lib:
>
> add_executable(dummy dummy.cxx)
> target_link_libraries(dummy gdcmMSFF)
>
> Cheers
> -- 
> Mathieu
>   

Hello,

i found GDCMconfig.cmake as you mentioned and the definitions there in 
are GDCM_INCLUDE_DIRS and GDCM_LIBRARY_DIRS. But as in the former post i 
specified the needed libraries manually. Thank you all for your help.

FIND_PACKAGE(GDCM REQUIRED)
INCLUDE(${GDCM_USE_FILE})

SET(GDCM_LIBRARIES gdcmCommon gdcmDICT gdcmDSED gdcmIOD
    gdcmjpeg8 gdcmjpeg12 gdcmjpeg16 gdcmMSFF
    CACHE STRING "GDCM libraries")

MESSAGE(STATUS "Cmake GDCM: using includes at: ${GDCM_INCLUDE_DIRS}")
MESSAGE(STATUS "Cmake GDCM: using libraries at: ${GDCM_LIBRARY_DIRS}")
MESSAGE(STATUS "Cmake GDCM: using libraries: ${GDCM_LIBRARYRIES}")

TARGET_LINK_LIBRARIES(fileInfo ${GDCM_LIBRARIES})

But it is still unclear to me how to provide different link_directories 
for Debug and Release used by MSVC 9.0 on Windows for external libraries 
not using cmake . If i have release and debug libraries with different 
namens (i.e. test1.lib and test1d.lib) i can use something like

TARGET_LINK_LIBRARIES( Project1 debug test1d.lib optimized test1.lib)

But what if i have i.e. Debug/test1.lib and Release/test1.lib? How do i 
define configuration-type depended LINK_DIRECTORIES?

Best reguards,
    Michael



More information about the CMake mailing list