[CMake] Multiple versions of ITK in one build?

2013-05-28 Thread Zamir Khan
We have a project where multiple modules rely on ITK. Most modules have been
upgraded to ITK 4.31, but one still relies on ITK 3.20 and it would take a
significant effort to upgrade it. In the meantime, is there a way for us to
keep these modules under a single top-level CMake and have them use their
respective versions of ITK?

We thought we could just try to overwrite the ITK_DIR variable in the
appropriate place, but our first naive implementation of this did not work.

Just wondering if someone has done this and whether it is possible (before
we dive deeper).

Thanks!



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Multiple-versions-of-ITK-in-one-build-tp7584547.html
Sent from the CMake mailing list archive at Nabble.com.
--

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


Re: [CMake] Multiple versions of ITK in one build?

2013-05-28 Thread Bill Hoffman

On 5/28/2013 10:16 AM, Zamir Khan wrote:

We have a project where multiple modules rely on ITK. Most modules have been
upgraded to ITK 4.31, but one still relies on ITK 3.20 and it would take a
significant effort to upgrade it. In the meantime, is there a way for us to
keep these modules under a single top-level CMake and have them use their
respective versions of ITK?

We thought we could just try to overwrite the ITK_DIR variable in the
appropriate place, but our first naive implementation of this did not work.

Just wondering if someone has done this and whether it is possible (before
we dive deeper).

Thanks!

This is a question for the ITK mailing list.
http://www.itk.org/mailman/listinfo/insight-users

But, I don't think it will be easy to do what you want.  There is always 
a way, but it will be a big hack...  :)


-Bill

--

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


Re: [CMake] Multiple versions of ITK in one build?

2013-05-28 Thread John Drescher
On Tue, May 28, 2013 at 10:16 AM, Zamir Khan zamir.k...@gmail.com wrote:
 We have a project where multiple modules rely on ITK. Most modules have been
 upgraded to ITK 4.31, but one still relies on ITK 3.20 and it would take a
 significant effort to upgrade it. In the meantime, is there a way for us to
 keep these modules under a single top-level CMake and have them use their
 respective versions of ITK?

 We thought we could just try to overwrite the ITK_DIR variable in the
 appropriate place, but our first naive implementation of this did not work.

 Just wondering if someone has done this and whether it is possible (before
 we dive deeper).


On windows I have several completely separate build trees with their
own environment. This way I can build for different compiler versions,
32/64 bit and different versions of libraries like this. Inside the
root of each build tree there is a link to the appropriate Visual
Studio command prompt that has its default folder set to the build
tree root. Also in the root there is a batch file that sets quite a
few _DIR environment variables to help cmake find the correct compiled
libraries. This has worked well for the 5 or so years that I have done
it this way. I do not use INSTALL targets so none of the binaries end
up in Program Files.

John
--

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


Re: [CMake] Multiple versions of ITK in one build?

2013-05-28 Thread Bill Lorensen
You could use cmake's superbuild facility to build both itk3 and itk4 in a
superbuild tree.



On Tue, May 28, 2013 at 11:02 AM, John Drescher dresche...@gmail.comwrote:

 On Tue, May 28, 2013 at 10:16 AM, Zamir Khan zamir.k...@gmail.com wrote:
  We have a project where multiple modules rely on ITK. Most modules have
 been
  upgraded to ITK 4.31, but one still relies on ITK 3.20 and it would take
 a
  significant effort to upgrade it. In the meantime, is there a way for us
 to
  keep these modules under a single top-level CMake and have them use their
  respective versions of ITK?
 
  We thought we could just try to overwrite the ITK_DIR variable in the
  appropriate place, but our first naive implementation of this did not
 work.
 
  Just wondering if someone has done this and whether it is possible
 (before
  we dive deeper).
 

 On windows I have several completely separate build trees with their
 own environment. This way I can build for different compiler versions,
 32/64 bit and different versions of libraries like this. Inside the
 root of each build tree there is a link to the appropriate Visual
 Studio command prompt that has its default folder set to the build
 tree root. Also in the root there is a batch file that sets quite a
 few _DIR environment variables to help cmake find the correct compiled
 libraries. This has worked well for the 5 or so years that I have done
 it this way. I do not use INSTALL targets so none of the binaries end
 up in Program Files.

 John
 --

 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




-- 
Unpaid intern in BillsBasement at noware dot com
--

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

Re: [CMake] Multiple versions of ITK in one build?

2013-05-28 Thread Zamir Khan
I should probably clarify the situation (I'm not sure I provided enough
info up front). The larger dependencies like ITK are pre-built (I guess one
would assume this; we don't rebuild ITK or VTK with every build of our
project). So I thought it would be a simple problem of overwrite and then
restoring the ITK_DIR value at the right time (e.g. at the point of
find_package(ITK ...) for the modules in question). I feel like we've
almost got this working. There are some lingering issues that we're still
solving, but the respective modules seem to reference the correct versions
of ITK now. I guess I'm wondering whether this approach is doomed to fail
for a reason we haven't anticipated.

I'm doing the replacement as follows:

# This module uses an older version of ITK (3.2) than the rest of
# the project (4.31), so here we overwrite the ITK_DIR variable
# so that the correct version is found.
MESSAGE( STATUS ITK_DIR_SECONDARY value:${ITK_DIR_SECONDARY})

