#visual-studio-2010 #cmake
#visual-studio-2010 #cmake
Вопрос:
Есть ли способ настроить CMake для создания файла проекта VS2010, в котором есть событие предварительной сборки или после сборки?
Спасибо.
Ответ №1:
Из документации CMake:
add_custom_command(TARGET target
PRE_BUILD | PRE_LINK | POST_BUILD`
COMMAND command1 [ARGS] [args1...]
[COMMAND command2 [ARGS] [args2...] ...]
[WORKING_DIRECTORY dir]
[COMMENT comment] [VERBATIM])
This defines a new command that will be associated with building the specified
target. When the command will happen is determined by which of the following
is specified:
PRE_BUILD - run before all other dependencies
PRE_LINK - run after other dependencies
POST_BUILD - run after the target has been built
Note that the PRE_BUILD option is only supported on Visual Studio 7 or later.
For all other generators PRE_BUILD will be treated as PRE_LINK.
Например, если ваша цель названа MyProject
и вы хотите запустить команду SomeCommand
с аргументом -1 -2
после сборки, добавьте следующую строку после вашего add_executable
add_library
вызова или, потому что цель должна быть определена:
add_custom_command(TARGET MyProject
POST_BUILD
COMMAND SomeCommand ARGS "-1 -2"
COMMENT "Running SomeCommand")
Дополнительные сведения о том, как его использовать, см. В документации add_custom_command
.
Комментарии:
1. Хорошо структурированный и совершенно полезный ответ. : D