[ITK] [ITK-dev] ITK and old expat library

Rashad M mohammedrashadkm at gmail.com
Mon Jun 2 12:10:03 EDT 2014


Hello,

Please find attached patch to use system expat with ITK.


On Mon, Jun 2, 2014 at 2:40 PM, Rashad M <mohammedrashadkm at gmail.com> wrote:

>
>
>
> On Mon, Jun 2, 2014 at 2:34 PM, Bradley Lowekamp <blowekamp at mail.nih.gov>
> wrote:
>
>> Hello,
>>
>> As the symbols in the ITK library are not managled. So if you try to use
>> the a system expat in conjunction with the ITK expat you could have
>> conflicting symbols and undefined behavior. Simply installing the header in
>> a different location will not solve this problem.
>>
>> Configuring ITK to use a system expat will fully solve you problem.
>>
>> You can find how other third party libraries did it here:
>>
>>
>> https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/ThirdParty/JPEG/CMakeLists.txt
>>
>> https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/ThirdParty/TIFF/CMakeLists.txt
>>
>> Would you like to try to create a patch to address this issue?
>>
>
> Yes. I would like to try a patch
>
>>
>> Thanks,
>> Brad
>>
>> On Jun 2, 2014, at 8:22 AM, Rashad M <mohammedrashadkm at gmail.com> wrote:
>>
>>
>>
>>
>> On Mon, Jun 2, 2014 at 2:07 PM, Bradley Lowekamp <blowekamp at mail.nih.gov>
>> wrote:
>>
>>> Hello,
>>>
>>> It would be quite reasonable to support using a system expact.
>>>
>>> Could you please describe you problem a little clearer? Are you having
>>> problem compiling ITK? or an Application which uses ITK? or Issues
>>> compiling independent programs after ITK is installed?
>>>
>>
>> My problem not with compiling/installing ITK but when compiling libkml, a
>> dependency of OTB which uses ITK. This uses an expat library and instead of
>> using  a system expat i wind up using expat from ITK as expat.h is
>> installed in <prefix>/include/ITK4.6. I can confirm using system expat
>> doesnt have any problem with libkml when used with OTB.
>>
>> If you would like to have a look at bug report, see here[1]. I had a
>> temporary solution to build libkml before adding itk headers but a best
>> would be to have a fix in ITK' expat library.
>>
>> The issue is coming using an installed version of ITK.
>> So if you are planning to upgrade expat library to its latest version or
>> use system expat then the problem is solved.
>>
>>  [1] http://bugs.orfeo-toolbox.org/view.php?id=879
>>
>>
>>
>>
>>> Thanks,
>>> Brad
>>>
>>> On Jun 1, 2014, at 3:29 AM, Rashad M <mohammedrashadkm at gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> Is there an option to install expat includes in a different location?
>>> For now its installed in <prefix>/include. This seems to be a problem when
>>> using a latest expat version and by default ITK's expat is included.
>>>
>>> Or if it is possible to use a system expat to make sure that both ITK
>>> and other libraries uses same expat (latest version).
>>>
>>> best would be to change location <prefix>/include/expat. So that cmake
>>> can be used to remove item from list of include directories.
>>>
>>> eg:
>>> list(REMOVE_ITEM expat-includes itk-includes)
>>>
>>> --
>>> Regards,
>>>    Rashad
>>>  _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://kitware.com/products/protraining.php
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-developers
>>>
>>>
>>>
>>
>>
>> --
>> Regards,
>>    Rashad
>>
>>
>>
>
>
> --
> Regards,
>    Rashad
>



-- 
Regards,
   Rashad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140602/757adfb2/attachment-0002.html>
-------------- next part --------------
diff --git a/Modules/ThirdParty/Expat/CMakeLists.txt b/Modules/ThirdParty/Expat/CMakeLists.txt
index 8791cc4..4460690 100644
--- a/Modules/ThirdParty/Expat/CMakeLists.txt
+++ b/Modules/ThirdParty/Expat/CMakeLists.txt
@@ -1,10 +1,22 @@
 project(ITKExpat)
 set(ITKExpat_THIRD_PARTY 1)
 
+option(ITK_USE_SYSTEM_EXPAT "Use system-installed expat" OFF)
+mark_as_advanced(ITK_USE_SYSTEM_EXPAT)
+
+if(ITK_USE_SYSTEM_EXPAT)
+  find_package(EXPAT REQUIRED)
+  set(ITKExpat_INCLUDE_DIRS ${ITKExpat_BINARY_DIR}/src )
+  set(ITKExpat_SYSTEM_INCLUDE_DIRS "${EXPAT_INCLUDE_DIR}")
+  set(ITKExpat_LIBRARIES "${EXPAT_LIBRARY}")
+  set(ITKExpat_NO_SRC 1)
+else()
 set(ITKExpat_INCLUDE_DIRS
   ${ITKExpat_BINARY_DIR}/src/expat
   ${ITKExpat_SOURCE_DIR}/src/expat
   )
 set(ITKExpat_LIBRARIES ITKEXPAT)
 
-itk_module_impl()
+endif()
+
+itk_module_impl()
\ No newline at end of file
diff --git a/Modules/ThirdParty/GIFTI/src/gifticlib/CMakeLists.txt b/Modules/ThirdParty/GIFTI/src/gifticlib/CMakeLists.txt
index 60219d3..fc6a23a 100644
--- a/Modules/ThirdParty/GIFTI/src/gifticlib/CMakeLists.txt
+++ b/Modules/ThirdParty/GIFTI/src/gifticlib/CMakeLists.txt
@@ -14,7 +14,7 @@ if("${ITK_VERSION_MAJOR}" GREATER 0.0)
 # ITK provides expat and zlib.
   include_directories(${ITKNIFTI_INCLUDE_DIRS})
   set(PACKAGE_PREFIX "ITK")
-  set(EXPAT_LIBRARIES ITKEXPAT)
+  set(EXPAT_LIBRARIES ${ITKExpat_LIBRARIES})
   set(ZLIB_LIBRARIES ITKznz)
   set(NIFTI_LIBRARIES ITKniftiio)
   set(ZLIB_FOUND 1)
-------------- next part --------------
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-developers


More information about the Community mailing list