MESSAGE( STATUS ITK_DIR value (before overwrite):${ITK_DIR})
# Store the primary ITK directory in a temporary variable
set(ITK_DIR_PRIMARY ${ITK_DIR})
# Overwrite the ITK_DIR cache variable
set(ITK_DIR ${ITK_DIR_SECONDARY} CACHE STRING The directory containing a
CMake configuration file for ITK FORCE)
MESSAGE( STATUS ITK_DIR value (after overwrite):${ITK_DIR})

FIND_PACKAGE(ITK 3.2)
IF(ITK_FOUND)
INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
MESSAGE(FATAL_ERROR ITK not found. Please set ITK_DIR.)
ENDIF(ITK_FOUND)

# Restore the original (primary) ITK_DIR value
SET(ITK_DIR ${ITK_DIR_PRIMARY} CACHE STRING The directory containing a
CMake configuration file for ITK FORCE)
MESSAGE( STATUS ITK_DIR value (after restore):${ITK_DIR})



On Tue, May 28, 2013 at 11:30 AM, Bill Lorensen bill.loren...@gmail.comwrote:

 I just re-read your question. Superbuild won't help.



 On Tue, May 28, 2013 at 11:29 AM, Bill Lorensen 
 bill.loren...@gmail.comwrote:

 You could use cmake's superbuild facility to build both itk3 and itk4 in
 a superbuild tree.



 On Tue, May 28, 2013 at 11:02 AM, John Drescher dresche...@gmail.comwrote:

 On Tue, May 28, 2013 at 10:16 AM, Zamir Khan zamir.k...@gmail.com
 wrote:
  We have a project where multiple modules rely on ITK. Most modules
 have been
  upgraded to ITK 4.31, but one still relies on ITK 3.20 and it would
 take a
  significant effort to upgrade it. In the meantime, is there a way for
 us to
  keep these modules under a single top-level CMake and have them use
 their
  respective versions of ITK?
 
  We thought we could just try to overwrite the ITK_DIR variable in the
  appropriate place, but our first naive implementation of this did not
 work.
 
  Just wondering if someone has done this and whether it is possible
 (before
  we dive deeper).
 

 On windows I have several completely separate build trees with their
 own environment. This way I can build for different compiler versions,
 32/64 bit and different versions of libraries like this. Inside the
 root of each build tree there is a link to the appropriate Visual
 Studio command prompt that has its default folder set to the build
 tree root. Also in the root there is a batch file that sets quite a
 few _DIR environment variables to help cmake find the correct compiled
 libraries. This has worked well for the 5 or so years that I have done
 it this way. I do not use INSTALL targets so none of the binaries end
 up in Program Files.

 John
 --

 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




 --
 Unpaid intern in BillsBasement at noware dot com




 --
 Unpaid intern in BillsBasement at noware dot com

--

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

Re: [CMake] Multiple versions of ITK in one build?

2013-05-28 Thread Brad King
On 05/28/2013 11:38 AM, Zamir Khan wrote:
 I should probably clarify the situation (I'm not sure I provided enough info 
 up front). The larger dependencies like ITK are pre-built (I guess one would 
 assume this; we don't rebuild ITK or VTK with every build of our project). So 
 I thought it would be a simple problem of overwrite and then
 restoring the ITK_DIR value at the right time (e.g. at the point of 
 find_package(ITK ...) for the modules in question). I feel like we've almost 
 got this working. There are some lingering issues that we're still solving, 
 but the respective modules seem to reference the correct versions of ITK now. 
 I
 guess I'm wondering whether this approach is doomed to fail for a reason we 
 haven't anticipated.
 
 I'm doing the replacement as follows:
 
 # This module uses an older version of ITK (3.2) than the rest of
 # the project (4.31), so here we overwrite the ITK_DIR variable
 # so that the correct version is found.
 MESSAGE( STATUS ITK_DIR_SECONDARY value:${ITK_DIR_SECONDARY})
 
 MESSAGE( STATUS ITK_DIR value (before overwrite):${ITK_DIR})
 # Store the primary ITK directory in a temporary variable
 set(ITK_DIR_PRIMARY ${ITK_DIR})
 # Overwrite the ITK_DIR cache variable
 set(ITK_DIR ${ITK_DIR_SECONDARY} CACHE STRING The directory containing a 
 CMake configuration file for ITK FORCE)
 MESSAGE( STATUS ITK_DIR value (after overwrite):${ITK_DIR})
 
 FIND_PACKAGE(ITK 3.2)
 IF(ITK_FOUND)
 INCLUDE(${ITK_USE_FILE})
 ELSE(ITK_FOUND)
 MESSAGE(FATAL_ERROR ITK not found. Please set ITK_DIR.)
 ENDIF(ITK_FOUND)
 
 # Restore the original (primary) ITK_DIR value
 SET(ITK_DIR ${ITK_DIR_PRIMARY} CACHE STRING The directory containing a CMake 
 configuration file for ITK FORCE)
 MESSAGE( STATUS ITK_DIR value (after restore):${ITK_DIR})

CACHE values are loaded only at the beginning of processing CMake code
so the FORCE set will not take effect until the next time you run CMake.
Instead set ITK_DIR as a normal (non-cached) variable:

 set(ITK_DIR ${ITK_DIR_4_3})
 find_package(ITK 4.3)

 ...

 set(ITK_DIR ${ITK_DIR_3_2})
 find_package(ITK 3.2)

That should get the package configuration file from each ITK loaded.

There may be other problems with multiple versions of ITK in a single
project but I can't enumerate any off the top of my head.  Certainly
it will work only when the two find_package calls are in separate
subdirectories (via add_subdirectory) and cannot see each other.

-Brad
--

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