<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 id="netease_mail_footer"></span></span>