[Insight-users] [CMake] INSTALL(EXPORT)

Michael Schildt michael.schildt at ifn-magdeburg.de
Fri Jun 26 07:28:45 EDT 2009


Hello,

to get rid of this nasty manual configuration switching under Visual 
Studio I created an quick work around. Maybe this is of interest for 
other people too. So, i present it here:

- download, extract ITK source
- generate a Visual Studio Solution for ITK
- compile the Insight Toolkit in Debug configuration
- install it to <libDir> // <libDir> is an place holder for the concrete 
directory in teh file system
- created an subdirectory <libDir>/Debug
- copied all *.lib and *.pdb to <libDir>/Debug
- repeat this for all wanted configurations 
[Release,Debug,RelWithDebInfo, MinSizeRel,...]
- in the <libDir> *.cmake files are still present
- edit ITKConfig.cmake to reflect the new subdirectories (changed lines 
start with **):
-------------------------------------------------------------------------------------------------------------------------
# Compute the installation prefix from this ITKConfig.cmake file location.
GET_FILENAME_COMPONENT(ITK_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
GET_FILENAME_COMPONENT(ITK_INSTALL_PREFIX "${ITK_INSTALL_PREFIX}" PATH)
** # GET_FILENAME_COMPONENT(ITK_INSTALL_PREFIX "${ITK_INSTALL_PREFIX}" PATH)

# The ITK include file directories.
SET(ITK_INCLUDE_DIRS 
"${ITK_INSTALL_PREFIX}/include/InsightToolkit;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Numerics/Statistics;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Algorithms;${ITK_INSTALL_PREFIX}/include/InsightToolkit/BasicFilters;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Common;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Numerics;${ITK_INSTALL_PREFIX}/include/InsightToolkit/IO;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Numerics/FEM;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Numerics/NeuralNetworks;${ITK_INSTALL_PREFIX}/include/InsightToolkit/SpatialObject;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Utilities/MetaIO;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Utilities/NrrdIO;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Utilities/DICOMParser;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Utilities/expat;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Utilities/nifti/niftilib;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Utilities/nifti/znzlib;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Utilities/itkExtHdrs;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Utilities;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Utilities/vxl/v3p/netlib;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Utilities/vxl/vcl;${ITK_INSTALL_PREFIX}/include/InsightToolkit/Utilities/vxl/core;${ITK_INSTALL_PREFIX}/include/InsightToolkit/gdcm;${ITK_INSTALL_PREFIX}/include/InsightToolkit/gdcm/src")

MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
MESSAGE (STATUS "Build Setting: ${CMAKE_BUILD_SETTING_BUILD_TYPE}")

** IF(CMAKE_GENERATOR MATCHES "Visual Studio")
**    # Benutze den Namen der aktuellen Konfiguration um die richtigen 
Bibliotheken von ITK zu linken
**    SET(ITK_CONFIG_LIB_DIR $(ConfigurationName))
** ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio")

# The ITK library directories.
** SET(ITK_LIBRARY_DIRS "${ITK_INSTALL_PREFIX}/lib/${ITK_CONFIG_LIB_DIR}")

# The C and C++ flags added by ITK to the cmake-configured flags.
SET(ITK_REQUIRED_C_FLAGS "")
SET(ITK_REQUIRED_CXX_FLAGS " -library=stlport4 -DNOMINMAX")
SET(ITK_REQUIRED_LINK_FLAGS "")

# The ITK version number
SET(ITK_VERSION_MAJOR "3")
SET(ITK_VERSION_MINOR "14")
SET(ITK_VERSION_PATCH "0")

# The location of the UseITK.cmake file.
** SET(ITK_USE_FILE "${ITK_INSTALL_PREFIX}/lib/UseITK.cmake")

# The build settings file.
** SET(ITK_BUILD_SETTINGS_FILE 
"${ITK_INSTALL_PREFIX}/lib/ITKBuildSettings.cmake")

# The library dependencies file.
** SET(ITK_LIBRARY_DEPENDS_FILE 
"${ITK_INSTALL_PREFIX}/lib/ITKLibraryDepends.cmake")
-------------------------------------------------------------------------------------------------------------------------
filesystem under <libDir> should look something like:

 Directory of F:\BrainGUI_CMake\ITK\lib

26.06.2009  13:15    <DIR>          .
26.06.2009  13:15    <DIR>          ..
26.06.2009  08:50    <DIR>          Debug
26.06.2009  10:05    <DIR>          MinSizeRel
26.06.2009  08:55    <DIR>          Release
26.06.2009  10:05    <DIR>          RelWithDebInfo
25.06.2009  17:34             1,555 ITKBuildSettings.cmake
26.06.2009  08:56             4,539 ITKConfig.cmake
24.06.2009  13:51             3,054 ITKLibraryDepends.cmake
24.06.2009  13:51             4,396 UseITK.cmake
               4 File(s)         13,544 bytes
               6 Dir(s)  62,464,081,920 bytes free

-------------------------------------------------------------------------------------------------------------------------
- use find_package(ITK) stuff exactly the way as before in your project 
CMakeList.txt to generate Visual Studio Solution
- switch between the configurations and ITK gets linked with the correct 
ConfigurationType automatically
-------------------------------------------------------------------------------------------------------------------------

This solution needs far fewer changes than the one suggestet before and 
no changes to the source tree are required. But it no option if you 
delevelop on the InsightToolkit source. Only, when you use it as support 
library for your own project. As you probably know, it is really a pain 
to test registrations stuff in debug mode configuration of ITK for 
performance reasons. But you need it to find problems.

Best reguards,
    Michael Schildt

Michael Schildt schrieb:
> Hello!
>
> It been a while for this topic...
> I would like to know if there are any (good) news on this issue. I 
> have exactly the mentioned problem using the ITK 3.14 source.
> Do I have to make the suggested modification of the first post on this 
> topic to ALL the CMakeLists.txt? I do not hope so. For now, i compiled 
> debug and release versions to different dirs and change the lib dir 
> manually in my projects managed via cmake. Probably, that is not what 
> cmake was intended for, right?
>
> Best Reguards,
>    Michael Schildt
>
>
> Brad King schrieb:
>> Rupert Brooks wrote:
>>  
>>> Checking this in would
>>> break every test running against a build tree.   Not only does this
>>> approach require an install tree, it unfortunately destroys the
>>> ability to link against the build tree.  I spent some effort trying to
>>> figure out how to get around this, and i didn't find a good way.
>>>     
>>
>> There is a good way, but I've not yet looked at your patch to see why it
>> is a problem.  When I get time and we decide to require CMake 2.6 I will
>> take your patch as a starting point and make this feature work.
>>
>> Thanks for your contribution.
>>
>> -Brad
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>>   
> _____________________________________
> 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 ITK FAQ at: 
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>



More information about the Insight-users mailing list