2012/3/23 Mike Krus <m...@mve.com>: > Hi > > I would like run a script with different options for debug and release > builds. I can do this easily for Makefiles but am struggling to get it to > work for Visual Studio. > > I basically: > - add a custom command the output of which depends on the configuration > - add a custom target for that command > - add that target as a dependency of my other targets (I want the > script to run first)
Why can't you use the "PRE_BUILD" options of add_custom_command with TARGET target signature? It is not possible because this script should be run before any target? > > Here's the CMake code below... > > > My problem is that for Visual Studio ${CMAKE_BUILD_TYPE} is not set (normal) > and CMake doesn't know about $(CONFIGURATION) since it's a build time thing > (again, normal). > So as it stands, the scripts always runs at every build because it's not > picking up the correct output file. Did have a look at "generator expressions" they are meant to be used in your precise case, i.e. they are evaluated at "build time" and not at CMake time. Valid expressions are: $<CONFIGURATION> = configuration name $<TARGET_FILE:tgt> = main file (.exe, .so.1.2, .a) $<TARGET_LINKER_FILE:tgt> = file used to link (.a, .lib, .so) $<TARGET_SONAME_FILE:tgt> = file with soname (.so.3) more doc in: cmake --help-command add_custom_command -- Erk Le gouvernement représentatif n'est pas la démocratie -- http://www.le-message.org -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake