diff --git a/CMakeLists.txt b/CMakeLists.txt index d8e5492..0920c7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,160 +1,160 @@ cmake_minimum_required(VERSION 2.8.8) # Start project, set version here. project("RoSA") 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 target for RoSA examples." ON) option(ROSA_ENABLE_CXX1Y "Compile with C++1y enabled." ON) option(ROSA_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" ) option(ROSA_ENABLE_ASSERTIONS "Enable assertions." OFF) else() option(ROSA_ENABLE_ASSERTIONS "Enable assertions." ON) endif() include(HandleROSAOptions) # Configure the ROSA configuration header file. if( ROSA_LOG_LEVEL ) set(ROSA_LOG_LEVEL_INT ${ROSA_LOG_LEVEL}) else() set(ROSA_LOG_LEVEL_INT -1) endif() macro(to_int_value name) if(${name}) set(${name}_INT 1) else() set(${name}_INT -1) endif() endmacro() to_int_value(ROSA_ENABLE_ASSERTIONS) configure_file( - ${ROSA_MAIN_INCLUDE_DIR}/rosa/config/rosa-config.h.cmake - ${ROSA_INCLUDE_DIR}/rosa/config/rosa-config.h + ${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() #TODO: install? # Print summary set(LOG_LEVEL_STR "none") 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") 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}" "\nLog level: ${LOG_LEVEL_STR}" "\n" "\nBuild tools: ${ROSA_INCLUDE_TOOLS}" "\nBuild examples: ${ROSA_INCLUDE_EXAMPLES}" "\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/include/rosa/config/config.h b/include/rosa/config/config.h index 9cdc02a..5021e3c 100644 --- a/include/rosa/config/config.h +++ b/include/rosa/config/config.h @@ -1,55 +1,55 @@ /******************************************************************************* * * File: config.h * * Contents: Configuration nformation on the build of the library. * * Copyright 2017 * * Author: David Juhasz (david.juhasz@tuwien.ac.at) * ******************************************************************************/ #ifndef ROSA_CONFIG_CONFIG_H #define ROSA_CONFIG_CONFIG_H #include // Various preprocessor macros containing config information. -#include "rosa/config/rosa-config.h" +#include "rosa/config/rosa_config.h" // This OS-specific block defines one of the following: // - ROSA_LINUX // - ROSA_WINDOWS // It also defines ROSA_POSIX for POSIX-compatible systems #if defined(__linux__) #define ROSA_LINUX #elif defined(WIN32) || defined(_WIN32) #define ROSA_WINDOWS #else #error Platform and/or compiler not supported #endif #if defined(ROSA_LINUX) #define ROSA_POSIX #endif // Defining filenames in a project-relative way based on absolute paths. #include "rosa/config/project_path.hpp" #define __FILENAME__ (__FILE__ + project_relative_path_index(__FILE__)) // Convenience macros. #define ROSA_VOID_STMT static_cast(0) #define ROSA_IGNORE_UNUSED(x) static_cast(x) #define ROSA_CRITICAL(error) \ do { \ std::cerr << "[FATAL] " << __FILENAME__ << ":" << __LINE__ \ << ": critical error: '" << (error) << "'" << std::endl; \ ::abort(); \ } while (false) #define ROSA_RAISE_ERROR(msg) throw std::runtime_error(msg) #endif // ROSA_CONFIG_CONFIG_H diff --git a/include/rosa/config/project_path.hpp b/include/rosa/config/project_path.hpp index 1dac229..29f7273 100644 --- a/include/rosa/config/project_path.hpp +++ b/include/rosa/config/project_path.hpp @@ -1,50 +1,50 @@ /******************************************************************************* * * File: project_path.hpp * * Contents: Facility for compile-time manipulation of paths. * * Copyright 2017 * * Author: David Juhasz (david.juhasz@tuwien.ac.at) * ******************************************************************************/ #ifndef ROSA_SUPPORT_PROJECT_PATH_H #define ROSA_SUPPORT_PROJECT_PATH_H -#include "rosa/config/rosa-config.h" +#include "rosa/config/rosa_config.h" namespace rosa { // Nested namespace containing the implementation of the provided features, // not supposed to be used directly. namespace impl { // Implementation of the static search for the project-relative part of an // absolute path. constexpr size_t project_relative_path_index_impl(const char *const path, const char *const project = ROSA_SRC_DIR, const size_t index = 0) { return project[index] == '\0' ? index // Found it. : (path[index] == '\0' || project[index] != path[index]) ? 0 // Path is not under project. : project_relative_path_index_impl( path, project, index + 1); // Continue searching... } } // End namespace impl // Staticaly finds the index of the project-relative part of a absolute path. // Returns 0 if the absolute path is not located under the project directory. constexpr size_t project_relative_path_index(const char * const path) { return impl::project_relative_path_index_impl(path); } } // End namespace rosa #endif // ROSA_SUPPORT_PROJECT_PATH_H diff --git a/include/rosa/config/rosa-config.h.cmake b/include/rosa/config/rosa_config.h.cmake similarity index 100% rename from include/rosa/config/rosa-config.h.cmake rename to include/rosa/config/rosa_config.h.cmake diff --git a/include/rosa/config/version.h b/include/rosa/config/version.h index eb0c8cb..af16211 100644 --- a/include/rosa/config/version.h +++ b/include/rosa/config/version.h @@ -1,35 +1,35 @@ /******************************************************************************* * * File: version.h * * Contents: Version information about the build of the library. * * Copyright 2017 * * Author: David Juhasz (david.juhasz@tuwien.ac.at) * ******************************************************************************/ #ifndef ROSA_CONFIG_VERSION_H #define ROSA_CONFIG_VERSION_H #include // Various preprocessor macros containing the information. -#include "rosa/config/rosa-config.h" +#include "rosa/config/rosa_config.h" namespace rosa { // Returns a string containing the name of the library followed by its version. std::string library_string(void); // Returns a string containing the version number of the library. std::string version(void); // Returns a multi-line string containing verbose information on the library. std::string verbose_version(void); } // End namespace rosa #endif // ROSA_CONFIG_VERSION_H