Matthias, check out the following article which solves exactly the same
problem as yours, just with GoogleTest as the third party package:

https://crascit.com/2015/07/25/cmake-gtest/

It includes a fully general implementation hosted on github (MIT license)
which you can use directly in your project. The technique discussed there
causes the download to happen immediately so that the sources can be pulled
in via add_subdirectory() without having to restructure  your project as a
superbuild. FWIW, a superbuild is also a good solution, the above article
is just another alternative.



On Sat, Apr 9, 2016 at 6:27 AM, Nicholas Braden <nicholas11bra...@gmail.com>
wrote:

> To solve the dependency order problem, generally you would make a
> superbuild which builds your dependencies and also your own project
> via ExternalProject, using the DEPENDS option to guarantee build
> order. This way all your dependencies are fully built and installed
> before it even gets to configuring your own project.
>
> On Fri, Apr 8, 2016 at 3:25 PM, Matthias Möller <mmoel...@gmail.com>
> wrote:
> > Dear all,
> >
> > I have difficulties including a XYZ.cmake file from an external project.
> >
> > ExternalProject_Add(MTL4
> >     SVN_REPOSITORY    https://simunova.zih.tu-dresden.de/svn/mtl4/trunk
> >     SVN_USERNAME      guest
> >     SVN_PASSWORD      guest
> >     SVN_TRUST_CERT    1
> >     TIMEOUT           180
> >     PREFIX            ${CMAKE_BINARY_DIR}/external/MTL4
> >     CONFIGURE_COMMAND ""
> >     BUILD_COMMAND     ""
> >     INSTALL_COMMAND   “"
> > )
> >
> > ExternalProject_Get_Property(MTL4 source_dir)
> > set(MTL4_INCLUDE_DIRS ${source_dir})
> > set(MTL_DIR ${source_dir})
> >
> > # Include MTLConfig from the unpacked(!!!) MTL4 library
> > include("${source_dir}/MTLConfig.cmake" OPTIONAL RESULT_VARIABLE
> > MTLCONFIG_FOUND)
> >
> >
> > # MTL4 is a header-only library, hence downloading and unpacking is
> > sufficient
> > add_executable (demo demo.cxx)
> > add_dependencies(demo MTL4)
> >
> > The problem is, that in a fresh build the MTL4 library is not yet
> unpacked,
> > and hence, the MTLConfig.cmake file is not available.
> > How can I “include(…)” a cmake file which is only available after the
> > external project has been processed?
> >
> > Kind regards,
> > Matthias
> >
> >
> > --
> >
> > 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://public.kitware.com/mailman/listinfo/cmake
> --
>
> 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://public.kitware.com/mailman/listinfo/cmake




-- 
Craig Scott
Melbourne, Australia
http://crascit.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://public.kitware.com/mailman/listinfo/cmake

Reply via email to