Secure collaboration server using 0MQ and Curve.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

84 lines
2.8 KiB

# Project settings and common targets.
# Copyright (C) 2019-2021 David Sugar <tychosoft@gmail.com>.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
if(NOT UNIX)
error("Unsupported platform")
endif()
string(TOLOWER "${PROJECT_NAME}" PROJECT_ARCHIVE)
include(GNUInstallDirs)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(RELEASE AND NOT PROJECT_RELEASE)
set(PROJECT_RELEASE "${RELEASE}")
elseif(NOT PROJECT_RELEASE)
set(PROJECT_RELEASE "1")
endif()
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(EXISTS "/usr/local/lib/")
include_directories("/usr/local/include")
link_directories("/usr/local/lib")
list(APPEND lint_tidy_includes -I/usr/local/include)
endif()
if(EXISTS "/usr/pkg/lib/")
include_directories("/usr/pkg/include")
link_directories("/usr/pkg/lib")
list(APPEND lint_tidy_includes -I/usr/pkg/include)
endif()
endif()
if(NOT DEFINED OPEN_BROWSER)
set(OPEN_BROWSER "xdg-open")
endif()
if(NOT DEFINED DB_HOST)
set(DB_HOST "")
endif()
if(NOT DEFINED DB_NAME)
set(DB_NAME "${PROJECT_ARCHIVE}")
endif()
if(NOT DEFINED DB_MIGRATION)
set(DB_MIGRATION "postgres://${DB_HOST}/${DB_NAME}")
endif()
# Common tarball distribution
add_custom_target(dist
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "${CMAKE_COMMAND}" -E remove -F "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_ARCHIVE}-*.tar.gz"
COMMAND git archive -o "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_ARCHIVE}-${PROJECT_VERSION}.tar.gz" --format tar.gz --prefix="${PROJECT_ARCHIVE}-${PROJECT_VERSION}/" "v${PROJECT_VERSION}" 2>/dev/null || git archive -o "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_ARCHIVE}-${PROJECT_VERSION}.tar.gz" --format tar.gz --prefix="${PROJECT_ARCHIVE}-${PROJECT_VERSION}/" HEAD
)
# Documentation generation
find_package(Doxygen COMPONENTS dot doxygen)
if(DOXYGEN_FOUND)
add_custom_target(docgen
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
COMMAND ${OPEN_BROWSER} out/html/index.html
)
endif()
# Introduce project migration targets
find_program(SEQUEL_EXECUTABLE NAMES sequel)
if(EXISTS "${SEQUEL_EXECUTABLE}")
add_custom_target(migration
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND ${SEQUEL_EXECUTABLE} -m db ${DB_MIGRATION}
)
add_custom_target(unmigrate
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND ${SEQUEL_EXECUTABLE} -m db -M 0 ${DB_MIGRATION}
)
endif()