diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f5dea3..b26d42f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,182 +1,184 @@ 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_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) # 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) 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) set(LOG_LEVEL_STR "ERROR") elseif(${ROSA_LOG_LEVEL} EQUAL 1) set(LOG_LEVEL_STR "WARNING") elseif(${ROSA_LOG_LEVEL} EQUAL 2) set(LOG_LEVEL_STR "INFO") elseif(${ROSA_LOG_LEVEL} EQUAL 3) set(LOG_LEVEL_STR "DEBUG") elseif(${ROSA_LOG_LEVEL} EQUAL 4) set(LOG_LEVEL_STR "TRACE") 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/TODO b/TODO index 0ea1355..1e5e8ff 100755 --- a/TODO +++ b/TODO @@ -1,5 +1,6 @@ Things to do: * Project logo - docs/_themes/rosa-theme/static/logo.png * API documentation welcome - docs/doxygen-mainpage.dox * Documentation index - docs/index.rst +* Fix clang-format rules diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 337e182..fe592e2 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -1,76 +1,106 @@ # available programs checks function(rosa_find_program name) string(TOUPPER ${name} NAME) string(REGEX REPLACE "\\." "_" NAME ${NAME}) find_program(ROSA_PATH_${NAME} NAMES ${ARGV}) mark_as_advanced(ROSA_PATH_${NAME}) if(ROSA_PATH_${NAME}) set(HAVE_${NAME} 1 CACHE INTERNAL "Is ${name} available ?") mark_as_advanced(HAVE_${NAME}) else(ROSA_PATH_${NAME}) set(HAVE_${NAME} "" CACHE INTERNAL "Is ${name} available ?") endif(ROSA_PATH_${NAME}) endfunction() if (ROSA_ENABLE_CLANG_TIDY) message(STATUS "Clang-tidy enabled.") # Make sure CMake knows about clang-tidy cmake_minimum_required(VERSION 3.6.0) # clang-tidy specific options set(ROSA_CLANG_TIDY_PATH "" CACHE STRING "Custom path for clang-tidy executable.") option(ROSA_CLANG_TIDY_FIX "Apply suggested clang-tidy fixes to the sources." OFF) - # Find clang-tidy - if ("${ROSA_CLANG_TIDY_PATH}" STREQUAL "") - find_program(CLANG_TIDY clang-tidy) + find_package(ClangTidy REQUIRED) + +else() + message(STATUS "Clang-tidy disabled.") +endif() + +if (ROSA_INCLUDE_CLANG_FORMAT) + message(STATUS "Clang-format enabled.") + + # Disable clang-format for Windows hosts because of unix-style path + # separators used below. + if ("${CMAKE_HOST_SYSTEM}" MATCHES ".*Windows.*") + set(ROSA_INCLUDE_CLANG_FORMAT OFF) + message(WARNING "Disabling clang-format on a Windows host.") else() - find_program(CLANG_TIDY clang-tidy PATHS ${ROSA_CLANG_TIDY_PATH}) - endif() - if (${CLANG_TIDY} STREQUAL "CLANG_TIDY-NOTFOUND") - message(FATAL_ERROR "Clang-tidy cannot be found!") - endif() + #clang-format specific options + set(ROSA_CLANG_FORMAT_PATH "" CACHE STRING "Custom path for clang-format executable.") + + # Find clang-format + find_package(ClangFormat REQUIRED) + + file(GLOB_RECURSE ALL_SOURCE_FILES + *.[ch]pp *.c[c] *.h[h]) + + add_custom_target(format-rosa) + foreach (SOURCE_FILE ${ALL_SOURCE_FILES}) + string(REGEX REPLACE "^${ROSA_MAIN_SRC_DIR}/" "" SOURCE_RELPATH ${SOURCE_FILE}) + string(REPLACE "/" "_" SOURCE_TARGET ${SOURCE_RELPATH}) + add_custom_target( + format-${SOURCE_TARGET} + COMMAND ${CLANGFORMAT_EXECUTABLE} + -i + -style=file + ${SOURCE_FILE} + ) + add_dependencies(format-rosa format-${SOURCE_TARGET}) + endforeach() + + endif() else() - message(STATUS "Clang-tidy disabled.") + message(STATUS "Clang-format disabled.") endif() if (ROSA_ENABLE_DOXYGEN) rosa_find_program(dot) endif () if (ROSA_ENABLE_DOXYGEN) message(STATUS "Doxygen enabled.") find_package(Doxygen REQUIRED) if (DOXYGEN_FOUND) # If we find doxygen and we want to enable doxygen by default create a # global aggregate doxygen target for generating llvm and any/all # subprojects doxygen documentation. if (ROSA_BUILD_DOCS) add_custom_target(doxygen ALL) endif() option(ROSA_DOXYGEN_EXTERNAL_SEARCH "Enable doxygen external search." OFF) if (ROSA_DOXYGEN_EXTERNAL_SEARCH) set(ROSA_DOXYGEN_SEARCHENGINE_URL "" CACHE STRING "URL to use for external search.") set(ROSA_DOXYGEN_SEARCH_MAPPINGS "" CACHE STRING "Doxygen Search Mappings.") endif() endif() else() message(STATUS "Doxygen disabled.") endif() if (ROSA_ENABLE_SPHINX) message(STATUS "Sphinx enabled.") find_package(Sphinx REQUIRED) if (ROSA_BUILD_DOCS) add_custom_target(sphinx ALL) endif() else() message(STATUS "Sphinx disabled.") endif() diff --git a/cmake/modules/FindClangFormat.cmake b/cmake/modules/FindClangFormat.cmake new file mode 100755 index 0000000..ba19d37 --- /dev/null +++ b/cmake/modules/FindClangFormat.cmake @@ -0,0 +1,22 @@ +# CMake find_package() Module for clang-format +# +# Example usage: +# +# find_package(ClangFormat) +# +# If successful the following variables will be defined +# CLANGFORMAT_FOUND +# CLANGFORMAT_EXECUTABLE + +find_program(CLANGFORMAT_EXECUTABLE + NAMES clang-format + PATHS ${ROSA_CLANG_FORMAT_PATH} + DOC "Path to clang-format executable") + +# Handle REQUIRED and QUIET arguments +# this will also set CLANGFORMAT_FOUND to true if CLANGFORMAT_EXECUTABLE exists +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ClangFormat + "Failed to locate clang-format executable" + CLANGFORMAT_EXECUTABLE) + diff --git a/cmake/modules/FindClangTidy.cmake b/cmake/modules/FindClangTidy.cmake new file mode 100755 index 0000000..05702ac --- /dev/null +++ b/cmake/modules/FindClangTidy.cmake @@ -0,0 +1,22 @@ +# CMake find_package() Module for clang-tidy +# +# Example usage: +# +# find_package(ClangTidy) +# +# If successful the following variables will be defined +# CLANGTIDY_FOUND +# CLANGTIDY_EXECUTABLE + +find_program(CLANGTIDY_EXECUTABLE + NAMES clang-tidy + PATHS ${ROSA_CLANG_TIDY_PATH} + DOC "Path to clang-tidy executable") + +# Handle REQUIRED and QUIET arguments +# this will also set CLANGTIDY_FOUND to true if CLANGTIDY_EXECUTABLE exists +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ClangTidy + "Failed to locate clang-tidy executable" + CLANGTIDY_EXECUTABLE) + diff --git a/cmake/modules/HandleROSAOptions.cmake b/cmake/modules/HandleROSAOptions.cmake index 7a618c0..ad04f21 100644 --- a/cmake/modules/HandleROSAOptions.cmake +++ b/cmake/modules/HandleROSAOptions.cmake @@ -1,102 +1,102 @@ # This CMake module is responsible for interpreting the user defined ROSA_ # options and executing the appropriate CMake commands to realize the users' # selections. include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) if( CMAKE_COMPILER_IS_GNUCXX ) set(ROSA_COMPILER_IS_GCC_COMPATIBLE ON) elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) set(ROSA_COMPILER_IS_GCC_COMPATIBLE ON) elseif( MSVC ) set(ROSA_COMPILER_IS_GCC_COMPATIBLE OFF) endif() function(append value) foreach(variable ${ARGN}) set(${variable} "${${variable}} ${value}" PARENT_SCOPE) endforeach(variable) endfunction() function(append_if condition value) if (${condition}) foreach(variable ${ARGN}) set(${variable} "${${variable}} ${value}" PARENT_SCOPE) endforeach(variable) endif() endfunction() # NDEBUG on non-Debug builds append("-DNDEBUG" CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_MINSIZEREL) # Assertions are always enabled on Debug builds, this is interesting for # non-Debug builds. if( NOT "${uppercase_CMAKE_BUILD_TYPE}" STREQUAL "DEBUG" AND ${ROSA_ENABLE_ASSERTIONS} ) # MSVC doesn't like _DEBUG on release builds. See PR 4379. if( NOT MSVC ) add_definitions( -D_DEBUG ) set(ENABLE_ASSERTIONS "1") else() set(ENABLE_ASSERTIONS "0") endif() # On non-Debug builds we NDEBUG, but in this case we need to undefine it: add_definitions(-UNDEBUG) # Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines. foreach (flags_var_to_scrub CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_MINSIZEREL) string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " "${flags_var_to_scrub}" "${${flags_var_to_scrub}}") endforeach() endif() set(ROSA_ENABLE_ASSERTIONS_INT -1) if( "${uppercase_CMAKE_BUILD_TYPE}" STREQUAL "DEBUG" OR ${ROSA_ENABLE_ASSERTIONS} ) set(ROSA_ENABLE_ASSERTIONS_INT 1) endif() #FIXME: Disable RTTI and exceptions, once gen_agent_test2 is cleared up. if( ROSA_COMPILER_IS_GCC_COMPATIBLE ) append("-Wall -Wextra -Wdocumentation -Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) append_if(ROSA_ENABLE_PEDANTIC "-pedantic -Wno-long-long" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) check_cxx_compiler_flag("-std=c++14" CXX_SUPPORTS_CXX14) if ( CXX_SUPPORTS_CXX14 ) append("-std=c++14" CMAKE_CXX_FLAGS) else() message(FATAL_ERROR "RoSA requires C++14 support but the '-std=c++14' flag isn't supported.") endif() check_c_compiler_flag("-std=c11" C_SUPPORTS_C11) if ( C_SUPPORTS_C11 ) append("-std=c11" CMAKE_C_FLAGS) else() message(FATAL_ERROR "RoSA requires C11 support but the '-std=c11' flag isn't supported.") endif() else ( ROSA_COMPILER_IS_GCC_COMPATIBLE ) # FIXME: set the same things as for GCC-compatible compilers endif( ROSA_COMPILER_IS_GCC_COMPATIBLE ) if( ROSA_ENABLE_CLANG_TIDY ) # Set clang-tidy arguments, use the same for both C and CXX. - set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY};-header-filter=.*") + set(CMAKE_C_CLANG_TIDY "${CLANGTIDY_EXECUTABLE};-header-filter=.*") set(CMAKE_CXX_CLANG_TIDY ${CMAKE_C_CLANG_TIDY}) # Apply suggested fixes if requested. append_if(ROSA_CLANG_TIDY_FIX ",-fix" CMAKE_C_CLANG_TIDY CMAKE_CXX_CLANG_TIDY) endif( ROSA_ENABLE_CLANG_TIDY ) diff --git a/docs/Build.rst b/docs/Build.rst index 919bb3a..98cf394 100755 --- a/docs/Build.rst +++ b/docs/Build.rst @@ -1,263 +1,298 @@ =========================== 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 addition tools are required to check the used coding standard: - -* `clang-tidy `_ - 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 =============== 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 this variable is enabled, build targets created by *Makefile* and *Ninja* + 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. ======== ========= 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/ [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. 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*. #. 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.