<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
So , <br>
<br>
I just discovered the solution: <br>
<br>
macro ( build_sample_cpp_file project cpp_file )<br>
GET_FILENAME_COMPONENT( tmp_cpp_file ${cpp_file} NAME )<br>
STRING(REGEX REPLACE "\\.cpp$" "" binary_name ${tmp_cpp_file})<br>
ADD_EXECUTABLE( "${project}_${binary_name}" ${cpp_file} )<br>
SET_TARGET_PROPERTIES( "${project}_${binary_name}" PROPERTIES
OUTPUT_NAME ${binary_name} ) <br>
TARGET_LINK_LIBRARIES( "${project}_${binary_name}" ${LINK_LIBS} )<br>
endmacro ( build_sample_cpp_file )<br>
<br>
Created an elongated name for the full target name and then
specified the OUTPUT_NAME to be the shortened name,<br>
<br>
<br>
<br>
On 10/03/2013 11:24 AM, Jimi Damon wrote:
<blockquote cite="mid:524DB671.6070308@accesio.com" type="cite">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
Hi,<br>
<br>
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<br>
<br>
add_subdirectory( samples/Product1 )<br>
add_subdirectory( samples/Product2 )<br>
<br>
<br>
What happens is that I get the error saying <br>
<b> add_executable cannot create target "sample" because another
target with<br>
the same name already exists. The existing target is an
executable created<br>
in source directory</b><br>
<br>
What I was trying to get is a namespace encapsulated sample, such
that I would have to issue a <br>
<br>
make samples/Product1/sample1 in order to build that sample. <br>
<br>
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.<br>
<br>
Thanks<br>
<br>
-Jimi<br>
<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">--
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>
Please keep messages on-topic and check the CMake FAQ at: <a class="moz-txt-link-freetext" href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:
CMake Support: <a class="moz-txt-link-freetext" href="http://cmake.org/cmake/help/support.html">http://cmake.org/cmake/help/support.html</a>
CMake Consulting: <a class="moz-txt-link-freetext" href="http://cmake.org/cmake/help/consulting.html">http://cmake.org/cmake/help/consulting.html</a>
CMake Training Courses: <a class="moz-txt-link-freetext" href="http://cmake.org/cmake/help/training.html">http://cmake.org/cmake/help/training.html</a>
Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake</a></pre>
<div class="moz-signature">--
<table>
<tbody>
<tr>
<td><br>
</td>
<td>
<br>
</td>
</tr>
</tbody>
</table>
<table>
</table>
</div>
</blockquote>
</body>
</html>