9
A
回答
14
從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
和你想要的建築後的參數-1 -2
運行命令SomeCommand
,添加以下行後您add_executable
或add_library
呼叫,因爲目標已經被定義爲:
add_custom_command(TARGET MyProject
POST_BUILD
COMMAND SomeCommand ARGS "-1 -2"
COMMENT "Running SomeCommand")
莫見https://cmake.org/cmake/help/v2.8.8/cmake.html#command:add_custom_command詳細瞭解如何使用add_custom_command()
。
相關問題
- 1. 在CMake中添加自定義生成步驟
- 2. cmake,add_subdirectory沒有將其添加到生成的項目文件?
- 3. 將數據文件添加到cmake生成的項目
- 4. 如何將自定義內容添加到CMake項目?
- 5. 從MSVC項目生成CMAKE?
- 6. C++ - 自定義生成事件
- 7. 自定義StronglyTyped的BindingSource添加項目
- 8. 不能添加自定義項目arrayadapter
- 9. 添加自定義項目到TShellTreeView
- 10. CMake添加頭到項目文件
- 11. 使用CMake生成Visual Studio 2015生成文件項目(GDB)
- 12. 如何自定義在故事板上添加的tabbar項目
- 13. 添加自定義iOS生成設置選項
- 14. 如何將自定義條目添加到生成的Android MANIFEST.MF
- 15. 將預處理器定義添加到cmake外部項目
- 16. 將自定義事件添加到Object3D
- 17. rcarousel添加自定義事件
- 18. 如何爲所有子模塊添加CMake自定義目標
- 19. 如何將自定義生成參數添加到Visual Studio 2013 C#項目?
- 20. 添加自定義域成員作爲業主在項目 - GAE
- 21. 與自定義文件生成器一起使用cmake
- 22. CMake:使用自定義工具輸出生成頭文件
- 23. 添加引導3自定義組件自耕農角項目
- 24. 自動將生成的源文件添加到xcode項目
- 25. VS2010「添加項目」目錄更改
- 26. 添加項目自定義ListView與自定義自定義適配器
- 27. 自定義AlertDialog.Builder添加自定義按鈕事件點擊
- 28. Qt Creator中的自動完成:如何爲cmake項目添加頭文件
- 29. 使用CMake生成C#項目
- 30. cmake:自動生成構建目錄
非常感謝... –
結構良好,非常有用的答案。 :d – MABVT