I\'d like to add a custom target named \"package\" which depends on install target.
When I run make package
it should cause first running make install
You can create custom target which will run install and some other script after.
For instance if you have a CMake script MyScript.cmake
:
add_custom_target(
MyInstall
COMMAND
"${CMAKE_COMMAND}" --build . --target install
COMMAND
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/MyScript.cmake"
WORKING_DIRECTORY
"${CMAKE_BINARY_DIR}"
)
You can run it by building target MyInstall
:
cmake --build /path/to/build/directory --target MyInstall
Of course you can use any scripting language. Just remember to be polite to other platforms (so probably it's a bad idea to write bash script, it will not work on windows).
For example python script MyScript.py
:
find_package(PythonInterp 3.2 REQUIRED)
add_custom_target(
MyInstall
COMMAND
"${CMAKE_COMMAND}" --build . --target install
COMMAND
"${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/MyScript.py"
WORKING_DIRECTORY
"${CMAKE_BINARY_DIR}"
)