[CMake] Including another CMakeLists project

Petr Bena benapetr at gmail.com
Wed Dec 10 10:00:03 EST 2014


Yup, that works.

Thanks

On Wed, Dec 10, 2014 at 3:48 PM, Parag Chandra <parag at ionicsecurity.com> wrote:
> I think you may want to try the add_subdirectory() command instead of
> include(), if you truly have multiple projects that are being built by
> CMake. The name suggests that it would only work with a hierarchical
> directory structure, but that is not the case - you can specify absolute
> paths if necessary.
>
> On the other hand, if you need to use include() to add shared logic across
> build scripts (but not actual entire projects), then it¹s helpful to think
> of include() as analogous to the #include directive. I¹ve found that I
> needed to condition guard the included file, something like this:
>
> if (NOT (DEFINED Foo_cmake))
> set (Foo_cmake TRUE)
> # Add shared logic below, then end with:
> endif ()
>
> Hope this helps.
>
>
> Parag Chandra
> Software Engineer, Mobile Team
> Mobile: +1.919.824.1410
>
>  <https://ionic.com>
>
> Ionic Security Inc.
> 1170 Peachtree St. NE STE 2285, Atlanta, GA 30309
>
>
>
>
>
>
>
>
>
>
>
> On 12/10/14, 9:42 AM, "Petr Bena" <benapetr at gmail.com> wrote:
>
>>I have 3 projects, all using cmake. When I run cmake on each of them
>>and separately build them, it's all fine.
>>
>>When I use include() on these 2 cmake files in 1 of them, so that I
>>could run only 1 cmake and then build them all using 1 make, it fails.
>>
>>I believe that these 3 cmakes are colliding with each other, is there
>>a way to run it isolated?
>>--
>>
>>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
>


More information about the CMake mailing list