[CMake] Question regarding External Project add and VTK

2014-06-02 Thread jmerkow
Hello,

I want to add VTK as an external project, but I have a few questions.

Looking online at examples of other projects using vtk as an external
project, many of them use a 'superbuild' style technique (example here from
the archives: [1]).  
By that I mean that they have some option to enable SuperBuild (or a
seperate CMakeLists.txt file) then that adds all the external projects (i.e.
vtk or itk), and finally they add their own project as an external project
(obv with superbuild turned off).  I am wondering why this is done this
way..

What I would like to do it have options for these libraries (starting with
VTK) to download and build it if they wish. Doing it this way, all of the
other options are available to the user.

-Jameson

[1]
http://cmake.3232098.n2.nabble.com/How-to-use-VTK-as-an-ExternalProject-td6002193.html



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Question-regarding-External-Project-add-and-VTK-tp7587557.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] cmake project patterns / examples

2014-06-02 Thread Adam Boseley
There's a lot of legacy examples around the web but not too many using the
newer features.  What is the current best practise?

Here's some simple examples
https://github.com/toomuchatonce/cmake-examples/wiki/cmake-patterns-and-examples

Are these patterns or anti-patterns?

Regards,
Adam
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Question regarding External Project add and VTK

2014-06-02 Thread Matthew Woehlke
On 2014-06-02 17:48, jmerkow wrote:
> I want to add VTK as an external project, but I have a few questions.
> 
> Looking online at examples of other projects using vtk as an
> external project, many of them use a 'superbuild' style technique
> [...] they have some option to enable SuperBuild (or a seperate
> CMakeLists.txt file) then that adds all the external projects (i.e. 
> vtk or itk), and finally they add their own project as an external
> project (obv with superbuild turned off).  I am wondering why this is
> done this way..

I think the answer is that you otherwise get into a chicken-and-egg
situation. Basically, your own project can't configure until VTK is
available; therefore, it is necessary to make configuration of your own
project be done as a build step that can depend on the build of VTK,
which is what the above pattern achieves.

-- 
Matthew

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Question regarding External Project add and VTK

2014-06-02 Thread jmerkow
I see, that makes a lot of sense.   And in order to pass options from the
'superbuild' build to the 'normal' build you make them options as command
line args in your ExternalProhect_Add command?  i.e.:

set( proj my_prog )
  ExternalProject_Add( ${proj}
DOWNLOAD_COMMAND ""
SOURCE_DIR "${${proj}_Source_Dir}"
BINARY_DIR "${${proj}_Binary_Dir}"
CMAKE_GENERATOR ${gen}
CMAKE_ARGS
-D${proj}_option1:BOOL=${proj}_option1
-D${proj}_some_LIBRARY:FILEPATH=${proj}_some_LIBRARY
...
INSTALL_DIR ${proj}/path/
DEPENDSsd
${proj_DEPENDS})

Is there an easier way to pass all the options to the 'normal' build? 

-Jameson



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Question-regarding-External-Project-add-and-VTK-tp7587557p7587560.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Question regarding External Project add and VTK

2014-06-02 Thread Jean-Christophe Fillion-Robin
Hi Jameson,

To specifically address the issue you described, I started to develop an
(experimental) module extending ExternalProject and providing some
convenience function.

Documentation is far from being perfect but looking at

  (1) the tests: https://github.com/commontk/Artichoke/tree/master/Tests
  (2) the "to be extended/improved" documentation:
http://cmake-artichoke.readthedocs.org/en/latest/
  (3) example of usage in 3DSlicer: https://github.com/Slicer/Slicer

... you should be able to get the idea.


It basically provide to convenience function:

  make_as_superbuild

  ExternalProject_Include_Dependencies

allowing to

automatically generate the value to pass to either CMAKE_CACHE_ARGS
(or CMAKE_ARGS if needed)



Ultimately, if the module API stabilizes and turns out to be of general
use, it could be integrate into CMake ...

Hth
Jc



On Mon, Jun 2, 2014 at 9:00 PM, jmerkow  wrote:

> I see, that makes a lot of sense.   And in order to pass options from the
> 'superbuild' build to the 'normal' build you make them options as command
> line args in your ExternalProhect_Add command?  i.e.:
>
> set( proj my_prog )
>   ExternalProject_Add( ${proj}
> DOWNLOAD_COMMAND ""
> SOURCE_DIR "${${proj}_Source_Dir}"
> BINARY_DIR "${${proj}_Binary_Dir}"
> CMAKE_GENERATOR ${gen}
> CMAKE_ARGS
> -D${proj}_option1:BOOL=${proj}_option1
> -D${proj}_some_LIBRARY:FILEPATH=${proj}_some_LIBRARY
> ...
> INSTALL_DIR ${proj}/path/
> DEPENDSsd
> ${proj_DEPENDS})
>
> Is there an easier way to pass all the options to the 'normal' build?
>
> -Jameson
>
>
>
> --
> View this message in context:
> http://cmake.3232098.n2.nabble.com/Question-regarding-External-Project-add-and-VTK-tp7587557p7587560.html
> Sent from the CMake mailing list archive at Nabble.com.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
+1 919 869 8849
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Bracket Argument

