Hi:
It solved the compiler definitions. However, when I come to work with library, it came with further errors. In my project, we have an extra configuration named GraphicDebug. I want to have my project to use different library files which are compiled using different options. Firstly I tried this: add_library(foo_lib_use STATIC IMPORTED) set_property(TARGET foo_lib_use PROPERTY IMPORTED_LOCATION_GRAPHICDEBUG libfoo_gdbg.a ) It failed to set foo_lib_use: Demo/Demo: juze_lib_use-NOTFOUND I guessed the XXX_<Config> don't work for customized configs, then I tried $<$<>> way: add_library(foo_lib_use STATIC IMPORTED) set_property(TARGET foo_lib_use PROPERTY IMPORTED_LOCATION $<$<CONFIG:Debug>: libfoo_dbg.a> $<$<CONFIG:GraphicDebug>: libfoo_gdbg.a> $<$<CONFIG:Release>: libfoo_rel.a> $<$<CONFIG:RelWithDebInfo>: libfoo_reldbg.a> ) However, the foo_lib_use is not properly set according to configuration, it was instead set to the whole string with all $<$<>> stuffs. This is the line in generated build.make: Demo/Demo: $<$<CONFIG:Debug>:;/home/yangxi/software/JUZE/lib/libjuce_dbg.a>;$<$<CONFIG:GraphicDebug>:;/home/yangxi/software/JUZE/lib/libjuce_gdbg.a>;$<$<CONFIG:Release>:;/home/yangxi/software/JUZE/lib/libjuce_rel.a>;$<$<CONFIG:RelWithDebInfo>:/home/yangxi/software/JUZE/lib/libjuce_reldbg.a> So, how can I properly set the library according to configuration? Thanks! 在 2015-07-17 21:42:50,"Petr Kmoch" <petr.km...@gmail.com> 写道: Hi. Looking at the documentation ( 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-targets ), 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: set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:FOO> $<$<CONFIG:Release>:BAR>) Petr On Fri, Jul 17, 2015 at 3:08 PM, Xi Yang <jianding...@163.com> wrote: 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
-- 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