2015-09-13 20:25:26 +00:00
|
|
|
###
|
|
|
|
### Copyright 2015 Oliver Giles
|
|
|
|
###
|
|
|
|
### This file is part of Laminar
|
|
|
|
###
|
|
|
|
### Laminar is free software: you can redistribute it and/or modify
|
|
|
|
### it under the terms of the GNU General Public License as published by
|
|
|
|
### the Free Software Foundation, either version 3 of the License, or
|
|
|
|
### (at your option) any later version.
|
|
|
|
###
|
|
|
|
### Laminar is distributed in the hope that it will be useful,
|
|
|
|
### but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
### GNU General Public License for more details.
|
|
|
|
###
|
|
|
|
### You should have received a copy of the GNU General Public License
|
|
|
|
### along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
###
|
|
|
|
project(laminar)
|
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
|
|
|
add_definitions("-std=c++11 -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror -DDEBUG")
|
|
|
|
|
|
|
|
# This macro takes a list of files, gzips them and converts the output into
|
|
|
|
# object files so they can be linked directly into the application.
|
|
|
|
# ld generates symbols based on the string argument given to its executable,
|
|
|
|
# so it is significant from which directory it is called. BASEDIR will be
|
|
|
|
# removed from the beginning of paths to the remaining arguments
|
|
|
|
macro(generate_compressed_bins BASEDIR)
|
|
|
|
foreach(FILE ${ARGN})
|
|
|
|
set(COMPRESSED_FILE "${FILE}.z")
|
|
|
|
set(OUTPUT_FILE "${FILE}.o")
|
2015-11-19 20:43:57 +00:00
|
|
|
get_filename_component(DIR ${FILE} PATH)
|
2015-09-13 20:25:26 +00:00
|
|
|
if(DIR)
|
|
|
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
|
|
|
|
endif()
|
|
|
|
add_custom_command(OUTPUT ${COMPRESSED_FILE}
|
|
|
|
COMMAND gzip < ${BASEDIR}/${FILE} > ${COMPRESSED_FILE}
|
|
|
|
DEPENDS ${BASEDIR}/${FILE}
|
|
|
|
)
|
|
|
|
add_custom_command(OUTPUT ${OUTPUT_FILE}
|
|
|
|
COMMAND ld -r -b binary -o ${OUTPUT_FILE} ${COMPRESSED_FILE}
|
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COMPRESSED_FILE}
|
|
|
|
)
|
|
|
|
list(APPEND COMPRESSED_BINS ${OUTPUT_FILE})
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Generates Cap'n Proto interface from definition file
|
|
|
|
add_custom_command(OUTPUT laminar.capnp.c++ laminar.capnp.h
|
|
|
|
COMMAND capnp compile -oc++:${CMAKE_BINARY_DIR}
|
|
|
|
--src-prefix=${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/laminar.capnp
|
|
|
|
DEPENDS src/laminar.capnp)
|
|
|
|
|
|
|
|
# Zip and compile statically served resources
|
|
|
|
generate_compressed_bins(${CMAKE_SOURCE_DIR}/src/resources index.html js/app.js
|
2015-09-26 20:54:27 +00:00
|
|
|
tpl/home.html tpl/job.html tpl/run.html tpl/browse.html
|
2015-11-01 10:24:28 +00:00
|
|
|
favicon.ico favicon-152.png icon.png progress.png)
|
2015-09-13 20:25:26 +00:00
|
|
|
# Download 3rd-party frontend JS libs...
|
|
|
|
file(DOWNLOAD https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js
|
|
|
|
js/angular.min.js EXPECTED_MD5 b1137641dbb512a60e83d673f7e2d98f)
|
|
|
|
file(DOWNLOAD https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-route.min.js
|
|
|
|
js/angular-route.min.js EXPECTED_MD5 28ef7d7b4349ae0dce602748185ef32a)
|
|
|
|
file(DOWNLOAD https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-sanitize.min.js
|
|
|
|
js/angular-sanitize.min.js EXPECTED_MD5 0854eae86bcdf5f92b1ab2b458d8d054)
|
|
|
|
file(DOWNLOAD https://raw.githubusercontent.com/drudru/ansi_up/v1.3.0/ansi_up.js
|
|
|
|
js/ansi_up.js EXPECTED_MD5 158566dc1ff8f2804de972f7e841e2f6)
|
|
|
|
file(DOWNLOAD https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js
|
|
|
|
js/Chart.min.js EXPECTED_MD5 0d3004601c1a855a3d203502549528a7)
|
|
|
|
file(DOWNLOAD https://raw.githubusercontent.com/tomsouthall/Chart.HorizontalBar.js/v1.04/Chart.HorizontalBar.js
|
|
|
|
js/Chart.HorizontalBar.js EXPECTED_MD5 95070a38e69bc56534e1b2086d985270)
|
|
|
|
file(DOWNLOAD https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css
|
|
|
|
css/bootstrap.min.css EXPECTED_MD5 5d5357cb3704e1f43a1f5bfed2aebf42)
|
|
|
|
# ...and compile them
|
|
|
|
generate_compressed_bins(${CMAKE_BINARY_DIR} js/angular.min.js js/angular-route.min.js
|
|
|
|
js/angular-sanitize.min.js js/ansi_up.js js/Chart.min.js js/Chart.HorizontalBar.js
|
|
|
|
css/bootstrap.min.css)
|
|
|
|
# (see resources.cpp where these are fetched)
|
|
|
|
|
|
|
|
## Server
|
|
|
|
add_executable(laminard src/database.cpp src/main.cpp src/server.cpp src/laminar.cpp
|
2015-09-24 20:02:11 +00:00
|
|
|
src/conf.cpp src/resources.cpp src/run.cpp laminar.capnp.c++ ${COMPRESSED_BINS})
|
2015-09-13 20:25:26 +00:00
|
|
|
# TODO: some alternative to boost::filesystem?
|
2015-12-06 12:47:43 +00:00
|
|
|
target_link_libraries(laminard capnp-rpc capnp kj-async kj pthread boost_filesystem boost_system sqlite3 z)
|
2015-09-13 20:25:26 +00:00
|
|
|
|
|
|
|
## Client
|
|
|
|
add_executable(laminarc src/client.cpp laminar.capnp.c++)
|
2015-11-19 20:44:18 +00:00
|
|
|
target_link_libraries(laminarc capnp-rpc capnp kj-async kj pthread)
|
2015-09-13 20:25:26 +00:00
|
|
|
|
2015-09-19 12:50:22 +00:00
|
|
|
install(TARGETS laminard laminarc RUNTIME DESTINATION usr/bin)
|
|
|
|
install(FILES laminar.service DESTINATION usr/lib/systemd/system)
|
|
|
|
install(FILES laminar.conf DESTINATION etc)
|