Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8878005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:36:28+00:00 2026-06-14T19:36:28+00:00

I am using CMake to build and pack a C++ Web Application. The application

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:36:30+00:00Added an answer on June 14, 2026 at 7:36 pm

    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.

    set(js_in_files
        foo.js
        bar.js
        baz.js
    )
    
    find_program(YUI_EXECUTABLE yui-compressor)
    if(YUI_EXECUTABLE AND (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug"))
        message(STATUS "JS files will be minified before install.")
        foreach(jsfile ${js_in_files})
            set(jsmin "${CMAKE_CURRENT_BINARY_DIR}/${jsfile}.min")
            add_custom_command(OUTPUT ${jsmin}
                COMMAND ${YUI_EXECUTABLE}
                ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${jsfile}" -o "${jsmin}"
            )
            install(FILES ${jsmin}
                DESTINATION "${WEB_INSTALL_PATH}/cgi-bin/scripts/"
                RENAME ${jsfile}
            )
            set(js_out_files ${js_out_files} ${jsmin})
        endforeach(jsfile)
    else()
        message(STATUS "JS files will be installed unmodified.")
        foreach(jsfile ${js_in_files})
            install(FILES ${jsfile}
                DESTINATION "${WEB_INSTALL_PATH}/cgi-bin/scripts/"
            )
            set(js_out_files ${js_out_files} ${jsfile})
        endforeach(jsfile)
    endif()
    
    add_custom_target(installjs ALL DEPENDS ${js_out_files})
    

    Be sure you adapt the DESTINATION of the install commands. 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using CMake to build a Qt based application of mine on Windows with
I am using CMake to build my project and I have the following line:
I have downloaded mysql-connector-c-6.0.2. I build it using below commands: cmake -G Unix Makefiles
I want to run code which needs boost libraries. I built it using CMake.
I have an c++ application developed using gcc(4.1) and compiled with CMAKE MakeFiles .
I'm using cmake to generate an nmake build system using the NMake Makefiles generator.
This is my first time using CMake and I'm trying to build QJSon, a
I have been using cmake to build my projects out of source, which is
I have built the OpenCV libraries using the cmake build system as described here
I want to set up automated build using CMake on Windows. I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.