Commit ac507741 authored by Ciarán Ó Rourke's avatar Ciarán Ó Rourke
Browse files

* project version

* set install directories through CMake
* print built subdirectories during build
* set up installation directories
* use development flags during debug build
* remove authorisation double negative cmake variable
* update README
parent 5f97c454
Pipeline #1946 passed with stages
in 8 minutes and 9 seconds
......@@ -17,7 +17,7 @@ image: ciaranorourke/fiphoboserver:debian
-DCMAKE_PREFIX_PATH="${DEPS_DIR}"
-DCUSTOM_DOCU_PATH="${DEIMOS_DOC_DIR}"
-DDEIMOS_BUILD_DOCUMENTATION="${DEIMOS_BUILD_DOCUMENTATION}"
-DDEIMOS_DISABLE_AUTHORISATION="${DEIMOS_DISABLE_AUTHORISATION}"
-DDEIMOS_AUTHORISATION="${DEIMOS_AUTHORISATION}"
..
)
&& popd
......@@ -36,7 +36,7 @@ image: ciaranorourke/fiphoboserver:debian
DEPS_DIR: /home/superfiphoboserver/build/install
DEIMOS_DOC_DIR: ""
DEIMOS_BUILD_TESTS: "ON"
DEIMOS_DISABLE_AUTHORISATION: "OFF"
DEIMOS_AUTHORISATION: "ON"
.default_job: &default_job
tags:
......@@ -123,5 +123,5 @@ Authorisation Disabled:
<<: *default_job
variables:
<<: *default_cmake_variables
DEIMOS_DISABLE_AUTHORISATION: "ON"
DEIMOS_AUTHORISATION: "OFF"
stage: test
cmake_minimum_required(VERSION 3.0)
project(deimos)
set(CUSTOM_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
find_package(proxygen REQUIRED)
project(
deimos
VERSION 0.0.1
LANGUAGES C CXX
)
#
# Provide options to build or skip building the
# programs/libraries in the given subdirectories
# Set subdirectory options
#
option(
DEIMOS_BUILD_TESTS
"build Deimos tests. Depends on Catch2."
OFF
)
option(
DEIMOS_BUILD_DOCUMENTATION
"build Deimos Documentation. Depends on Doxygen."
OFF
)
#
# Setup installation path options.
#
# Initialy set paths to GNU defaults.
# Users can specify directoryies using the various DEIMOS_INSTALL_XXX
# variables.
# eg. setting the include install dir
# cmake -DDEIMOS_INSTALL_INCLUDE_DIR=/path/to/include /path/to/deimos
# Get some sane default install directories
include(GNUInstallDirs)
set(
DEIMOS_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE STRING
"The install directory for Deimos executables."
)
set(
DEIMOS_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING
"The install directory for Deimos libraries."
)
set(
DEIMOS_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING
"The install directory for Deimos headers."
)
set(
DEIMOS_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR} CACHE STRING
"The install directory for Deimos data (eg. cmake scripts)."
)
#
# Set build type options
#
option(
DEIMOS_DISABLE_AUTHORISATION
"build Deimos with AWS authorisation disabled. Default is enabled"
OFF
DEIMOS_AUTHORISATION
"build Deimos with AWS authorisation enabled. Default is enabled"
ON
)
#
# Find needed libraries
#
find_package(proxygen REQUIRED)
#
# Setup the Deimos library
#
add_subdirectory(src)
target_include_directories(
......@@ -33,6 +86,18 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
)
#
# Include optional subdirectories
#
# Output project build options
message(STATUS "Build options:")
message(STATUS " DEIMOS_AUTHORISATION = ${DEIMOS_AUTHORISATION}")
message(STATUS " DEIMOS_BUILD_DOCUMENTATION = ${DEIMOS_BUILD_DOCUMENTATION}")
message(STATUS " DEIMOS_BUILD_TESTS = ${DEIMOS_BUILD_TESTS}")
# Build documentation
if(DEIMOS_BUILD_DOCUMENTATION)
add_subdirectory(doc)
endif(DEIMOS_BUILD_DOCUMENTATION)
......@@ -42,3 +107,17 @@ if(DEIMOS_BUILD_TESTS)
add_subdirectory(test/unit_tests)
enable_testing()
endif(DEIMOS_BUILD_TESTS)
#
# Set up installation directories
#
install(
TARGETS deimos
EXPORT deimos-targets
RUNTIME DESTINATION ${DEIMOS_INSTALL_BINDIR}
LIBRARY DESTINATION ${DEIMOS_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${DEIMOS_INSTALL_LIBDIR}
INCLUDES DESTINATION ${DEIMOS_INSTALL_INCLUDEDIR}
)
......@@ -8,7 +8,7 @@ Deimos has many dependencies that require much patience to build. It may be simp
FROM ciaranorourke/deimos:debian
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get -y install doxygen graphviz
RUN apt-get -y install doxygen graphviz libspdlog-dev
RUN apt-get -y install \
[personal installation preferences]
CMD /home/superdeimos/tools/build_phobos.sh -r && [favourite shell]
......@@ -42,8 +42,13 @@ cmake \
[more options below] \
/path/to/deimos/project
cd /path/to/deimos/project
# Build the Deimos project
make
make -C build install
# Install the Deimos executable
make -C build install
```
### Build instructions using the superbuild
......@@ -60,21 +65,30 @@ Option | Effect
------ | ------
`-DCMAKE_CXX_COMPILER=...` | Set the C++ compiler.
`-DCMAKE_CXX_FLAGS=...` | Set the flags to pass to the C++ compiler. Overrides the default flags.
`-DCMAKE_BUILD_TYPE=...` | Set to `Release` or `Debug` for release or debug builds. Sets a number of flags by default.
#### Enabling/Disabling Sections of Deimos
Option | Effect
------ | ------
`-DDEIMOS_BUILD_TESTS=...` | Set to `ON` to build Deimos tests and enable the `make test` target, or `OFF` to skip (Default `OFF`).
`-DDEIMOS_DISABLE_AUTHORISATION=...` | Set to `ON` to disable AWS V4 authorisation (= letting everything through), or `OFF` to authorise requests (Default `OFF`).
`-DDEIMOS_AUTHORISATION=...` | Set to `OFF` to disable AWS V4 authorisation (= letting everything through), or `ON` to authorise requests (Default `ON`).
`-DDEIMOS_BUILD_DOCUMENTATION=...` | Set to `ON` to build Deimos Doxygen documentation, or `OFF` to skip (Default `OFF`).
`-DCUSTOM_DOCU_PATH=...` | Set to the path to the `src` folder in [DoxygenXMLParser](https://git.ichec.ie/sophie.wenzel-teuber/doxygen-xml-parser) to create the Markdown output from the Doxygen XML, that can also be found [here](doc/Markdown/deimos) or don't set to skip (Default `not set`).
#### Setting installation directories
Option | Effect
------ | ------
`-DDEIMOS_INSTALL_PREFIX=...` | Set to the root install directory for the compiled libraries and programs.
`-DDEIMOS_INSTALL_BINDIR=...` | Set the install directory for the `deimos` executable. Use a relative path to set the path relative to `${CMAKE_INSTALL_PREFIX}`. (Default `bin`).
`-DDEIMOS_INSTALL_LIBDIR=...` | Set the install directory for `deimos` libraries. Use a relative path to set the path relative to `${CMAKE_INSTALL_PREFIX}`. (Default `lib`).
## Testing
Units test can be run with `make -C build tests`, given `DEIMOS_BUILD_TESTS` was set to `ON` during the build process.
Integration tests can be run from the `test/integration_tests/` directory with `python -m unittest client`.
## Documentation
The Doxygen documentation can be found [here](doc/Markdown/deimos).
## Usage
......
add_library(development_flags INTERFACE)
option(DEIMOS_ENABLE_SANITIZERS "Enable address and undefined behavior sanitizers." ON)
if(DEIMOS_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(
development_flags
INTERFACE
-Wall -Wextra -Wpedantic -pedantic
-Wno-error=unknown-pragmas
-Wswitch-enum
-Wimplicit-fallthrough
-Werror
-0g
)
if(DEIMOS_ENABLE_SANITIZERS)
target_compile_options(
development_flags
INTERFACE
-fsanitize=address,undefined
-fno-sanitize=recover=all
-fno-omit-frame-pointer
)
target_link_libraries(
development_flags
INTERFACE
-fsanitize=address,undefined
)
endif(DEIMOS_ENABLE_SANITIZERS)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(development_flags INTERFACE -ferror-limit=1)
endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(development_flags INTERFACE -fmax-errors=1)
endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
......@@ -14,15 +14,21 @@ add_executable(
main.cc
utils/config.cc
)
)
target_compile_features(deimos PUBLIC cxx_std_14)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1")
target_link_libraries(deimos PUBLIC proxygen::proxygen)
target_link_libraries(deimos PUBLIC proxygen::proxygenhttpserver)
target_link_libraries(deimos PUBLIC server)
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
include(../cmake/development_flags.cmake)
target_link_libraries(deimos PUBLIC development_flags)
endif(CMAKE_BUILD_TYPE MATCHES DEBUG)
add_custom_command(
TARGET deimos POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
......
......@@ -9,10 +9,10 @@ add_library(
unsupported_request_handler.cc
)
if(DEIMOS_DISABLE_AUTHORISATION)
if(NOT DEIMOS_AUTHORISATION)
message("Disabling AWS V4 authorisation for the server")
set_target_properties(server PROPERTIES COMPILE_DEFINITIONS "DEIMOS_NO_AUTHORISATION")
endif(DEIMOS_DISABLE_AUTHORISATION)
endif(NOT DEIMOS_AUTHORISATION)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1")
target_link_libraries(server PUBLIC proxygen::proxygen)
......
......@@ -15,7 +15,6 @@ cli_options Config::parse(int argc, char* argv[])
m_parser.parse(argc, argv);
}
catch (const CLI::ParseError& e) {
std::cout << "m_hostname = " << m_hostname << std::endl;
m_parser.exit(e);
throw DeimosException(
"Returning after command line parsing. --help or invalid argument(s)");
......
......@@ -15,11 +15,11 @@ add_executable(
utils.cc
)
if(NOT DEIMOS_DISABLE_AUTHORISATION)
if(DEIMOS_AUTHORISATION)
target_sources(tests PRIVATE s3_authorisation.cc)
else()
message("Disabling AWS V4 authorisation testing")
endif(NOT DEIMOS_DISABLE_AUTHORISATION)
endif(DEIMOS_AUTHORISATION)
target_compile_features(tests PUBLIC cxx_std_14)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment