2016-09-27 22:01:08 +03:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2013-10-15 19:17:36 +04:00
|
|
|
#.rst:
|
|
|
|
# FindDCMTK
|
|
|
|
# ---------
|
2016-01-13 18:53:03 +03:00
|
|
|
#
|
2016-01-12 23:44:10 +03:00
|
|
|
# Find DCMTK libraries and applications
|
2004-04-23 00:16:15 +04:00
|
|
|
#
|
2016-01-12 23:44:10 +03:00
|
|
|
# The module defines the following variables::
|
2016-01-12 00:08:56 +03:00
|
|
|
#
|
|
|
|
# DCMTK_INCLUDE_DIRS - Directories to include to use DCMTK
|
2005-12-14 21:51:08 +03:00
|
|
|
# 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
|
2004-04-23 00:16:15 +04:00
|
|
|
#
|
2016-01-13 18:53:03 +03:00
|
|
|
# Compatibility
|
|
|
|
# ^^^^^^^^^^^^^
|
2016-01-12 00:08:56 +03:00
|
|
|
#
|
2016-01-13 18:53:03 +03:00
|
|
|
# This module is able to find a version of DCMTK that does or does not export
|
|
|
|
# a *DCMTKConfig.cmake* file. It applies a two step process:
|
2016-01-12 23:44:10 +03:00
|
|
|
#
|
2016-01-13 18:53:03 +03:00
|
|
|
# * Step 1: Attempt to find DCMTK version providing a *DCMTKConfig.cmake* file.
|
|
|
|
# * Step 2: If step 1 failed, rely on *FindDCMTK.cmake* to set `DCMTK_*` variables details below.
|
2016-01-12 23:44:10 +03:00
|
|
|
#
|
2016-01-12 00:08:56 +03:00
|
|
|
#
|
2016-01-13 18:53:03 +03:00
|
|
|
# `Recent DCMTK
|
|
|
|
# <http://git.dcmtk.org/web?p=dcmtk.git;a=commit;h=662ae187c493c6b9a73dd5e3875372cebd0c11fe>`_
|
|
|
|
# provides a *DCMTKConfig.cmake* :manual:`package configuration file
|
|
|
|
# <cmake-packages(7)>`. To exclusively use the package configuration file
|
|
|
|
# (recommended when possible), pass the `NO_MODULE` option to
|
|
|
|
# :command:`find_package`. For example, `find_package(DCMTK NO_MODULE)`.
|
|
|
|
# This requires official DCMTK snapshot *3.6.1_20140617* or newer.
|
2016-01-12 00:08:56 +03:00
|
|
|
#
|
|
|
|
#
|
2016-01-13 18:53:03 +03:00
|
|
|
# Until all clients update to the more recent DCMTK, build systems will need
|
2016-01-12 00:08:56 +03:00
|
|
|
# to support different versions of DCMTK.
|
|
|
|
#
|
2016-01-13 18:53:03 +03:00
|
|
|
# On any given system, the following combinations of DCMTK versions could be
|
2016-01-12 00:08:56 +03:00
|
|
|
# considered:
|
|
|
|
#
|
2016-01-12 23:44:10 +03:00
|
|
|
# +--------+---------------------+-----------------------+-------------------+
|
|
|
|
# | | SYSTEM DCMTK | LOCAL DCMTK | Supported ? |
|
|
|
|
# +--------+---------------------+-----------------------+-------------------+
|
|
|
|
# | Case A | NA | [ ] DCMTKConfig | YES |
|
|
|
|
# +--------+---------------------+-----------------------+-------------------+
|
|
|
|
# | Case B | NA | [X] DCMTKConfig | YES |
|
|
|
|
# +--------+---------------------+-----------------------+-------------------+
|
|
|
|
# | Case C | [ ] DCMTKConfig | NA | YES |
|
|
|
|
# +--------+---------------------+-----------------------+-------------------+
|
|
|
|
# | Case D | [X] DCMTKConfig | NA | YES |
|
|
|
|
# +--------+---------------------+-----------------------+-------------------+
|
|
|
|
# | Case E | [ ] DCMTKConfig | [ ] DCMTKConfig | YES (*) |
|
|
|
|
# +--------+---------------------+-----------------------+-------------------+
|
|
|
|
# | Case F | [X] DCMTKConfig | [ ] DCMTKConfig | NO |
|
|
|
|
# +--------+---------------------+-----------------------+-------------------+
|
|
|
|
# | Case G | [ ] DCMTKConfig | [X] DCMTKConfig | YES |
|
|
|
|
# +--------+---------------------+-----------------------+-------------------+
|
|
|
|
# | Case H | [X] DCMTKConfig | [X] DCMTKConfig | YES |
|
|
|
|
# +--------+---------------------+-----------------------+-------------------+
|
2016-01-12 00:08:56 +03:00
|
|
|
#
|
|
|
|
# (*) See Troubleshooting section.
|
|
|
|
#
|
|
|
|
# Legend:
|
|
|
|
#
|
|
|
|
# NA ...............: Means that no System or Local DCMTK is available
|
|
|
|
#
|
|
|
|
# [ ] DCMTKConfig ..: Means that the version of DCMTK does NOT export a DCMTKConfig.cmake file.
|
|
|
|
#
|
|
|
|
# [X] DCMTKConfig ..: Means that the version of DCMTK exports a DCMTKConfig.cmake file.
|
|
|
|
#
|
|
|
|
#
|
2016-01-12 23:44:10 +03:00
|
|
|
# Troubleshooting
|
|
|
|
# ^^^^^^^^^^^^^^^
|
2016-01-12 00:08:56 +03:00
|
|
|
#
|
2016-01-12 23:44:10 +03:00
|
|
|
# What to do if my project finds a different version of DCMTK?
|
2016-01-12 00:08:56 +03:00
|
|
|
#
|
2016-01-13 18:53:03 +03:00
|
|
|
# Remove DCMTK entry from the CMake cache per :command:`find_package`
|
2016-01-12 23:44:10 +03:00
|
|
|
# documentation.
|
2016-01-13 18:53:03 +03:00
|
|
|
|
2004-04-23 00:16:15 +04:00
|
|
|
#
|
|
|
|
# Written for VXL by Amitha Perera.
|
2009-10-30 18:48:44 +03:00
|
|
|
# Upgraded for GDCM by Mathieu Malaterre.
|
2010-06-15 11:51:14 +04:00
|
|
|
# Modified for EasyViz by Thomas Sondergaard.
|
|
|
|
#
|
|
|
|
|
2016-01-12 00:08:56 +03:00
|
|
|
set(_dcmtk_dir_description "The directory of DCMTK build or install tree.")
|
|
|
|
|
|
|
|
# Ensure that DCMTK_DIR is set to a reasonable default value
|
|
|
|
# so that DCMTK libraries can be found on a standard Unix distribution.
|
|
|
|
# It also overwrite the value of DCMTK_DIR after this one has been
|
|
|
|
# set by a successful discovery of DCMTK by the unpatched FindDCMTK.cmake module
|
|
|
|
# distributed with CMake (as of 0167cea)
|
|
|
|
if(NOT DCMTK_DIR OR DCMTK_DIR STREQUAL "/usr/include/dcmtk")
|
|
|
|
set(DCMTK_DIR "/usr" CACHE PATH ${_dcmtk_dir_description} FORCE)
|
2010-06-15 11:51:14 +04:00
|
|
|
endif()
|
|
|
|
|
2016-01-12 00:08:56 +03:00
|
|
|
set(_SAVED_DCMTK_DIR ${DCMTK_DIR})
|
2010-06-15 11:51:14 +04:00
|
|
|
|
2016-01-12 00:08:56 +03:00
|
|
|
#
|
|
|
|
# Step1: Attempt to find a version of DCMTK providing a DCMTKConfig.cmake file.
|
|
|
|
#
|
2016-01-12 00:46:12 +03:00
|
|
|
if(NOT DCMTK_FIND_QUIETLY)
|
|
|
|
message(STATUS "Trying to find DCMTK expecting DCMTKConfig.cmake")
|
|
|
|
endif()
|
2016-01-12 00:08:56 +03:00
|
|
|
find_package(DCMTK QUIET NO_MODULE)
|
|
|
|
if(DCMTK_FOUND
|
|
|
|
AND NOT "x" STREQUAL "x${DCMTK_LIBRARIES}"
|
|
|
|
AND NOT "x" STREQUAL "x${DCMTK_INCLUDE_DIRS}")
|
2016-01-12 00:46:12 +03:00
|
|
|
|
|
|
|
if(NOT DCMTK_FIND_QUIETLY)
|
|
|
|
message(STATUS "Trying to find DCMTK expecting DCMTKConfig.cmake - ok")
|
|
|
|
endif()
|
2016-01-12 00:08:56 +03:00
|
|
|
return()
|
|
|
|
else()
|
2016-01-12 00:46:12 +03:00
|
|
|
if(NOT DCMTK_FIND_QUIETLY)
|
|
|
|
message(STATUS "Trying to find DCMTK expecting DCMTKConfig.cmake - failed")
|
|
|
|
endif()
|
2016-01-12 00:08:56 +03:00
|
|
|
endif()
|
|
|
|
|
2016-01-12 00:46:12 +03:00
|
|
|
if(NOT DCMTK_FIND_QUIETLY)
|
|
|
|
message(STATUS "Trying to find DCMTK relying on FindDCMTK.cmake")
|
|
|
|
endif()
|
2016-01-12 00:08:56 +03:00
|
|
|
|
|
|
|
# Restore the value reset by the previous call to 'find_package(DCMTK QUIET NO_MODULE)'
|
|
|
|
set(DCMTK_DIR ${_SAVED_DCMTK_DIR} CACHE PATH ${_dcmtk_dir_description} FORCE)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Step2: Attempt to find a version of DCMTK that does NOT provide a DCMTKConfig.cmake file.
|
|
|
|
#
|
|
|
|
|
|
|
|
# prefer DCMTK_DIR over default system paths like /usr/lib
|
|
|
|
if(DCMTK_DIR)
|
|
|
|
set(CMAKE_PREFIX_PATH ${DCMTK_DIR}/lib ${CMAKE_PREFIX_PATH}) # this is given to FIND_LIBRARY or FIND_PATH
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Find all libraries, store debug and release separately
|
2010-06-15 11:51:14 +04:00
|
|
|
foreach(lib
|
|
|
|
dcmpstat
|
|
|
|
dcmsr
|
2016-01-12 00:08:56 +03:00
|
|
|
dcmsign
|
2010-06-15 11:51:14 +04:00
|
|
|
dcmtls
|
2016-01-12 00:08:56 +03:00
|
|
|
dcmqrdb
|
|
|
|
dcmnet
|
|
|
|
dcmjpeg
|
|
|
|
dcmimage
|
|
|
|
dcmimgle
|
|
|
|
dcmdata
|
|
|
|
oflog
|
|
|
|
ofstd
|
2010-06-15 11:51:14 +04:00
|
|
|
ijg12
|
|
|
|
ijg16
|
|
|
|
ijg8
|
2016-01-12 00:08:56 +03:00
|
|
|
)
|
2010-06-15 11:51:14 +04:00
|
|
|
|
2016-01-12 00:08:56 +03:00
|
|
|
# Find Release libraries
|
|
|
|
find_library(DCMTK_${lib}_LIBRARY_RELEASE
|
2010-06-15 11:51:14 +04:00
|
|
|
${lib}
|
|
|
|
PATHS
|
|
|
|
${DCMTK_DIR}/${lib}/libsrc
|
|
|
|
${DCMTK_DIR}/${lib}/libsrc/Release
|
|
|
|
${DCMTK_DIR}/${lib}/Release
|
2016-01-12 00:08:56 +03:00
|
|
|
${DCMTK_DIR}/lib
|
|
|
|
${DCMTK_DIR}/lib/Release
|
|
|
|
${DCMTK_DIR}/dcmjpeg/lib${lib}/Release
|
|
|
|
NO_DEFAULT_PATH
|
|
|
|
)
|
|
|
|
|
|
|
|
# Find Debug libraries
|
|
|
|
find_library(DCMTK_${lib}_LIBRARY_DEBUG
|
|
|
|
${lib}${DCMTK_CMAKE_DEBUG_POSTFIX}
|
|
|
|
PATHS
|
|
|
|
${DCMTK_DIR}/${lib}/libsrc
|
|
|
|
${DCMTK_DIR}/${lib}/libsrc/Debug
|
2010-06-15 11:51:14 +04:00
|
|
|
${DCMTK_DIR}/${lib}/Debug
|
2016-01-12 00:08:56 +03:00
|
|
|
${DCMTK_DIR}/lib
|
|
|
|
${DCMTK_DIR}/lib/Debug
|
|
|
|
${DCMTK_DIR}/dcmjpeg/lib${lib}/Debug
|
|
|
|
NO_DEFAULT_PATH
|
|
|
|
)
|
|
|
|
|
|
|
|
mark_as_advanced(DCMTK_${lib}_LIBRARY_RELEASE)
|
|
|
|
mark_as_advanced(DCMTK_${lib}_LIBRARY_DEBUG)
|
2010-06-15 11:51:14 +04:00
|
|
|
|
2016-01-12 00:08:56 +03:00
|
|
|
# Add libraries to variable according to build type
|
|
|
|
if(DCMTK_${lib}_LIBRARY_RELEASE)
|
|
|
|
list(APPEND DCMTK_LIBRARIES optimized ${DCMTK_${lib}_LIBRARY_RELEASE})
|
|
|
|
endif()
|
2010-06-15 11:51:14 +04:00
|
|
|
|
2016-01-12 00:08:56 +03:00
|
|
|
if(DCMTK_${lib}_LIBRARY_DEBUG)
|
|
|
|
list(APPEND DCMTK_LIBRARIES debug ${DCMTK_${lib}_LIBRARY_DEBUG})
|
2010-06-15 11:51:14 +04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
endforeach()
|
|
|
|
|
2016-01-12 00:08:56 +03:00
|
|
|
set(CMAKE_THREAD_LIBS_INIT)
|
|
|
|
if(DCMTK_oflog_LIBRARY_RELEASE OR DCMTK_oflog_LIBRARY_DEBUG)
|
|
|
|
# Hack - Not having a DCMTKConfig.cmake file to read the settings from, we will attempt to
|
|
|
|
# find the library in all cases.
|
|
|
|
# Ideally, pthread library should be discovered only if DCMTK_WITH_THREADS is enabled.
|
|
|
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
|
|
|
find_package(Threads)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_THREAD_LIBS_INIT)
|
|
|
|
list(APPEND DCMTK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#
|
|
|
|
# SPECIFIC CASE FOR DCMTK BUILD DIR as DCMTK_DIR
|
|
|
|
# (as opposed to a DCMTK install dir)
|
|
|
|
# Have to find the source directory.
|
|
|
|
if(EXISTS ${DCMTK_DIR}/CMakeCache.txt)
|
|
|
|
load_cache(${DCMTK_DIR} READ_WITH_PREFIX "EXT"
|
|
|
|
DCMTK_SOURCE_DIR)
|
|
|
|
if(NOT EXISTS ${EXTDCMTK_SOURCE_DIR})
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"DCMTK build directory references
|
|
|
|
nonexistant DCMTK source directory ${EXTDCMTK_SOURCE_DIR}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2010-06-15 11:51:14 +04:00
|
|
|
|
|
|
|
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)
|
2016-01-12 00:08:56 +03:00
|
|
|
set(DCMTK_oflog_TEST_HEADER oflog.h)
|
|
|
|
set(DCMTK_dcmjpls_TEST_HEADER djlsutil.h)
|
|
|
|
|
|
|
|
set(DCMTK_INCLUDE_DIR_NAMES)
|
2010-06-15 11:51:14 +04:00
|
|
|
|
|
|
|
foreach(dir
|
|
|
|
config
|
|
|
|
dcmdata
|
|
|
|
dcmimage
|
|
|
|
dcmimgle
|
|
|
|
dcmjpeg
|
2016-01-12 00:08:56 +03:00
|
|
|
dcmjpls
|
2010-06-15 11:51:14 +04:00
|
|
|
dcmnet
|
|
|
|
dcmpstat
|
|
|
|
dcmqrdb
|
|
|
|
dcmsign
|
|
|
|
dcmsr
|
|
|
|
dcmtls
|
2016-01-12 00:08:56 +03:00
|
|
|
ofstd
|
|
|
|
oflog)
|
|
|
|
if(EXTDCMTK_SOURCE_DIR)
|
|
|
|
set(SOURCE_DIR_PATH
|
|
|
|
${EXTDCMTK_SOURCE_DIR}/${dir}/include/dcmtk/${dir})
|
|
|
|
endif()
|
2010-06-15 11:51:14 +04:00
|
|
|
find_path(DCMTK_${dir}_INCLUDE_DIR
|
|
|
|
${DCMTK_${dir}_TEST_HEADER}
|
|
|
|
PATHS
|
|
|
|
${DCMTK_DIR}/${dir}/include
|
|
|
|
${DCMTK_DIR}/${dir}
|
2011-08-09 23:13:46 +04:00
|
|
|
${DCMTK_DIR}/include/dcmtk/${dir}
|
|
|
|
${DCMTK_DIR}/${dir}/include/dcmtk/${dir}
|
2016-01-12 00:08:56 +03:00
|
|
|
${DCMTK_DIR}/include/${dir}
|
|
|
|
${SOURCE_DIR_PATH}
|
2011-08-09 23:13:46 +04:00
|
|
|
)
|
2010-06-15 11:51:14 +04:00
|
|
|
mark_as_advanced(DCMTK_${dir}_INCLUDE_DIR)
|
2016-01-12 00:08:56 +03:00
|
|
|
list(APPEND DCMTK_INCLUDE_DIR_NAMES DCMTK_${dir}_INCLUDE_DIR)
|
2010-06-15 11:51:14 +04:00
|
|
|
|
|
|
|
if(DCMTK_${dir}_INCLUDE_DIR)
|
2016-01-12 00:08:56 +03:00
|
|
|
# add the 'include' path so eg
|
|
|
|
#include "dcmtk/dcmimgle/dcmimage.h"
|
|
|
|
# works
|
|
|
|
get_filename_component(_include ${DCMTK_${dir}_INCLUDE_DIR} PATH)
|
|
|
|
get_filename_component(_include ${_include} PATH)
|
2010-06-15 11:51:14 +04:00
|
|
|
list(APPEND
|
|
|
|
DCMTK_INCLUDE_DIRS
|
2016-01-12 00:08:56 +03:00
|
|
|
${DCMTK_${dir}_INCLUDE_DIR}
|
|
|
|
${_include})
|
2010-06-15 11:51:14 +04:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2016-01-12 00:08:56 +03:00
|
|
|
list(APPEND DCMTK_INCLUDE_DIRS ${DCMTK_DIR}/include)
|
|
|
|
|
2010-06-15 11:51:14 +04:00
|
|
|
if(WIN32)
|
|
|
|
list(APPEND DCMTK_LIBRARIES netapi32 wsock32)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DCMTK_ofstd_INCLUDE_DIR)
|
|
|
|
get_filename_component(DCMTK_dcmtk_INCLUDE_DIR
|
2004-04-23 00:16:15 +04:00
|
|
|
${DCMTK_ofstd_INCLUDE_DIR}
|
2010-06-15 11:51:14 +04:00
|
|
|
PATH
|
|
|
|
CACHE)
|
|
|
|
list(APPEND DCMTK_INCLUDE_DIRS ${DCMTK_dcmtk_INCLUDE_DIR})
|
|
|
|
mark_as_advanced(DCMTK_dcmtk_INCLUDE_DIR)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Compatibility: This variable is deprecated
|
|
|
|
set(DCMTK_INCLUDE_DIR ${DCMTK_INCLUDE_DIRS})
|
2009-10-30 18:48:44 +03:00
|
|
|
|
2016-01-12 00:08:56 +03:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(DCMTK
|
|
|
|
REQUIRED_VARS ${DCMTK_INCLUDE_DIR_NAMES} DCMTK_LIBRARIES
|
|
|
|
FAIL_MESSAGE "Please set DCMTK_DIR and re-run configure")
|
|
|
|
|
|
|
|
# Workaround bug in packaging of DCMTK 3.6.0 on Debian.
|
|
|
|
# See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=637687
|
|
|
|
if(DCMTK_FOUND AND UNIX AND NOT APPLE)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS )
|
|
|
|
set(CMAKE_REQUIRED_DEFINITIONS )
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${DCMTK_INCLUDE_DIRS})
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${DCMTK_LIBRARIES})
|
2016-01-12 00:46:12 +03:00
|
|
|
set(CMAKE_REQUIRED_QUIET ${DCMTK_FIND_QUIETLY})
|
2016-01-12 00:08:56 +03:00
|
|
|
check_cxx_source_compiles("#include <dcmtk/config/osconfig.h>\n#include <dcmtk/ofstd/ofstream.h>\nint main(int,char*[]){return 0;}"
|
|
|
|
DCMTK_HAVE_CONFIG_H_OPTIONAL
|
|
|
|
)
|
|
|
|
if(NOT DCMTK_HAVE_CONFIG_H_OPTIONAL)
|
|
|
|
set(DCMTK_DEFINITIONS "HAVE_CONFIG_H")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-01-12 00:46:12 +03:00
|
|
|
if(NOT DCMTK_FIND_QUIETLY)
|
|
|
|
message(STATUS "Trying to find DCMTK relying on FindDCMTK.cmake - ok")
|
|
|
|
endif()
|