Quellcode durchsuchen

FindDCMTK - Do not explicitly set DCMTK_DEFINITIONS

Following commit commontk/CTK@12c052 fixing a packaging Debian bug,
the DCMTK_DEFINITIONS was set directly inside the FindDCMTK.cmake
module using "add_definitions".

When used outside of this project, setting automatically the definition
could have some unintended effects. For example, by globally adding
DCMTK_DEFINITIONS (and more specifically HAVE_CONFIG_H), it prevented from
compiling successfully program against the "tclap" library. Compile errors
like the following occurred:

// ------------------
In file included from <DIR>/SlicerExecutionModel/tclap/include/tclap/CmdLine.h:27:0,
                 from <DIR>/Slicer-build/Modules/CLI/CheckerBoardFilter/CheckerBoardFilterCLP.h:13,
                 from <SRC>/Modules/CLI/CheckerBoardFilter/CheckerBoardFilter.cxx:23:
<DIR>/SlicerExecutionModel/tclap/include/tclap/MultiSwitchArg.h:44:2: error: #error "Need a stringstream (sstream or strstream) to compile!"
 #error "Need a stringstream (sstream or strstream) to compile!"
  ^
<DIR>/SlicerExecutionModel/tclap/include/tclap/MultiSwitchArg.h:171:2: error: #error "Need a stringstream (sstream or strstream) to compile!"
 #error "Need a stringstream (sstream or strstream) to compile!"
  ^
In file included from <DIR>/SlicerExecutionModel/tclap/include/tclap/UnlabeledValueArg.h:30:0,
                 from <DIR>/SlicerExecutionModel/tclap/include/tclap/CmdLine.h:28,
                 from <DIR>/Slicer-build/Modules/CLI/CheckerBoardFilter/CheckerBoardFilterCLP.h:13,
                 from <SRC>/Modules/CLI/CheckerBoardFilter/CheckerBoardFilter.cxx:23:
<DIR>/SlicerExecutionModel/tclap/include/tclap/ValueArg.h:43:2: error: #error "Need a stringstream (sstream or strstream) to compile!"
 #error "Need a stringstream (sstream or strstream) to compile!"
  ^
<DIR>/SlicerExecutionModel/tclap/include/tclap/ValueArg.h:97:2: error: #error "Need a stringstream (sstream or strstream) to compile!"
 #error "Need a stringstream (sstream or strstream) to compile!"
  ^
// ------------------

See #382
Jean-Christophe Fillion-Robin vor 11 Jahren
Ursprung
Commit
9fc69917f5
1 geänderte Dateien mit 1 neuen und 8 gelöschten Zeilen
  1. 1 8
      Utilities/CMake/FindDCMTK.cmake

+ 1 - 8
Utilities/CMake/FindDCMTK.cmake

@@ -329,10 +329,6 @@ find_package_handle_standard_args(DCMTK
 
 # Workaround bug in packaging of DCMTK 3.6.0 on Debian.
 # See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=637687
-#
-# By setting 'DCMTK_FIND_PACKAGE_SKIP_ADD_DEFINITIONS' to '1' before
-# calling 'find_package(DCMTK)', the variable 'DCMTK_DEFINITIONS' will be set
-# appropriately.
 if(DCMTK_FOUND AND UNIX AND NOT APPLE)
   include(CheckCXXSourceCompiles)
   set(CMAKE_REQUIRED_FLAGS )
@@ -343,10 +339,7 @@ if(DCMTK_FOUND AND UNIX AND NOT APPLE)
     DCMTK_HAVE_CONFIG_H_OPTIONAL
     )
   if(NOT DCMTK_HAVE_CONFIG_H_OPTIONAL)
-    set(DCMTK_DEFINITIONS "-DHAVE_CONFIG_H")
-  endif()
-  if(NOT DCMTK_HAVE_CONFIG_H_OPTIONAL AND NOT DCMTK_FIND_PACKAGE_SKIP_ADD_DEFINITIONS)
-    add_definitions(${DCMTK_DEFINITIONS})
+    set(DCMTK_DEFINITIONS "HAVE_CONFIG_H")
   endif()
 endif()