From 5cbbc595e8f3bc4044e55c3ff967e6a4178f5b4d 2017-05-16 07:53:00 From: mperrinel Date: 2017-05-16 07:53:00 Subject: [PATCH] Initialisation de l'archi cmake --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bba0294 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +CMakeLists.txt.user \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..95bdbed --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,11 @@ + + +## Main CMakeLists for SCIQLOP +CMAKE_MINIMUM_REQUIRED (VERSION 2.8.12) + +PROJECT(SCIQLOP) + +# +# build the project +# +INCLUDE("cmake/sciqlop.cmake") \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1333ed7 --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +TODO diff --git a/README.md b/README.md new file mode 100644 index 0000000..30404ce --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +TODO \ No newline at end of file diff --git a/cmake/compiler/compiler.cmake b/cmake/compiler/compiler.cmake new file mode 100644 index 0000000..dce29a6 --- /dev/null +++ b/cmake/compiler/compiler.cmake @@ -0,0 +1,11 @@ +# +# compiler.cmake : configure the compilation flags +# + +IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + INCLUDE("cmake/compiler/compiler_gnu.cmake") +ELSEIF(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") + INCLUDE("cmake/compiler/compiler_msvc.cmake") +ELSE() + MESSAGE(FATAL_ERROR "Compiler not supported") +ENDIF() diff --git a/cmake/compiler/compiler_gnu.cmake b/cmake/compiler/compiler_gnu.cmake new file mode 100644 index 0000000..a37f3ea --- /dev/null +++ b/cmake/compiler/compiler_gnu.cmake @@ -0,0 +1,18 @@ +# +# compiler_gnu.cmake : specific configuration for GNU compilers +# + +# Set the flag -Wall to activate all warnings + IF (${CMAKE_BUILD_TYPE} STREQUAL Debug) + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -std=c++14") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}") + ELSE() + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -O2 -std=c++14") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wall -O2") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}") +ENDIF() diff --git a/cmake/compiler/compiler_msvc.cmake b/cmake/compiler/compiler_msvc.cmake new file mode 100644 index 0000000..32d15fa --- /dev/null +++ b/cmake/compiler/compiler_msvc.cmake @@ -0,0 +1,7 @@ +# +# compiler_msvc.cmake : specific configuration for MSVC compilers +# + +ADD_DEFINITIONS( /D _USE_MATH_DEFINES) +ADD_DEFINITIONS( /D _VARIADIC_MAX=10 ) +ADD_DEFINITIONS( /D _CRT_SECURE_NO_WARNINGS) diff --git a/cmake/find_libs.cmake b/cmake/find_libs.cmake new file mode 100644 index 0000000..4bb40c2 --- /dev/null +++ b/cmake/find_libs.cmake @@ -0,0 +1,30 @@ +# +# findslibs.cmake +# + +# +# Qt +# +# Find Qt here so that a message is displayed in the console when executing +# cmake, but each application must call SCIQLOP_FIND_QT() to load the Qt modules that +# it needs. +FIND_PACKAGE(Qt5Core REQUIRED) +FIND_PACKAGE(Qt5Test REQUIRED) +FIND_PACKAGE(Qt5Gui REQUIRED) + +# +# doxygen tools +# +FIND_PACKAGE(Doxygen) + +# +# Cppcheck tool +# +FIND_PACKAGE(cppcheck) + +# +# Formatting tools +# +LIST( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/formatting/cmake") +FIND_PACKAGE(vera++) +FIND_PACKAGE(ClangFormat) diff --git a/cmake/sciqlop.cmake b/cmake/sciqlop.cmake new file mode 100644 index 0000000..3e8ae2f --- /dev/null +++ b/cmake/sciqlop.cmake @@ -0,0 +1,39 @@ +# +# sciqlop.cmake +# + +# +# Update the CMAKE_MODULE_PATH to use custom FindXXX files +# +LIST( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/CMakeModules/") + +# Include the sciqlop version file +INCLUDE("cmake/sciqlop_version.cmake") + +# Include the sciqlop cmake macros +INCLUDE("cmake/sciqlop_macros.cmake") + +# +# Define the project parameters +# +INCLUDE("cmake/sciqlop_params.cmake") + +# +# Configure the compiler +# +INCLUDE("cmake/compiler/compiler.cmake") + +# +# Find all necessary dependencies +# +INCLUDE("cmake/find_libs.cmake") + +# +# Compile all applications +# +INCLUDE("cmake/sciqlop_applications.cmake") + +# +# Package creation using CPack +# +INCLUDE("cmake/sciqlop_package.cmake") diff --git a/cmake/sciqlop_applications.cmake b/cmake/sciqlop_applications.cmake new file mode 100644 index 0000000..bb04452 --- /dev/null +++ b/cmake/sciqlop_applications.cmake @@ -0,0 +1,38 @@ +# +# Sciqlop_modules.cmake +# +# Set ouptut directories +# +SET (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE}) +SET (LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE}) + + +# +# Compile the core +# +ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/sqpcore") + +# +# Compile the gui +# +ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/sqpgui") + +# +# Compile the app +# +ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/sqpapp") + +# +# Code formatting +# +INCLUDE ("cmake/sciqlop_formatting.cmake") + +# +# Documentation generation +# +INCLUDE ("cmake/sciqlop_doxygen.cmake") + +# +# Source code analysis +# +INCLUDE ("cmake/sciqlop_code_analysis.cmake") diff --git a/cmake/sciqlop_code_analysis.cmake b/cmake/sciqlop_code_analysis.cmake new file mode 100644 index 0000000..8edcf2f --- /dev/null +++ b/cmake/sciqlop_code_analysis.cmake @@ -0,0 +1,52 @@ +# +# sciqlop_code_analysis.cmake + +# Launch code source analysis with cppcheck. Can be activated with the +# ANALYZE_CODE option. +# +# The following CACHE variables are available: +# * CPPCHECK_EXTRA_ARGS: extra arguments for cppcheck; +# * CPPCHECK_OUTPUT: path to the xml report of cppcheck. +# +# The following variables are used (must be set by the cmake file calling this +# one): +# * ANALYSIS_INPUT_DIRS: directories to analyze; +# * ANALYSIS_EXCLUDE_DIRS: directories to exclude from the analysis. +# + +# +# Analyze the source code with cppcheck +# +OPTION (ANALYZE_CODE "Analyze the source code with cppcheck" ON) +IF (ANALYZE_CODE) + + # Make sure cppcheck has been found, otherwise the source code can't be + # analyzed + IF (CPPCHECK_FOUND) + SET (CPPCHECK_EXTRA_ARGS --inline-suppr --xml --enable=style --force -v + CACHE STRING "Extra arguments for cppcheck") + MARK_AS_ADVANCED (CPPCHECK_EXTRA_ARGS) + + SET (CPPCHECK_OUTPUT "${CMAKE_BINARY_DIR}/cppcheck-report.xml" + CACHE STRING "Output file for the cppcheck report") + MARK_AS_ADVANCED (CPPCHECK_OUTPUT) + + SET (CPPCHECK_EXCLUDE_DIRS) + FOREACH (dir ${ANALYSIS_EXCLUDE_DIRS}) + LIST (APPEND CPPCHECK_EXCLUDE_DIRS "-i${dir}") + ENDFOREACH () + + # Add the analyze target to launch cppcheck + ADD_CUSTOM_TARGET (analyze + COMMAND + ${CPPCHECK_EXECUTABLE} + ${CPPCHECK_EXTRA_ARGS} + ${ANALYSIS_INPUT_DIRS} + ${CPPCHECK_EXCLUDE_DIRS} + 2> ${CPPCHECK_OUTPUT} + ) + + ELSE (CPPCHECK_FOUND) + MESSAGE (STATUS "The source code won't be analyzed - Cppcheck not found") + ENDIF (CPPCHECK_FOUND) +ENDIF (ANALYZE_CODE) diff --git a/cmake/sciqlop_doxygen.cmake b/cmake/sciqlop_doxygen.cmake new file mode 100644 index 0000000..e1fe072 --- /dev/null +++ b/cmake/sciqlop_doxygen.cmake @@ -0,0 +1,110 @@ +# +# sciqlop_doxygen.cmake +# +# Launch doxygen generation. Can be activated with the BUILD_DOCUMENTATION +# option. +# +# The following CACHE variables are available: +# * DOXYGEN_LANGUAGE: Documentation language; +# +# The following variables are used (must be set by the cmake file calling this +# one): +# * DOXYGEN_INPUT_DIRS: directories to document; +# * DOXYGEN_EXCLUDE_PATTERNS: directories to exclude from the documentation +# generation. +# + +# +# Compile the doxygen documentation +# +OPTION (BUILD_DOCUMENTATION "Build the doxygen-based documentation" ON) +IF (BUILD_DOCUMENTATION) + + # Make sure Doxygen is on the system, if not then the documentation can't be built + IF (DOXYGEN_FOUND) + + # Append the global docs directory to the list of input directories + LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_SOURCE_DIR}/docs") + LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_BINARY_DIR}/gendocs") + + # Exclude the "*_private.h" files by default + list(APPEND DOXYGEN_EXCLUDE_PATTERNS "*_private.h") + # Exclude cpp files + list(APPEND DOXYGEN_EXCLUDE_PATTERNS "*.cpp") + + # Set the variables used by the Doxyfile template + SET (PROJECT_NAME "${CMAKE_PROJECT_NAME}") + SET (INPUT_DIRECTORIES) + FOREACH (dir ${DOXYGEN_INPUT_DIRS}) + SET (INPUT_DIRECTORIES "${INPUT_DIRECTORIES}\\ \n \"${dir}\" ") + ENDFOREACH () + SET (EXCLUDE_PATTERNS) + FOREACH (pattern ${DOXYGEN_EXCLUDE_PATTERNS}) + SET (EXCLUDE_PATTERNS "${EXCLUDE_PATTERNS}\\ \n \"${pattern}\" ") + ENDFOREACH () + + SET (INDEX_LIST_MODULES "\n") + + # This is the doxyfile that will be used to generate the documentation + # You can use programs like doxywizard to edit the settings + SET (doxygenConfigFileIn "${CMAKE_SOURCE_DIR}/docs/Doxyfile.dox.in") + SET (doxygenConfigFile "${CMAKE_BINARY_DIR}/Doxyfile.dox") + + SET (DOXYGEN_LANGUAGE "English" CACHE STRING "Documentation language") + MARK_AS_ADVANCED (DOXYGEN_LANGUAGE) + + SET (doxygenIndexFileIn "${CMAKE_SOURCE_DIR}/docs/index.md.in") + SET (doxygenIndexFile "${CMAKE_BINARY_DIR}/gendocs/index.md") + + # Using a .in file means we can use CMake to insert project settings + # into the doxyfile. For example, CMake will replace @PROJECT_NAME@ in + # a configured file with the CMake PROJECT_NAME variable's value. + + + CONFIGURE_FILE (${doxygenConfigFileIn} ${doxygenConfigFile} @ONLY) + CONFIGURE_FILE (${doxygenIndexFileIn} ${doxygenIndexFile} @ONLY) + + # Add the documentation target. This lets you run "make docs" from the + # generated CMake makefiles + ADD_CUSTOM_TARGET (docs + ${DOXYGEN_EXECUTABLE} ${doxygenConfigFile} + DEPENDS ${doxygenConfigFile} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + VERBATIM) + + # You can add an "install" directive to install the resulting documentation + # if desired. + INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/documentation/html DESTINATION ${INSTALL_DOCUMENTATION_DIR} OPTIONAL COMPONENT binaries) + + # Add a custom command to archive the current HTML documentation generated + # by doxygen + set(ARCHIVED_HTML_OUTPUT_FILE_NAME "${PROJECT_NAME}-${SCIQLOP_VERSION}-documentation-html.tar.bz2") + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/documentation/${ARCHIVED_HTML_OUTPUT_FILE_NAME} + COMMAND sh -c "tar --bzip2 -cf ${ARCHIVED_HTML_OUTPUT_FILE_NAME} html" + DEPENDS docs + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/documentation) + # Add a custom target to execute the above command + add_custom_target(htmldocs DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/documentation/${ARCHIVED_HTML_OUTPUT_FILE_NAME}) + + # Add a custom command to execute pdflatex on the latex documentation + # generated by doxygen + set(LATEX_OUTPUT_FILE_NAME "${PROJECT_NAME}-${SCIQLOP_VERSION}-documentation.pdf") + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/documentation/${LATEX_OUTPUT_FILE_NAME} + COMMAND make + COMMAND cp refman.pdf ../${LATEX_OUTPUT_FILE_NAME} + DEPENDS docs + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/documentation/latex) + # Add a custom target to execute the above command + add_custom_target(latexdocs DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/documentation/${LATEX_OUTPUT_FILE_NAME}) + + # Add a custom target to execute all the docs commands + add_custom_target(alldocs DEPENDS htmldocs latexdocs) + + ELSE (DOXYGEN_FOUND) + MESSAGE (STATUS "Documentation will not be built - Doxygen not found") + ENDIF (DOXYGEN_FOUND) +ENDIF (BUILD_DOCUMENTATION) diff --git a/cmake/sciqlop_formatting.cmake b/cmake/sciqlop_formatting.cmake new file mode 100644 index 0000000..98fa28e --- /dev/null +++ b/cmake/sciqlop_formatting.cmake @@ -0,0 +1,53 @@ +# +# sciqlop_formatting.cmake +# +# Launch code formatting tools. Can be activated with ENABLE_FORMATTING and +# ENABLE_CHECKSTYLE options. +# +# The following variables are used (must be set by the cmake file calling this +# one): +# * FORMATTING_INPUT_FILES: list of files to format; +# * CHECKSTYLE_INPUT_FILES: list of files to check for style; +# * CHECKSTYLE_EXCLUSION_FILES: list of vera++ exclusion files. +# + +OPTION (ENABLE_FORMATTING "Format the source code while compiling" ON) +OPTION (ENABLE_CHECKSTYLE "Analyse the style of the code while compiling" ON) + +IF (ENABLE_FORMATTING) + IF (CLANGFORMAT_FOUND) + INCLUDE(${CLANGFORMAT_USE_FILE}) + + ADD_CLANGFORMAT_TARGETS(${FORMATTING_INPUT_FILES} + ADD_TO_ALL) + ELSE() + MESSAGE (STATUS "Source code will not be formatted - clang-format not found") + ENDIF() +ENDIF() + +IF (ENABLE_CHECKSTYLE) + IF (VERA++_FOUND) + INCLUDE(${VERA++_USE_FILE}) + + SET(EXCLUSIONS) + FOREACH (e ${CHECKSTYLE_EXCLUSION_FILES}) + LIST(APPEND EXCLUSIONS EXCLUSION ${e}) + ENDFOREACH() + + ADD_VERA_TARGETS(${CHECKSTYLE_INPUT_FILES} + ADD_TO_ALL + PROFILE "sciqlop" + ROOT "${CMAKE_SOURCE_DIR}/formatting/vera-root" + PARAMETER "project-name=${PROJECT_NAME}" + ${EXCLUSIONS}) + + ADD_VERA_CHECKSTYLE_TARGET(${CHECKSTYLE_INPUT_FILES} + PROFILE "sciqlop" + ROOT "${CMAKE_SOURCE_DIR}/formatting/vera-root" + PARAMETER "project-name=${PROJECT_NAME}" + ${EXCLUSIONS}) + + ELSE() + MESSAGE (STATUS "Source code will not be checkstyled - vera++ not found") + ENDIF() +ENDIF() diff --git a/cmake/sciqlop_macros.cmake b/cmake/sciqlop_macros.cmake new file mode 100644 index 0000000..2cf91d5 --- /dev/null +++ b/cmake/sciqlop_macros.cmake @@ -0,0 +1,191 @@ +# +# sciqlop_macros.cmake +# +# The following functions or macros are defined in this document: +# - SUBDIRLIST +# - SCIQLOP_SET_TO_PARENT_SCOPE +# - SCIQLOP_PROCESS_EXTERN_DEPENDENCIES +# - SCIQLOP_COPY_TO_TARGET +# - SCIQLOP_READ_FILE +# - SCIQLOP_FIND_QT +# - SCIQLOP_ADD_EXTERN_DEPENDENCY + +# +# Define a macro to retrieve all subdirectory names of a specific directory +# +MACRO(SUBDIRLIST result curdir) + FILE(GLOB children RELATIVE ${curdir} ${curdir}/*) + SET(dirlist "") + FOREACH(child ${children}) + IF(IS_DIRECTORY ${curdir}/${child}) + LIST(APPEND dirlist ${child}) + ENDIF() + ENDFOREACH() + SET(${result} ${dirlist}) +ENDMACRO() + +# SCIQLOP_SET_TO_PARENT_SCOPE(variable) +# +# Set the given variable to the parent scope. +# +MACRO (SCIQLOP_SET_TO_PARENT_SCOPE variable) + SET(${variable} ${${variable}} PARENT_SCOPE) +ENDMACRO (SCIQLOP_SET_TO_PARENT_SCOPE) + +MACRO(SCIQLOP_FIND_QT) + # Find includes in corresponding build directories + set(CMAKE_INCLUDE_CURRENT_DIR ON) + # Instruct CMake to run moc automatically when needed. + set(CMAKE_AUTOMOC ON) + + # Find Qt5 and the modules asked + FOREACH(component ${ARGN}) + FIND_PACKAGE(Qt5${component} QUIET REQUIRED) + INCLUDE_DIRECTORIES(${Qt5${component}_INCLUDE_DIRS}) + ENDFOREACH(component) +ENDMACRO(SCIQLOP_FIND_QT) + +# SCIQLOP_PROCESS_EXTERN_DEPENDENCIES(externFile externLibraries externSharedLibraries) +# +# Process the dependencies file for the modules. Each line of this file must +# contain the parameters to pass to the FIND_PACKAGE function. This function +# will append the libraries of the extern dependency found to the variable +# passed as a second parameter, and add the include directories of the extern +# dependency to the global include directories. Moreover, the extern shared +# libraries are stored in the variable passed as a third parameter. These shared +# libraries can then be copied to a target output path by using the +# SCIQLOP_COPY_TO_TARGET function. +# +# Examples: +# +# SCIQLOP_PROCESS_MODULE_DEPENDENCIES("path/to/extern.dependencies" +# EXTERN_LIBRARIES +# EXTERN_SHARED_LIBRARIES) +# +FUNCTION (SCIQLOP_PROCESS_EXTERN_DEPENDENCIES externFile librariesVar sharedLibrariesVar) + + SCIQLOP_READ_FILE(${externFile} externDependencies) + SET (externLibraries) + SET (externSharedLibraries) + FOREACH (externDependency ${externDependencies}) + # Check if the line is a comment (begins with #) + STRING(REGEX MATCH "^ *#.*$" matched "${externDependency}") + IF (NOT matched) + STRING(REGEX REPLACE " +" ";" externDependency "${externDependency}") + SCIQLOP_ADD_EXTERN_DEPENDENCY(externLibraries externSharedLibraries ${externDependency}) + ENDIF() + ENDFOREACH() + + LIST (APPEND ${librariesVar} ${externLibraries}) + SCIQLOP_SET_TO_PARENT_SCOPE(${librariesVar}) + + LIST (APPEND ${sharedLibrariesVar} ${externSharedLibraries}) + SCIQLOP_SET_TO_PARENT_SCOPE(${sharedLibrariesVar}) +ENDFUNCTION (SCIQLOP_PROCESS_EXTERN_DEPENDENCIES) + +# SCIQLOP_COPY_TO_TARGET copy the given files to the given target output path. +# +# The first parameter must be RUNTIME or LIBRARY, and it indicates the type of +# the target. +# +# The second parameter is the name of the target where the files must be copied. +# The RUNTIME_OUTPUT_DIRECTORY or LIBRARY_OUTPUT_DIRECTORY target properties +# will be used to find the output path of the copy. If these properties are +# empty, then the EXECUTABLE_OUTPUT_PATH or LIBRARY_OUTPUT_PATH variables will +# be used. +# +# The rest of the parameters are the files that must be copied. +FUNCTION (SCIQLOP_COPY_TO_TARGET runtimeOrLibrary targetName) + # Check RUNTIME or LIBRARY argument + IF (${runtimeOrLibrary} STREQUAL "RUNTIME") + SET (targetProperty "RUNTIME_OUTPUT_DIRECTORY") + SET (pathProperty ${EXECUTABLE_OUTPUT_PATH}) + ELSEIF (${runtimeOrLibrary} STREQUAL "LIBRARY") + SET (targetProperty "LIBRARY_OUTPUT_DIRECTORY") + SET (pathProperty ${LIBRARY_OUTPUT_PATH}) + ELSE () + MESSAGE (FATAL "The first parameter of COPY_TO_TARGET must be either RUNTIME or LIBRARY, not \"${runtimeOrLibrary}\"") + ENDIF () + + # Select the output directory + GET_TARGET_PROPERTY(OUTPUT_DIR ${targetName} ${targetProperty}) + IF (OUTPUT_DIR STREQUAL "OUTPUT_DIR-NOTFOUND") + SET (OUTPUT_DIR ${pathProperty}) + ENDIF () + + # Retrieve the list of files to copy by listing the rest of the macro + # arguments + FOREACH (arg ${ARGN}) + LIST(APPEND fileList ${arg}) + ENDFOREACH() + + # Only copy if the list isn't empty + IF (fileList) + FILE(COPY ${fileList} DESTINATION ${OUTPUT_DIR}) + ENDIF() +ENDFUNCTION (SCIQLOP_COPY_TO_TARGET) + +# SCIQLOP_READ_FILE(file contents) +# +# Read the given file line by line and store the resulting list inside the +# contents variable. +# +# /!\ If the file contains semicolons, the macro will escape them before +# returning the list. +# +# From +FUNCTION (SCIQLOP_READ_FILE file contentsVar) + FILE (READ ${file} contents) + + # Convert file contents into a CMake list (where each element in the list + # is one line of the file) + # + STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}") + STRING(REGEX REPLACE "\n" ";" contents "${contents}") + + # Return file contents as a list + SET (${contentsVar} "${contents}" PARENT_SCOPE) +ENDFUNCTION (SCIQLOP_READ_FILE) + +# SCIQLOP_ADD_EXTERN_DEPENDENCY(externLibrariesVar externSharedLibrariesVar dependencyName [EXTRA FIND_PACKAGE ARGS]) +# +# SCIQLOP_ADD_EXTERN_DEPENDENCY can be used to add a dependency residing in the +# extern subdirectory to a module. +# +# The first parameter is the name of the variable where the found libraries will +# be added. +# +# The second parameter is the name of the variable where the found shared +# libraries will be added. +# +# The third parameter is the name of the dependency, and the rest of the +# arguments are the same than the FIND_PACKAGE command. In fact they are passed +# as-is to the command. +# +# If the dependency is found, then INCLUDE_DIRECTORIES is called for the +# dependency include directories, and the libraries are added to the +# externLibrariesVar variable. Moreover, if the dependency is a shared library, +# then the dynamic libraries are added to the externSharedLibrariesVar so that +# they can be copied and installed alongside the module. The libraries in this +# variable are ordered so that the real library is before the symlinks to the +# library, so that the copy and install works as expected. +FUNCTION (SCIQLOP_ADD_EXTERN_DEPENDENCY externLibrariesVar externSharedLibrariesVar dependencyName) + STRING (TOUPPER ${dependencyName} upperDependencyName) + + FIND_PACKAGE(${dependencyName} ${ARGN}) + IF (${upperDependencyName}_FOUND) + # Add the include directories of the dependency + INCLUDE_DIRECTORIES(${${upperDependencyName}_INCLUDE_DIRS}) + + # Add the libraries to the externLibrariesVar variable and export it to + # the parent scope + LIST(APPEND ${externLibrariesVar} ${${upperDependencyName}_LIBRARIES}) + SCIQLOP_SET_TO_PARENT_SCOPE(${externLibrariesVar}) + + # Find the shared libraries + LIST(APPEND ${externSharedLibrariesVar} ${${upperDependencyName}_SHARED_LIBRARIES}) + + # Export the externSharedLibrariesVar variable to the parent scope + SCIQLOP_SET_TO_PARENT_SCOPE(${externSharedLibrariesVar}) + ENDIF () +ENDFUNCTION (SCIQLOP_ADD_EXTERN_DEPENDENCY) diff --git a/cmake/sciqlop_package.cmake b/cmake/sciqlop_package.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/cmake/sciqlop_package.cmake diff --git a/cmake/sciqlop_params.cmake b/cmake/sciqlop_params.cmake new file mode 100644 index 0000000..917bf6f --- /dev/null +++ b/cmake/sciqlop_params.cmake @@ -0,0 +1,90 @@ +# +# sciqlop_params : Define compilation parameters +# +# Debug or release +# +# As the "NMake Makefiles" forces by default the CMAKE_BUILD_TYPE variable to Debug, SCIQLOP_BUILD_TYPE variable is used to be sure that the debug mode is a user choice +SET(SCIQLOP_BUILD_TYPE "Release" CACHE STRING "Choose to compile in Debug or Release mode") + +IF(SCIQLOP_BUILD_TYPE MATCHES "Debug") + MESSAGE (STATUS "Build in Debug") + SET (CMAKE_BUILD_TYPE "Debug") + SET (DEBUG_SUFFIX "d") +ELSE() + MESSAGE (STATUS "Build in Release") + SET (CMAKE_BUILD_TYPE "Release") + SET (SCIQLOP_BUILD_TYPE "Release") + SET (DEBUG_SUFFIX "") +ENDIF() + +# +# Need to compile tests? +# +OPTION (BUILD_TESTS "Build the tests" OFF) +ENABLE_TESTING(${BUILD_TESTS}) + +# +# Path to the folder for sciqlop's extern libraries. +# +# When looking for an external library in sciqlop, we look to the following +# folders: +# - The specific folder for the library (generally of the form _ROOT_DIR +# - The global Sciqlop extern folder +# - The system folders. +# +# If a dependency is found in the global extern folder or a specific folder for +# the library, then it is installed with the sciqlop libraries. If it is found +# in the system folders, it is not. This behavior can be overriden with the +# _COPY_SHARED_LIBRARIES flag. +# +set(SCIQLOP_EXTERN_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/extern" + CACHE PATH "Path to the folder for sciqlop's extern libraries") +option(SCIQLOP_FORCE_UPDATE_EXT_ROOT_DIR "Force the _ROOT_DIR to be updated to the global sciqlop extern folder" + OFF) + +if (SCIQLOP_FORCE_UPDATE_EXT_ROOT_DIR) + set(libRootDirForceValue FORCE) +else() + set(libRootDirForceValue) +endif() + + + +# +# Static or shared libraries +# +OPTION (BUILD_SHARED_LIBS "Build the shared libraries" ON) + +# Generate position independant code (-fPIC) +SET(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + +# +# Configure installation directories +# +IF (UNIX) + SET(defaultBin "bin") + SET(defaultInc "include/sciqlop") + + # 32 or 64 bits compiler + IF( CMAKE_SIZEOF_VOID_P EQUAL 8 ) + SET(defaultLib "lib64/sciqlop") + ELSE() + SET(defaultLib "lib/sciqlop") + ENDIF() + + SET(defaultDoc "share/docs/sciqlop") +ELSE() + SET(defaultBin "bin") + SET(defaultInc "include/sciqlop") + SET(defaultLib "lib/sciqlop") + SET(defaultDoc "docs/sciqlop") +ENDIF() + +SET(INSTALL_BINARY_DIR "${defaultBin}" CACHE STRING + "Installation directory for binaries") +SET(INSTALL_LIBRARY_DIR "${defaultLib}" CACHE STRING + "Installation directory for libraries") +SET(INSTALL_INCLUDE_DIR "${defaultInc}" CACHE STRING + "Installation directory for headers") +SET(INSTALL_DOCUMENTATION_DIR "${defaultDoc}" CACHE STRING + "Installation directory for documentations") diff --git a/cmake/sciqlop_version.cmake b/cmake/sciqlop_version.cmake new file mode 100644 index 0000000..6899550 --- /dev/null +++ b/cmake/sciqlop_version.cmake @@ -0,0 +1,22 @@ +# +# sciqlop_version.cmake +# +# Holds the version of sciqlop. +# +# These variables are used to generate the +# "Version.h" and "Version.cpp" files so that the version number is available +# inside of sciqlop source code. +# +# Moreover, they're used with CPack to display the version number in the setups. +# + +# Version number parts. These variables must be updated when the version change. +SET (SCIQLOP_VERSION_MAJOR 0) +SET (SCIQLOP_VERSION_MINOR 1) +SET (SCIQLOP_VERSION_PATCH 0) +SET (SCIQLOP_VERSION_SUFFIX "") + +# Version number as a string. This variable is automatically generated from the +# above variables to build a version number of the form: MAJOR.MINOR.PATCH. If +# SCIQLOP_VERSION_SUFFIX isn't empty, it is appended to the version number. +SET (SCIQLOP_VERSION "${SCIQLOP_VERSION_MAJOR}.${SCIQLOP_VERSION_MINOR}.${SCIQLOP_VERSION_PATCH}${SCIQLOP_VERSION_SUFFIX}") diff --git a/sqpapp/CMakeLists.txt b/sqpapp/CMakeLists.txt new file mode 100644 index 0000000..24c6fe9 --- /dev/null +++ b/sqpapp/CMakeLists.txt @@ -0,0 +1,141 @@ + +## sciqlop - CMakeLists.txt +SET(EXECUTABLE_NAME "sciqlop") +SET(SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/) +SET(INCLUDE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/include) +SET(UI_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/src) +SET(RES_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/resources) + +# +# Find Qt modules +# +SCIQLOP_FIND_QT(Core Widgets) + +# +# Find dependent libraries +# ======================== +SET(LIBRARIES) +SET(EXTERN_LIBRARIES) +SET(EXTERN_SHARED_LIBRARIES) + +# Add sqpcore to the list of libraries to use +list(APPEND LIBRARIES ${SQPCORE_LIBRARY_NAME}) + +# Include sqpcore directory +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../sqpcore/src") + +# Add dependent shared libraries +list(APPEND SHARED_LIBRARIES ${SQPCORE_SHARED_LIBRARIES}) + +# Retrieve the location of the dynamic library to copy it to the output path +get_property(sqpcoreLocation TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY LOCATION) +list(APPEND SHARED_LIBRARIES_FROM_TARGETS ${sqpcoreLocation}) + +# +# Compile the application +# +FILE (GLOB_RECURSE APPLICATION_SOURCES + ${SOURCES_DIR}/*.c + ${SOURCES_DIR}/*.cpp + ${SOURCES_DIR}/*.h) + +# Headers files (.h) +FILE (GLOB_RECURSE PROJECT_HEADERS ${INCLUDE_FOLDER}/*.h) + +# Ui files +FILE (GLOB_RECURSE PROJECT_FORMS ${UI_FOLDER}/*.ui) + +# Resources files +FILE (GLOB_RECURSE PROJECT_RESOURCES ${RES_FOLDER}/*.qrc) + +# Retrieve resources files +FILE (GLOB_RECURSE APPLICATION_RESOURCES ${RES_FOLDER}/*.qrc) + +QT5_ADD_RESOURCES(RCC_HDRS ${APPLICATION_RESOURCES} ) + +QT5_WRAP_UI(UIS_HDRS + ${PROJECT_FORMS} +) + + +ADD_EXECUTABLE(${EXECUTABLE_NAME} ${APPLICATION_SOURCES} ${RCC_HDRS} ${UIS_HDRS}) +target_link_libraries(${EXECUTABLE_NAME} + ${LIBRARIES}) + +# Link with Qt5 modules +qt5_use_modules(${EXECUTABLE_NAME} Core Widgets) + + +# Add the files to the list of files to be analyzed +LIST(APPEND CHECKSTYLE_INPUT_FILES ${APPLICATION_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) +# Vera++ exclusion files +#LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/path/to/exclusionFiles.tcl) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) + +# +# Compile the tests +# +IF(BUILD_TESTS) + INCLUDE_DIRECTORIES(${SOURCES_DIR}) + FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp) + FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h) + SET( TEST_LIBRARIES ${LIBRARIES} ${EXTERN_LIBRARIES}) + + FOREACH( testFile ${TESTS_SOURCES} ) + GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) + GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) + + # Add to the list of sources files all the sources in the same + # directory that aren't another test + FILE (GLOB currentTestSources + ${testDirectory}/*.c + ${testDirectory}/*.cpp + ${testDirectory}/*.h) + LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) + LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) + + ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) + TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} ) + qt5_use_modules(${testName} Test) + + ADD_TEST( NAME ${testName} COMMAND ${testName} ) + + SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) + ENDFOREACH( testFile ) + + LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) + LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) + LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) + SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) +ENDIF(BUILD_TESTS) + +# +# Set the files that must be formatted by clang-format. +# +LIST (APPEND FORMATTING_INPUT_FILES ${APPLICATION_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) + +# +# Set the directories that doxygen must browse to generate the +# documentation. +# +# Source directories: +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) +# Source directories to exclude from the documentation generation +#LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) + +# +# Set the directories with the sources to analyze and propagate the +# modification to the parent scope +# +# Source directories to analyze: +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) +# Source directories to exclude from the analysis +#LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) diff --git a/sqpcore/CMakeLists.txt b/sqpcore/CMakeLists.txt new file mode 100644 index 0000000..f4e6fcf --- /dev/null +++ b/sqpcore/CMakeLists.txt @@ -0,0 +1,121 @@ + +## sqpcore - CMakeLists.txt +STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) +SET(SQPCORE_LIBRARY_NAME "${LIBRARY_PREFFIX}_sqpcore${DEBUG_SUFFIX}") +SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/") + +# Set a variable to display a warning in the version files. +SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.") +# Generate the version file from the cmake version variables. The version +# variables are defined in the cmake/sciqlop_version.cmake file. +CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.h.in" + "${SOURCES_DIR}/Version.h") +CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.cpp.in" + "${SOURCES_DIR}/Version.cpp") + +# +# Find Qt modules +# +SCIQLOP_FIND_QT(Core) + +# +# Compile the library library +# +FILE (GLOB_RECURSE MODULE_SOURCES + ${SOURCES_DIR}/*.c + ${SOURCES_DIR}/*.cpp + ${SOURCES_DIR}/*.h) + +ADD_LIBRARY(${SQPCORE_LIBRARY_NAME} ${MODULE_SOURCES}) +TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME} ${EXTERN_LIBRARIES}) +qt5_use_modules(${SQPCORE_LIBRARY_NAME} Core) + +# From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html +# Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order. +# The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets +IF(BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES(${SQPCORE_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT") +ELSE() + TARGET_COMPILE_DEFINITIONS(${SQPCORE_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES") +ENDIF() + +# Set the variable to parent scope so that the other projects can copy the +# dependent shared libraries +SCIQLOP_SET_TO_PARENT_SCOPE(SQPCORE_LIBRARY_NAME) + +# Copy extern shared libraries to the lib folder +SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPCORE_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES}) + +# Add the files to the list of files to be analyzed +LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) +# Vera++ exclusion files +#LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/path/to/exclusionFiles.tcl) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) + +# +# Compile the tests +# +IF(BUILD_TESTS) + INCLUDE_DIRECTORIES(${SOURCES_DIR}) + FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp) + FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h) + SET( TEST_LIBRARIES ${SQPCORE_LIBRARY_NAME} ${EXTERN_LIBRARIES}) + + FOREACH( testFile ${TESTS_SOURCES} ) + GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) + GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) + + # Add to the list of sources files all the sources in the same + # directory that aren't another test + FILE (GLOB currentTestSources + ${testDirectory}/*.c + ${testDirectory}/*.cpp + ${testDirectory}/*.h) + LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) + LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) + + ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) + TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} ) + qt5_use_modules(${testName} Test) + + ADD_TEST( NAME ${testName} COMMAND ${testName} ) + + SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) + ENDFOREACH( testFile ) + + LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) + LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) + LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) + SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) +ENDIF(BUILD_TESTS) + +# +# Set the files that must be formatted by clang-format. +# +LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) + +# +# Set the directories that doxygen must browse to generate the +# documentation. +# +# Source directories: +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) +# Source directories to exclude from the documentation generation +#LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) + +# +# Set the directories with the sources to analyze and propagate the +# modification to the parent scope +# +# Source directories to analyze: +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) +# Source directories to exclude from the analysis +#LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) diff --git a/sqpgui/CMakeLists.txt b/sqpgui/CMakeLists.txt new file mode 100644 index 0000000..1e768ae --- /dev/null +++ b/sqpgui/CMakeLists.txt @@ -0,0 +1,138 @@ + +## sqpgui - CMakeLists.txt +STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) +SET(SQPGUI_LIBRARY_NAME "${LIBRARY_PREFFIX}_sqpgui${DEBUG_SUFFIX}") +SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") +SET(INCLUDE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/include) +SET(UI_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/ui) +SET(RES_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/resources) + +# Set a variable to display a warning in the version files. +SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.") + +# +# Find Qt modules +# +SCIQLOP_FIND_QT(Core Widgets) + +# +# Compile the library library +# +FILE (GLOB_RECURSE MODULE_SOURCES + ${SOURCES_DIR}/*.c + ${SOURCES_DIR}/*.cpp + ${SOURCES_DIR}/*.h) + +# Headers files (.h) +FILE (GLOB_RECURSE PROJECT_HEADERS ${INCLUDE_FOLDER}/*.h) + +# Ui files +FILE (GLOB_RECURSE PROJECT_FORMS ${UI_FOLDER}/*.ui) + +# Resources files +FILE (GLOB_RECURSE PROJECT_RESOURCES ${RES_FOLDER}/*.qrc) + +QT5_ADD_RESOURCES(RCC_HDRS + ${PROJECT_RESOURCES} +) + +QT5_WRAP_UI(UIS_HDRS + ${PROJECT_FORMS} +) + +include_directories("${CMAKE_CURRENT_BINARY_DIR}") +message(CURRENT INCLUDE : ${CMAKE_CURRENT_BINARY_DIR}) + +ADD_LIBRARY(${SQPGUI_LIBRARY_NAME} ${MODULE_SOURCES} ${UIS_HDRS}) +TARGET_LINK_LIBRARIES(${SQPGUI_LIBRARY_NAME} ${EXTERN_LIBRARIES}) +qt5_use_modules(${SQPGUI_LIBRARY_NAME} Core Widgets) + +# From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html +# Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order. +# The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets +IF(BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES(${SQPGUI_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT") +ELSE() + TARGET_COMPILE_DEFINITIONS(${SQPGUI_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES") +ENDIF() + +# Set the variable to parent scope so that the other projects can copy the +# dependent shared libraries +SCIQLOP_SET_TO_PARENT_SCOPE(SQPGUI_LIBRARY_NAME) + +# Copy extern shared libraries to the lib folder +SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPGUI_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES}) + +# Add the files to the list of files to be analyzed +LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) +# Vera++ exclusion files +#LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/path/to/exclusionFiles.tcl) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) + +# +# Compile the tests +# +IF(BUILD_TESTS) + INCLUDE_DIRECTORIES(${SOURCES_DIR}) + FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp) + FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h) + SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME} ${EXTERN_LIBRARIES}) + + FOREACH( testFile ${TESTS_SOURCES} ) + GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) + GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) + + # Add to the list of sources files all the sources in the same + # directory that aren't another test + FILE (GLOB currentTestSources + ${testDirectory}/*.c + ${testDirectory}/*.cpp + ${testDirectory}/*.h) + LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) + LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) + + ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) + TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} ) + qt5_use_modules(${testName} Test) + + ADD_TEST( NAME ${testName} COMMAND ${testName} ) + + SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) + ENDFOREACH( testFile ) + + LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) + LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) + LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) + SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) +ENDIF(BUILD_TESTS) + +# +# Set the files that must be formatted by clang-format. +# +LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) + +# +# Set the directories that doxygen must browse to generate the +# documentation. +# +# Source directories: +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) +# Source directories to exclude from the documentation generation +#LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) + +# +# Set the directories with the sources to analyze and propagate the +# modification to the parent scope +# +# Source directories to analyze: +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) +# Source directories to exclude from the analysis +#LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)