[CMake] Custom command on cpack target
Gonzalo Garramuño
ggarra13 at gmail.com
Sat Jan 14 18:44:33 EST 2017
El 10/01/17 a las 17:34, Gonzalo Garramuño escribió:
>
> I would like to run a custom command on the zip file generated by
> cpack. The idea is that I want to calculate its sha256 checksum.
> Unfortunately it seems the zip file cannot be a target in a
> CMakeLists.txt file or I'm doing something wrong.
>
> Can someone give me a hand?
>
To answer my own question and for others that might want to do the same:
# Cmake only adds the default package target if a package config file
# named CPackConfig.cmake exists in the outermost binary build directory.
# By forcing the CPack module to generate the package file under a
# different name, we prevent the "target" path from being generated.
SET( CPACK_OUTPUT_CONFIG_FILE "${CMAKE_BINARY_DIR}/BundleConfig.cmake" )
include(CPack)
ADD_CUSTOM_TARGET( bundle
COMMAND "${CMAKE_CPACK_COMMAND}"
"-C" "$<CONFIGURATION>"
"--config" "${CMAKE_BINARY_DIR}/BundleConfig.cmake"
COMMENT "Running CPack. Please wait..."
DEPENDS ${PROJECT_NAME})
IF (WIN32)
ADD_CUSTOM_COMMAND( TARGET bundle
POST_BUILD
COMMAND ${CMAKE_COMMAND} -D
CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -D VERSION=${VERSION} "-P"
"${CMAKE_CURRENT_SOURCE_DIR}/../../chocolatey/mrViewer/CMakeLists.txt"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
ENDIF( WIN32 )
This works in that instead of calling make/ninja package you call
make/ninja bundle.
--
Gonzalo Garramuño
More information about the CMake
mailing list