121 lines
3.9 KiB
CMake
121 lines
3.9 KiB
CMake
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
|
|
|
# add project files
|
|
set(WEB_FILES
|
|
3rdparty/jquery-1.11.2/jquery.min.js
|
|
3rdparty/bootstrap/css/bootstrap-theme.min.css
|
|
3rdparty/bootstrap/css/bootstrap.min.css
|
|
3rdparty/bootstrap/fonts/glyphicons-halflings-regular.eot
|
|
3rdparty/bootstrap/fonts/glyphicons-halflings-regular.svg
|
|
3rdparty/bootstrap/fonts/glyphicons-halflings-regular.ttf
|
|
3rdparty/bootstrap/fonts/glyphicons-halflings-regular.woff
|
|
3rdparty/bootstrap/fonts/glyphicons-halflings-regular.woff2
|
|
3rdparty/bootstrap/js/bootstrap.min.js
|
|
3rdparty/bootstrap_dropdowns_enhancement/css/dropdowns-enhancement.min.css
|
|
css/core.css
|
|
css/dashboard.css
|
|
js/client.js
|
|
js/entrymanagement.js
|
|
js/expandcollapse.js
|
|
js/groupmanagement.js
|
|
js/packagemanagement.js
|
|
js/pagemanagement.js
|
|
js/pagination.js
|
|
js/proto.js
|
|
js/repomanagement.js
|
|
js/tabbing.js
|
|
js/utils.js
|
|
)
|
|
|
|
# insert meta data in index.html
|
|
configure_file(
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/index.html"
|
|
"${CMAKE_BINARY_DIR}/web/index.html"
|
|
)
|
|
|
|
# add install target for web files / minimizing
|
|
# -> don't minimize debug builds
|
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
# find JavaScript/CSS minimizer
|
|
find_program(YUI_EXECUTABLE yuicompressor)
|
|
if(YUI_EXECUTABLE)
|
|
set(JS_MIN_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/jsmin.sh")
|
|
endif()
|
|
if(NOT JS_MIN_EXECUTABLE)
|
|
message(STATUS "YUI compressor not found -> installing JavaScript/CSS files unminimized")
|
|
endif()
|
|
# find html minimizer
|
|
find_program(HTML_MIN_EXECUTABLE htmlmin)
|
|
endif()
|
|
if(NOT HTML_MIN_EXECUTABLE)
|
|
message(STATUS "htmlmin not found -> installing HTML files unminimized")
|
|
# install unminimized index.html
|
|
install(
|
|
FILES "${PROJECT_BINARY_DIR}/web/index.html"
|
|
DESTINATION share/${META_PROJECT_NAME}/web
|
|
COMPONENT web
|
|
)
|
|
else()
|
|
# minimize index.html
|
|
set(MIN_FILE "${PROJECT_BINARY_DIR}/web/index.min/index.html")
|
|
add_custom_command(
|
|
OUTPUT ${MIN_FILE}
|
|
COMMAND "${HTML_MIN_EXECUTABLE}"
|
|
ARGS "${HTML_MIN_EXECUTABLE}" "${PROJECT_BINARY_DIR}/web/index.html" "${MIN_FILE}"
|
|
)
|
|
install(
|
|
FILES ${MIN_FILE}
|
|
DESTINATION share/${META_PROJECT_NAME}/web
|
|
COMPONENT web
|
|
)
|
|
list(APPEND HTML_MIN_FILES "${MIN_FILE}")
|
|
endif()
|
|
foreach(WEB_FILE ${WEB_FILES})
|
|
# check whether file can be minimized
|
|
get_filename_component(WEB_DIR ${WEB_FILE} DIRECTORY)
|
|
get_filename_component(WEB_EXT ${WEB_FILE} EXT)
|
|
if(JS_MIN_EXECUTABLE AND (${WEB_EXT} STREQUAL ".js" OR ${WEB_EXT} STREQUAL ".css"))
|
|
# minimize web file
|
|
set(MIN_FILE "${CMAKE_CURRENT_BINARY_DIR}/min/${WEB_FILE}")
|
|
add_custom_command(
|
|
OUTPUT ${MIN_FILE}
|
|
COMMAND "${JS_MIN_EXECUTABLE}"
|
|
ARGS "${YUI_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/${WEB_FILE}" "${MIN_FILE}"
|
|
)
|
|
install(
|
|
FILES ${MIN_FILE}
|
|
DESTINATION share/${META_PROJECT_NAME}/web/${WEB_DIR}
|
|
COMPONENT web
|
|
)
|
|
list(APPEND JS_MIN_FILES "${MIN_FILE}")
|
|
else()
|
|
# install unminimized version of web file
|
|
install(
|
|
FILES ${WEB_FILE}
|
|
DESTINATION share/${META_PROJECT_NAME}/web/${WEB_DIR}
|
|
COMPONENT web
|
|
)
|
|
endif()
|
|
endforeach()
|
|
install(
|
|
FILES ../resources/icons/hicolor/scalable/apps/${META_PROJECT_NAME}.svg
|
|
DESTINATION share/${META_PROJECT_NAME}/web/img
|
|
COMPONENT web
|
|
)
|
|
|
|
# add target for minimizing
|
|
if(HTML_MIN_FILES)
|
|
add_custom_target(htmlmin ALL DEPENDS ${HTML_MIN_FILES})
|
|
endif()
|
|
if(JS_MIN_FILES)
|
|
add_custom_target(jsmin ALL DEPENDS ${JS_MIN_FILES})
|
|
endif()
|
|
|
|
# add install target
|
|
if(NOT TARGET install-web)
|
|
add_custom_target(install-web
|
|
DEPENDS ${META_PROJECT_NAME}
|
|
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=web -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
|
)
|
|
endif()
|