2014-06-02 Thread James Bigler
Are there some good examples of why one would use bracket arguments?  I'm
trying to understand the anticipated use cases.  The bracket comments are
great for a /**/ substitute.

James
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Question regarding External Project add and VTK

2014-06-02 Thread jmerkow
Jc,

Thanks a lot this may be exactly what I am looking for. 

Basically I include ExternalProjectDependency in my project, then
mark_as_superbuild() options/vars that I want to pass back to the 'normal'
build.  Add the external project with 'CMAKE_CACHE_ARGS' and this will pass
those variables to the build (assuming that it has the same name).  Then as
long as a lib is contained in '${${PROJECT_NAME}_DEPENDS}' it will be loaded
from the Externals dir (set(EXTERNAL_PROJECT_DIR
${CMAKE_CURRENT_SOURCE_DIR}/TheExternals)), similar to the FindPackage(lib)
mechanic.  
Does this sum it up? 

I've added a few mark_as_superbuild to my project is there an easy way to
list out what variables will me passed?

-Jameson



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Question-regarding-External-Project-add-and-VTK-tp7587557p7587563.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Question regarding External Project add and VTK

2014-06-02 Thread Jean-Christophe Fillion-Robin
Hi Jameson,

That is indeed the idea.


To clarify even further,

1) the call to

   ExternalProject_Include_Dependencies [1]

should be added before "ExternalProject_Add".  It  will recursively include
the needed dependencies.


2) By simply adding an additional parameter:

by default ${_EP_ARGS}

to ExternalProject_Add, the required argument will be automatically set.
These includes CMAKE_CACHE_ARGS, CMAKE_ARGS, CMAKE_GENERATOR,
LIST_SEPARATOR. See [2] for an example. Note that doesn't prevent you to
explicitly pass additional CMAKE(_CACHE)_ARGS.


3) The name of the variable  to pass to ExternalProject_Add can explicitly
be specified by passing the EP_ARGS_VAR variable. See [3] for full
signature.


4) Using this module implies that each external project will be specified
in a separate file. This is currently needed because the "return()" command
is called in case the external project has already been included by an
other project.


5) To debug, it is possible to uncomment line referenced in [4]


6) The yet to be integrated module "ExternalProjectForNonCMakeProject"
could also be useful. See [5]


7) Finally, the best way to contribute, propose API change to support more
use case or ask question is pull requests :) The list issue is available
here: https://github.com/commontk/Artichoke/issues

Hth
Jc

[1]
https://github.com/Slicer/Slicer/blob/45bba0632e37239be3ae3d2ca4b5cf0833dbe4fc/SuperBuild/External_VTKv6.cmake#L11

[2]
https://github.com/Slicer/Slicer/blob/45bba0632e37239be3ae3d2ca4b5cf0833dbe4fc/SuperBuild/External_VTKv6.cmake#L100

[3]
http://cmake-artichoke.readthedocs.org/en/latest/ExternalProjectDependency.html#function:ExternalProject_Include_Dependencies

[4]
https://github.com/commontk/Artichoke/blob/b0cf6fc85d5a490dc5a10a8f4a319678151722d2/ExternalProjectDependency.cmake#L671-675

[5] https://github.com/commontk/Artichoke/issues/7


On Tue, Jun 3, 2014 at 1:49 AM, jmerkow  wrote:

> Jc,
>
> Thanks a lot this may be exactly what I am looking for.
>
> Basically I include ExternalProjectDependency in my project, then
> mark_as_superbuild() options/vars that I want to pass back to the 'normal'
> build.  Add the external project with 'CMAKE_CACHE_ARGS' and this will pass
> those variables to the build (assuming that it has the same name).  Then as
> long as a lib is contained in '${${PROJECT_NAME}_DEPENDS}' it will be
> loaded
> from the Externals dir (set(EXTERNAL_PROJECT_DIR
> ${CMAKE_CURRENT_SOURCE_DIR}/TheExternals)), similar to the FindPackage(lib)
> mechanic.
> Does this sum it up?
>
> I've added a few mark_as_superbuild to my project is there an easy way to
> list out what variables will me passed?
>

See remark (5) above.


>
> -Jameson
>
>
>
> --
> View this message in context:
> http://cmake.3232098.n2.nabble.com/Question-regarding-External-Project-add-and-VTK-tp7587557p7587563.html
> Sent from the CMake mailing list archive at Nabble.com.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
+1 919 869 8849
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake