Install Debug and Release at the same time?

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
A. Haferburg
Posts: 4
Joined: Mon, 2011-03-21, 14:33

Install Debug and Release at the same time?

#1 Post by A. Haferburg »

Hello,
we need both a Debug and Release version of the DCMTK libraries. Otherwise, when trying to link our Debug build against a Release version of the DCMTK we get the linker error LNK2038 (_ITERATOR_DEBUG_LEVEL conflict). However, when we build the DCMTK in either Debug or Release, the INSTALL target of one configuration simply overwrites the installation of the other configuration. We would have expected INSTALL to copy the debug .libs to either Debug/*.lib or to *d.lib, but it simply overwrites everything.

Ultimately, we just want to link our application. If there's a way to link DCMTK Release against our Debug that would be great. If not, how do we install the Debug and Release configurations at the same time?

Edit: Btw we're on Windows 7 using VS10, CMake 2.8.3, and DCMTK 3.6.0.
Edit2: The best workaround we found so far is to set install prefix := build directory. But we would obviously prefer to keep both directories separate.
Last edited by A. Haferburg on Mon, 2011-03-21, 15:54, edited 1 time in total.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

What about using different installation directories (change "CMAKE_INSTALL_PREFIX" in CMake)?

A. Haferburg
Posts: 4
Joined: Mon, 2011-03-21, 14:33

#3 Post by A. Haferburg »

In that case the FindDCMTK.cmake script finds only one of the installations. There's only one DCMTK_DIR.

A. Haferburg
Posts: 4
Joined: Mon, 2011-03-21, 14:33

#4 Post by A. Haferburg »

I found a similar post here. I've modified the root CMakeLists.txt to add two variables, DCMTK_WITH_DEBUG_POSTFIX to solve our problem, and DCMTK_LINK_AGAINST_DLL (Windows only) to address FAQ #26. Maybe you could include these modifications in the next release.

I've also "attached" the modified FindDCMTK.cmake script we use. Maybe it's useful to someone.

Thank you,
Andreas

CMakeLists.txt

Code: Select all

# Declare project
PROJECT(DCMTK)

# Minimum CMake version required
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
IF(CMAKE_BACKWARDS_COMPATIBILITY GREATER 2.8.3)
  SET(CMAKE_BACKWARDS_COMPATIBILITY 2.8.3 CACHE STRING "Latest version of CMake when this project was released." FORCE)
ENDIF(CMAKE_BACKWARDS_COMPATIBILITY GREATER 2.8.3)

#-----------------------------------------------------------------------------
# General project settings to configure DCMTK build process
#-----------------------------------------------------------------------------

# Modules to be built (default: build all public modules)
SET(DCMTK_MODULES config ofstd oflog dcmdata dcmimgle dcmjpeg dcmimage dcmtls dcmnet dcmwlm dcmqrdb dcmsr dcmpstat dcmsign dcmjpls doxygen)
# Add non-public modules
#SET(DCMTK_MODULES ${DCMTK_MODULES} dcmdbsup dcmwlmxl dcmpps dcmppswm dcmjp2k dcmloco dcmqrdbx dcmcheck dcmprint dcmprscp dcmavi dcmmisc dcmppscu dcmstcom dcmrt dcmwave dcmeval)

# Package "release" settings (some are currently unused)
SET(DCMTK_PACKAGE_NAME "dcmtk")
SET(DCMTK_PACKAGE_DATE "2011-01-06")
#SET(DCMTK_PACKAGE_TARNAME "dcmtk-3.6.0")
SET(DCMTK_PACKAGE_VERSION "3.6.0")
SET(DCMTK_PACKAGE_VERSION_NUMBER "360")
SET(DCMTK_PACKAGE_VERSION_SUFFIX "")
#SET(DCMTK_PACKAGE_STRING "dcmtk 3.6.0")
#SET(DCMTK_PACKAGE_BUGREPORT "dicom-bugs@offis.de")

# DCMTK build options
OPTION(DCMTK_WITH_TIFF "Configure DCMTK with support for TIFF" ON)
OPTION(DCMTK_WITH_PNG "Configure DCMTK with support for PNG" ON)
OPTION(DCMTK_WITH_XML "Configure DCMTK with support for XML" OFF)
OPTION(DCMTK_WITH_ZLIB "Configure DCMTK with support for ZLIB" ON)
OPTION(DCMTK_WITH_OPENSSL "Configure DCMTK with support for OPENSSL" OFF)
OPTION(DCMTK_WITH_SNDFILE "Configure DCMTK with support for SNDFILE" OFF)
MARK_AS_ADVANCED(SNDFILE_DIR DCMTK_WITH_SNDFILE) # not yet needed in public DCMTK
OPTION(DCMTK_WITH_PRIVATE_TAGS "Configure DCMTK with support for DICOM private tags coming with DCMTK" OFF)
OPTION(DCMTK_WITH_THREADS "Configure DCMTK with support for multi-threading" ON)
OPTION(DCMTK_WITH_DOXYGEN "Build API documentation with doxygen" ON)
OPTION(DCMTK_WITH_DEBUG_POSTFIX "Use postfix 'd' for debug libraries (e.g. Release dcmsr.lib, Debug dcmsrd.lib)" ON)

IF(DCMTK_WITH_DEBUG_POSTFIX)
  SET(CMAKE_DEBUG_POSTFIX  "d")
ENDIF(DCMTK_WITH_DEBUG_POSTFIX)


#SET(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})

#-----------------------------------------------------------------------------
# Include directories
#-----------------------------------------------------------------------------

SET(DCMTK_INCLUDE_DIR
  ${DCMTK_BINARY_DIR}/include
  #${DCMTK_SOURCE_DIR}/config/include
  ${DCMTK_SOURCE_DIR}/ofstd/include
  ${DCMTK_SOURCE_DIR}/oflog/include
  ${DCMTK_SOURCE_DIR}/dcmdata/include
  ${DCMTK_SOURCE_DIR}/dcmimgle/include
  ${DCMTK_SOURCE_DIR}/dcmimage/include
  ${DCMTK_SOURCE_DIR}/dcmjpeg/libijg8
  ${DCMTK_SOURCE_DIR}/dcmjpeg/libijg12
  ${DCMTK_SOURCE_DIR}/dcmjpeg/libijg16
  ${DCMTK_SOURCE_DIR}/dcmjpeg/include
  ${DCMTK_SOURCE_DIR}/dcmjpls/include
  ${DCMTK_SOURCE_DIR}/dcmnet/include
  ${DCMTK_SOURCE_DIR}/dcmpstat/include
  ${DCMTK_SOURCE_DIR}/dcmqrdb/include
  ${DCMTK_SOURCE_DIR}/dcmsign/include
  ${DCMTK_SOURCE_DIR}/dcmsr/include
  ${DCMTK_SOURCE_DIR}/dcmtls/include
  ${DCMTK_SOURCE_DIR}/dcmwlm/include
)
INCLUDE_DIRECTORIES(${DCMTK_INCLUDE_DIR})

#-----------------------------------------------------------------------------
# Installation sub-directories
#-----------------------------------------------------------------------------

SET(INSTALL_BINDIR "/bin")
SET(INSTALL_INCDIR "/include")
SET(INSTALL_LIBDIR "/lib")
SET(INSTALL_ETCDIR "/etc/dcmtk")
SET(INSTALL_DATDIR "/share/dcmtk")
SET(INSTALL_DOCDIR "/share/doc/dcmtk")
SET(INSTALL_HTMDIR "/share/doc/dcmtk/html")
SET(INSTALL_MANDIR "/share/man")

#-----------------------------------------------------------------------------
# Platform-independent settings
#-----------------------------------------------------------------------------

IF(COMMAND CMAKE_POLICY)
  # Enable new CMake behaviour when dealing with libraries whose full path is
  # given to the linker. This is necessary to avoid warnings in CMake versions
  # greater than 2.6.
  # See http://www.cmake.org/cmake/help/cmake-2.6.html#policy:CMP0003
  CMAKE_POLICY(SET CMP0003 NEW)

  # Works around warnings about escaped quotes in ADD_DEFINITIONS statements
  CMAKE_POLICY(SET CMP0005 OLD)
ENDIF(COMMAND CMAKE_POLICY)

# pass optional build date to compiler
#ADD_DEFINITIONS("-DDCMTK_BUILD_DATE=\\\"YYYY-MM-DD\\\"")

# make OFString(NULL) safe by default
ADD_DEFINITIONS("-DUSE_NULL_SAFE_OFSTRING")

#-----------------------------------------------------------------------------
# Platform-specific settings
#-----------------------------------------------------------------------------

# set project wide flags for compiler and linker

IF(WIN32)
  OPTION(DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS "Overwrite compiler flags with DCMTK's WIN32 package default values." ON)
  OPTION(DCMTK_LINK_AGAINST_DLL "Link dynamically instead of statically against CRT (Compile with /MD[d] flag instead of /MT[d])" ON)
ENDIF(WIN32)

IF(DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS)
  IF(DCMTK_LINK_DLL)
    SET(DCMTK_CRT_FLAG_DEBUG "/MTd")
    SET(DCMTK_CRT_FLAG "/MT")
  ELSE(DCMTK_LINK_DLL)
    SET(DCMTK_CRT_FLAG_DEBUG "/MDd")
    SET(DCMTK_CRT_FLAG "/MD")
  ENDIF(DCMTK_LINK_DLL)

  # settings for Microsoft Visual C
  IF(CMAKE_C_COMPILER MATCHES "CL|cl")
    IF(NOT WITH_SHARED_LIBS)
      IF(CMAKE_GENERATOR STREQUAL "Visual Studio 6")
        SET(CMAKE_C_FLAGS "/nologo /W3 /GX /Gy /YX")
        SET(CMAKE_C_FLAGS_DEBUG "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
        SET(CMAKE_C_FLAGS_RELEASE "${DCMTK_CRT_FLAG} /O2")
        SET(CMAKE_C_FLAGS_MINSIZEREL "${DCMTK_CRT_FLAG} /O2")
        SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
      ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 6")
      IF(CMAKE_GENERATOR STREQUAL "Visual Studio 7" OR CMAKE_GENERATOR STREQUAL "Visual Studio 7 .NET 2003")
        SET(CMAKE_C_FLAGS "/nologo /W3 /Gy")
        SET(CMAKE_C_FLAGS_DEBUG "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
        SET(CMAKE_C_FLAGS_RELEASE "${DCMTK_CRT_FLAG} /O2")
        SET(CMAKE_C_FLAGS_MINSIZEREL "${DCMTK_CRT_FLAG} /O2")
        SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
      ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 7" OR CMAKE_GENERATOR STREQUAL "Visual Studio 7 .NET 2003")
      IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008" OR CMAKE_GENERATOR STREQUAL "Visual Studio 10")
        SET(CMAKE_C_FLAGS "/nologo /W3 /Gy /EHsc")
	SET(CMAKE_C_FLAGS_DEBUG "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
	SET(CMAKE_C_FLAGS_RELEASE "${DCMTK_CRT_FLAG} /O2")
	SET(CMAKE_C_FLAGS_MINSIZEREL "${DCMTK_CRT_FLAG} /O2")
	SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
      ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008" OR CMAKE_GENERATOR STREQUAL "Visual Studio 10")
    ENDIF(NOT WITH_SHARED_LIBS)
  ENDIF(CMAKE_C_COMPILER MATCHES "CL|cl")

  # settings for Microsoft Visual C++
  IF(CMAKE_CXX_COMPILER MATCHES "CL|cl")
    IF(NOT WITH_SHARED_LIBS)
      IF(CMAKE_GENERATOR STREQUAL "Visual Studio 6")
        SET(CMAKE_CXX_FLAGS "/nologo /W3 /GX /Gy /YX /Zm500") # /Zm500 increments heap size which is needed on some system to compile templates in dcmimgle
        SET(CMAKE_CXX_FLAGS_DEBUG "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
        SET(CMAKE_CXX_FLAGS_RELEASE "${DCMTK_CRT_FLAG} /O2")
        SET(CMAKE_CXX_FLAGS_MINSIZEREL "${DCMTK_CRT_FLAG} /O2")
        SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
      ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 6")
      IF(CMAKE_GENERATOR STREQUAL "Visual Studio 7" OR CMAKE_GENERATOR STREQUAL "Visual Studio 7 .NET 2003")
        SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy")
        SET(CMAKE_CXX_FLAGS_DEBUG "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
        SET(CMAKE_CXX_FLAGS_RELEASE "${DCMTK_CRT_FLAG} /O2")
        SET(CMAKE_CXX_FLAGS_MINSIZEREL "${DCMTK_CRT_FLAG} /O2")
        SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
      ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 7" OR CMAKE_GENERATOR STREQUAL "Visual Studio 7 .NET 2003")
      IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008" OR CMAKE_GENERATOR STREQUAL "Visual Studio 10")
        SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy /EHsc")
	SET(CMAKE_CXX_FLAGS_DEBUG "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
	SET(CMAKE_CXX_FLAGS_RELEASE "${DCMTK_CRT_FLAG} /O2")
	SET(CMAKE_CXX_FLAGS_MINSIZEREL "${DCMTK_CRT_FLAG} /O2")
	SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${DCMTK_CRT_FLAG_DEBUG} /Z7 /Od")
      ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008" OR CMAKE_GENERATOR STREQUAL "Visual Studio 10")
    ENDIF(NOT WITH_SHARED_LIBS)
  ENDIF(CMAKE_CXX_COMPILER MATCHES "CL|cl")

  # settings for Borland C++
  IF(CMAKE_CXX_COMPILER MATCHES "BCC32|bcc32")
    # further settings required?
    SET(CMAKE_STANDARD_LIBRARIES "import32.lib cw32mt.lib")
  ENDIF(CMAKE_CXX_COMPILER MATCHES "BCC32|bcc32")

ENDIF(DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS)

IF(WIN32)   # special handling for Windows systems

  IF(MINGW)
    # Avoid auto-importing warnings on MinGW
    SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--enable-auto-import")
  ELSE(MINGW)
    # On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security warnings.
    IF(NOT BORLAND)
      IF(NOT CYGWIN)
        IF(NOT DCMTK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
          ADD_DEFINITIONS(
            -D_CRT_FAR_MAPPINGS_NO_DEPRECATE
            -D_CRT_IS_WCTYPE_NO_DEPRECATE
            -D_CRT_MANAGED_FP_NO_DEPRECATE
            -D_CRT_NONSTDC_NO_DEPRECATE
            -D_CRT_SECURE_NO_DEPRECATE
            -D_CRT_SECURE_NO_DEPRECATE_GLOBALS
            -D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
            -D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
            -D_CRT_VCCLRIT_NO_DEPRECATE
            -D_SCL_SECURE_NO_DEPRECATE
            )
        ENDIF(NOT DCMTK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
      ENDIF(NOT CYGWIN)
    ENDIF(NOT BORLAND)
  ENDIF(MINGW)

ELSE(WIN32)   # ... for non-Windows systems

  # Compiler flags for Mac OS X
  IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_DARWIN_C_SOURCE")
    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_DARWIN_C_SOURCE")
  ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    # FreeBSD fails with these flags
    IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
      # Compiler flags for all other non-Windows systems
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L")
      SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L")
    ENDIF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
  ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

ENDIF(WIN32)

# define libraries that must be linked to most Windows applications
IF(WIN32)
  SET(WIN32_STD_LIBRARIES ws2_32 netapi32 wsock32)
  # settings for Borland C++
  IF(CMAKE_CXX_COMPILER MATCHES bcc32)
    # to be checked: further settings required?
    SET(CMAKE_STANDARD_LIBRARIES "import32.lib cw32mt.lib")
  ENDIF(CMAKE_CXX_COMPILER MATCHES bcc32)
ENDIF(WIN32)

# add definition of "DEBUG" to debug mode (since CMake does not do this automatically)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")

#-----------------------------------------------------------------------------
# Third party libraries
#-----------------------------------------------------------------------------

INCLUDE(CMake/3rdparty.cmake)

#-----------------------------------------------------------------------------
# Prepare osconfig.h
#-----------------------------------------------------------------------------

# add the osconfig.h.in file
INCLUDE(${DCMTK_SOURCE_DIR}/CMake/GenerateDCMTKConfigure.cmake)
CONFIGURE_FILE(${DCMTK_SOURCE_DIR}/CMake/osconfig.h.in
               ${DCMTK_BINARY_DIR}/include/dcmtk/config/osconfig.h)

#-----------------------------------------------------------------------------
# Dart configuration (disabled per default)
#-----------------------------------------------------------------------------

# Includes build targets Experimental, Nightly and Continous which are the standard
# groups pre-configured in Dashboard. In CTest these groups are called "Tracks".
#
# INCLUDE(${CMAKE_ROOT}/Modules/Dart.cmake)
# IF(BUILD_TESTING)
#   ENABLE_TESTING()
# ENDIF(BUILD_TESTING)

#-----------------------------------------------------------------------------
# Thread support
#-----------------------------------------------------------------------------

# See dcmtk/config/configure.in
IF(WITH_THREADS)
  ADD_DEFINITIONS(-D_REENTRANT)
  IF(HAVE_PTHREAD_RWLOCK)
    IF(APPLE)
      ADD_DEFINITIONS(-D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE)
    ENDIF(APPLE)
    IF("${CMAKE_SYSTEM_NAME}" MATCHES "^IRIX")
      ADD_DEFINITIONS(-D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT)
    ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES "^IRIX")
  ENDIF(HAVE_PTHREAD_RWLOCK)

  IF(HAVE_PTHREAD_H)
    CHECK_LIBRARY_EXISTS(pthread pthread_key_create "" HAVE_LIBPTHREAD)
    IF(HAVE_LIBPTHREAD)
      SET(THREAD_LIBS pthread)
    ENDIF(HAVE_LIBPTHREAD)
    CHECK_LIBRARY_EXISTS(rt sem_init "" HAVE_LIBRT)
    IF(HAVE_LIBRT)
      SET(THREAD_LIBS ${THREAD_LIBS} rt)
    ENDIF(HAVE_LIBRT)
  ENDIF(HAVE_PTHREAD_H)
ENDIF(WITH_THREADS)

#-----------------------------------------------------------------------------
# Start actual compilation tasks
#-----------------------------------------------------------------------------

# Recurse into subdirectories
FOREACH(module ${DCMTK_MODULES})
  ADD_SUBDIRECTORY(${module})
ENDFOREACH(module)

#-----------------------------------------------------------------------------
# Installation tasks
#-----------------------------------------------------------------------------

# Install global headers
INSTALL_FILES(${INSTALL_INCDIR}/dcmtk/config FILES ${CMAKE_CURRENT_BINARY_DIR}/include/dcmtk/config/osconfig.h)

# Install DCMTK's general documentation files
INSTALL_FILES(${INSTALL_DOCDIR} FILES ANNOUNCE.${DCMTK_PACKAGE_VERSION_NUMBER} CHANGES.${DCMTK_PACKAGE_VERSION_NUMBER} COPYRIGHT FAQ HISTORY VERSION)
FindDCMTK.cmake

Code: Select all

# - find DCMTK libraries and applications
#
#
#  DCMTK_INCLUDE_DIRS   - Directories to include to use DCMTK
#  DCMTK_LIBRARIES     - Files to link against to use DCMTK
#  DCMTK_FOUND         - If false, don't try to use DCMTK
#  DCMTK_DIR           - (optional) Source directory for DCMTK
#
# DCMTK_DIR can be used to make it simpler to find the various include
# directories and compiled libraries if you've just compiled it in the
# source tree. Just set it to the root of the tree where you extracted
# the source (default to /usr/include/dcmtk/)

#=============================================================================
# Copyright 2004-2009 Kitware, Inc.
# Copyright 2009-2010 Mathieu Malaterre <mathieu.malaterre@gmail.com>
# Copyright 2010 Thomas Sondergaard <ts@medical-insight.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
#  License text for the above reference.)

#
# Written for VXL by Amitha Perera.
# Upgraded for GDCM by Mathieu Malaterre.
# Modified for EasyViz by Thomas Sondergaard.
#

if(NOT DCMTK_DIR)
  set(DCMTK_DIR
    "C:/dev/lib/vs10/dcmtk-3.6.0-VS10"
    CACHE
    PATH
    "Root of DCMTK source tree (optional).")
endif()


foreach(lib
    dcmdata
    dcmimage
    dcmimgle
    dcmjpeg
    dcmnet
    dcmpstat
    dcmqrdb
    dcmsign
    dcmsr
    dcmtls
    ijg12
    ijg16
    ijg8
    ofstd
	 oflog)

  find_library(DCMTK_${lib}_LIBRARY
    ${lib}
    PATHS
    ${DCMTK_DIR}/${lib}/libsrc
    ${DCMTK_DIR}/${lib}/libsrc/Release
    ${DCMTK_DIR}/${lib}/Release
    ${DCMTK_DIR}/lib
    ${DCMTK_DIR}/dcmjpeg/lib${lib}/Release)

  mark_as_advanced(DCMTK_${lib}_LIBRARY)

  if(DCMTK_${lib}_LIBRARY)
    list(APPEND DCMTK_LIBRARIES ${DCMTK_${lib}_LIBRARY})
  endif()
  
  find_library(DCMTK_${lib}_LIBRARY_DEBUG
    # Try suffixes first
    NAMES ${lib}d ${lib}_d ${lib}
    PATHS
    ${DCMTK_DIR}/${lib}/libsrc
    ${DCMTK_DIR}/${lib}/libsrc/Debug
    ${DCMTK_DIR}/${lib}/Debug
    ${DCMTK_DIR}/lib
    ${DCMTK_DIR}/dcmjpeg/lib${lib}/Debug)

  mark_as_advanced(DCMTK_${lib}_LIBRARY_DEBUG)

  if(DCMTK_${lib}_LIBRARY_DEBUG)
    list(APPEND DCMTK_LIBRARIES_DEBUG ${DCMTK_${lib}_LIBRARY_DEBUG})
  endif()

endforeach()


set(DCMTK_config_TEST_HEADER osconfig.h)
set(DCMTK_dcmdata_TEST_HEADER dctypes.h)
set(DCMTK_dcmimage_TEST_HEADER dicoimg.h)
set(DCMTK_dcmimgle_TEST_HEADER dcmimage.h)
set(DCMTK_dcmjpeg_TEST_HEADER djdecode.h)
set(DCMTK_dcmnet_TEST_HEADER assoc.h)
set(DCMTK_dcmpstat_TEST_HEADER dcmpstat.h)
set(DCMTK_dcmqrdb_TEST_HEADER dcmqrdba.h)
set(DCMTK_dcmsign_TEST_HEADER sicert.h)
set(DCMTK_dcmsr_TEST_HEADER dsrtree.h)
set(DCMTK_dcmtls_TEST_HEADER tlslayer.h)
set(DCMTK_ofstd_TEST_HEADER ofstdinc.h)
set(DCMTK_oflog_TEST_HEADER oflog.h)

foreach(dir
    config
    dcmdata
    dcmimage
    dcmimgle
    dcmjpeg
    dcmnet
    dcmpstat
    dcmqrdb
    dcmsign
    dcmsr
    dcmtls
    ofstd
	 oflog)
  find_path(DCMTK_${dir}_INCLUDE_DIR
    ${DCMTK_${dir}_TEST_HEADER}
    PATHS
    ${DCMTK_DIR}/${dir}/include
    ${DCMTK_DIR}/${dir}
    ${DCMTK_DIR}/include/${dir}
    ${DCMTK_DIR}/include/dcmtk/${dir})

  mark_as_advanced(DCMTK_${dir}_INCLUDE_DIR)

  if(DCMTK_${dir}_INCLUDE_DIR)
    list(APPEND
      DCMTK_INCLUDE_DIRS
      ${DCMTK_${dir}_INCLUDE_DIR})
  endif()
endforeach()

if(WIN32)
  list(APPEND DCMTK_LIBRARIES netapi32 wsock32)
endif()

if(DCMTK_ofstd_INCLUDE_DIR)
  get_filename_component(DCMTK_dcmtk_INCLUDE_DIR
    ${DCMTK_ofstd_INCLUDE_DIR}
    PATH
    CACHE)
  list(APPEND DCMTK_INCLUDE_DIRS ${DCMTK_dcmtk_INCLUDE_DIR})
  mark_as_advanced(DCMTK_dcmtk_INCLUDE_DIR)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DCMTK DEFAULT_MSG
  DCMTK_config_INCLUDE_DIR
  DCMTK_ofstd_INCLUDE_DIR
  DCMTK_ofstd_LIBRARY
  DCMTK_dcmdata_INCLUDE_DIR
  DCMTK_dcmdata_LIBRARY
  DCMTK_dcmimgle_INCLUDE_DIR
  DCMTK_dcmimgle_LIBRARY)

# Compatibility: This variable is deprecated
set(DCMTK_INCLUDE_DIR ${DCMTK_INCLUDE_DIRS})

foreach(executable dcmdump dcmdjpeg dcmdrle)
  string(TOUPPER ${executable} EXECUTABLE)
  find_program(DCMTK_${EXECUTABLE}_EXECUTABLE ${executable} ${DCMTK_DIR}/bin)
  mark_as_advanced(DCMTK_${EXECUTABLE}_EXECUTABLE)
endforeach()

Michael Onken
DCMTK Developer
Posts: 2049
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#5 Post by Michael Onken »

Hi,

as far as I can see there is no solution to your problem so far, taking into account our current CMake setup and the FindDCMTK script coming with CMake.

So, I would do a combination (as necessary) of the following:

Compile and install DCMTK with different INSTALL_PREFIXes, one for debug one for release. This should be also scriptable, by the way. Even compiling should be possible using NMake Makefiles without the need starting the Visual Studio GUI. Of course this makes only sense if you update your DCMTK installation very often which I do not expect.

Then, for your own application do _not_ use the FindDCMTK script from CMake but set DCMTK_DIR yourself. Either you have to do that manually each time you change your build target (debug versus release) or you use a little script for that which can be automatically started from your CMakeLIsts.txt files. Alternatively, you can change the CMakeLists.txt for your application to consider two variables DCMTK_DIR_DEBUG and DCMTK_DIR_RELEASE, but I wouldnt like that too much.

Please note that CMake's FindDCMTK script is currently insufficient at all, since it does not consider oflog and there might be other issues. You may be interested in the custom FindDCMTK scriptthat is used on the CTK project. It also takes into account that there might be installation structures like dcmdata\libsrc\Debug (however, finds only a single version, too).

I think there are also possibilities foreseen to let CMake do the work of appending _d to debug build libraries (which is what you also requested). We will add this (or other possibilities to solve your problem) to our internal TODO list and look to solve it in a cross-plaform way as time permits.


Best regards,
Michael

A. Haferburg
Posts: 4
Joined: Mon, 2011-03-21, 14:33

#6 Post by A. Haferburg »

Hi Micheal, thank you for your reply. It appears we cross-posted. CMake does provide a way to append a suffix to debug libraries, and I added it to your CMakeLists.txt, see above.

I also suggest that you try to maintain the FindDCMTK.cmake script, considering that you also maintain the INSTALL. I'm sure the CMake guys would be happy about it.

Michael Onken
DCMTK Developer
Posts: 2049
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#7 Post by Michael Onken »

Hi Andreas,

yes, we should maintain or at least have an eye on the FindDCMTK script since it seems to be actually used by several people. It is more a question of time/priorities than will ;) But we'll try. Thanks for the your contributing the script!

Best regards,
Michael

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#8 Post by Jörg Riesmeier »

We've now added support for both CMAKE_DEBUG_POSTFIX and configurable installation sub-directories (see git repository).

Chung-Yueh Lien
Posts: 61
Joined: Wed, 2010-05-19, 09:27
Location: Taipei, Taiwan

#9 Post by Chung-Yueh Lien »

Hi,

In VS, Build-->configure management, you can build both debug and release libraries separately. It is not necessary to change cmakelist.txt.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest