I am using CMake to build and pack a C++ Web Application. The application needs additional CSS and Javascript files. To ease the installation process on different machines I prepare a ZIP file and add the required files using rules similar to the following ones.
# add javascript/CSS
install(DIRECTORY "${PROJECT_SOURCE_DIR}/css" DESTINATION "${THE_HTDOCS_DIR}"
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
# add images/icons
install(DIRECTORY "${PROJECT_SOURCE_DIR}/ico" DESTINATION "${THE_HTDOCS_DIR}"
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
What is the best way to integrate a compressor or minify tool into the CMake/CPack release process? For example it would be nice to call the YUICompressor to compress the CSS/JS files. I haven’t found any hints to solve this during my web search. So any hint is welcome.
Using ant or other build systems is not an option for me – I am aware of ant support for YUICompressor.
I needed this for myself and used CMake add_custom_command() and add_custom_target() to call the minifier. It looks for the yui-copmressor binary and compresses if CMAKE_BUILD_TYPE is not “Debug” so you have it a little easier while developing.
Be sure you adapt the DESTINATION of the install commands. 😉