[CMake] What is the preferred way to avoid "same name already exists" error
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Thu Oct 3 14:56:38 EDT 2013
tOn 2013-10-03 11:24-0700 Jimi Damon wrote:
> Hi,
>
> I have a number of directories that are named according to an acquisition
> board in our full product line. Under each directory there are sample
> programs labeled "sample1.c", "sample2.c" ...etc. While this isn't a very
> useful naming convention, I ran into the problem of when I migrated the
> current GNU makefile based system over to CMAKE, I tried to create a
> structure like the following
>
> add_subdirectory( samples/Product1 )
> add_subdirectory( samples/Product2 )
>
>
> What happens is that I get the error saying
> * add_executable cannot create target "sample" because another target with
> the same name already exists. The existing target is an executable created
> in source directory*
>
> What I was trying to get is a namespace encapsulated sample, such that I
> would have to issue a
>
> make samples/Product1/sample1 in order to build that sample.
>
> Is there a way to prevent these namespace collisions other than just renaming
> every single executable to have a unique name ? I want to know the correct
> answer to this because I have a feeling that in the future I won't always
> want to keep every single target name unique.
One possibility is to make each product an individual CMake project
and implement an overall CMake project that used ExternalProject_Add
to build any of those products as needed and with appropriate
dependencies between them.
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
-------------- next part --------------
--
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
More information about the CMake
mailing list