[CMake] Modified FindDCMTK

Mathieu Malaterre mathieu.malaterre at gmail.com
Fri Jun 11 05:22:11 EDT 2010


Thomas,

I made two changes to your proposed cmake file:

- include(FindPackageHandleStandardArgs)
- use a foreach to simplify the finding of executables

If this is ok with you I can update it on CMake/Modules

Ref:
http://gdcm.svn.sf.net/viewvc/gdcm/trunk/CMake/FindDCMTK.cmake?view=markup

Thanks,

On Fri, Jun 11, 2010 at 11:07 AM, Thomas Sondergaard
<ts at medical-insight.com> wrote:
> Ryan Pavlik wrote:
>>
>> On 06/10/2010 03:28 PM, Thomas Sondergaard wrote:
>>>
>>> The FindDCMTK.cmake module in the git master branch doesn't find all the
>>> dcmtk libraries. I've attached a modified version of FindDCMTK that finds
>>> all the dcmtk libraries. It is also about 25% smaller as some duplicated
>>> code has been unified using FOREACH.
>>>
>>> I hope you will consider including it in the CMake distribution.
>>>
>>> Regards,
>>>
>>> Thomas Sondergaard
>>
>> I ran it through my cleanup tool and made two manual fixes: using
>> list(APPEND where appropriate, and using the plural INCLUDE_DIRS.  It could
>> be further improved by using the find_package_handle_standard_args macro.
>>
>> I've attached my update of your file.
>>
>> Ryan
>>
>
> Thanks for the update and suggestions. I've attached a new version and a
> diff between your version and my new version.
>
> Thomas
>
> # - 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 Mathieu Malaterre <mathieu.malaterre at gmail.com>
> # Copyright 2010 Thomas Sondergaard <ts at 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_FOUND AND NOT DCMTK_DIR)
>        set(DCMTK_DIR
>                "/usr/include/dcmtk/"
>                CACHE
>                PATH
>                "Root of DCMTK source tree (optional).")
>        mark_as_advanced(DCMTK_DIR)
> endif()
>
>
> foreach(lib
>        dcmdata
>        dcmimage
>        dcmimgle
>        dcmjpeg
>        dcmnet
>        dcmpstat
>        dcmqrdb
>        dcmsign
>        dcmsr
>        dcmtls
>        ijg12
>        ijg16
>        ijg8
>        ofstd)
>
>        find_library(DCMTK_${lib}_LIBRARY
>                ${lib}
>                ${DCMTK_DIR}/${lib}/libsrc
>                ${DCMTK_DIR}/${lib}/libsrc/Release
>                ${DCMTK_DIR}/${lib}/libsrc/Debug
>                ${DCMTK_DIR}/${lib}/Release
>                ${DCMTK_DIR}/${lib}/Debug
>                ${DCMTK_DIR}/lib)
>
>        mark_as_advanced(DCMTK_${lib}_LIBRARY)
>
>        if(DCMTK_${lib}_LIBRARY)
>                list(APPEND DCMTK_LIBRARIES ${DCMTK_${lib}_LIBRARY})
>        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)
>
> foreach(dir
>        config
>        dcmdata
>        dcmimage
>        dcmimgle
>        dcmjpeg
>        dcmnet
>        dcmpstat
>        dcmqrdb
>        dcmsign
>        dcmsr
>        dcmtls
>        ofstd)
>        find_path(DCMTK_${dir}_INCLUDE_DIR
>                ${DCMTK_${dir}_TEST_HEADER}
>                PATHS
>                ${DCMTK_DIR}/${dir}/include
>                ${DCMTK_DIR}/${dir}
>                ${DCMTK_DIR}/include/${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)
> 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})
> endif()
>
>
> 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})
>
> find_program(DCMTK_DCMDUMP_EXECUTABLE dcmdump ${DCMTK_DIR}/bin)
>
> find_program(DCMTK_DCMDJPEG_EXECUTABLE dcmdjpeg ${DCMTK_DIR}/bin)
>
> find_program(DCMTK_DCMDRLE_EXECUTABLE dcmdrle ${DCMTK_DIR}/bin)
>
> mark_as_advanced(DCMTK_DCMDUMP_EXECUTABLE
>        DCMTK_DCMDJPEG_EXECUTABLE
>        DCMTK_DCMDRLE_EXECUTABLE)
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
Mathieu


More information about the CMake mailing list