[CMake] MSVC and different link_directories for release and debug

John Drescher drescherjm at gmail.com
Wed Mar 24 14:10:41 EDT 2010


On Wed, Mar 24, 2010 at 1:42 PM, Michael Schildt
<michael.schildt at ifn-magdeburg.de> 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)


John


More information about the CMake mailing list