<div dir="ltr"><div><div><div>Hi.<br><br></div>Looking at the documentation ( <a href="http://www.cmake.org/cmake/help/v3.3/manual/cmake-properties.7.html#properties-on-directories">http://www.cmake.org/cmake/help/v3.3/manual/cmake-properties.7.html#properties-on-directories</a> , <a href="http://www.cmake.org/cmake/help/v3.3/manual/cmake-properties.7.html#properties-on-targets">http://www.cmake.org/cmake/help/v3.3/manual/cmake-properties.7.html#properties-on-targets</a> ), you will find that neither the directory property nor the target property COMPILE_DEFINITIONS has per-configuration variants. They do support generator expressions, however, so you could use these instead:<br><br></div>  set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:FOO> $<$<CONFIG:Release>:BAR>)<br><br></div>Petr<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 17, 2015 at 3:08 PM, Xi Yang <span dir="ltr"><<a href="mailto:jiandingzhe@163.com" target="_blank">jiandingzhe@163.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi everyone!</div><div><br></div><div>I'm trying to use config-specific definitions, but it seems doesn't work in VS2013.</div><div><br></div><div>This is the CMakeLists.txt:</div><div><br></div><div><div><span style="font-family:Courier">cmake_minimum_required(VERSION 3.0)</span></div><div><br></div><div><span style="font-family:Courier">set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG</span></div><div><span style="font-family:Courier">    FOO</span></div><div><span style="font-family:Courier">)</span></div><div><br></div><div><span style="font-family:Courier">set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_RELEASE</span></div><div><span style="font-family:Courier">    BAR</span></div><div><span style="font-family:Courier">)</span></div><div><br></div><div><span style="font-family:Courier">add_executable(main main.cpp)</span></div><div><span style="font-family:Courier">set_target_properties(main</span></div><div><span style="font-family:Courier">    PROPERTIES</span></div><div><span style="font-family:Courier">        COMPILE_DEFINITIONS_DEBUG   FOO</span></div><div><span style="font-family:Courier">        COMPILE_DEFINITIONS_RELEASE BAR</span></div><div><span style="font-family:Courier">)</span></div></div><div><br></div><div>Both target property and directory property are tried. A<span style="line-height:1.7">nd this is the source code main.cpp:</span></div><div><br></div><div><div><span style="font-family:Courier">#ifdef FOO</span></div><div><span style="font-family:Courier">#error got foo</span></div><div><span style="font-family:Courier">#endif</span></div><div><br></div><div><span style="font-family:Courier">#ifdef BAR</span></div><div><span style="font-family:Courier">#error got bar</span></div><div><span style="font-family:Courier">#endif</span></div><div><br></div><div><span style="font-family:Courier">int main(int argc, char** argv)</span></div><div><span style="font-family:Courier">{</span></div><div><span style="font-family:Courier">    return 0;</span></div><div><span style="font-family:Courier">}</span></div></div><div><br></div><div>If the definitions are sent to compilers, it should die with foo on Debug config, and die with bar on Release config. However, it finished compilation on both Debug and Release.</div><div><br></div><div>I also have a look at the command line parameters of the Debug and Release config, it don't have "/D FOO" and "/D BAR".</div><div><br></div><div>Thanks for a lot!</div></div><br><br><span title="neteasefooter"><span></span></span><br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>