<div dir="ltr"><div>SET_TARGET_PROPERTIES( <target> PROPERTIES</div><div>                  COMPILE_FLAGS  "${ExtraFlags}"</div><div>                  COMPILE_DEFINITIONS "SIMPLE_FLAG;DEFINED_SYMBOL=xxxx;DEFINED_STRING=\"string value\""</div><div> )</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 26, 2015 at 11:07 AM, Murali Paluru <span dir="ltr"><<a href="mailto:mpaluru@gmail.com" target="_blank">mpaluru@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi David,<div><br></div><div>The project that I am working on has similar needs of having different flags for each target. I have placed the different targets in different sub-folders and set the CMAKE_*_FLAGS. This approach seems to work fine as you mentioned. </div><div><br></div><div>From my understanding, a new add_subdirectory creates a new scope of variables. </div><div><br></div><div>I feel that having different targets in different directories is a good logical separation. So if that's working for you, why not use it? I am not sure if there is a better way, but I hope someone will comment.</div><div><br></div><div>Regards,</div><div>Murali.</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 25, 2015 at 1:04 PM, David Hauck <span dir="ltr"><<a href="mailto:davidh@netacquire.com" target="_blank">davidh@netacquire.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I've been searching for a definitive discussion of this but haven't been successful finding it. I have a (Unix Makefile) CMakeLists.txt project sub-directory that defines several (3) targets (for executable and shared targets). I'm trying to reset/redefine the CMAKE_C??_FLAGS (specifically CMAKE_C_FLAGS) property on one of the targets via the following statement in the CMakeLists.txt file:<br>
<br>
set_property(TARGET <target_name> PROPERTY CMAKE_C_FLAGS "-Wall -shared")<br>
set_property(TARGET <target_name> PROPERTY CMAKE_C_FLAGS_DEBUG "-g")<br>
set_property(TARGET <target_name> PROPERTY CMAKE_C_FLAGS_RELEASE "-O3")<br>
<br>
However, this isn't working and the resulting target compilation is using the directory's value for these properties. Other redefinitions of per-target properties (e.g., INCLUDE_DIRECTORIES) do seem to take so I'm wondering if certain properties are per-directory only and aren't meaningful with the "set_property(TARGET ...)" construct?<br>
<br>
If I move the target to its own sub-directory and use the following CMakeLists.txt commands instead the compile flags are properly (re)set:<br>
<br>
SET (CMAKE_C_FLAGS "-Wall -shared")<br>
SET (CMAKE_C_FLAGS_DEBUG "-g")<br>
SET (CMAKE_C_FLAGS_RELEASE "-O3")<br>
<br>
Oddly the aforementioned "set_property(TARGET..." constructs in place of the above "SET(CMAKE..." constructs also fail to reset the flags in this new directory so this doesn't seem related to the sub-directory CMakeLists.txt file when multiple targets are defined.<br>
<br>
I must have missed something obvious related to this in the documentation and/or the mailing list/Google. Any ideas?<br>
<br>
Thanks,<br>
-David<br>
<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>
</div></div><br>--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>