view CMakeLists.txt @ 8:ebd8f6170cd4

Remove p in style
author David Demelier <markand@malikania.fr>
date Thu, 11 Feb 2016 13:18:03 +0100
parents 5e018b977bbd
children 18890b4edcb2
line wrap: on
line source

#
# CMakeLists.txt -- CMake build system for irccd-web
#
# Copyright (c) 2016 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

cmake_minimum_required(VERSION 3.0)
project(irccd-web)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${irccd-web_SOURCE_DIR}/cmake)

find_package(Pandoc REQUIRED)

set(WITH_IRCCDDOCDIR "" CACHE STRING "Location of irccd documentation directory")

if (NOT WITH_IRCCDDOCDIR)
	message(FATAL_ERROR "Please define WITH_IRCCDDOCDIR to the irccd's documentation output")
elseif (NOT EXISTS "${WITH_IRCCDDOCDIR}/guide.html")
	message(FATAL_ERROR "Invalid directory given (did you build the documentation?)")
endif ()

# Some variables
set(TEMPLATE ${irccd-web_SOURCE_DIR}/templates/template.html)
set(OUTPUT ${CMAKE_BINARY_DIR}/html)
set(SOURCE ${CMAKE_SOURCE_DIR})
set(JS ${CMAKE_SOURCE_DIR}/js/joke.js)
set(CSS ${CMAKE_SOURCE_DIR}/css/irccd.css)

# Prepare output
file(MAKE_DIRECTORY ${OUTPUT})
file(COPY ${CMAKE_SOURCE_DIR}/css DESTINATION ${OUTPUT})
file(COPY ${CMAKE_SOURCE_DIR}/js DESTINATION ${OUTPUT})

# Define the files to generate.
set(FILES about contribute documentation documentation download index support)

# Arguments for specific files.
set(index_VARS home:yes)

foreach (f ${FILES})
	pandoc(
		OUTPUT ${OUTPUT}/${f}.html
		SOURCES ${SOURCE}/${f}.md
		VARIABLE baseurl:. web:1 general:1 ${${f}_VARS}
		FROM markdown
		TO html5
		ARGS --no-highlight
		TEMPLATE ${TEMPLATE}
	)

	list(APPEND OUTPUTS ${OUTPUT}/${f}.html)
	list(APPEND SOURCES ${SOURCE}/${f}.md)
endforeach ()

add_custom_target(
	files
	SOURCES ${SOURCES} ${TEMPLATE} ${CSS} ${JS}
	DEPENDS ${OUTPUTS}
)

add_custom_target(
	web
	ALL
	COMMENT "Generating website"
	COMMAND ${CMAKE_COMMAND} -E copy ${WITH_IRCCDDOCDIR}/guide.html ${OUTPUT}
	COMMAND ${CMAKE_COMMAND} -E copy_directory ${WITH_IRCCDDOCDIR}/css ${OUTPUT}/css
	COMMAND ${CMAKE_COMMAND} -E copy_directory ${WITH_IRCCDDOCDIR}/api ${OUTPUT}/api
	COMMAND ${CMAKE_COMMAND} -E copy_directory ${WITH_IRCCDDOCDIR}/plugin ${OUTPUT}/plugin
	DEPENDS files
)

message("")
message("Don't forget to set WITH_WEB into the irccd's build directory !")
message("")