Hi everyone!

I'm trying to use config-specific definitions, but it seems doesn't work in 
VS2013.


This is the CMakeLists.txt:


cmake_minimum_required(VERSION 3.0)


set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG
    FOO
)


set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_RELEASE
    BAR
)


add_executable(main main.cpp)
set_target_properties(main
    PROPERTIES
        COMPILE_DEFINITIONS_DEBUG   FOO
        COMPILE_DEFINITIONS_RELEASE BAR
)


Both target property and directory property are tried. And this is the source 
code main.cpp:


#ifdef FOO
#error got foo
#endif


#ifdef BAR
#error got bar
#endif


int main(int argc, char** argv)
{
    return 0;
}


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.


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".


Thanks for a lot!
-- 

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://public.kitware.com/mailman/listinfo/cmake

Reply via email to