Using DCMTK from CMakeLists.txt

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
afe
Posts: 11
Joined: Mon, 2012-02-13, 20:31

Using DCMTK from CMakeLists.txt

#1 Post by afe »

Hi,

I realize I may be missing something very basic here.

I am trying to use DCMTK from a CMake project on Mac. I compiled DCMTK configured with CMake (had to turn off ICONV, following the advice here https://github.com/commontk/CTK/issues/178).

In my project, I have the following CMakeLists.txt:

Code: Select all


project(Test)

find_package(DCMTK REQUIRED)
include_directories(${DCMTK_INCLUDE_DIRS})

add_executable(test test.cxx)
target_link_libraries(test  ${DCMTK_LIBRARIES})

When I configure my project, I point DCMTK_DIR to the location of my cmake-built DCMTK.

Cmake gives me this error:

Code: Select all

 CMake Error at /Users/fedorov/local/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
   Could NOT find DCMTK (missing: 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)
 Call Stack (most recent call first):
   /Users/fedorov/local/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
   /Users/fedorov/local/share/cmake-2.8/Modules/FindDCMTK.cmake:138 (find_package_handle_standard_args)
   CMakeLists.txt:3 (find_package)
I have the latest cmake 2.8.12.1.

thank you for your attention

AF
Andrey

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Using DCMTK from CMakeLists.txt

#2 Post by J. Riesmeier »

As far as I understood and followed the discussions with the CMake and CTK people, I guess that the issue is caused by your "find_package()" call.
Michael is working on a couple of proposed patches (provided by Jean-Christophe Fillion-Robin)...

afe
Posts: 11
Joined: Mon, 2012-02-13, 20:31

Re: Using DCMTK from CMakeLists.txt

#3 Post by afe »

Jorg, thank you for confirming this. I didn't know if this is supposed to work or not.

I will see JC next week at the NA-MIC project week, and will ask him about the status of this issue. I will post an update to this thread if I learn something of general interest.
Andrey

afe
Posts: 11
Joined: Mon, 2012-02-13, 20:31

Re: Using DCMTK from CMakeLists.txt

#4 Post by afe »

Ok, so I talked with JC today, and he pointed me to the FindDCMTK.cmake file that should be used to be able to configure an external project to use DCMTK configured with CMake:

https://github.com/commontk/CTK/blob/ma ... CMTK.cmake

The details can be learned from the comments in that file. Thanks to JC, I can now use DCMTK from my CMake project!

I copied this file to ${CMAKE_INSTALL_DIR}/share/cmake-2.8/Modules. Also note extra line should be added to this file (JC will commit this fix to the file soon, but in case he didn't and you need it now):

Code: Select all

include(FindPackageHandleStandardArgs)
After that external project defined by a CMakeLists.txt like this:

Code: Select all

cmake_minimum_required(VERSION 2.8)
find_package(DCMTK REQUIRED)

include_directories(${DCMTK_INCLUDE_DIRS})
add_executable(dcmtk_test dcmtk_test.cxx)
target_link_libraries(dcmtk_test ${DCMTK_LIBRARIES} z)
can be configured and DCMTK will be correctly discovered. Note I had to add z to the target libraries list.

On Mac it was also necessary to manually initialize the following variables:

Code: Select all

MAKE_OSX_ARCHITECTURES     x86_64
CMAKE_OSX_DEPLOYMENT_TARGET   10.9
CMAKE_OSX_SYSROOT  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
Hopefully this process will be simplified soon by fixes to DCMTK and CMake!
Andrey

afe
Posts: 11
Joined: Mon, 2012-02-13, 20:31

Re: Using DCMTK from CMakeLists.txt

#5 Post by afe »

As of today, FindDCMTK.cmake in CTK has been updated with the missing include, see

https://github.com/commontk/CTK/commit/ ... 5cd7a3aad3

Also, in my previous post, there is a typo: MAKE_OSX_ARCHITECTURES should instead be CMAKE_OSX_ARCHITECTURES.
Andrey

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest