[Insight-developers] CMakeLists.txt in BasicIOAndFilter

Mark Foskey mark_foskey@unc.edu
Thu, 17 Oct 2002 13:16:44 -0400


I had been having trouble getting SampleProject to compile outside of 
ITK (under Linux) until I set BUILD_SHARED_LIBS to ON.  Is that right? 
It seems like something that simple should compile without shared libs.

Luis Ibanez wrote:
> Mark Foskey wrote:
> 
>> OK, just out of curiosity I uncommented those lines

[The USE_ITK lines, that is]

>> from the 
>> CMakeLists.txt file as you had modified it and it still compiled fine 
>> inside ITK.  Is there a reason it will sometimes fail if we leave 
>> those lines uncommented?
>>
> 
> 
> It will not actually fail, but it will add an ITK_BINARY_DIR to the
> top list of CMake variables when you configure ITK.
> 
> It will be confusing since it may look as if CMake where asking
> where to put ITK, while it is is fact asking : "where did you put
> ITK" thinking that it is an external project looking for an installed
> ITK.
> 
> A part from that, it should work ok, as you mention....
> 
> 
> 
>> On the other hand, I just tried to compile SampleProject outside ITK 
>> and it failed, as follows:
>>
>> /usr/local/bin/cmake -S/WorkSpace/foskey/SampleProject 
>> -O/WorkSpace/foskey/SampleProject-Linux 
>> -H/WorkSpace/foskey/SampleProject -B/WorkSpace/foskey/SampleProject-Linux
>> c++ -rdynamic  itkSampleProject.o  
>> -L/WorkSpace/foskey/Insight-Linux/bin -lVXLNumerics -lITKCommon 
>> -Wl,-rpath,/WorkSpace/foskey/Insight-Linux/bin  -o itkSampleProject
>> /WorkSpace/foskey/Insight-Linux/bin/libITKCommon.a(itkDynamicLoader.o): 
>> In function `itk::DynamicLoader::OpenLibrary(char const *)':
>> /WorkSpace/foskey/Insight/Code/Common/itkDynamicLoader.cxx:261: 
>> undefined reference to `dlopen'
>> [...many more errors]
> 
> 
> 
> 
> Did you tryied this using the same ITK for which you uncommented the
> lines in the previous section ?
> 
> It may well be an entanglement of Caches....
> Since an external project import all the cache from ITK, the
> uncommenting of the INCLUDE( ${USE_ITK_FILE} ) line could result
> in the cache being self-referenced (some kind of cyclic definition
> of cache variables). Since it is basically importing ITK's cache
> into ITK's cache...
> 
> ...Just a guess....
> 
> 
>>
>> The CMakeLists.txt file is, I believe, unchanged:
>>
>> ----
>>
>> PROJECT(SampleProject)
>>
>> #
>> # Find ITK
>> #
>> INCLUDE (${CMAKE_ROOT}/Modules/FindITK.cmake)
>> IF (USE_ITK_FILE)
>>   INCLUDE(${USE_ITK_FILE})
>> ENDIF(USE_ITK_FILE)
>>
>> LINK_LIBRARIES (
>> VXLNumerics
>> ITKCommon
>> )
>>
>>
>> ADD_EXECUTABLE(itkSampleProject itkSampleProject.cxx )
>>
>> ----
>>
>> Luis Ibanez wrote:
>>
>>> Hi Mark,
>>>
>>> The lines in the CMakeLists.txt file that
>>> include FindITK.cmake are intenteded to be
>>> used only outside the build tree.
>>>
>>> The four lines were set in comments.
>>>
>>> Probably we should define a CMake variable
>>> like
>>>
>>>        IS_IN_ITK_TREE
>>>
>>> and put the FindITK.cmake lines in between
>>>
>>> IF( NOT IS_IN_ITK_TREE )
>>>    ...
>>> ENDIF( NOT IS_IN_ITK_TREE )
>>>
>>>
>>> It would be nice to find a more compact
>>> way of doing this so all the small examples
>>> can be configured to build inside and
>>> outside the ITK tree.
>>>
>>>
>>>     Luis
>>>
>>>
>>> _______________________________________________
>>> Insight-developers mailing list
>>> Insight-developers@public.kitware.com
>>> http://public.kitware.com/mailman/listinfo/insight-developers
>>
>>
>>
> 
> 
> 
> 
> 

-- 
Mark Foskey    (919) 843-5436   Computer-Aided Diagnosis and Display Lab
mark_foskey@unc.edu             Department of Radiology, CB 7515, UNC
http://www.cs.unc.edu/~foskey   Chapel Hill, NC  27599-7515