diff --git a/CMakeLists.txt b/CMakeLists.txt
index b26d42f..846833f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,184 +1,186 @@
cmake_minimum_required(VERSION 2.8.8)
# Start project, set version here.
project("RoSA")
# NOTE: Adjust the variables version and release in docs/conf.py according to
# version changes here.
set(ROSA_VERSION_MAJOR 0)
set(ROSA_VERSION_MINOR 1)
set(ROSA_VERSION_PATCH 0)
# Add path for custom modules
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
)
# Package information
if( NOT PACKAGE_VERSION )
set(PACKAGE_VERSION "${ROSA_VERSION_MAJOR}.${ROSA_VERSION_MINOR}.${ROSA_VERSION_PATCH}")
endif()
set(PACKAGE_NAME "Research on Self-Awareness Framework")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "david.juhasz@tuwien.ac.at")
#TODO: cpack?
# Sanity check we are to make out-of-tree build
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
message(FATAL_ERROR "In-source builds are not allowed.")
endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
# Set various paths
set(ROSA_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(ROSA_MAIN_INCLUDE_DIR ${ROSA_MAIN_SRC_DIR}/include)
set(ROSA_MAIN_BIN_DIR ${ROSA_MAIN_SRC_DIR}/bin)
set(ROSA_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(ROSA_RUNTIME_OUTPUT_INTDIR ${ROSA_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(ROSA_LIBRARY_OUTPUT_INTDIR ${ROSA_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib)
set(ROSA_TOOLS_BINARY_DIR ${ROSA_RUNTIME_OUTPUT_INTDIR})
set(ROSA_LIBRARY_DIR ${ROSA_LIBRARY_OUTPUT_INTDIR})
set(ROSA_INCLUDE_DIR ${ROSA_BINARY_DIR}/include)
# Set build options
option(ROSA_INCLUDE_TOOLS "Generate build targets for RoSA tools." ON)
option(ROSA_INCLUDE_EXAMPLES "Generate build targets for RoSA examples." ON)
option(ROSA_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
# Assertions are always enabled for Debug builds, this option is respected only
# for non-Debug builds.
option(ROSA_ENABLE_ASSERTIONS "Enable assertions for non-Debug builds." OFF)
-option(ROSA_ENABLE_CLANG_TIDY "Run clang-tidy checks when building RoSA." ON)
+option(ROSA_ENABLE_CLANG_TIDY "Run clang-tidy checks when building RoSA." OFF)
option(ROSA_INCLUDE_CLANG_FORMAT "Generate build target for formatting RoSA sources with clang-format." OFF)
option(ROSA_INCLUDE_DOCS "Generate build targets for RoSA documentation." ON)
option(ROSA_BUILD_DOCS "Build RoSA documentation." OFF)
option(ROSA_ENABLE_DOXYGEN "Use doxygen to generate RoSA API documentation." OFF)
option(ROSA_ENABLE_SPHINX "Use Sphinx to generate RoSA documentation." OFF)
+set(ROSA_LOG_LEVEL "" CACHE STRING "Level of logging to be used.")
+
# All options referred to from HandleROSAOptions have to be specified
# BEFORE this include, otherwise options will not be correctly set on
# first cmake run
include(config-ix)
include(HandleROSAOptions)
# Configure the ROSA configuration header file.
-if( ROSA_LOG_LEVEL )
- if(${ROSA_LOG_LEVEL} EQUAL 5)
+if( NOT ROSA_LOG_LEVEL STREQUAL "")
+ if( ${ROSA_LOG_LEVEL} EQUAL 5 )
set(ROSA_LOG_LEVEL_INT -1)
else()
set(ROSA_LOG_LEVEL_INT ${ROSA_LOG_LEVEL})
endif()
else()
set(ROSA_LOG_LEVEL_INT -1)
endif()
configure_file(
${ROSA_MAIN_INCLUDE_DIR}/rosa/config/rosa_config.h.cmake
${ROSA_INCLUDE_DIR}/rosa/config/rosa_config.h
)
# They are not referenced. See set_output_directory().
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ROSA_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ROSA_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${ROSA_BINARY_DIR}/lib)
# Set include directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(${ROSA_INCLUDE_DIR} ${ROSA_MAIN_INCLUDE_DIR})
# Set extra compiler options for Visual Studio
if ( MSVC )
add_definitions(-EHsc) # Use Exception Handling
endif()
# Set up YCM
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
message("Set compilation_database_folder in .ymc_extra_conf.py in the source directory if you want to use YMC.")
# Add parts of the project
include(AddROSATools)
add_subdirectory(lib)
if( ROSA_INCLUDE_TOOLS )
add_subdirectory(tools)
endif()
if( ROSA_INCLUDE_EXAMPLES )
add_subdirectory(examples)
endif()
if( ROSA_INCLUDE_DOCS )
add_subdirectory(docs)
endif()
#TODO: install?
# Print summary
set(ROSA_ENABLE_ASSERTIONS_STR "OFF")
if( ROSA_ENABLE_ASSERTIONS_INT EQUAL 1 )
set(ROSA_ENABLE_ASSERTIONS_STR "ON")
endif()
set(LOG_LEVEL_STR "disabled")
-if(ROSA_LOG_LEVEL)
- if(${ROSA_LOG_LEVEL} EQUAL 0)
+if( NOT ROSA_LOG_LEVEL STREQUAL "" )
+ if( ${ROSA_LOG_LEVEL} EQUAL 0 )
set(LOG_LEVEL_STR "ERROR")
- elseif(${ROSA_LOG_LEVEL} EQUAL 1)
+ elseif( ${ROSA_LOG_LEVEL} EQUAL 1 )
set(LOG_LEVEL_STR "WARNING")
- elseif(${ROSA_LOG_LEVEL} EQUAL 2)
+ elseif( ${ROSA_LOG_LEVEL} EQUAL 2 )
set(LOG_LEVEL_STR "INFO")
- elseif(${ROSA_LOG_LEVEL} EQUAL 3)
+ elseif( ${ROSA_LOG_LEVEL} EQUAL 3 )
set(LOG_LEVEL_STR "DEBUG")
- elseif(${ROSA_LOG_LEVEL} EQUAL 4)
+ elseif( ${ROSA_LOG_LEVEL} EQUAL 4 )
set(LOG_LEVEL_STR "TRACE")
- elseif(${ROSA_LOG_LEVEL} EQUAL 5)
+ elseif( ${ROSA_LOG_LEVEL} EQUAL 5 )
set(LOG_LEVEL_STR "disabled")
else()
set(LOG_LEVEL_STR "invalid")
endif()
endif()
message(STATUS
"\n====================| Build Summary |===================="
"\n"
"\nRoSA version: ${PACKAGE_VERSION}"
"\n"
"\nBuild type: ${CMAKE_BUILD_TYPE}"
"\nAssertions: ${ROSA_ENABLE_ASSERTIONS_STR}"
"\nClang-tidy: ${ROSA_ENABLE_CLANG_TIDY}"
"\nClang-format: ${ROSA_INCLUDE_CLANG_FORMAT}"
"\nLog level: ${LOG_LEVEL_STR}"
"\n"
"\nBuild tools: ${ROSA_INCLUDE_TOOLS}"
"\nBuild examples: ${ROSA_INCLUDE_EXAMPLES}"
"\nInclude docs: ${ROSA_INCLUDE_DOCS}"
"\nBuild docs: ${ROSA_BUILD_DOCS}"
"\n -enable doxygen: ${ROSA_ENABLE_DOXYGEN}"
"\n -enable Sphinx: ${ROSA_ENABLE_SPHINX}"
"\n"
"\nCC: ${CMAKE_C_COMPILER}"
"\nCFLAGS: ${CMAKE_C_FLAGS}"
"\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS}"
"\nLIBRARIES: ${LD_FLAGS}"
"\n"
"\nSource directory: ${ROSA_MAIN_SRC_DIR}"
"\nBuild directory: ${ROSA_BINARY_DIR}"
"\nExecutable path: ${ROSA_TOOLS_BINARY_DIR}"
"\nLibrary path: ${ROSA_LIBRARY_DIR}"
"\nGenerator: ${CMAKE_GENERATOR}"
"\n"
"\n===========================================================\n")
diff --git a/docs/Build.rst b/docs/Build.rst
index 8c74ebb..eb4c7b2 100755
--- a/docs/Build.rst
+++ b/docs/Build.rst
@@ -1,302 +1,303 @@
===========================
Building the RoSA Framework
===========================
.. contents::
:local:
General notes
=============
* The framework is delivered with a CMake project, which can be used to generate
build projects to build the framework.
* The provided CMake project supports out-of-tree builds only, i.e. one must use
a separate build directory outside of the RoSA source directory.
Build Dependencies
==================
In order to build RoSA, the following tools are required:
* `CMake `_ (minimum version 3.6.0 if clang-tidy is used,
2.8.8 otherwise);
* Build system of your choice that can be targeted by CMake -- including a
compiler supporting C++14.
The following additional tools are required to generate documentation:
* `Doxygen `_ -- for generating API documentation;
* `Graphviz `_ -- not necessary, but the API
documentation has nicer graphics when `dot` is available;
* `Sphinx `_ (with *Python 2*) -- for generating
documentation.
The following additional tools are required to check and possibly enforce coding
standard:
* `clang-tidy `_
* `clang-format `_
.. _cmake-variables:
CMake Variables
===============
Beyond the usual CMake variables, the following project-related options are
available:
`ROSA_INCLUDE_TOOLS`
Generate build targets for RoSA tools. The tools are also built when the
option is set to `ON`, which is the default setting.
`ROSA_INCLUDE_EXAMPLES`
Generate build targets for RoSA examples. The examples are also built when the
option is set to `ON`, which is the default setting.
`ROSA_ENABLE_PEDANTIC`
Compile the framework with using `-pedantic`. The option defaults to `ON`.
`ROSA_ENABLE_ASSERTIONS`
Enable assertions for non-Debug builds, which defaults to `OFF`.
Note that assertions are always enabled for Debug builds and this option is
ignored for such builds.
`ROSA_ENABLE_CLANG_TIDY`
Run *clang-tidy* checks when building RoSA, which defaults to `OFF`.
When the variable is enabled, build targets created by *Makefile* and *Ninja*
generators include calls for clang-tidy. Other generators ignore this option.
Note that CMake variables `CMAKE__CLANG_TIDY` are set when enabled.
Settings for clang-tidy are defined by the file `.clang-tidy` in the RoSA
source directory.
Consider the following options when the option is enabled:
`ROSA_CLANG_TIDY_PATH`
Custom path for `clang-tidy` executable.
In order to use clang-tidy, CMake needs to find the `clang-tidy` executable.
If `clang-tidy` is available via `PATH`, just leave the option empty
-- which is default. Set the absolute path of the directory containing the
`clang-tidy` executable otherwise.
`ROSA_CLANG_TIDY_FIX`
Apply suggested clang-tidy fixes to the sources, which defaults to `OFF`.
Enable the option only if you know what you are doing.
`ROSA_INCLUDE_CLANG_FORMAT` **[experimental]**
Generate build target -- `format-rosa` -- for formatting RoSA sources with
*clang-format*, which defatuls to `OFF`.
When the variable is enabled and *CMake is not running on a Windows host*, a
build target is generated which can be used to have all the RoSA sources
formatted with clang-format. Settings for clang-format are defined by the file
`.clang-format` in the RoSA source directory.
Note that executing build target `format-rosa` will reformat all the source
files *inplace*.
Consider the following option when a build target for clang-format is to be
generated:
`ROSA_CLANG_FORMAT_PATH`
Custom path for `clang-format` executable.
In order to use clang-format, CMake needs to find the `clang-format`
executable. If `clang-format` is available via `PATH`, just leave the option
empty -- which is default. Set the absolute path of the directory containing
the `clang-format` executable otherwise.
`ROSA_LOG_LEVEL`
- Select level of logging to be used, use one of the following valid integer
- values.
+ Level of logging to be used, use one of the following valid integer values.
======== =========
Variable Log Level
======== =========
`0` `ERROR`
`1` `WARNING`
`2` `INFO`
`3` `DEBUG`
`4` `TRACE`
`5` *disabled*
======== =========
Level of logging defaults to *disabled*.
`ROSA_INCLUDE_DOCS`
Generate build targets for RoSA documentation, defaults to `ON`.
Note that the automatic execution of the generated build targets is
controlled by the option `ROSA_BUILD_DOCS`. The actual documentations to
build are controlled by the options `ROSA_ENABLE_DOXYGEN` and
`ROSA_ENABLE_SPHINX`.
`ROSA_BUILD_DOCS`
Build RoSA documentation automatically as part of the build process. The
option defaults to `OFF` and takes effect only if the option
`ROSA_INCLUDE_DOCS` is enabled.
`ROSA_ENABLE_DOXYGEN`
Use *doxygen* to generate RoSA API documentation. The option defaults to `OFF`
and takes effect only if the option `ROSA_INCLUDE_DOCS` is enabled.
Doxygen documentation may be generated by executing build target
`doxygen-rosa`, which is done as part of the default build process if
`ROSA_BUILD_DOCS` is enabled.
Doxygen must be available via `PATH` if the option is enabled.
The following options are also available to tune doxygen:
`ROSA_DOXYGEN_SVG`
Use *svg* instead of *png* files for doxygen graphs. The option defaults to
`OFF` and takes effect if the tool *dot* is available via `PATH` to be used
to generated graph images.
`ROSA_DOXYGEN_EXTERNAL_SEARCH`
Enable doxygen external search, which defatuls to `OFF`.
The following options need to be set if the option is enabled:
`ROSA_DOXYGEN_SEARCHENGINE_URL`
URL to use for external search.
`ROSA_DOXYGEN_SEARCH_MAPPINGS`
Doxygen Search Mappings.
`ROSA_ENABLE_SPHINX`
Use *Sphinx* to generate RoSA documentation. The option defaults to `OFF` and
takes effect only if the option `ROSA_INCLUDE_DOCS` is enabled.
Sphinx must be available via `PATH` if the option is enabled.
The following options are also available to tune Sphinx:
`SPHINX_OUTPUT_HTML`
Output standalone HTML files. The option defaults to `ON`.
Documentation may be generated by executing build target `docs-rosa-html`,
which is done as part of the default build process if `ROSA_BUILD_DOCS` is
enabled.
`SPHINX_OUTPUT_MAN`
Output man pages for RoSA tools. The option defaults to `ON`.
Man pages may be generated by executing build target `docs-rosa-man`, which
is done as part of the default build process if `ROSA_BUILD_DOCS` is
enabled.
`SPHINX_WARNINGS_AS_ERRORS`
When building documentation, treat Sphinx warnings as errors. The option
defaults to `ON`.
Building RoSA Step-by-Step
==========================
Building on Linux with Make
---------------------------
Configuring and building the framework on Linux using *Make* is a
straightforward process which does not require performing any tricks. The
framework compiles with *Clang 3.8.0*.
Set C and C++ compilers with the variables `CC` and `CXX`, respectively. Use the
CMake variable `CMAKE_BUILD_TYPE` to set the type of build: `Debug`, `Release`.
Follows an example on building the framework. You need to have RoSA sources on
your computer and Clang executables available via `PATH`.::
rosa-src$ cd ..
$ mkdir rosa-build
$ cd rosa-build
- rosa-build$ CC=clang CXX=clang++ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DROSA_LOG_LEVEL="4" ../rosa-src/
+ rosa-build$ CC=clang CXX=clang++ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DROSA_LOG_LEVEL=4 ../rosa-src/
[CMake configures and generates without errors]
$ make
[Make builds the project]
You just need to re-run Make in order to re-build the project after changing
the source code and the CMake project. In case the CMake project is changed,
Make automatically calls CMake to update the build project.
In order to build documentation and enforce coding standard, refer to
corresponding :ref:`cmake-variables`.
Building on Windows with Visual Studio
--------------------------------------
Unfortunately, the native MSVC compiler cannot compile the framework. One needs
to use Clang with Visual Studio in order to build the framework. There are two
alternatives to do that:
* using the *Clang/C2* module for *Visual Studio 2017*,
* using *LLVM for Windows* as an external toolset for Visual Studio
(necessary for older versions of Visual Studio).
For using Visual Studio 2017 -- which would be the preferred way -- one needs to
select *Clang/C2 (experimental)* on the *Individual components* tab in *Visual
Studio Installer*.
For using *LLVM for Windows*, one downloads the official binary release from
http://llvm.org and consults with its documentation. The release provides
integration for Visual Studio versions between 2010 and 2014 (as of LLVM 4.0.0).
Having your build system prepared and RoSA sources fetched to your computer,
configure and build the framework like this:
#. Generate Visual Studio solution with CMake:
#. Start CMake.
#. Define *source directory* and a separate *build directory* in CMake.
#. Click *Configure*.
#. Select the proper *generator* for your version of Visual Studio.
#. Define your optional toolset (argument for `-T`):
* Clang/C2 with VS2017: `v141_clang_c2`.
* LLVM for Windows with older VS: `LLVM-vs`.
#. Click *Finish*.
#. Tune CMake variables as you wish.
* Note that Visual Studio Generators are multi-configuration generators,
hence you cannot set `CMAKE_BUILD_TYPE`. You need to select a
configuration to build in Visual Studio.
#. Click *Generate*.
+ .. _CMake-VS2017-Clang-fix:
+
#. Fix the generated Visual Studio projects (*applies for Clang/C2*):
* The generated projects define `ExceptionHandling` as `Sync`, which is an
invalid value for Clang/C2 and needs to be changed to `Enabled` in all
Visual Studio project files:
* using GNU command line tools::
rosa-build$ find . -name "*.vcxproj" -print|xargs sed -i -e 's/Sync/Enabled/g'
* using PowerShell::
rosa-build> ls -path . -include *.vcxproj -recurse | %{ $f=$_; (gc $f.PSPath) | %{ $_ -replace "Sync", "Enabled" } | sc $f.PSPath }
* Note that the project files need to be fixed every time CMake regenerates
them, which may happen when building the project in Visual Studio in case
you have the CMake project changed in the source directory.
#. Build the framework with Visual Studio:
#. Open the generated `RoSA.sln` from the build directory with Visual
Studio.
#. Build the project `ALL_BUILD`.
You just need to re-build the project in Visual Studio after changing the
source code and the CMake project.
In case the CMake project is changed, Visual Studio automatically calls CMake
-the update the build project. Should you use Clang/C2, do not forget to fix the
-newly generated Visual Studio project files as described above.
+the update the build project. Should you use Clang/C2, do not forget to
+:ref:`fix the generated Visual Studio projects `.
diff --git a/docs/Plan.rst b/docs/Plan.rst
index 4186236..c3e6311 100755
--- a/docs/Plan.rst
+++ b/docs/Plan.rst
@@ -1,17 +1,28 @@
=================================
Future Work on the RoSA Framework
=================================
.. contents::
:local:
TODO
====
* Project logo - `docs/_themes/rosa-theme/static/logo.png`
* API documentation welcome - `docs/doxygen-mainpage.dox`
* Documentation index - `docs/index.rst`
* Complete initial docs...
* Fix rules in `.clang-format`
* What about testing?
+Known Issues
+============
+
+* CMake
+
+ * VS2017 generates intermediate files for the `ZERO_CHECK` project out of the
+ build directory, see `CMake issue #16458`_.
+ * VS2017 with `v141_clang_c2` toolset requires
+ :ref:`fix of the generated Visual Studio projects `.
+
+.. _CMake issue #16458: https://gitlab.kitware.com/cmake/cmake/issues/16458