[CMake] Include Guard to Stop Duplicate Targets?

Aaron_Wright at selinc.com Aaron_Wright at selinc.com
Mon Oct 26 12:09:40 EDT 2009


That solution works pretty good Mike. Not quite what I thought I was 
looking for, but it works.
---------------------------------------------------------
Aaron Wright
Software Engineer - DCS Group
Schweitzer Engineering Laboratories, Inc.
Pullman, WA 99163
509-334-8087



Mike Jackson <mike.jackson at bluequartz.net> 
Sent by: cmake-bounces at cmake.org
10/24/2009 04:50 AM

To
Aaron_Wright at selinc.com
cc
cmake at cmake.org
Subject
Re: [CMake] Include Guard to Stop Duplicate Targets?






Few possibilities:
    Are Components a and b just libraries that do NOT really depend on
Executable A, B, or C? If so, then in the top level CMakeLists.txt
file add those subdirectories FIRST, then add the Executable's
directories with dependencies on components a and b.

   If components a and b are something like plugins and they need the
executables A, B or C built first then you may have to add some logic
to the components a and b to avoid adding them again.

_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio




On Fri, Oct 23, 2009 at 6:09 PM,  <Aaron_Wright at selinc.com> wrote:
>
> I have a small project with several different parts that I would like to
> build with CMake, but I'm having some trouble pulling it all together.
>
>  For example purposes, there's an overall project with three executables
> that use two static libraries. The executables and static libraries are
> produced as part of the build. The directory structure looks like this:
>
>    /
>       projects/
>          00-0000/
>             CMakeLists.txt
>       products/
>          executable_a/
>             src/
>             include/
>            CMakeLists.txt
>          executable_b/
>             src/
>             include/
>            CMakeLists.txt
>          executable_c/
>             src/
>             include/
>            CMakeLists.txt
>       components/
>          a/
>             src/
>             include/
>             CMakeLists.txt
>          b/
>             src/
>             include/
>             CMakeLists.txt
>
> I would like /projects/00-0000/CMakeLists.txt to be the top level
> CMakeLists.txt file and to contain:
>
>    PROJECT(00-0000)
>
>    ADD_SUBDIRECTORY(../../products/executable_a executable_a)
>    ADD_SUBDIRECTORY(../../products/executable_b executable_b)
>    ADD_SUBDIRECTORY(../../products/executable_c executable_c)
>
> And /products/executable_a/CMakeLists.txt to contain:
>
>    PROJECT(executable_a)
>
>    ADD_SUBDIRECTORY(../../components/a a)
>
> And /products/executable_b/CMakeLists.txt to contain:
>
>    PROJECT(executable_b)
>
>    ADD_SUBDIRECTORY(../../components/b b)
>
> And /products/executable_c/CMakeLists.txt to contain:
>
>    PROJECT(executable_c)
>
>    ADD_SUBDIRECTORY(../../components/a a)
>    ADD_SUBDIRECTORY(../../components/b b)
>
> So I have each executable using ADD_SUBDIRECTORY to get the components 
it
> needs. The problem obviously is that the CMakeLists.txt for components a 
and
> b are included twice, producing duplicate targets that CMake doesn't 
like. I
> was thinking that this was similar to header files in C/C++, and in that
> world every header files uses an include guard to prevent duplication. 
So is
> there a way in CMake to implement include guards, or rather 
ADD_SUBDIRECTORY
> guards?
>
> Or, am I headed down the wrong path entirely?
>
> ---------------------------------------------------------
> Aaron Wright
> _______________________________________________
> 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
>
_______________________________________________
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091026/22bd5846/attachment.htm>


More information about the CMake mailing list