From a1e680fa6ae9ccf115b530f49131e5c01b8921de Mon Sep 17 00:00:00 2001 From: lobis Date: Fri, 4 Feb 2022 19:17:38 +0100 Subject: [PATCH 01/61] update docker image --- .github/workflows/ci.yml | 67 +++++----------------------------------- .gitlab-ci.yml | 3 +- 2 files changed, 8 insertions(+), 62 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd2de908d..2eaaa8102 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,86 +2,33 @@ name: CI on: push: - branches: [master] + branches: [ cmake-ctest ] pull_request: - branches: [master] + branches: [ cmake-ctest ] workflow_dispatch: jobs: - Check-Image: - runs-on: ubuntu-latest - container: - image: lobis/root-geant4-garfieldpp:latest - - steps: - - name: Check ROOT - run: | - root-config --version - root-config --libs - root-config --cflags - - - name: Check Geant4 - # TODO: We should run `geant4-config` but can't do it easily without interactive shell. This ENV variable is from the docker image - run: | - echo $GEANT4_VERSION - ls -lht /opt/geant4/install - - # TODO: We should check that garfield is installed and working - - name: Check Garfield++ - run: | - ls -lht /opt/garfieldpp/install - - Build-Default: - needs: Check-Image - runs-on: ubuntu-latest - env: - REST_PATH: /opt/rest/install - container: - image: lobis/root-geant4-garfieldpp:latest - - steps: - - uses: actions/checkout@v2 - - - name: Pull Submodules - run: python3 pull-submodules.py - - - name: Build - run: | - mkdir -p build - cd build - cmake .. - make - make install - - - name: REST config - run: | - ${REST_PATH}/bin/rest-config --version - ${REST_PATH}/bin/rest-config --libs - ${REST_PATH}/bin/rest-config --flags - ${REST_PATH}/bin/rest-config --commit - Build-Full: - # TODO: install requiered dependencies so this job doesn't fail + Build: needs: Check-Image runs-on: ubuntu-latest env: - REST_PATH: /opt/rest/install + REST_PATH: /REST/install container: - image: lobis/root-geant4-garfieldpp:latest + image: ghcr.io/lobis/root-geant4-garfield:cxx17_ROOT-v6-25-01_Geant4-v10.4.3_Garfield-4.0 steps: - uses: actions/checkout@v2 - name: Pull Submodules - run: python3 pull-submodules.py + run: yes | python3 pull-submodules - name: Build run: | - export GARFIELD_HOME=/opt/garfieldpp/install mkdir -p build cd build - cmake .. -DREST_ALL_LIBS=ON -DREST_G4=ON -DREST_GARFIELD=ON -DCMAKE_PREFIX_PATH=/opt/geant4/install + cmake .. -DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DREST_ALL_LIBS=OFF make make install diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d62d1b4de..26ea21fb5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,4 @@ -#image: lobis/root-geant4-garfieldpp:cxx14_ROOTv6-25-01_Geant4v10.4.3 -image: nkx1231/root6-geant4-garfield:0.6 +image: ghcr.io/lobis/root-geant4-garfield:cxx17_ROOT-v6-25-01_Geant4-v10.4.3_Garfield-4.0 variables: # GIT_SUBMODULE_STRATEGY: recursive From f55887223ea0c176930dd1465fe11eed28e1e10e Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Mon, 7 Feb 2022 11:30:56 +0100 Subject: [PATCH 02/61] Started refactoring --- CMakeLists.txt | 10 +- cmake/FindGarfield.cmake | 61 --- cmake/FindROOT.cmake | 98 ----- cmake/MacroRootDict.cmake | 524 ----------------------- cmake/ThisGenerateRootDictionaries.cmake | 38 ++ source/CMakeLists.txt | 141 +++--- source/framework/CMakeLists.txt | 47 +- source/framework/analysis/CMakeLists.txt | 0 source/framework/core/CMakeLists.txt | 13 + source/framework/tools/CMakeLists.txt | 0 10 files changed, 173 insertions(+), 759 deletions(-) delete mode 100644 cmake/FindGarfield.cmake delete mode 100644 cmake/FindROOT.cmake delete mode 100644 cmake/MacroRootDict.cmake create mode 100644 cmake/ThisGenerateRootDictionaries.cmake create mode 100644 source/framework/analysis/CMakeLists.txt create mode 100644 source/framework/core/CMakeLists.txt create mode 100644 source/framework/tools/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index a047571b3..a790b478b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ -PROJECT(REST) -CMAKE_MINIMUM_REQUIRED(VERSION 3.5) +PROJECT(REST LANGUAGES CXX HOMEPAGE_URL https://github.com/rest-for-physics/framework) + +cmake_minimum_required(VERSION 3.14) # Minimum compiler version if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") @@ -27,6 +28,7 @@ if (NOT DEFINED INSTALL_PREFIX) set(INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/install) endif () endif () + get_filename_component(INSTALL_PREFIX_ABSOLUTE ${INSTALL_PREFIX} ABSOLUTE BASE_DIR "${CMAKE_BINARY_DIR}") set(REST_PATH ${INSTALL_PREFIX_ABSOLUTE}) if (NOT DEFINED CMAKE_INSTALL_PREFIX) @@ -58,6 +60,7 @@ set(CMAKE_MACOSX_RPATH 1) find_package(ROOT REQUIRED) +# Use same cpp version as the ROOT install execute_process(COMMAND root-config --has-cxx20 OUTPUT_VARIABLE HASCXX20) execute_process(COMMAND root-config --has-cxx17 OUTPUT_VARIABLE HASCXX17) execute_process(COMMAND root-config --has-cxx14 OUTPUT_VARIABLE HASCXX14) @@ -116,8 +119,9 @@ message(STATUS "external libraries to link: " ${external_libs}) string(TIMESTAMP date "%Y-%m-%d %H:%M") # Start compile -include(MacroRootDict) +include(ThisGenerateRootDictionaries) add_subdirectory(source) + message("") message(STATUS "rest Libraries: " ${rest_libraries_regular}) message(STATUS "rest executables: " ${rest_exes}) diff --git a/cmake/FindGarfield.cmake b/cmake/FindGarfield.cmake deleted file mode 100644 index cdbf9c43b..000000000 --- a/cmake/FindGarfield.cmake +++ /dev/null @@ -1,61 +0,0 @@ - -# - Try to find Garfield++ instalation -# This module sets up Garfield information -# It defines: -# Garfield_FOUND If Garfiled++ is found -# Garfield_INCLUDE_DIRS PATH to the include directories -# Garfield_LIBRARIES the libraries needed to use Garfield++ - -#message(STATUS "Looking for Garfield ...") - -# Alternative paths which can be defined by user -#set(Garfield_DIR "" CACHE PATH "Directory where Garfield is installed") -#set(Garfield_INC_DIR "" CACHE PATH "Alternative directory for Garfield includes") -#set(Garfield_LIB_DIR "" CACHE PATH "Alternative directory for Garfield libraries") -set(Garfield_DIR $ENV{GARFIELD_HOME}) - -find_path(Garfield_INCLUDE_DIRS Sensor.hh - HINTS ${Garfield_DIR}/include/ ${Garfield_DIR}/include/Garfield ${Garfield_INC_DIR} - ${Garfield_DIR}/Include) - -#message(STATUS Garfield_INCLUDE_DIRS ${Garfield_INCLUDE_DIRS}) - -find_library(Garfield_LIBRARIES NAMES libGarfield.so Garfield - HINTS ${Garfield_DIR}/lib ${Garfield_LIB_DIR} - $ENV{GARFIELD_HOME}/lib) -#message(STATUS Garfield_LIBRARIES ${Garfield_LIBRARIES}) - -#if (${Garfield_LIBRARY_DIR}) -# set (Garfield_LIBRARIES -L${Garfield_LIBRARY_DIR} -lGarfield) -#endif() - -if (Garfield_INCLUDE_DIRS AND Garfield_LIBRARIES) - set (Garfield_FOUND TRUE) -endif() - -if (NOT DEFINED ENV{GARFIELD_HOME} ) - message("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nError : GARFIELD HOME is not defined! - \nCheck Garfield is installed and GARFIELD_HOME is pointing to install directory - \nHINT : GARFIELD_HOME/lib/libGarfield.so should exist. - \nIf you do not need Garfield++ interface in your REST installation, then, - \nplease, run cmake disabling REST_GARFIELD variable - \n\ni.e. : cmake -DREST_GARFIELD=OFF ../ - \n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ) -endif() - -if (Garfield_FOUND) - if (NOT Garfield_FIND_QUIETLY) - message(STATUS "Found Garfield includes in ${Garfield_INCLUDE_DIRS}") - message(STATUS "Found Garfield libraries ${Garfield_LIBRARIES}") - endif (NOT Garfield_FIND_QUIETLY) -else(Garfield_FOUND) - if (Garfield_FIND_REQUIRED) - message(FATAL_ERROR "Garfield required, but not found!\ntry to run \"./scripts/installation/v2.2/installGarfield.sh\" to install it. - ") - endif (Garfield_FIND_REQUIRED) -endif(Garfield_FOUND) - -# Make variables changeble to the advanced user -mark_as_advanced(Garfield_INCLUDE_DIRS) -mark_as_advanced(Garfield_LIBRARIES) -mark_as_advanced(Garfield_LIBRARY_DIR) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake deleted file mode 100644 index 6855cb6f2..000000000 --- a/cmake/FindROOT.cmake +++ /dev/null @@ -1,98 +0,0 @@ -# - Finds ROOT instalation -# This module sets up ROOT information -# It defines: -# ROOT_FOUND If the ROOT is found -# ROOT_INCLUDE_DIR PATH to the include directory (deprecated) -# ROOT_INCLUDE_DIRS PATH to the include directory -# ROOT_LIBRARIES Most common libraries -# ROOT_LIBRARY_DIR PATH to the library directory -# ROOT_BIN_DIR PATH to the excutables directory -# ROOT_PYTHONVER Compatible python version string - -# First search for ROOTConfig.cmake on the path defined via user setting -# ROOT_DIR - -if (CMAKE_SYSTEM_NAME MATCHES "Windows") - - if(DEFINED ENV{ROOTSYS}) - set(ROOTSYS $ENV{ROOTSYS}) - endif() - - if(NOT ROOTSYS) - set(ROOT_FOUND FALSE) - else() - set(ROOT_FOUND TRUE) - - set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib) - set(ROOT_INCLUDE_DIRS ${ROOTSYS}/include) - set(ROOT_BIN_DIR ${ROOTSYS}/bin) - set(ROOTCINT_EXECUTABLE ${ROOTSYS}/bin/rootcint.exe) - set(GENREFLEX_EXECUTABLE ${ROOTSYS}/bin/genreflex.exe) - - set(CMAKE_FIND_LIBRARY_PREFIXES "lib") - set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll") - set(ROOT_LIBRARIES) - foreach(_cpt Core Imt RIO Net Hist Gui Eve RGL Gdml Geom Graf Graf3d Gpad Tree TreePlayer Rint Postscript Matrix Physics MathCore Thread MultiProc Minuit) - find_library(ROOT_${_cpt}_LIBRARY ${_cpt} HINTS ${ROOT_LIBRARY_DIR}) - if(ROOT_${_cpt}_LIBRARY) - mark_as_advanced(ROOT_${_cpt}_LIBRARY) - list(APPEND ROOT_LIBRARIES ${ROOT_${_cpt}_LIBRARY}) - endif() - endforeach() - if(ROOT_LIBRARIES) - list(REMOVE_DUPLICATES ROOT_LIBRARIES) - endif() - - endif() -else() - - find_program(ROOT_CONFIG_EXECUTABLE root-config - PATHS ${ROOTSYS}/bin $ENV{ROOTSYS}/bin) - - if(NOT ROOT_CONFIG_EXECUTABLE) - set(ROOT_FOUND FALSE) - else() - set(ROOT_FOUND TRUE) - - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir - OUTPUT_VARIABLE ROOT_INCLUDE_DIRS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --libdir - OUTPUT_VARIABLE ROOT_LIBRARY_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - - - set(ROOTCINT_EXECUTABLE $ENV{ROOTSYS}/bin/rootcint) - set(GENREFLEX_EXECUTABLE $ENV{ROOTSYS}/bin/genreflex) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --version - OUTPUT_VARIABLE ROOT_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --libs - OUTPUT_VARIABLE ROOT_LIBRARIES - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --bindir - OUTPUT_VARIABLE ROOT_BIN_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - - # Make variables changeble to the advanced user - mark_as_advanced(ROOT_CONFIG_EXECUTABLE) - endif() -endif() - - -if (NOT ROOT_FOUND) - message(FATAL_ERROR "ROOT required, but not found") -else() - message(STATUS "Find ROOT ${ROOT_VERSION} in ${ROOT_BIN_DIR}") -endif() - diff --git a/cmake/MacroRootDict.cmake b/cmake/MacroRootDict.cmake deleted file mode 100644 index 8efd860d5..000000000 --- a/cmake/MacroRootDict.cmake +++ /dev/null @@ -1,524 +0,0 @@ -IF(APPLE) - SET( LD_LIBRARY_PATH_VAR DYLD_LIBRARY_PATH ) -ELSE() - SET( LD_LIBRARY_PATH_VAR LD_LIBRARY_PATH ) -ENDIF() -SET( LD_LIBRARY_PATH_CONTENTS $ENV{${LD_LIBRARY_PATH_VAR}} ) -#MESSAGE( STATUS "LD_LIBRARY_PATH_CONTENTS: ${LD_LIBRARY_PATH_CONTENTS}" ) - -SET( ROOT_CINT_WRAPPER ${LD_LIBRARY_PATH_VAR}=${ROOT_LIBRARY_DIR}:${LD_LIBRARY_PATH_CONTENTS} ${ROOTCINT_EXECUTABLE} ) - -if(CMAKE_SYSTEM_NAME MATCHES "Windows") - SET( ROOT_CINT_WRAPPER ${ROOTCINT_EXECUTABLE} ) -endif() - -IF( NOT DEFINED ROOT_DICT_OUTPUT_DIR ) - SET( ROOT_DICT_OUTPUT_DIR "${PROJECT_BINARY_DIR}/rootdict" ) -ENDIF() - -# clean generated header files with 'make clean' -SET_DIRECTORY_PROPERTIES( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${ROOT_DICT_OUTPUT_DIR}" ) - -IF( NOT ROOT_FIND_QUIETLY ) - MESSAGE( STATUS "Check for ROOT_DICT_OUTPUT_DIR: ${PROJECT_BINARY_DIR}/rootdict" ) - MESSAGE( STATUS "Check for ROOT_DICT_CINT_DEFINITIONS: ${ROOT_DICT_CINT_DEFINITIONS}" ) -ENDIF() - - -# ============================================================================ -# helper macro to prepare input headers for GEN_ROOT_DICT_SOURCES -# sorts LinkDef.h to be the last header (required by rootcint) -# -# arguments: -# input_dir - directory to search for headers matching *.hh -# -# returns: -# ROOT_DICT_INPUT_HEADERS - all header files found in input_dir with -# ${input_dir}_LinkDef.h as the last header (if found) -# -# ---------------------------------------------------------------------------- -MACRO( PREPARE_ROOT_DICT_HEADERS _input_dir ) - - FILE( GLOB ROOT_DICT_INPUT_HEADERS "${_input_dir}/*.h" ) - FILE( GLOB _linkdef_hdr "${_input_dir}/LinkDef.h" ) - - IF( _linkdef_hdr ) - LIST( REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" ) - LIST( APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}") - ENDIF() - - #MESSAGE( STATUS "ROOT_DICT_INPUT_HEADERS: ${ROOT_DICT_INPUT_HEADERS}" ) - -ENDMACRO( PREPARE_ROOT_DICT_HEADERS ) - - - -# ============================================================================ -# helper macro to generate Linkdef.h files for rootcint -# -# arguments: -# namespace - prefix used for creating header _Linkdef.h -# ARGN - list of sources to be used for generating Linkdef.h -# -# returns: -# ROOT_DICT_INPUT_HEADERS - all header files + _LinkDef.h in the -# correct order to be used by macro GEN_ROOT_DICT_SOURCES -# -# ---------------------------------------------------------------------------- -MACRO( GEN_ROOT_DICT_LINKDEF_HEADER _namespace ) - - SET( _input_headers ${ARGN} ) - SET( _linkdef_header "${ROOT_DICT_OUTPUT_DIR}/${_namespace}_Linkdef.h" ) - - FOREACH( _header ${_input_headers} ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#ifdef __CINT__" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all globals\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all classes\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all functions\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ nestedclasses\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ nestedclasses\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ class ${_namespace}+\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#endif" \n ) - ENDFOREACH() - - file(MAKE_DIRECTORY ${ROOT_DICT_OUTPUT_DIR}) - file(WRITE ${_linkdef_header} ${${_namespace}_file_contents}) - - SET( ROOT_DICT_INPUT_HEADERS ${_input_headers} ${_linkdef_header} ) - -ENDMACRO() - - -# ============================================================================ -# macro for generating root dict sources with rootcint -# -# arguments: -# dict_src_filename - filename of the dictionary source (to be generated) -# -# requires following variables: -# ROOT_DICT_INPUT_HEADERS - list of headers needed to generate dict source -# * if $LinkDef.h is in the list it must be at the end !! -# ROOT_DICT_INCLUDE_DIRS - list of include dirs to pass to rootcint -I.. -# ROOT_DICT_CINT_DEFINITIONS - extra definitions to pass to rootcint -# ROOT_DICT_OUTPUT_DIR - where dictionary source should be generated -# -# returns: -# ROOT_DICT_OUTPUT_SOURCES - list containing generated source and other -# previously generated sources - -# ---------------------------------------------------------------------------- -MACRO( GEN_ROOT_DICT_SOURCE _dict_src_filename ) - - SET( _input_depend ${ARGN} ) - # TODO check for ROOT_CINT_EXECUTABLE - file(MAKE_DIRECTORY ${ROOT_DICT_OUTPUT_DIR}) - # need to prefix all include dirs with -I - set( _dict_includes ) - FOREACH( _inc ${ROOT_DICT_INCLUDE_DIRS} ) - SET( _dict_includes "${_dict_includes}\t-I${_inc}") #fg: the \t fixes a wired string expansion - ENDFOREACH() - - # We modify the list of headers to be given to ROOTCINT command. - # We must remove/clean the full path from the main header - list ( GET ROOT_DICT_INPUT_HEADERS 0 MAIN_HEADER) - get_filename_component( MAIN_HEADER_CLEAN ${MAIN_HEADER} NAME) - list ( GET ROOT_DICT_INPUT_HEADERS 1 LINKDEF_HEADER ) - set( ROOT_DICT_INPUT_HEADERS_CLEAN ${MAIN_HEADER_CLEAN} ${LINKDEF_HEADER} ) - - STRING( REPLACE "/" "_" _dict_src_filename_nosc ${_dict_src_filename} ) - SET( _dict_src_file ${ROOT_DICT_OUTPUT_DIR}/${_dict_src_filename_nosc} ) - STRING( REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" _dict_hdr_file "${_dict_src_file}" ) - ADD_CUSTOM_COMMAND( - OUTPUT ${_dict_src_file} - COMMAND ${ROOT_CINT_WRAPPER} -f "${_dict_src_file}" ${_dict_includes} ${ROOT_DICT_INPUT_HEADERS_CLEAN} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - DEPENDS ${ROOT_DICT_INPUT_HEADERS} ${_input_depend} - COMMENT "generating: ${_dict_src_file} with ${ROOT_DICT_INPUT_HEADERS}" - ) - LIST( APPEND ROOT_DICT_OUTPUT_SOURCES ${_dict_src_file} ) - -ENDMACRO() - -# for backwards compatibility -MACRO( GEN_ROOT_DICT_SOURCES _dict_src_filename ) - #MESSAGE( "USING DEPRECATED GEN_ROOT_DICT_SOURCES. PLEASE USE GEN_ROOT_DICT_SOURCE instead." ) - SET( ROOT_DICT_OUTPUT_SOURCES ) - GEN_ROOT_DICT_SOURCE( ${_dict_src_filename} ) -ENDMACRO() -# ============================================================================ - - - -# ============================================================================ -# Macro to compile the whole directories into a single library -# -# The working directory of this macro should have regular form like: -# DIR -# ©À©¤©¤ CMakeLists.txt -# ©À©¤©¤ SUB-DIR-1 -# ©¦ ©À©¤©¤ inc -# ©¦ ©¦ ©¸©¤©¤ CLASS_A.h -# ©¦ ©¸©¤©¤ src -# ©¦ ©¸©¤©¤ CLASS_A.cxx -# ©¸©¤©¤ SUB-DIR-2 -# ©À©¤©¤ inc -# ©¦ ©À©¤©¤ CLASS_B.h -# ©¦ ©¸©¤©¤ CLASS_C.h -# ©¸©¤©¤ src -# ©À©¤©¤ CLASS_B.cxx -# ©¸©¤©¤ CLASS_C.cxx -# Or: -# DIR -# ©À©¤©¤ CMakeLists.txt -# ©À©¤©¤ inc -# ©¦ ©À©¤©¤ CLASS_A.h -# ©¦ ©¸©¤©¤ CLASS_B.h -# ©¸©¤©¤ src -# ©À©¤©¤ CLASS_A.cxx -# ©¸©¤©¤ CLASS_B.cxx -# -# This macro will first set include directories of cmake to ${CMAKE_CURRENT_SOURCE_DIR}, -# ${CMAKE_CURRENT_SOURCE_DIR}/inc, sub-directories, and sub-directories/inc. -# -# Then it will find out all the cxx files and call CINT. -# -# Finally it will call cmake to add a library, using the found cxx files, CINT-wrappered -# cxx files, and other defined c++ scripts. -# -## Arguments: -# libname - the generated library name -# -## OUTPUT variables (global): -# local_include_dirs - After this macro, additional inc dirs from the current -# directory will be attatched at the end of this variable. -# -# external_include_dirs - the external inc dirs, for example from ROOT. -# -## Optional local variables: -# contents - this variable defines needed sub-directories of current directory -# -# addon_src - if some of the scripts do not follow regular directory form, -# set them in this argument to compile them. CINT will not be -# called for them. -# -# addon_CINT - if some of the scripts do not follow regular directory form, -# set them in this argument to compile them with CINT -# -# addon_inc - if some of the header directories do not follow regular directory -# form, set them in this argument to include them. -# -# ---------------------------------------------------------------------------- -MACRO( COMPILEDIR libname ) - - message(STATUS "making build files for ${CMAKE_CURRENT_SOURCE_DIR}, schema evolution: ${local_SE}") - - # We need to define the include paths relative to the compilation directory - set ( REAL_SOURCE_DIR "${CMAKE_SOURCE_DIR}/source" ) - string( REPLACE ${REAL_SOURCE_DIR} "" RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ) - set(RELATIVE_PATH "..${RELATIVE}") - - set(contentfiles) - - if(DEFINED contents) - message("specified sub-dirs: ${contents}") - foreach(content ${contents}) - set(local_include_dirs ${local_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR}/${content} ${CMAKE_CURRENT_SOURCE_DIR}/${content}/inc) - endforeach(content) - set(local_include_dirs ${local_include_dirs} PARENT_SCOPE) - - foreach(content ${contents}) - file(GLOB_RECURSE files ${content}/*.cxx) - foreach (file ${files}) - - string(REGEX MATCH "[^/\\]*cxx" temp ${file}) - string(REPLACE ".cxx" "" class ${temp}) - - set ( SKIP "FALSE" ) - if(DEFINED excludes) - foreach(exclude ${excludes}) - if ( "${exclude}" STREQUAL "${class}" ) - set ( SKIP "TRUE" ) - # message( STATUS "Skipping ${class}" ) - endif() - endforeach(exclude) - endif() - - if( ${SKIP} STREQUAL "FALSE" ) - set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - if(NOT header) - message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") - else() - set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - if(${SCHEMA_EVOLUTION} MATCHES "ON") - GEN_ROOT_DICT_LINKDEF_HEADER( ${class} ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - else() - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) - endif() - - set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) - endif() - endif( ${SKIP} STREQUAL "FALSE" ) - - endforeach (file) - - # message( STATUS "contentfiles: ${contentfiles}" ) - endforeach(content) - else() - message("using inc/src folders in root directory") - set(local_include_dirs ${local_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) - set(local_include_dirs ${local_include_dirs} PARENT_SCOPE) - - file(GLOB_RECURSE files src/*.cxx) - foreach (file ${files}) - string(REGEX MATCH "[^/\\]*cxx" temp ${file}) - string(REPLACE ".cxx" "" class ${temp}) - - set ( SKIP "FALSE" ) - if(DEFINED excludes) - # message ( STATUS "EXCLUDES: ${excludes}" ) - foreach(exclude ${excludes}) - if ( "${exclude}" STREQUAL "${class}" ) - set ( SKIP "TRUE" ) - # message( STATUS "Skipping ${class}" ) - endif() - endforeach(exclude) - endif() - - if( ${SKIP} STREQUAL "FALSE" ) - set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - if(NOT header) - message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") - else() - set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - if(${SCHEMA_EVOLUTION} MATCHES "ON") - GEN_ROOT_DICT_LINKDEF_HEADER( ${class} ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - else() - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) - endif() - - set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) - endif() - endif( ${SKIP} STREQUAL "FALSE" ) - endforeach (file) - endif() - - - foreach(src ${addon_CINT}) - string(REGEX MATCH "[^/\\]+$" filename ${src}) - set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) - set(ROOT_DICT_INPUT_HEADERS ${src}) - GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) - set(contentfiles ${contentfiles} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) - endforeach(src) - - include_directories(${local_include_dirs}) - add_library(${libname} SHARED ${contentfiles} ${addon_src}) - - - if(CMAKE_SYSTEM_NAME MATCHES "Windows") - set_target_properties(${libname} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - target_link_libraries(${libname} ${local_libraries} ${external_libs}) - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION bin - ARCHIVE DESTINATION lib) - else() - target_link_libraries(${libname} ${local_libraries} ${external_libs}) - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static) - endif() - set(local_libraries ${local_libraries} ${libname}) - set(local_libraries ${local_libraries} PARENT_SCOPE) -ENDMACRO() - -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() - -# ============================================================================ -# Macro to convert directory name to REST library name -# e.g. axion --> RestAxion -# e.g. detector --> RestDetector -MACRO(DIRNAME2LIBNAME result dirname) - string(SUBSTRING ${dirname} 0 1 firstletter) - string(TOUPPER ${firstletter} firstlettercapital) - string(SUBSTRING ${dirname} 1 -1 remainingletter) - set(${result} "Rest${firstlettercapital}${remainingletter}") -ENDMACRO() - -# ============================================================================ -# Macro to convert directory name to REST CMake Option name -# e.g. source/libraries/axion --> RESTLIB_AXION -# e.g. source/packages/restG4 --> REST_G4 -# -# result: the converted option string. Will be empty if error -# dirname: the relative path from CMAKE_CURRENT_SOURCE_DIR to the target dir -macro(DIRNAME2OPTION result dirname) - set(${result} "") - if(${dirname} MATCHES "libraries/") - string(REPLACE "libraries/" "" purename ${dirname}) - string(TOUPPER ${purename} uppername) - set(${result} "RESTLIB_${uppername}") - endif() - - if(${dirname} MATCHES "packages/") - string(REPLACE "packages/rest" "" purename ${dirname}) - set(${result} "REST_${purename}") - endif() - -ENDMACRO() - - -# ============================================================================ -# Macro to compile REST libraries sub-dir into a single library -# -# The working directory of this macro should have regular form like: -# DIR -# ©À©¤©¤ CMakeLists.txt -# ©À©¤©¤ inc -# ©¦ ©À©¤©¤ CLASS_A.h -# ©¦ ©¸©¤©¤ CLASS_B.h -# ©¸©¤©¤ src -# ©À©¤©¤ CLASS_A.cxx -# ©¸©¤©¤ CLASS_B.cxx -# --- xxx.cc -# -# This macro will first set include directories of cmake to ${CMAKE_CURRENT_SOURCE_DIR}, -# ${CMAKE_CURRENT_SOURCE_DIR}/inc, sub-directories, and sub-directories/inc. -# -# Then it will find out all the cxx files and call CINT. -# -# Finally it will call cmake to add a library, using the found cxx files, CINT-wrappered -# cxx files, and other defined c++ scripts. -# -## Arguments: -# dependency - the libraries which this one depends on. Should be the name of a list. -# Could be -L/usr/local/lib/xxx.so, or be other libname(e.g. RestDetector) -# If RestDetector_COMPULED=FALSE, then it will execute this macro -# firstly on that library. -# -## OUTPUT variables (will be changed after this macro): -# dirs_included - After this macro, additional inc dirs from the current -# directory will be attatched at the end of this variable. -# -# library_added - After this macro, the generated library name will be attatched -# at the end of this variable. -# -## Optional variables (to be set before this macro): -# contents - this variable defines needed sub-directories of current directory -# -# addon_src - if some of the scripts do not follow regular directory form, -# set them in this argument to compile them. CINT will not be -# called for them. -# -# addon_CINT - if some of the scripts do not follow regular directory form, -# set them in this argument to compile them with CINT -# -# addon_inc - if some of the header directories do not follow regular directory -# form, set them in this argument to include them. -# -# ---------------------------------------------------------------------------- -MACRO( COMPILELIB dependency) - - string(REGEX MATCH "[^/\\]*$" puredirname ${CMAKE_CURRENT_SOURCE_DIR}) - DIRNAME2LIBNAME(libname ${puredirname}) - - message(STATUS "making build files in ${CMAKE_CURRENT_SOURCE_DIR}, dependency: ${${dependency}}") - - set(files_cxx) - set(files_to_compile_cxx) - set(files_to_compile_cint) - set(dirs_to_include ${rest_framework_include_dirs}) - set(libs_to_link ${rest_framework_libraries}) - - # check dependency - foreach(dep ${${dependency}}) - set(dirs_to_include ${dirs_to_include} "${CMAKE_CURRENT_SOURCE_DIR}/../${dep}/inc") - DIRNAME2LIBNAME(deplibname ${dep}) - set(libs_to_link ${libs_to_link} ${deplibname}) - endforeach() - - # include dir - set(dirs_to_include ${dirs_to_include} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) - - # generate CINT files - file(GLOB_RECURSE files_cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cxx) - foreach (file ${files_cxx}) - string(REGEX MATCH "[^/\\]*cxx$" temp ${file}) # get pure file name - string(REPLACE ".cxx" "" class ${temp}) # get file name without extension, i.e. class name - - set ( SKIP "FALSE" ) - if(DEFINED excludes) - foreach(exclude ${excludes}) - if ( "${exclude}" STREQUAL "${class}" ) - set ( SKIP "TRUE" ) - # message( STATUS "Skipping ${class}" ) - endif() - endforeach(exclude) - endif() - - if( ${SKIP} STREQUAL "FALSE" ) - set(ROOT_DICT_INCLUDE_DIRS ${dirs_to_include} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - if(NOT header) - message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") - else() - set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - if(${SCHEMA_EVOLUTION} MATCHES "ON") - GEN_ROOT_DICT_LINKDEF_HEADER( ${class} ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - else() - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) - endif() - - set(files_to_compile_cxx ${files_to_compile_cxx} ${file}) - set(files_to_compile_cint ${files_to_compile_cint} ${ROOT_DICT_OUTPUT_SOURCES}) - endif() - endif( ${SKIP} STREQUAL "FALSE" ) - endforeach (file) - - foreach(src ${addon_CINT}) - string(REGEX MATCH "[^/\\]+$" filename ${src}) - set(ROOT_DICT_INCLUDE_DIRS ${dirs_to_include} ${external_include_dirs}) - set(ROOT_DICT_INPUT_HEADERS ${src}) - GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) - set(files_to_compile ${files_to_compile} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) - endforeach(src) - - list(LENGTH files_cxx Nfiles_cxx) - list(LENGTH files_to_compile_cint Nfiles_cint) - list(LENGTH addon_src Nfiles_add) - - message(STATUS "${Nfiles_cxx} source files in total, ${Nfiles_cint} classes to generete, ${Nfiles_add} additional source files") - - # start compile - include_directories(${dirs_to_include} ${external_include_dirs}) - add_library(${libname} SHARED ${files_to_compile_cxx} ${files_to_compile_cint} ${addon_src}) - target_link_libraries(${libname} ${libs_to_link} ${external_libs}) - - # install - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static) - - file(GLOB_RECURSE Headers "${CMAKE_CURRENT_SOURCE_DIR}/inc/*.h") - INSTALL(FILES ${Headers} DESTINATION include) - - set(dirs_included ${dirs_to_include} PARENT_SCOPE) - set(library_added ${libname}) - set(library_added ${library_added} PARENT_SCOPE) -ENDMACRO() \ No newline at end of file diff --git a/cmake/ThisGenerateRootDictionaries.cmake b/cmake/ThisGenerateRootDictionaries.cmake new file mode 100644 index 000000000..dbc801de1 --- /dev/null +++ b/cmake/ThisGenerateRootDictionaries.cmake @@ -0,0 +1,38 @@ +message(STATUS "LOADING GENERATE ROOT DICTIONARIES MACRO") +if (NOT ${FIND_ROOT}) + message(ERROR "ROOT NOT FOUND") +endif () + +set(MODULEMAP_FILENAME ${CMAKE_BINARY_DIR}/module.modulemap) +file(WRITE ${MODULEMAP_FILENAME}) +install(FILES ${MODULEMAP_FILENAME} DESTINATION lib) + +macro(THIS_GENERATE_ROOT_DICTIONARIES HEADERS) + # Create LinkDef.h file + set(LINKDEF_FILE ${CMAKE_CURRENT_BINARY_DIR}/LinkDef.h) + file(WRITE ${LINKDEF_FILE}) + file(APPEND ${LINKDEF_FILE} "#ifdef __CLING__\n") + file(APPEND ${LINKDEF_FILE} "#pragma link off all globals;\n") + file(APPEND ${LINKDEF_FILE} "#pragma link off all classes;\n") + file(APPEND ${LINKDEF_FILE} "#pragma link off all functions;\n") + file(APPEND ${LINKDEF_FILE} "#pragma link C++ nestedclasses;\n") + + foreach (header ${HEADERS}) + get_filename_component(class ${header} NAME_WE) + file(APPEND ${LINKDEF_FILE} "#pragma link C++ class ${class}+;\n") + endforeach () + + file(APPEND ${LINKDEF_FILE} "#endif\n") + + ROOT_GENERATE_DICTIONARY(${LIBRARY}RootDict ${HEADERS} LINKDEF ${LINKDEF_FILE} MODULE ${LIBRARY}) + + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBRARY}_rdict.pcm DESTINATION lib) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBRARY}.rootmap DESTINATION lib) + + file(READ ${CMAKE_CURRENT_BINARY_DIR}/module.modulemap MODULEMAP_CONTENTS) + + string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_INSTALL_PREFIX}/include" MODULEMAP_CONTENTS ${MODULEMAP_CONTENTS}) + + file(APPEND ${MODULEMAP_FILENAME} "${MODULEMAP_CONTENTS}\n") + +endmacro() \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 433ed717d..f788b4b10 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -5,6 +5,9 @@ set(rest_macros) set(rest_macros_str) add_subdirectory(framework) + +return() + add_subdirectory(../macros tasks.out) set(rest_framework_include_dirs ${local_include_dirs}) @@ -30,76 +33,76 @@ add_subdirectory(bin) # clear the cache first SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/libraries") -foreach(subdir ${subdirs}) - DIRNAME2LIBNAME(libname ${subdir}) - set("${libname}_COMPILED" "FALSE") -endforeach() +foreach (subdir ${subdirs}) + DIRNAME2LIBNAME(libname ${subdir}) + set("${libname}_COMPILED" "FALSE") +endforeach () # loop all the dirs and set the option set(dirs "libraries" "packages") -foreach(dir ${dirs}) - SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") - foreach(subdir ${subdirs}) - set(fullname "${dir}/${subdir}") - DIRNAME2OPTION(option ${fullname}) - - file(GLOB ff "*/${subdir}/CMakeLists.txt") - if(ff) # if dir not empty, set the option to ON - if (NOT DEFINED ${option}) - IF(${REST_ALL_LIBS} MATCHES "ON") - set(${option} ON) - else() - set(${option} OFF) - endif() - endif() - message("Submodule found: ${fullname}. Option: ${option}=${${option}}") - else() - set(${option} OFF) - message("Empty submodule dir: ${fullname}. Option: ${option}=${${option}}") - endif() - endforeach() -endforeach() - -if( ${REST_G4} MATCHES ON ) - set( RESTLIB_GEANT4 ON ) -endif() - -if( ${RESTLIB_DETECTOR} MATCHES ON ) - if( ${RESTLIB_RAW} MATCHES ON) - set( RESTLIB_CONNECTORS ON ) - endif() -endif() +foreach (dir ${dirs}) + SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") + foreach (subdir ${subdirs}) + set(fullname "${dir}/${subdir}") + DIRNAME2OPTION(option ${fullname}) + + file(GLOB ff "*/${subdir}/CMakeLists.txt") + if (ff) # if dir not empty, set the option to ON + if (NOT DEFINED ${option}) + IF (${REST_ALL_LIBS} MATCHES "ON") + set(${option} ON) + else () + set(${option} OFF) + endif () + endif () + message("Submodule found: ${fullname}. Option: ${option}=${${option}}") + else () + set(${option} OFF) + message("Empty submodule dir: ${fullname}. Option: ${option}=${${option}}") + endif () + endforeach () +endforeach () + +if (${REST_G4} MATCHES ON) + set(RESTLIB_GEANT4 ON) +endif () + +if (${RESTLIB_DETECTOR} MATCHES ON) + if (${RESTLIB_RAW} MATCHES ON) + set(RESTLIB_CONNECTORS ON) + endif () +endif () # loop all the dirs and compile if option is ON -foreach(dir ${dirs}) - SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") - foreach(subdir ${subdirs}) - set(fullname "${dir}/${subdir}") - DIRNAME2OPTION(option ${fullname}) - - if(${${option}} MATCHES "ON") - add_subdirectory(${fullname}) - set(rest_include_dirs ${rest_include_dirs} ${dirs_included}) - set(rest_libraries ${rest_libraries} ${library_added}) - set(rest_packages ${rest_packages} ${package_added}) - set(rest_features ${rest_features} ${feature_added}) - endif() - endforeach() -endforeach() +foreach (dir ${dirs}) + SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") + foreach (subdir ${subdirs}) + set(fullname "${dir}/${subdir}") + DIRNAME2OPTION(option ${fullname}) + + if (${${option}} MATCHES "ON") + add_subdirectory(${fullname}) + set(rest_include_dirs ${rest_include_dirs} ${dirs_included}) + set(rest_libraries ${rest_libraries} ${library_added}) + set(rest_packages ${rest_packages} ${package_added}) + set(rest_features ${rest_features} ${feature_added}) + endif () + endforeach () +endforeach () # remove duplicates -if(DEFINED rest_include_dirs) - list(REMOVE_DUPLICATES rest_include_dirs) -endif() -if(DEFINED rest_libraries) - list(REMOVE_DUPLICATES rest_libraries) -endif() -if(DEFINED rest_packages) - list(REMOVE_DUPLICATES rest_packages) -endif() -if(DEFINED rest_features) - list(REMOVE_DUPLICATES rest_features) -endif() +if (DEFINED rest_include_dirs) + list(REMOVE_DUPLICATES rest_include_dirs) +endif () +if (DEFINED rest_libraries) + list(REMOVE_DUPLICATES rest_libraries) +endif () +if (DEFINED rest_packages) + list(REMOVE_DUPLICATES rest_packages) +endif () +if (DEFINED rest_features) + list(REMOVE_DUPLICATES rest_features) +endif () # set REST compilation flags to main cmake set(rest_include_dirs ${rest_include_dirs} PARENT_SCOPE) @@ -108,16 +111,16 @@ set(rest_packages ${rest_packages} PARENT_SCOPE) set(rest_features ${rest_features} PARENT_SCOPE) set(rest_libraries_regular "-L${CMAKE_INSTALL_PREFIX}/lib ") -foreach(lib ${rest_libraries}) - set(rest_libraries_regular "${rest_libraries_regular} -l${lib} ") -endforeach(lib) +foreach (lib ${rest_libraries}) + set(rest_libraries_regular "${rest_libraries_regular} -l${lib} ") +endforeach (lib) set(rest_libraries_regular ${rest_libraries_regular} PARENT_SCOPE) set(rest_exes ${rest_exes} PARENT_SCOPE) set(rest_macros ${rest_macros} PARENT_SCOPE) -# construct REST macros string(separate with blank) +# construct REST macros string (separate with blank) set(rest_macros_str) -foreach(mac ${rest_macros}) +foreach (mac ${rest_macros}) set(rest_macros_str "${rest_macros_str}${mac} ") -endforeach(mac ${rest_macros}) +endforeach (mac ${rest_macros}) set(rest_macros_str ${rest_macros_str} PARENT_SCOPE) diff --git a/source/framework/CMakeLists.txt b/source/framework/CMakeLists.txt index 50f36a7bf..d89970473 100644 --- a/source/framework/CMakeLists.txt +++ b/source/framework/CMakeLists.txt @@ -1,11 +1,50 @@ + set(contents external/tinyxml tools core analysis) +message(STATUS "CONTENTS: ${contents}") file(GLOB_RECURSE addon_src - "tiny*cpp" - "startup.cpp") + "tiny*cpp" + "startup.cpp") if (NOT ${REST_EVE} MATCHES "ON") - set( excludes TRestEveEventViewer) + set(excludes TRestEveEventViewer) endif (NOT ${REST_EVE} MATCHES "ON") -COMPILEDIR(RestFramework) +# COMPILEDIR(RestFramework) + +set(LIBRARY RestFramework) + +set(SOURCES) +set(HEADERS) + +add_subdirectory(core) +# add_subdirectory(analysis) + +message(STATUS "HEADERS: ${HEADERS}") +message(STATUS "SOURCES: ${SOURCES}") + +add_library(${LIBRARY} SHARED) +install(TARGETS ${LIBRARY} DESTINATION lib) + +string(STRIP "${SOURCES}" SOURCES) +message(STATUS "SOURCES: ${SOURCES}") + +target_sources( + ${LIBRARY} PUBLIC + ${SOURCES} +) + +target_include_directories( + ${LIBRARY} SYSTEM PUBLIC + ${ROOT_INCLUDE_DIRS} + ${HEADERS} +) + +target_link_libraries( + ${LIBRARY} PUBLIC + ${ROOT_LIBRARIES} +) + +return() + +THIS_GENERATE_ROOT_DICTIONARIES(RestFrameWork) diff --git a/source/framework/analysis/CMakeLists.txt b/source/framework/analysis/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb diff --git a/source/framework/core/CMakeLists.txt b/source/framework/core/CMakeLists.txt new file mode 100644 index 000000000..d3fb9531c --- /dev/null +++ b/source/framework/core/CMakeLists.txt @@ -0,0 +1,13 @@ + +# set(SOURCES PARENT_SCOPE) + +FILE(GLOB THIS_SOURCES src/*.cxx) + +# message(STATUS "THIS_SOURCES: ${THIS_SOURCES}") + +SET(SOURCES "${SOURCES} ${THIS_SOURCES}" PARENT_SCOPE) + +# message(STATUS "NEW SOURCES: ${SOURCES}") + +FILE(GLOB THIS_HEADERS inc/*.h) +SET(HEADERS "${HEADERS} ${THIS_HEADERS}" PARENT_SCOPE) \ No newline at end of file diff --git a/source/framework/tools/CMakeLists.txt b/source/framework/tools/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb From 62f5a7a8d0da762a142a74c22db83da127c65b45 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Tue, 8 Feb 2022 12:35:33 +0100 Subject: [PATCH 03/61] Added installation of external dependencies via cmake, added testing PoC --- CMakeLists.txt | 2 + cmake/AddTest.cmake | 6 + cmake/FindGarfield.cmake | 61 --- cmake/FindROOT.cmake | 98 ---- cmake/MacroRootDict.cmake | 610 +++++++++++----------- source/framework/CMakeLists.txt | 21 +- source/framework/external/CMakeLists.txt | 39 ++ source/framework/test/CMakeLists.txt | 21 + source/framework/test/src/ExampleTest.cxx | 10 + 9 files changed, 395 insertions(+), 473 deletions(-) create mode 100644 cmake/AddTest.cmake delete mode 100644 cmake/FindGarfield.cmake delete mode 100644 cmake/FindROOT.cmake create mode 100644 source/framework/external/CMakeLists.txt create mode 100644 source/framework/test/CMakeLists.txt create mode 100644 source/framework/test/src/ExampleTest.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index a047571b3..55c8090a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,6 +116,8 @@ message(STATUS "external libraries to link: " ${external_libs}) string(TIMESTAMP date "%Y-%m-%d %H:%M") # Start compile + +include(AddTest) include(MacroRootDict) add_subdirectory(source) message("") diff --git a/cmake/AddTest.cmake b/cmake/AddTest.cmake new file mode 100644 index 000000000..34715b399 --- /dev/null +++ b/cmake/AddTest.cmake @@ -0,0 +1,6 @@ +macro(ADD_TEST) + if (TEST) + message(STATUS "Adding tests at ${CMAKE_CURRENT_SOURCE_DIR}") + add_subdirectory(test) + endif () +endmacro() diff --git a/cmake/FindGarfield.cmake b/cmake/FindGarfield.cmake deleted file mode 100644 index cdbf9c43b..000000000 --- a/cmake/FindGarfield.cmake +++ /dev/null @@ -1,61 +0,0 @@ - -# - Try to find Garfield++ instalation -# This module sets up Garfield information -# It defines: -# Garfield_FOUND If Garfiled++ is found -# Garfield_INCLUDE_DIRS PATH to the include directories -# Garfield_LIBRARIES the libraries needed to use Garfield++ - -#message(STATUS "Looking for Garfield ...") - -# Alternative paths which can be defined by user -#set(Garfield_DIR "" CACHE PATH "Directory where Garfield is installed") -#set(Garfield_INC_DIR "" CACHE PATH "Alternative directory for Garfield includes") -#set(Garfield_LIB_DIR "" CACHE PATH "Alternative directory for Garfield libraries") -set(Garfield_DIR $ENV{GARFIELD_HOME}) - -find_path(Garfield_INCLUDE_DIRS Sensor.hh - HINTS ${Garfield_DIR}/include/ ${Garfield_DIR}/include/Garfield ${Garfield_INC_DIR} - ${Garfield_DIR}/Include) - -#message(STATUS Garfield_INCLUDE_DIRS ${Garfield_INCLUDE_DIRS}) - -find_library(Garfield_LIBRARIES NAMES libGarfield.so Garfield - HINTS ${Garfield_DIR}/lib ${Garfield_LIB_DIR} - $ENV{GARFIELD_HOME}/lib) -#message(STATUS Garfield_LIBRARIES ${Garfield_LIBRARIES}) - -#if (${Garfield_LIBRARY_DIR}) -# set (Garfield_LIBRARIES -L${Garfield_LIBRARY_DIR} -lGarfield) -#endif() - -if (Garfield_INCLUDE_DIRS AND Garfield_LIBRARIES) - set (Garfield_FOUND TRUE) -endif() - -if (NOT DEFINED ENV{GARFIELD_HOME} ) - message("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nError : GARFIELD HOME is not defined! - \nCheck Garfield is installed and GARFIELD_HOME is pointing to install directory - \nHINT : GARFIELD_HOME/lib/libGarfield.so should exist. - \nIf you do not need Garfield++ interface in your REST installation, then, - \nplease, run cmake disabling REST_GARFIELD variable - \n\ni.e. : cmake -DREST_GARFIELD=OFF ../ - \n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ) -endif() - -if (Garfield_FOUND) - if (NOT Garfield_FIND_QUIETLY) - message(STATUS "Found Garfield includes in ${Garfield_INCLUDE_DIRS}") - message(STATUS "Found Garfield libraries ${Garfield_LIBRARIES}") - endif (NOT Garfield_FIND_QUIETLY) -else(Garfield_FOUND) - if (Garfield_FIND_REQUIRED) - message(FATAL_ERROR "Garfield required, but not found!\ntry to run \"./scripts/installation/v2.2/installGarfield.sh\" to install it. - ") - endif (Garfield_FIND_REQUIRED) -endif(Garfield_FOUND) - -# Make variables changeble to the advanced user -mark_as_advanced(Garfield_INCLUDE_DIRS) -mark_as_advanced(Garfield_LIBRARIES) -mark_as_advanced(Garfield_LIBRARY_DIR) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake deleted file mode 100644 index 6855cb6f2..000000000 --- a/cmake/FindROOT.cmake +++ /dev/null @@ -1,98 +0,0 @@ -# - Finds ROOT instalation -# This module sets up ROOT information -# It defines: -# ROOT_FOUND If the ROOT is found -# ROOT_INCLUDE_DIR PATH to the include directory (deprecated) -# ROOT_INCLUDE_DIRS PATH to the include directory -# ROOT_LIBRARIES Most common libraries -# ROOT_LIBRARY_DIR PATH to the library directory -# ROOT_BIN_DIR PATH to the excutables directory -# ROOT_PYTHONVER Compatible python version string - -# First search for ROOTConfig.cmake on the path defined via user setting -# ROOT_DIR - -if (CMAKE_SYSTEM_NAME MATCHES "Windows") - - if(DEFINED ENV{ROOTSYS}) - set(ROOTSYS $ENV{ROOTSYS}) - endif() - - if(NOT ROOTSYS) - set(ROOT_FOUND FALSE) - else() - set(ROOT_FOUND TRUE) - - set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib) - set(ROOT_INCLUDE_DIRS ${ROOTSYS}/include) - set(ROOT_BIN_DIR ${ROOTSYS}/bin) - set(ROOTCINT_EXECUTABLE ${ROOTSYS}/bin/rootcint.exe) - set(GENREFLEX_EXECUTABLE ${ROOTSYS}/bin/genreflex.exe) - - set(CMAKE_FIND_LIBRARY_PREFIXES "lib") - set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll") - set(ROOT_LIBRARIES) - foreach(_cpt Core Imt RIO Net Hist Gui Eve RGL Gdml Geom Graf Graf3d Gpad Tree TreePlayer Rint Postscript Matrix Physics MathCore Thread MultiProc Minuit) - find_library(ROOT_${_cpt}_LIBRARY ${_cpt} HINTS ${ROOT_LIBRARY_DIR}) - if(ROOT_${_cpt}_LIBRARY) - mark_as_advanced(ROOT_${_cpt}_LIBRARY) - list(APPEND ROOT_LIBRARIES ${ROOT_${_cpt}_LIBRARY}) - endif() - endforeach() - if(ROOT_LIBRARIES) - list(REMOVE_DUPLICATES ROOT_LIBRARIES) - endif() - - endif() -else() - - find_program(ROOT_CONFIG_EXECUTABLE root-config - PATHS ${ROOTSYS}/bin $ENV{ROOTSYS}/bin) - - if(NOT ROOT_CONFIG_EXECUTABLE) - set(ROOT_FOUND FALSE) - else() - set(ROOT_FOUND TRUE) - - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir - OUTPUT_VARIABLE ROOT_INCLUDE_DIRS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --libdir - OUTPUT_VARIABLE ROOT_LIBRARY_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - - - set(ROOTCINT_EXECUTABLE $ENV{ROOTSYS}/bin/rootcint) - set(GENREFLEX_EXECUTABLE $ENV{ROOTSYS}/bin/genreflex) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --version - OUTPUT_VARIABLE ROOT_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --libs - OUTPUT_VARIABLE ROOT_LIBRARIES - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --bindir - OUTPUT_VARIABLE ROOT_BIN_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - - # Make variables changeble to the advanced user - mark_as_advanced(ROOT_CONFIG_EXECUTABLE) - endif() -endif() - - -if (NOT ROOT_FOUND) - message(FATAL_ERROR "ROOT required, but not found") -else() - message(STATUS "Find ROOT ${ROOT_VERSION} in ${ROOT_BIN_DIR}") -endif() - diff --git a/cmake/MacroRootDict.cmake b/cmake/MacroRootDict.cmake index 8efd860d5..6fdcaa11f 100644 --- a/cmake/MacroRootDict.cmake +++ b/cmake/MacroRootDict.cmake @@ -1,29 +1,28 @@ -IF(APPLE) - SET( LD_LIBRARY_PATH_VAR DYLD_LIBRARY_PATH ) -ELSE() - SET( LD_LIBRARY_PATH_VAR LD_LIBRARY_PATH ) -ENDIF() -SET( LD_LIBRARY_PATH_CONTENTS $ENV{${LD_LIBRARY_PATH_VAR}} ) +IF (APPLE) + SET(LD_LIBRARY_PATH_VAR DYLD_LIBRARY_PATH) +ELSE () + SET(LD_LIBRARY_PATH_VAR LD_LIBRARY_PATH) +ENDIF () +SET(LD_LIBRARY_PATH_CONTENTS $ENV{${LD_LIBRARY_PATH_VAR}}) #MESSAGE( STATUS "LD_LIBRARY_PATH_CONTENTS: ${LD_LIBRARY_PATH_CONTENTS}" ) -SET( ROOT_CINT_WRAPPER ${LD_LIBRARY_PATH_VAR}=${ROOT_LIBRARY_DIR}:${LD_LIBRARY_PATH_CONTENTS} ${ROOTCINT_EXECUTABLE} ) +SET(ROOT_CINT_WRAPPER ${LD_LIBRARY_PATH_VAR}=${ROOT_LIBRARY_DIR}:${LD_LIBRARY_PATH_CONTENTS} ${ROOTCINT_EXECUTABLE}) -if(CMAKE_SYSTEM_NAME MATCHES "Windows") - SET( ROOT_CINT_WRAPPER ${ROOTCINT_EXECUTABLE} ) -endif() +if (CMAKE_SYSTEM_NAME MATCHES "Windows") + SET(ROOT_CINT_WRAPPER ${ROOTCINT_EXECUTABLE}) +endif () -IF( NOT DEFINED ROOT_DICT_OUTPUT_DIR ) - SET( ROOT_DICT_OUTPUT_DIR "${PROJECT_BINARY_DIR}/rootdict" ) -ENDIF() +IF (NOT DEFINED ROOT_DICT_OUTPUT_DIR) + SET(ROOT_DICT_OUTPUT_DIR "${PROJECT_BINARY_DIR}/rootdict") +ENDIF () # clean generated header files with 'make clean' -SET_DIRECTORY_PROPERTIES( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${ROOT_DICT_OUTPUT_DIR}" ) - -IF( NOT ROOT_FIND_QUIETLY ) - MESSAGE( STATUS "Check for ROOT_DICT_OUTPUT_DIR: ${PROJECT_BINARY_DIR}/rootdict" ) - MESSAGE( STATUS "Check for ROOT_DICT_CINT_DEFINITIONS: ${ROOT_DICT_CINT_DEFINITIONS}" ) -ENDIF() +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${ROOT_DICT_OUTPUT_DIR}") +IF (NOT ROOT_FIND_QUIETLY) + MESSAGE(STATUS "Check for ROOT_DICT_OUTPUT_DIR: ${PROJECT_BINARY_DIR}/rootdict") + MESSAGE(STATUS "Check for ROOT_DICT_CINT_DEFINITIONS: ${ROOT_DICT_CINT_DEFINITIONS}") +ENDIF () # ============================================================================ # helper macro to prepare input headers for GEN_ROOT_DICT_SOURCES @@ -37,21 +36,17 @@ ENDIF() # ${input_dir}_LinkDef.h as the last header (if found) # # ---------------------------------------------------------------------------- -MACRO( PREPARE_ROOT_DICT_HEADERS _input_dir ) - - FILE( GLOB ROOT_DICT_INPUT_HEADERS "${_input_dir}/*.h" ) - FILE( GLOB _linkdef_hdr "${_input_dir}/LinkDef.h" ) +MACRO(PREPARE_ROOT_DICT_HEADERS _input_dir) - IF( _linkdef_hdr ) - LIST( REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" ) - LIST( APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}") - ENDIF() + FILE(GLOB ROOT_DICT_INPUT_HEADERS "${_input_dir}/*.h") + FILE(GLOB _linkdef_hdr "${_input_dir}/LinkDef.h") + IF (_linkdef_hdr) + LIST(REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}") + LIST(APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}") + ENDIF () #MESSAGE( STATUS "ROOT_DICT_INPUT_HEADERS: ${ROOT_DICT_INPUT_HEADERS}" ) - -ENDMACRO( PREPARE_ROOT_DICT_HEADERS ) - - +ENDMACRO(PREPARE_ROOT_DICT_HEADERS) # ============================================================================ # helper macro to generate Linkdef.h files for rootcint @@ -65,30 +60,29 @@ ENDMACRO( PREPARE_ROOT_DICT_HEADERS ) # correct order to be used by macro GEN_ROOT_DICT_SOURCES # # ---------------------------------------------------------------------------- -MACRO( GEN_ROOT_DICT_LINKDEF_HEADER _namespace ) +MACRO(GEN_ROOT_DICT_LINKDEF_HEADER _namespace) - SET( _input_headers ${ARGN} ) - SET( _linkdef_header "${ROOT_DICT_OUTPUT_DIR}/${_namespace}_Linkdef.h" ) + SET(_input_headers ${ARGN}) + SET(_linkdef_header "${ROOT_DICT_OUTPUT_DIR}/${_namespace}_Linkdef.h") - FOREACH( _header ${_input_headers} ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#ifdef __CINT__" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all globals\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all classes\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all functions\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ nestedclasses\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ nestedclasses\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ class ${_namespace}+\;" \n ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#endif" \n ) - ENDFOREACH() + FOREACH (_header ${_input_headers}) + SET(${_namespace}_file_contents "${${_namespace}_file_contents}#ifdef __CINT__" \n) + SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all globals\;" \n) + SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all classes\;" \n) + SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all functions\;" \n) + SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ nestedclasses\;" \n) + SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ nestedclasses\;" \n) + SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ class ${_namespace}+\;" \n) + SET(${_namespace}_file_contents "${${_namespace}_file_contents}#endif" \n) + ENDFOREACH () - file(MAKE_DIRECTORY ${ROOT_DICT_OUTPUT_DIR}) - file(WRITE ${_linkdef_header} ${${_namespace}_file_contents}) + file(MAKE_DIRECTORY ${ROOT_DICT_OUTPUT_DIR}) + file(WRITE ${_linkdef_header} ${${_namespace}_file_contents}) - SET( ROOT_DICT_INPUT_HEADERS ${_input_headers} ${_linkdef_header} ) + SET(ROOT_DICT_INPUT_HEADERS ${_input_headers} ${_linkdef_header}) ENDMACRO() - # ============================================================================ # macro for generating root dict sources with rootcint # @@ -105,50 +99,48 @@ ENDMACRO() # returns: # ROOT_DICT_OUTPUT_SOURCES - list containing generated source and other # previously generated sources - # ---------------------------------------------------------------------------- -MACRO( GEN_ROOT_DICT_SOURCE _dict_src_filename ) +MACRO(GEN_ROOT_DICT_SOURCE _dict_src_filename) - SET( _input_depend ${ARGN} ) + SET(_input_depend ${ARGN}) # TODO check for ROOT_CINT_EXECUTABLE - file(MAKE_DIRECTORY ${ROOT_DICT_OUTPUT_DIR}) + file(MAKE_DIRECTORY ${ROOT_DICT_OUTPUT_DIR}) # need to prefix all include dirs with -I - set( _dict_includes ) - FOREACH( _inc ${ROOT_DICT_INCLUDE_DIRS} ) - SET( _dict_includes "${_dict_includes}\t-I${_inc}") #fg: the \t fixes a wired string expansion - ENDFOREACH() + set(_dict_includes) + FOREACH (_inc ${ROOT_DICT_INCLUDE_DIRS}) + SET(_dict_includes "${_dict_includes}\t-I${_inc}") #fg: the \t fixes a wired string expansion + ENDFOREACH () # We modify the list of headers to be given to ROOTCINT command. # We must remove/clean the full path from the main header - list ( GET ROOT_DICT_INPUT_HEADERS 0 MAIN_HEADER) - get_filename_component( MAIN_HEADER_CLEAN ${MAIN_HEADER} NAME) - list ( GET ROOT_DICT_INPUT_HEADERS 1 LINKDEF_HEADER ) - set( ROOT_DICT_INPUT_HEADERS_CLEAN ${MAIN_HEADER_CLEAN} ${LINKDEF_HEADER} ) - - STRING( REPLACE "/" "_" _dict_src_filename_nosc ${_dict_src_filename} ) - SET( _dict_src_file ${ROOT_DICT_OUTPUT_DIR}/${_dict_src_filename_nosc} ) - STRING( REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" _dict_hdr_file "${_dict_src_file}" ) + list(GET ROOT_DICT_INPUT_HEADERS 0 MAIN_HEADER) + get_filename_component(MAIN_HEADER_CLEAN ${MAIN_HEADER} NAME) + list(GET ROOT_DICT_INPUT_HEADERS 1 LINKDEF_HEADER) + set(ROOT_DICT_INPUT_HEADERS_CLEAN ${MAIN_HEADER_CLEAN} ${LINKDEF_HEADER}) + + STRING(REPLACE "/" "_" _dict_src_filename_nosc ${_dict_src_filename}) + SET(_dict_src_file ${ROOT_DICT_OUTPUT_DIR}/${_dict_src_filename_nosc}) + STRING(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" _dict_hdr_file "${_dict_src_file}") ADD_CUSTOM_COMMAND( - OUTPUT ${_dict_src_file} - COMMAND ${ROOT_CINT_WRAPPER} -f "${_dict_src_file}" ${_dict_includes} ${ROOT_DICT_INPUT_HEADERS_CLEAN} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - DEPENDS ${ROOT_DICT_INPUT_HEADERS} ${_input_depend} - COMMENT "generating: ${_dict_src_file} with ${ROOT_DICT_INPUT_HEADERS}" + OUTPUT ${_dict_src_file} + COMMAND ${ROOT_CINT_WRAPPER} -f "${_dict_src_file}" ${_dict_includes} ${ROOT_DICT_INPUT_HEADERS_CLEAN} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + DEPENDS ${ROOT_DICT_INPUT_HEADERS} ${_input_depend} + COMMENT "generating: ${_dict_src_file} with ${ROOT_DICT_INPUT_HEADERS}" ) - LIST( APPEND ROOT_DICT_OUTPUT_SOURCES ${_dict_src_file} ) + LIST(APPEND ROOT_DICT_OUTPUT_SOURCES ${_dict_src_file}) ENDMACRO() # for backwards compatibility -MACRO( GEN_ROOT_DICT_SOURCES _dict_src_filename ) +MACRO(GEN_ROOT_DICT_SOURCES _dict_src_filename) #MESSAGE( "USING DEPRECATED GEN_ROOT_DICT_SOURCES. PLEASE USE GEN_ROOT_DICT_SOURCE instead." ) - SET( ROOT_DICT_OUTPUT_SOURCES ) - GEN_ROOT_DICT_SOURCE( ${_dict_src_filename} ) + SET(ROOT_DICT_OUTPUT_SOURCES) + GEN_ROOT_DICT_SOURCE(${_dict_src_filename}) ENDMACRO() # ============================================================================ - # ============================================================================ # Macro to compile the whole directories into a single library # @@ -208,144 +200,141 @@ ENDMACRO() # form, set them in this argument to include them. # # ---------------------------------------------------------------------------- -MACRO( COMPILEDIR libname ) +MACRO(COMPILEDIR libname) - message(STATUS "making build files for ${CMAKE_CURRENT_SOURCE_DIR}, schema evolution: ${local_SE}") + message(STATUS "making build files for ${CMAKE_CURRENT_SOURCE_DIR}, schema evolution: ${local_SE}") # We need to define the include paths relative to the compilation directory - set ( REAL_SOURCE_DIR "${CMAKE_SOURCE_DIR}/source" ) - string( REPLACE ${REAL_SOURCE_DIR} "" RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ) + set(REAL_SOURCE_DIR "${CMAKE_SOURCE_DIR}/source") + string(REPLACE ${REAL_SOURCE_DIR} "" RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}) set(RELATIVE_PATH "..${RELATIVE}") - set(contentfiles) - - if(DEFINED contents) - message("specified sub-dirs: ${contents}") - foreach(content ${contents}) - set(local_include_dirs ${local_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR}/${content} ${CMAKE_CURRENT_SOURCE_DIR}/${content}/inc) - endforeach(content) - set(local_include_dirs ${local_include_dirs} PARENT_SCOPE) - - foreach(content ${contents}) - file(GLOB_RECURSE files ${content}/*.cxx) - foreach (file ${files}) - - string(REGEX MATCH "[^/\\]*cxx" temp ${file}) - string(REPLACE ".cxx" "" class ${temp}) - - set ( SKIP "FALSE" ) - if(DEFINED excludes) - foreach(exclude ${excludes}) - if ( "${exclude}" STREQUAL "${class}" ) - set ( SKIP "TRUE" ) - # message( STATUS "Skipping ${class}" ) - endif() - endforeach(exclude) - endif() - - if( ${SKIP} STREQUAL "FALSE" ) - set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - if(NOT header) - message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") - else() - set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - if(${SCHEMA_EVOLUTION} MATCHES "ON") - GEN_ROOT_DICT_LINKDEF_HEADER( ${class} ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - else() - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) - endif() - - set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) - endif() - endif( ${SKIP} STREQUAL "FALSE" ) - - endforeach (file) - - # message( STATUS "contentfiles: ${contentfiles}" ) - endforeach(content) - else() - message("using inc/src folders in root directory") - set(local_include_dirs ${local_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) - set(local_include_dirs ${local_include_dirs} PARENT_SCOPE) - - file(GLOB_RECURSE files src/*.cxx) - foreach (file ${files}) - string(REGEX MATCH "[^/\\]*cxx" temp ${file}) - string(REPLACE ".cxx" "" class ${temp}) - - set ( SKIP "FALSE" ) - if(DEFINED excludes) - # message ( STATUS "EXCLUDES: ${excludes}" ) - foreach(exclude ${excludes}) - if ( "${exclude}" STREQUAL "${class}" ) - set ( SKIP "TRUE" ) - # message( STATUS "Skipping ${class}" ) - endif() - endforeach(exclude) - endif() - - if( ${SKIP} STREQUAL "FALSE" ) - set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - if(NOT header) - message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") - else() - set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - if(${SCHEMA_EVOLUTION} MATCHES "ON") - GEN_ROOT_DICT_LINKDEF_HEADER( ${class} ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - else() - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) - endif() - - set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) - endif() - endif( ${SKIP} STREQUAL "FALSE" ) - endforeach (file) - endif() - - - foreach(src ${addon_CINT}) - string(REGEX MATCH "[^/\\]+$" filename ${src}) - set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) - set(ROOT_DICT_INPUT_HEADERS ${src}) - GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) - set(contentfiles ${contentfiles} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) - endforeach(src) - - include_directories(${local_include_dirs}) - add_library(${libname} SHARED ${contentfiles} ${addon_src}) - - - if(CMAKE_SYSTEM_NAME MATCHES "Windows") - set_target_properties(${libname} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - target_link_libraries(${libname} ${local_libraries} ${external_libs}) - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION bin - ARCHIVE DESTINATION lib) - else() - target_link_libraries(${libname} ${local_libraries} ${external_libs}) - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static) - endif() - set(local_libraries ${local_libraries} ${libname}) - set(local_libraries ${local_libraries} PARENT_SCOPE) + set(contentfiles) + + if (DEFINED contents) + message("specified sub-dirs: ${contents}") + foreach (content ${contents}) + set(local_include_dirs ${local_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR}/${content} ${CMAKE_CURRENT_SOURCE_DIR}/${content}/inc) + endforeach (content) + set(local_include_dirs ${local_include_dirs} PARENT_SCOPE) + + foreach (content ${contents}) + file(GLOB_RECURSE files ${content}/*.cxx) + foreach (file ${files}) + + string(REGEX MATCH "[^/\\]*cxx" temp ${file}) + string(REPLACE ".cxx" "" class ${temp}) + + set(SKIP "FALSE") + if (DEFINED excludes) + foreach (exclude ${excludes}) + if ("${exclude}" STREQUAL "${class}") + set(SKIP "TRUE") + # message( STATUS "Skipping ${class}" ) + endif () + endforeach (exclude) + endif () + + if (${SKIP} STREQUAL "FALSE") + set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) + file(GLOB_RECURSE header ${class}.h) + if (NOT header) + message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") + else () + set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + if (${SCHEMA_EVOLUTION} MATCHES "ON") + GEN_ROOT_DICT_LINKDEF_HEADER(${class} ${header}) + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + else () + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) + endif () + + set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) + endif () + endif (${SKIP} STREQUAL "FALSE") + + endforeach (file) + # message( STATUS "contentfiles: ${contentfiles}" ) + endforeach (content) + else () + message("using inc/src folders in root directory") + set(local_include_dirs ${local_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) + set(local_include_dirs ${local_include_dirs} PARENT_SCOPE) + + file(GLOB_RECURSE files src/*.cxx) + foreach (file ${files}) + string(REGEX MATCH "[^/\\]*cxx" temp ${file}) + string(REPLACE ".cxx" "" class ${temp}) + + set(SKIP "FALSE") + if (DEFINED excludes) + # message ( STATUS "EXCLUDES: ${excludes}" ) + foreach (exclude ${excludes}) + if ("${exclude}" STREQUAL "${class}") + set(SKIP "TRUE") + # message( STATUS "Skipping ${class}" ) + endif () + endforeach (exclude) + endif () + + if (${SKIP} STREQUAL "FALSE") + set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) + file(GLOB_RECURSE header ${class}.h) + if (NOT header) + message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") + else () + set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + if (${SCHEMA_EVOLUTION} MATCHES "ON") + GEN_ROOT_DICT_LINKDEF_HEADER(${class} ${header}) + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + else () + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) + endif () + set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) + endif () + endif (${SKIP} STREQUAL "FALSE") + endforeach (file) + endif () + + + foreach (src ${addon_CINT}) + string(REGEX MATCH "[^/\\]+$" filename ${src}) + set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) + set(ROOT_DICT_INPUT_HEADERS ${src}) + GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) + set(contentfiles ${contentfiles} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) + endforeach (src) + + include_directories(${local_include_dirs}) + add_library(${libname} SHARED ${contentfiles} ${addon_src}) + + if (CMAKE_SYSTEM_NAME MATCHES "Windows") + set_target_properties(${libname} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + target_link_libraries(${libname} ${local_libraries} ${external_libs}) + install(TARGETS ${libname} + RUNTIME DESTINATION bin + LIBRARY DESTINATION bin + ARCHIVE DESTINATION lib) + else () + target_link_libraries(${libname} ${local_libraries} ${external_libs}) + install(TARGETS ${libname} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static) + endif () + set(local_libraries ${local_libraries} ${libname}) + set(local_libraries ${local_libraries} PARENT_SCOPE) ENDMACRO() 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}) + 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() # ============================================================================ @@ -353,10 +342,10 @@ ENDMACRO() # e.g. axion --> RestAxion # e.g. detector --> RestDetector MACRO(DIRNAME2LIBNAME result dirname) - string(SUBSTRING ${dirname} 0 1 firstletter) - string(TOUPPER ${firstletter} firstlettercapital) - string(SUBSTRING ${dirname} 1 -1 remainingletter) - set(${result} "Rest${firstlettercapital}${remainingletter}") + string(SUBSTRING ${dirname} 0 1 firstletter) + string(TOUPPER ${firstletter} firstlettercapital) + string(SUBSTRING ${dirname} 1 -1 remainingletter) + set(${result} "Rest${firstlettercapital}${remainingletter}") ENDMACRO() # ============================================================================ @@ -367,21 +356,20 @@ ENDMACRO() # result: the converted option string. Will be empty if error # dirname: the relative path from CMAKE_CURRENT_SOURCE_DIR to the target dir macro(DIRNAME2OPTION result dirname) - set(${result} "") - if(${dirname} MATCHES "libraries/") - string(REPLACE "libraries/" "" purename ${dirname}) - string(TOUPPER ${purename} uppername) - set(${result} "RESTLIB_${uppername}") - endif() - - if(${dirname} MATCHES "packages/") - string(REPLACE "packages/rest" "" purename ${dirname}) - set(${result} "REST_${purename}") - endif() + set(${result} "") + if (${dirname} MATCHES "libraries/") + string(REPLACE "libraries/" "" purename ${dirname}) + string(TOUPPER ${purename} uppername) + set(${result} "RESTLIB_${uppername}") + endif () + + if (${dirname} MATCHES "packages/") + string(REPLACE "packages/rest" "" purename ${dirname}) + set(${result} "REST_${purename}") + endif () ENDMACRO() - # ============================================================================ # Macro to compile REST libraries sub-dir into a single library # @@ -431,94 +419,94 @@ ENDMACRO() # form, set them in this argument to include them. # # ---------------------------------------------------------------------------- -MACRO( COMPILELIB dependency) - - string(REGEX MATCH "[^/\\]*$" puredirname ${CMAKE_CURRENT_SOURCE_DIR}) - DIRNAME2LIBNAME(libname ${puredirname}) - - message(STATUS "making build files in ${CMAKE_CURRENT_SOURCE_DIR}, dependency: ${${dependency}}") - - set(files_cxx) - set(files_to_compile_cxx) - set(files_to_compile_cint) - set(dirs_to_include ${rest_framework_include_dirs}) - set(libs_to_link ${rest_framework_libraries}) - - # check dependency - foreach(dep ${${dependency}}) - set(dirs_to_include ${dirs_to_include} "${CMAKE_CURRENT_SOURCE_DIR}/../${dep}/inc") - DIRNAME2LIBNAME(deplibname ${dep}) - set(libs_to_link ${libs_to_link} ${deplibname}) - endforeach() - - # include dir - set(dirs_to_include ${dirs_to_include} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) - - # generate CINT files - file(GLOB_RECURSE files_cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cxx) - foreach (file ${files_cxx}) - string(REGEX MATCH "[^/\\]*cxx$" temp ${file}) # get pure file name - string(REPLACE ".cxx" "" class ${temp}) # get file name without extension, i.e. class name - - set ( SKIP "FALSE" ) - if(DEFINED excludes) - foreach(exclude ${excludes}) - if ( "${exclude}" STREQUAL "${class}" ) - set ( SKIP "TRUE" ) - # message( STATUS "Skipping ${class}" ) - endif() - endforeach(exclude) - endif() - - if( ${SKIP} STREQUAL "FALSE" ) - set(ROOT_DICT_INCLUDE_DIRS ${dirs_to_include} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - if(NOT header) - message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") - else() - set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - if(${SCHEMA_EVOLUTION} MATCHES "ON") - GEN_ROOT_DICT_LINKDEF_HEADER( ${class} ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - else() - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) - endif() - - set(files_to_compile_cxx ${files_to_compile_cxx} ${file}) - set(files_to_compile_cint ${files_to_compile_cint} ${ROOT_DICT_OUTPUT_SOURCES}) - endif() - endif( ${SKIP} STREQUAL "FALSE" ) - endforeach (file) - - foreach(src ${addon_CINT}) - string(REGEX MATCH "[^/\\]+$" filename ${src}) - set(ROOT_DICT_INCLUDE_DIRS ${dirs_to_include} ${external_include_dirs}) - set(ROOT_DICT_INPUT_HEADERS ${src}) - GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) - set(files_to_compile ${files_to_compile} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) - endforeach(src) - - list(LENGTH files_cxx Nfiles_cxx) - list(LENGTH files_to_compile_cint Nfiles_cint) - list(LENGTH addon_src Nfiles_add) - - message(STATUS "${Nfiles_cxx} source files in total, ${Nfiles_cint} classes to generete, ${Nfiles_add} additional source files") - - # start compile - include_directories(${dirs_to_include} ${external_include_dirs}) - add_library(${libname} SHARED ${files_to_compile_cxx} ${files_to_compile_cint} ${addon_src}) - target_link_libraries(${libname} ${libs_to_link} ${external_libs}) - - # install - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static) - - file(GLOB_RECURSE Headers "${CMAKE_CURRENT_SOURCE_DIR}/inc/*.h") - INSTALL(FILES ${Headers} DESTINATION include) - - set(dirs_included ${dirs_to_include} PARENT_SCOPE) - set(library_added ${libname}) - set(library_added ${library_added} PARENT_SCOPE) -ENDMACRO() \ No newline at end of file +MACRO(COMPILELIB dependency) + + string(REGEX MATCH "[^/\\]*$" puredirname ${CMAKE_CURRENT_SOURCE_DIR}) + DIRNAME2LIBNAME(libname ${puredirname}) + + message(STATUS "making build files in ${CMAKE_CURRENT_SOURCE_DIR}, dependency: ${${dependency}}") + + set(files_cxx) + set(files_to_compile_cxx) + set(files_to_compile_cint) + set(dirs_to_include ${rest_framework_include_dirs}) + set(libs_to_link ${rest_framework_libraries}) + + # check dependency + foreach (dep ${${dependency}}) + set(dirs_to_include ${dirs_to_include} "${CMAKE_CURRENT_SOURCE_DIR}/../${dep}/inc") + DIRNAME2LIBNAME(deplibname ${dep}) + set(libs_to_link ${libs_to_link} ${deplibname}) + endforeach () + + # include dir + set(dirs_to_include ${dirs_to_include} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) + + # generate CINT files + file(GLOB_RECURSE files_cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cxx) + foreach (file ${files_cxx}) + string(REGEX MATCH "[^/\\]*cxx$" temp ${file}) # get pure file name + string(REPLACE ".cxx" "" class ${temp}) # get file name without extension, i.e. class name + + set(SKIP "FALSE") + if (DEFINED excludes) + foreach (exclude ${excludes}) + if ("${exclude}" STREQUAL "${class}") + set(SKIP "TRUE") + # message( STATUS "Skipping ${class}" ) + endif () + endforeach (exclude) + endif () + + if (${SKIP} STREQUAL "FALSE") + set(ROOT_DICT_INCLUDE_DIRS ${dirs_to_include} ${external_include_dirs}) + file(GLOB_RECURSE header ${class}.h) + if (NOT header) + message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") + else () + set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + if (${SCHEMA_EVOLUTION} MATCHES "ON") + GEN_ROOT_DICT_LINKDEF_HEADER(${class} ${header}) + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + else () + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) + endif () + + set(files_to_compile_cxx ${files_to_compile_cxx} ${file}) + set(files_to_compile_cint ${files_to_compile_cint} ${ROOT_DICT_OUTPUT_SOURCES}) + endif () + endif (${SKIP} STREQUAL "FALSE") + endforeach (file) + + foreach (src ${addon_CINT}) + string(REGEX MATCH "[^/\\]+$" filename ${src}) + set(ROOT_DICT_INCLUDE_DIRS ${dirs_to_include} ${external_include_dirs}) + set(ROOT_DICT_INPUT_HEADERS ${src}) + GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) + set(files_to_compile ${files_to_compile} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) + endforeach (src) + + list(LENGTH files_cxx Nfiles_cxx) + list(LENGTH files_to_compile_cint Nfiles_cint) + list(LENGTH addon_src Nfiles_add) + + message(STATUS "${Nfiles_cxx} source files in total, ${Nfiles_cint} classes to generete, ${Nfiles_add} additional source files") + + # start compile + include_directories(${dirs_to_include} ${external_include_dirs}) + add_library(${libname} SHARED ${files_to_compile_cxx} ${files_to_compile_cint} ${addon_src}) + target_link_libraries(${libname} ${libs_to_link} ${external_libs}) + + # install + install(TARGETS ${libname} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static) + + file(GLOB_RECURSE Headers "${CMAKE_CURRENT_SOURCE_DIR}/inc/*.h") + INSTALL(FILES ${Headers} DESTINATION include) + + set(dirs_included ${dirs_to_include} PARENT_SCOPE) + set(library_added ${libname}) + set(library_added ${library_added} PARENT_SCOPE) +ENDMACRO() diff --git a/source/framework/CMakeLists.txt b/source/framework/CMakeLists.txt index 50f36a7bf..dc91f1d37 100644 --- a/source/framework/CMakeLists.txt +++ b/source/framework/CMakeLists.txt @@ -1,11 +1,26 @@ +# External dependencies + +add_subdirectory(external) + set(contents external/tinyxml tools core analysis) file(GLOB_RECURSE addon_src - "tiny*cpp" - "startup.cpp") + "tiny*cpp" + "startup.cpp") if (NOT ${REST_EVE} MATCHES "ON") - set( excludes TRestEveEventViewer) + set(excludes TRestEveEventViewer) endif (NOT ${REST_EVE} MATCHES "ON") COMPILEDIR(RestFramework) + +if (NOT DEFINED TEST OR NOT TEST) + set(TEST OFF) + message(STATUS "Testing disabled (Disabled by default, enabled via -DTEST=ON flag)") +endif () +if (TEST) + message(STATUS "Testing enabled (Disabled by default, enabled via -DTEST=ON flag)") + enable_testing() +endif () + +ADD_TEST() diff --git a/source/framework/external/CMakeLists.txt b/source/framework/external/CMakeLists.txt new file mode 100644 index 000000000..1a5183694 --- /dev/null +++ b/source/framework/external/CMakeLists.txt @@ -0,0 +1,39 @@ + +message(STATUS "External dependencies:") + +set(FETCHCONTENT_QUIET ON) + +include(FetchContent) + +# Google Test +if (TEST) + message(STATUS "- Google Test") + FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip + ) + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Windows only + FetchContent_MakeAvailable(googletest) +endif () + +# YAML parser +message(STATUS "- yaml-cpp") +FetchContent_Declare( + yaml-cpp + GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git + GIT_TAG yaml-cpp-0.7.0 +) +FetchContent_MakeAvailable(yaml-cpp) +install(DIRECTORY ${yaml-cpp_SOURCE_DIR}/include DESTINATION .) +install(TARGETS yaml-cpp DESTINATION lib) + +# Logging library +message(STATUS "- spdlog") +FetchContent_Declare( + spdlog + GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.9.2 +) +FetchContent_MakeAvailable(spdlog) +install(DIRECTORY ${spdlog_SOURCE_DIR}/include DESTINATION .) +install(TARGETS spdlog DESTINATION lib) diff --git a/source/framework/test/CMakeLists.txt b/source/framework/test/CMakeLists.txt new file mode 100644 index 000000000..a7b15614f --- /dev/null +++ b/source/framework/test/CMakeLists.txt @@ -0,0 +1,21 @@ +set(TESTING_EXECUTABLE testFramework) + +enable_testing() + +add_executable(${TESTING_EXECUTABLE}) + +FILE(GLOB SOURCES src/*.cxx) +target_sources( + ${TESTING_EXECUTABLE} PUBLIC + ${SOURCES} +) + +target_link_libraries( + ${TESTING_EXECUTABLE} PUBLIC + gtest_main + RestFramework +) + +include(GoogleTest) + +gtest_discover_tests(${TESTING_EXECUTABLE}) diff --git a/source/framework/test/src/ExampleTest.cxx b/source/framework/test/src/ExampleTest.cxx new file mode 100644 index 000000000..450b5714f --- /dev/null +++ b/source/framework/test/src/ExampleTest.cxx @@ -0,0 +1,10 @@ + +#include +#include + +TEST(Framework, example) { + auto run = TRestRun(); + run.PrintAllMetadata(); + EXPECT_TRUE(&run != nullptr); + return; +} From cd744cbea1066e2b881621cb6668b7e93cbefe1f Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Tue, 8 Feb 2022 12:50:00 +0100 Subject: [PATCH 04/61] fixed external deps --- source/framework/CMakeLists.txt | 2 ++ source/framework/external/CMakeLists.txt | 3 +++ 2 files changed, 5 insertions(+) diff --git a/source/framework/CMakeLists.txt b/source/framework/CMakeLists.txt index 8b567809d..b72e5a214 100644 --- a/source/framework/CMakeLists.txt +++ b/source/framework/CMakeLists.txt @@ -1,3 +1,5 @@ +add_subdirectory(external) + set(contents external/tinyxml tools core analysis) file(GLOB_RECURSE addon_src diff --git a/source/framework/external/CMakeLists.txt b/source/framework/external/CMakeLists.txt index 1a5183694..152fb236f 100644 --- a/source/framework/external/CMakeLists.txt +++ b/source/framework/external/CMakeLists.txt @@ -16,6 +16,9 @@ if (TEST) FetchContent_MakeAvailable(googletest) endif () +return() +# These are useful dependencies, we don't use them right now + # YAML parser message(STATUS "- yaml-cpp") FetchContent_Declare( From c7c10f559529edbf8ace8e99072a38543807eeac Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Tue, 8 Feb 2022 12:58:05 +0100 Subject: [PATCH 05/61] fixed bad image reference --- .github/workflows/ci.yml | 2 +- .gitlab-ci.yml | 88 ++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2eaaa8102..42b1c3ae0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: env: REST_PATH: /REST/install container: - image: ghcr.io/lobis/root-geant4-garfield:cxx17_ROOT-v6-25-01_Geant4-v10.4.3_Garfield-4.0 + image: ghcr.io/lobis/root-geant4-garfield:cpp17_ROOT-v6-25-01_Geant4-v10.4.3_Garfield-4.0 steps: - uses: actions/checkout@v2 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 26ea21fb5..33d5a4044 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,49 +1,49 @@ -image: ghcr.io/lobis/root-geant4-garfield:cxx17_ROOT-v6-25-01_Geant4-v10.4.3_Garfield-4.0 +image: ghcr.io/lobis/root-geant4-garfield:cpp17_ROOT-v6-25-01_Geant4-v10.4.3_Garfield-4.0 variables: # GIT_SUBMODULE_STRATEGY: recursive stages: - # Basic checks to verify correctness of code + # Basic checks to verify correctness of code - pre-build - # Project compilation validation + # Project compilation validation - build - # REST libraries installed as sub-modules + # REST libraries installed as sub-modules - libraries - # Basic validation tests of installation + # Basic validation tests of installation - install - # Basic core validation tests + # Basic core validation tests - core - # Stage dedicated to validate metadata classes. gas, readout, g4Metadata, etc + # Stage dedicated to validate metadata classes. gas, readout, g4Metadata, etc - metadata - # Stage to validate restG4 package examples + # Stage to validate restG4 package examples - restG4 - # Stage to validate data chain processing constructions (TREX-DM data, PandaX-III topology, etc). + # Stage to validate data chain processing constructions (TREX-DM data, PandaX-III topology, etc). - restManager_process - # Stage to validate tasks or executions over preprocessed data filesx + # Stage to validate tasks or executions over preprocessed data filesx - postProcessing - # Stage to validate other restManager tasks (metadata generation, script loading, etc). + # Stage to validate other restManager tasks (metadata generation, script loading, etc). - restManager_generate - # Scripts to launch more complete tests. TRestGas file generation, Geant4 physics validation, etc. + # Scripts to launch more complete tests. TRestGas file generation, Geant4 physics validation, etc. - deploy before_script: - pwd - export USER="test" - # - export GIT_SSL_NO_VERIFY=1 + # - export GIT_SSL_NO_VERIFY=1 - echo $CI_SERVER_HOST - echo $CRONJOB - # We redefine the HOME + # We redefine the HOME - export HOME=${CI_PROJECT_DIR}/install_latest/ - if [ -d $HOME/.rest ]; then rm -Rf $HOME/.rest; fi - if [ -f "/opt/root/install/bin/thisroot.sh" ]; then source /opt/root/install/bin/thisroot.sh; fi @@ -72,11 +72,11 @@ clang-format: - $CRONJOB == "YES" validateCode: - stage: pre-build - script: - - cd ${CI_PROJECT_DIR}/ - - python3 pull-submodules.py --force --dontask - - python3 pipeline/validateProcesses.py source/libraries/ + stage: pre-build + script: + - cd ${CI_PROJECT_DIR}/ + - python3 pull-submodules.py --force --dontask + - python3 pipeline/validateProcesses.py source/libraries/ #axionLib: # stage: libraries @@ -123,19 +123,19 @@ build_latest: - if [ -d ${CI_PROJECT_DIR}/install_latest ]; then rm -Rf ${CI_PROJECT_DIR}/install_latest; fi - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install_latest - make install -j2 - # - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + # - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh artifacts: paths: - ${CI_PROJECT_DIR}/install_latest expire_in: 1 day - #build_latest_root622_geant4v1042: - # image: lobis/root-geant4-garfieldpp:cxx14_ROOTv6-22-08_Geant4v10.4.2 - # type: build - # script: - # - cd ${CI_PROJECT_DIR}/ - # - python3 pull-submodules.py --force --dontask --latest - # - if [ -d ${CI_PROJECT_DIR}/build_latest2 ]; then rm -Rf ${CI_PROJECT_DIR}/build_latest2; fi + #build_latest_root622_geant4v1042: + # image: lobis/root-geant4-garfieldpp:cxx14_ROOTv6-22-08_Geant4v10.4.2 + # type: build + # script: + # - cd ${CI_PROJECT_DIR}/ + # - python3 pull-submodules.py --force --dontask --latest + # - if [ -d ${CI_PROJECT_DIR}/build_latest2 ]; then rm -Rf ${CI_PROJECT_DIR}/build_latest2; fi # - mkdir ${CI_PROJECT_DIR}/build_latest2 && cd ${CI_PROJECT_DIR}/build_latest2/ # - if [ -d ${CI_PROJECT_DIR}/install_latest2 ]; then rm -Rf ${CI_PROJECT_DIR}/install_latest2; fi # - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install_latest2 @@ -143,7 +143,7 @@ build_latest: # - . ${CI_PROJECT_DIR}/install_latest2/thisREST.sh # except: # variables: - # - $CRONJOB == "YES" + # - $CRONJOB == "YES" #build_nkx: # image: nkx1231/root6-geant4-garfield:0.6 @@ -201,24 +201,24 @@ listRESTMacros: expire_in: 1 day LoadGas: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/gas/ - restRoot -b -q LoadGasFromServerAndValidate.C only: - variables: - - $CI_SERVER_HOST == "lfna.unizar.es" + variables: + - $CI_SERVER_HOST == "lfna.unizar.es" GenerateGas: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/gas/ - restRoot -b -q GenerateDummyGas.C only: - variables: - - $CI_SERVER_HOST == "lfna.unizar.es" + variables: + - $CI_SERVER_HOST == "lfna.unizar.es" AnalysisTree: type: core @@ -228,17 +228,17 @@ AnalysisTree: - restRoot -b -q simpleTree.cpp GenerateReadout: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/readout/ - restManager --c generateReadout.rml --o readout.root - restRoot -b -q PrintReadout.C'("readout.root")' > /dev/null # We need to introduce basic validation here - # - diff validation.txt print.txt + # - diff validation.txt print.txt BasicReadout: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/projects/basic-readouts/ @@ -259,7 +259,7 @@ testMeta: - ${CI_PROJECT_DIR}/install_latest/examples/meta.root expire_in: 1 day -trexDM_data_latest: +trexDM_data_latest: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -278,7 +278,7 @@ trexDM_data_latest: - ${CI_PROJECT_DIR}/pipeline/trex/Hits_01928.root expire_in: 1 day -pandaXIII_Topological: +pandaXIII_Topological: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -292,7 +292,7 @@ pandaXIII_Topological: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/trackParameter.png expire_in: 1 week -pandaXIII_Topological_fromG4: +pandaXIII_Topological_fromG4: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -306,7 +306,7 @@ pandaXIII_Topological_fromG4: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/testOutput.root expire_in: 1 week -pandaXIII_data: +pandaXIII_data: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -318,8 +318,8 @@ pandaXIII_data: paths: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_data/TriggerRate.png expire_in: 1 week - -EventSelection: + +EventSelection: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -327,7 +327,7 @@ EventSelection: - restManager --c g4Analysis.rml --f "${CI_PROJECT_DIR}/install_latest/examples/restG4/01.NLDBD/Run00001_NLDBD_Test.root" - restManager --c g4OnSelection.rml --f Run00001_NLDBD_Test_g4Analysis.root - restRoot -b -q Validate.C'("Run00001_NLDBD_Test_EvSelection.root")' - + artifacts: paths: - ${CI_PROJECT_DIR}/pipeline/selection/IDs.txt From 18cb64a16eb29bd2d818b80bf6a564f63a8af81a Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 9 Feb 2022 09:57:56 +0100 Subject: [PATCH 06/61] making cmake-ctest match master --- .github/workflows/ci.yml | 67 +++- .gitlab-ci.yml | 89 ++--- CMakeLists.txt | 10 +- cmake/FindGarfield.cmake | 61 ++++ cmake/FindROOT.cmake | 98 +++++ cmake/MacroRootDict.cmake | 610 ++++++++++++++++---------------- source/CMakeLists.txt | 141 ++++---- source/framework/CMakeLists.txt | 21 +- 8 files changed, 649 insertions(+), 448 deletions(-) create mode 100644 cmake/FindGarfield.cmake create mode 100644 cmake/FindROOT.cmake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42b1c3ae0..dd2de908d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,33 +2,86 @@ name: CI on: push: - branches: [ cmake-ctest ] + branches: [master] pull_request: - branches: [ cmake-ctest ] + branches: [master] workflow_dispatch: jobs: + Check-Image: + runs-on: ubuntu-latest + container: + image: lobis/root-geant4-garfieldpp:latest + + steps: + - name: Check ROOT + run: | + root-config --version + root-config --libs + root-config --cflags + + - name: Check Geant4 + # TODO: We should run `geant4-config` but can't do it easily without interactive shell. This ENV variable is from the docker image + run: | + echo $GEANT4_VERSION + ls -lht /opt/geant4/install + + # TODO: We should check that garfield is installed and working + - name: Check Garfield++ + run: | + ls -lht /opt/garfieldpp/install + + Build-Default: + needs: Check-Image + runs-on: ubuntu-latest + env: + REST_PATH: /opt/rest/install + container: + image: lobis/root-geant4-garfieldpp:latest + + steps: + - uses: actions/checkout@v2 + + - name: Pull Submodules + run: python3 pull-submodules.py + + - name: Build + run: | + mkdir -p build + cd build + cmake .. + make + make install + + - name: REST config + run: | + ${REST_PATH}/bin/rest-config --version + ${REST_PATH}/bin/rest-config --libs + ${REST_PATH}/bin/rest-config --flags + ${REST_PATH}/bin/rest-config --commit - Build: + Build-Full: + # TODO: install requiered dependencies so this job doesn't fail needs: Check-Image runs-on: ubuntu-latest env: - REST_PATH: /REST/install + REST_PATH: /opt/rest/install container: - image: ghcr.io/lobis/root-geant4-garfield:cpp17_ROOT-v6-25-01_Geant4-v10.4.3_Garfield-4.0 + image: lobis/root-geant4-garfieldpp:latest steps: - uses: actions/checkout@v2 - name: Pull Submodules - run: yes | python3 pull-submodules + run: python3 pull-submodules.py - name: Build run: | + export GARFIELD_HOME=/opt/garfieldpp/install mkdir -p build cd build - cmake .. -DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DREST_ALL_LIBS=OFF + cmake .. -DREST_ALL_LIBS=ON -DREST_G4=ON -DREST_GARFIELD=ON -DCMAKE_PREFIX_PATH=/opt/geant4/install make make install diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 33d5a4044..d62d1b4de 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,49 +1,50 @@ -image: ghcr.io/lobis/root-geant4-garfield:cpp17_ROOT-v6-25-01_Geant4-v10.4.3_Garfield-4.0 +#image: lobis/root-geant4-garfieldpp:cxx14_ROOTv6-25-01_Geant4v10.4.3 +image: nkx1231/root6-geant4-garfield:0.6 variables: # GIT_SUBMODULE_STRATEGY: recursive stages: - # Basic checks to verify correctness of code + # Basic checks to verify correctness of code - pre-build - # Project compilation validation + # Project compilation validation - build - # REST libraries installed as sub-modules + # REST libraries installed as sub-modules - libraries - # Basic validation tests of installation + # Basic validation tests of installation - install - # Basic core validation tests + # Basic core validation tests - core - # Stage dedicated to validate metadata classes. gas, readout, g4Metadata, etc + # Stage dedicated to validate metadata classes. gas, readout, g4Metadata, etc - metadata - # Stage to validate restG4 package examples + # Stage to validate restG4 package examples - restG4 - # Stage to validate data chain processing constructions (TREX-DM data, PandaX-III topology, etc). + # Stage to validate data chain processing constructions (TREX-DM data, PandaX-III topology, etc). - restManager_process - # Stage to validate tasks or executions over preprocessed data filesx + # Stage to validate tasks or executions over preprocessed data filesx - postProcessing - # Stage to validate other restManager tasks (metadata generation, script loading, etc). + # Stage to validate other restManager tasks (metadata generation, script loading, etc). - restManager_generate - # Scripts to launch more complete tests. TRestGas file generation, Geant4 physics validation, etc. + # Scripts to launch more complete tests. TRestGas file generation, Geant4 physics validation, etc. - deploy before_script: - pwd - export USER="test" - # - export GIT_SSL_NO_VERIFY=1 + # - export GIT_SSL_NO_VERIFY=1 - echo $CI_SERVER_HOST - echo $CRONJOB - # We redefine the HOME + # We redefine the HOME - export HOME=${CI_PROJECT_DIR}/install_latest/ - if [ -d $HOME/.rest ]; then rm -Rf $HOME/.rest; fi - if [ -f "/opt/root/install/bin/thisroot.sh" ]; then source /opt/root/install/bin/thisroot.sh; fi @@ -72,11 +73,11 @@ clang-format: - $CRONJOB == "YES" validateCode: - stage: pre-build - script: - - cd ${CI_PROJECT_DIR}/ - - python3 pull-submodules.py --force --dontask - - python3 pipeline/validateProcesses.py source/libraries/ + stage: pre-build + script: + - cd ${CI_PROJECT_DIR}/ + - python3 pull-submodules.py --force --dontask + - python3 pipeline/validateProcesses.py source/libraries/ #axionLib: # stage: libraries @@ -123,19 +124,19 @@ build_latest: - if [ -d ${CI_PROJECT_DIR}/install_latest ]; then rm -Rf ${CI_PROJECT_DIR}/install_latest; fi - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install_latest - make install -j2 - # - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + # - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh artifacts: paths: - ${CI_PROJECT_DIR}/install_latest expire_in: 1 day - #build_latest_root622_geant4v1042: - # image: lobis/root-geant4-garfieldpp:cxx14_ROOTv6-22-08_Geant4v10.4.2 - # type: build - # script: - # - cd ${CI_PROJECT_DIR}/ - # - python3 pull-submodules.py --force --dontask --latest - # - if [ -d ${CI_PROJECT_DIR}/build_latest2 ]; then rm -Rf ${CI_PROJECT_DIR}/build_latest2; fi + #build_latest_root622_geant4v1042: + # image: lobis/root-geant4-garfieldpp:cxx14_ROOTv6-22-08_Geant4v10.4.2 + # type: build + # script: + # - cd ${CI_PROJECT_DIR}/ + # - python3 pull-submodules.py --force --dontask --latest + # - if [ -d ${CI_PROJECT_DIR}/build_latest2 ]; then rm -Rf ${CI_PROJECT_DIR}/build_latest2; fi # - mkdir ${CI_PROJECT_DIR}/build_latest2 && cd ${CI_PROJECT_DIR}/build_latest2/ # - if [ -d ${CI_PROJECT_DIR}/install_latest2 ]; then rm -Rf ${CI_PROJECT_DIR}/install_latest2; fi # - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install_latest2 @@ -143,7 +144,7 @@ build_latest: # - . ${CI_PROJECT_DIR}/install_latest2/thisREST.sh # except: # variables: - # - $CRONJOB == "YES" + # - $CRONJOB == "YES" #build_nkx: # image: nkx1231/root6-geant4-garfield:0.6 @@ -201,24 +202,24 @@ listRESTMacros: expire_in: 1 day LoadGas: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/gas/ - restRoot -b -q LoadGasFromServerAndValidate.C only: - variables: - - $CI_SERVER_HOST == "lfna.unizar.es" + variables: + - $CI_SERVER_HOST == "lfna.unizar.es" GenerateGas: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/gas/ - restRoot -b -q GenerateDummyGas.C only: - variables: - - $CI_SERVER_HOST == "lfna.unizar.es" + variables: + - $CI_SERVER_HOST == "lfna.unizar.es" AnalysisTree: type: core @@ -228,17 +229,17 @@ AnalysisTree: - restRoot -b -q simpleTree.cpp GenerateReadout: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/readout/ - restManager --c generateReadout.rml --o readout.root - restRoot -b -q PrintReadout.C'("readout.root")' > /dev/null # We need to introduce basic validation here - # - diff validation.txt print.txt + # - diff validation.txt print.txt BasicReadout: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/projects/basic-readouts/ @@ -259,7 +260,7 @@ testMeta: - ${CI_PROJECT_DIR}/install_latest/examples/meta.root expire_in: 1 day -trexDM_data_latest: +trexDM_data_latest: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -278,7 +279,7 @@ trexDM_data_latest: - ${CI_PROJECT_DIR}/pipeline/trex/Hits_01928.root expire_in: 1 day -pandaXIII_Topological: +pandaXIII_Topological: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -292,7 +293,7 @@ pandaXIII_Topological: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/trackParameter.png expire_in: 1 week -pandaXIII_Topological_fromG4: +pandaXIII_Topological_fromG4: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -306,7 +307,7 @@ pandaXIII_Topological_fromG4: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/testOutput.root expire_in: 1 week -pandaXIII_data: +pandaXIII_data: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -318,8 +319,8 @@ pandaXIII_data: paths: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_data/TriggerRate.png expire_in: 1 week - -EventSelection: + +EventSelection: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -327,7 +328,7 @@ EventSelection: - restManager --c g4Analysis.rml --f "${CI_PROJECT_DIR}/install_latest/examples/restG4/01.NLDBD/Run00001_NLDBD_Test.root" - restManager --c g4OnSelection.rml --f Run00001_NLDBD_Test_g4Analysis.root - restRoot -b -q Validate.C'("Run00001_NLDBD_Test_EvSelection.root")' - + artifacts: paths: - ${CI_PROJECT_DIR}/pipeline/selection/IDs.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index efc3cb85a..a047571b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,5 @@ -PROJECT(REST LANGUAGES CXX HOMEPAGE_URL https://github.com/rest-for-physics/framework) - -cmake_minimum_required(VERSION 3.14) +PROJECT(REST) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) # Minimum compiler version if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") @@ -28,7 +27,6 @@ if (NOT DEFINED INSTALL_PREFIX) set(INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/install) endif () endif () - get_filename_component(INSTALL_PREFIX_ABSOLUTE ${INSTALL_PREFIX} ABSOLUTE BASE_DIR "${CMAKE_BINARY_DIR}") set(REST_PATH ${INSTALL_PREFIX_ABSOLUTE}) if (NOT DEFINED CMAKE_INSTALL_PREFIX) @@ -60,7 +58,6 @@ set(CMAKE_MACOSX_RPATH 1) find_package(ROOT REQUIRED) -# Use same cpp version as the ROOT install execute_process(COMMAND root-config --has-cxx20 OUTPUT_VARIABLE HASCXX20) execute_process(COMMAND root-config --has-cxx17 OUTPUT_VARIABLE HASCXX17) execute_process(COMMAND root-config --has-cxx14 OUTPUT_VARIABLE HASCXX14) @@ -119,11 +116,8 @@ message(STATUS "external libraries to link: " ${external_libs}) string(TIMESTAMP date "%Y-%m-%d %H:%M") # Start compile - -include(AddTest) include(MacroRootDict) add_subdirectory(source) - message("") message(STATUS "rest Libraries: " ${rest_libraries_regular}) message(STATUS "rest executables: " ${rest_exes}) diff --git a/cmake/FindGarfield.cmake b/cmake/FindGarfield.cmake new file mode 100644 index 000000000..cdbf9c43b --- /dev/null +++ b/cmake/FindGarfield.cmake @@ -0,0 +1,61 @@ + +# - Try to find Garfield++ instalation +# This module sets up Garfield information +# It defines: +# Garfield_FOUND If Garfiled++ is found +# Garfield_INCLUDE_DIRS PATH to the include directories +# Garfield_LIBRARIES the libraries needed to use Garfield++ + +#message(STATUS "Looking for Garfield ...") + +# Alternative paths which can be defined by user +#set(Garfield_DIR "" CACHE PATH "Directory where Garfield is installed") +#set(Garfield_INC_DIR "" CACHE PATH "Alternative directory for Garfield includes") +#set(Garfield_LIB_DIR "" CACHE PATH "Alternative directory for Garfield libraries") +set(Garfield_DIR $ENV{GARFIELD_HOME}) + +find_path(Garfield_INCLUDE_DIRS Sensor.hh + HINTS ${Garfield_DIR}/include/ ${Garfield_DIR}/include/Garfield ${Garfield_INC_DIR} + ${Garfield_DIR}/Include) + +#message(STATUS Garfield_INCLUDE_DIRS ${Garfield_INCLUDE_DIRS}) + +find_library(Garfield_LIBRARIES NAMES libGarfield.so Garfield + HINTS ${Garfield_DIR}/lib ${Garfield_LIB_DIR} + $ENV{GARFIELD_HOME}/lib) +#message(STATUS Garfield_LIBRARIES ${Garfield_LIBRARIES}) + +#if (${Garfield_LIBRARY_DIR}) +# set (Garfield_LIBRARIES -L${Garfield_LIBRARY_DIR} -lGarfield) +#endif() + +if (Garfield_INCLUDE_DIRS AND Garfield_LIBRARIES) + set (Garfield_FOUND TRUE) +endif() + +if (NOT DEFINED ENV{GARFIELD_HOME} ) + message("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nError : GARFIELD HOME is not defined! + \nCheck Garfield is installed and GARFIELD_HOME is pointing to install directory + \nHINT : GARFIELD_HOME/lib/libGarfield.so should exist. + \nIf you do not need Garfield++ interface in your REST installation, then, + \nplease, run cmake disabling REST_GARFIELD variable + \n\ni.e. : cmake -DREST_GARFIELD=OFF ../ + \n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ) +endif() + +if (Garfield_FOUND) + if (NOT Garfield_FIND_QUIETLY) + message(STATUS "Found Garfield includes in ${Garfield_INCLUDE_DIRS}") + message(STATUS "Found Garfield libraries ${Garfield_LIBRARIES}") + endif (NOT Garfield_FIND_QUIETLY) +else(Garfield_FOUND) + if (Garfield_FIND_REQUIRED) + message(FATAL_ERROR "Garfield required, but not found!\ntry to run \"./scripts/installation/v2.2/installGarfield.sh\" to install it. + ") + endif (Garfield_FIND_REQUIRED) +endif(Garfield_FOUND) + +# Make variables changeble to the advanced user +mark_as_advanced(Garfield_INCLUDE_DIRS) +mark_as_advanced(Garfield_LIBRARIES) +mark_as_advanced(Garfield_LIBRARY_DIR) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake new file mode 100644 index 000000000..6855cb6f2 --- /dev/null +++ b/cmake/FindROOT.cmake @@ -0,0 +1,98 @@ +# - Finds ROOT instalation +# This module sets up ROOT information +# It defines: +# ROOT_FOUND If the ROOT is found +# ROOT_INCLUDE_DIR PATH to the include directory (deprecated) +# ROOT_INCLUDE_DIRS PATH to the include directory +# ROOT_LIBRARIES Most common libraries +# ROOT_LIBRARY_DIR PATH to the library directory +# ROOT_BIN_DIR PATH to the excutables directory +# ROOT_PYTHONVER Compatible python version string + +# First search for ROOTConfig.cmake on the path defined via user setting +# ROOT_DIR + +if (CMAKE_SYSTEM_NAME MATCHES "Windows") + + if(DEFINED ENV{ROOTSYS}) + set(ROOTSYS $ENV{ROOTSYS}) + endif() + + if(NOT ROOTSYS) + set(ROOT_FOUND FALSE) + else() + set(ROOT_FOUND TRUE) + + set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib) + set(ROOT_INCLUDE_DIRS ${ROOTSYS}/include) + set(ROOT_BIN_DIR ${ROOTSYS}/bin) + set(ROOTCINT_EXECUTABLE ${ROOTSYS}/bin/rootcint.exe) + set(GENREFLEX_EXECUTABLE ${ROOTSYS}/bin/genreflex.exe) + + set(CMAKE_FIND_LIBRARY_PREFIXES "lib") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll") + set(ROOT_LIBRARIES) + foreach(_cpt Core Imt RIO Net Hist Gui Eve RGL Gdml Geom Graf Graf3d Gpad Tree TreePlayer Rint Postscript Matrix Physics MathCore Thread MultiProc Minuit) + find_library(ROOT_${_cpt}_LIBRARY ${_cpt} HINTS ${ROOT_LIBRARY_DIR}) + if(ROOT_${_cpt}_LIBRARY) + mark_as_advanced(ROOT_${_cpt}_LIBRARY) + list(APPEND ROOT_LIBRARIES ${ROOT_${_cpt}_LIBRARY}) + endif() + endforeach() + if(ROOT_LIBRARIES) + list(REMOVE_DUPLICATES ROOT_LIBRARIES) + endif() + + endif() +else() + + find_program(ROOT_CONFIG_EXECUTABLE root-config + PATHS ${ROOTSYS}/bin $ENV{ROOTSYS}/bin) + + if(NOT ROOT_CONFIG_EXECUTABLE) + set(ROOT_FOUND FALSE) + else() + set(ROOT_FOUND TRUE) + + + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir + OUTPUT_VARIABLE ROOT_INCLUDE_DIRS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --libdir + OUTPUT_VARIABLE ROOT_LIBRARY_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + + set(ROOTCINT_EXECUTABLE $ENV{ROOTSYS}/bin/rootcint) + set(GENREFLEX_EXECUTABLE $ENV{ROOTSYS}/bin/genreflex) + + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --version + OUTPUT_VARIABLE ROOT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --libs + OUTPUT_VARIABLE ROOT_LIBRARIES + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --bindir + OUTPUT_VARIABLE ROOT_BIN_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + # Make variables changeble to the advanced user + mark_as_advanced(ROOT_CONFIG_EXECUTABLE) + endif() +endif() + + +if (NOT ROOT_FOUND) + message(FATAL_ERROR "ROOT required, but not found") +else() + message(STATUS "Find ROOT ${ROOT_VERSION} in ${ROOT_BIN_DIR}") +endif() + diff --git a/cmake/MacroRootDict.cmake b/cmake/MacroRootDict.cmake index 6fdcaa11f..8efd860d5 100644 --- a/cmake/MacroRootDict.cmake +++ b/cmake/MacroRootDict.cmake @@ -1,28 +1,29 @@ -IF (APPLE) - SET(LD_LIBRARY_PATH_VAR DYLD_LIBRARY_PATH) -ELSE () - SET(LD_LIBRARY_PATH_VAR LD_LIBRARY_PATH) -ENDIF () -SET(LD_LIBRARY_PATH_CONTENTS $ENV{${LD_LIBRARY_PATH_VAR}}) +IF(APPLE) + SET( LD_LIBRARY_PATH_VAR DYLD_LIBRARY_PATH ) +ELSE() + SET( LD_LIBRARY_PATH_VAR LD_LIBRARY_PATH ) +ENDIF() +SET( LD_LIBRARY_PATH_CONTENTS $ENV{${LD_LIBRARY_PATH_VAR}} ) #MESSAGE( STATUS "LD_LIBRARY_PATH_CONTENTS: ${LD_LIBRARY_PATH_CONTENTS}" ) -SET(ROOT_CINT_WRAPPER ${LD_LIBRARY_PATH_VAR}=${ROOT_LIBRARY_DIR}:${LD_LIBRARY_PATH_CONTENTS} ${ROOTCINT_EXECUTABLE}) +SET( ROOT_CINT_WRAPPER ${LD_LIBRARY_PATH_VAR}=${ROOT_LIBRARY_DIR}:${LD_LIBRARY_PATH_CONTENTS} ${ROOTCINT_EXECUTABLE} ) -if (CMAKE_SYSTEM_NAME MATCHES "Windows") - SET(ROOT_CINT_WRAPPER ${ROOTCINT_EXECUTABLE}) -endif () +if(CMAKE_SYSTEM_NAME MATCHES "Windows") + SET( ROOT_CINT_WRAPPER ${ROOTCINT_EXECUTABLE} ) +endif() -IF (NOT DEFINED ROOT_DICT_OUTPUT_DIR) - SET(ROOT_DICT_OUTPUT_DIR "${PROJECT_BINARY_DIR}/rootdict") -ENDIF () +IF( NOT DEFINED ROOT_DICT_OUTPUT_DIR ) + SET( ROOT_DICT_OUTPUT_DIR "${PROJECT_BINARY_DIR}/rootdict" ) +ENDIF() # clean generated header files with 'make clean' -SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${ROOT_DICT_OUTPUT_DIR}") +SET_DIRECTORY_PROPERTIES( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${ROOT_DICT_OUTPUT_DIR}" ) + +IF( NOT ROOT_FIND_QUIETLY ) + MESSAGE( STATUS "Check for ROOT_DICT_OUTPUT_DIR: ${PROJECT_BINARY_DIR}/rootdict" ) + MESSAGE( STATUS "Check for ROOT_DICT_CINT_DEFINITIONS: ${ROOT_DICT_CINT_DEFINITIONS}" ) +ENDIF() -IF (NOT ROOT_FIND_QUIETLY) - MESSAGE(STATUS "Check for ROOT_DICT_OUTPUT_DIR: ${PROJECT_BINARY_DIR}/rootdict") - MESSAGE(STATUS "Check for ROOT_DICT_CINT_DEFINITIONS: ${ROOT_DICT_CINT_DEFINITIONS}") -ENDIF () # ============================================================================ # helper macro to prepare input headers for GEN_ROOT_DICT_SOURCES @@ -36,17 +37,21 @@ ENDIF () # ${input_dir}_LinkDef.h as the last header (if found) # # ---------------------------------------------------------------------------- -MACRO(PREPARE_ROOT_DICT_HEADERS _input_dir) +MACRO( PREPARE_ROOT_DICT_HEADERS _input_dir ) + + FILE( GLOB ROOT_DICT_INPUT_HEADERS "${_input_dir}/*.h" ) + FILE( GLOB _linkdef_hdr "${_input_dir}/LinkDef.h" ) - FILE(GLOB ROOT_DICT_INPUT_HEADERS "${_input_dir}/*.h") - FILE(GLOB _linkdef_hdr "${_input_dir}/LinkDef.h") + IF( _linkdef_hdr ) + LIST( REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" ) + LIST( APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}") + ENDIF() - IF (_linkdef_hdr) - LIST(REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}") - LIST(APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}") - ENDIF () #MESSAGE( STATUS "ROOT_DICT_INPUT_HEADERS: ${ROOT_DICT_INPUT_HEADERS}" ) -ENDMACRO(PREPARE_ROOT_DICT_HEADERS) + +ENDMACRO( PREPARE_ROOT_DICT_HEADERS ) + + # ============================================================================ # helper macro to generate Linkdef.h files for rootcint @@ -60,29 +65,30 @@ ENDMACRO(PREPARE_ROOT_DICT_HEADERS) # correct order to be used by macro GEN_ROOT_DICT_SOURCES # # ---------------------------------------------------------------------------- -MACRO(GEN_ROOT_DICT_LINKDEF_HEADER _namespace) +MACRO( GEN_ROOT_DICT_LINKDEF_HEADER _namespace ) - SET(_input_headers ${ARGN}) - SET(_linkdef_header "${ROOT_DICT_OUTPUT_DIR}/${_namespace}_Linkdef.h") + SET( _input_headers ${ARGN} ) + SET( _linkdef_header "${ROOT_DICT_OUTPUT_DIR}/${_namespace}_Linkdef.h" ) - FOREACH (_header ${_input_headers}) - SET(${_namespace}_file_contents "${${_namespace}_file_contents}#ifdef __CINT__" \n) - SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all globals\;" \n) - SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all classes\;" \n) - SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all functions\;" \n) - SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ nestedclasses\;" \n) - SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ nestedclasses\;" \n) - SET(${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ class ${_namespace}+\;" \n) - SET(${_namespace}_file_contents "${${_namespace}_file_contents}#endif" \n) - ENDFOREACH () + FOREACH( _header ${_input_headers} ) + SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#ifdef __CINT__" \n ) + SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all globals\;" \n ) + SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all classes\;" \n ) + SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link off all functions\;" \n ) + SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ nestedclasses\;" \n ) + SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ nestedclasses\;" \n ) + SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#pragma link C++ class ${_namespace}+\;" \n ) + SET( ${_namespace}_file_contents "${${_namespace}_file_contents}#endif" \n ) + ENDFOREACH() - file(MAKE_DIRECTORY ${ROOT_DICT_OUTPUT_DIR}) - file(WRITE ${_linkdef_header} ${${_namespace}_file_contents}) + file(MAKE_DIRECTORY ${ROOT_DICT_OUTPUT_DIR}) + file(WRITE ${_linkdef_header} ${${_namespace}_file_contents}) - SET(ROOT_DICT_INPUT_HEADERS ${_input_headers} ${_linkdef_header}) + SET( ROOT_DICT_INPUT_HEADERS ${_input_headers} ${_linkdef_header} ) ENDMACRO() + # ============================================================================ # macro for generating root dict sources with rootcint # @@ -99,48 +105,50 @@ ENDMACRO() # returns: # ROOT_DICT_OUTPUT_SOURCES - list containing generated source and other # previously generated sources + # ---------------------------------------------------------------------------- -MACRO(GEN_ROOT_DICT_SOURCE _dict_src_filename) +MACRO( GEN_ROOT_DICT_SOURCE _dict_src_filename ) - SET(_input_depend ${ARGN}) + SET( _input_depend ${ARGN} ) # TODO check for ROOT_CINT_EXECUTABLE - file(MAKE_DIRECTORY ${ROOT_DICT_OUTPUT_DIR}) + file(MAKE_DIRECTORY ${ROOT_DICT_OUTPUT_DIR}) # need to prefix all include dirs with -I - set(_dict_includes) - FOREACH (_inc ${ROOT_DICT_INCLUDE_DIRS}) - SET(_dict_includes "${_dict_includes}\t-I${_inc}") #fg: the \t fixes a wired string expansion - ENDFOREACH () + set( _dict_includes ) + FOREACH( _inc ${ROOT_DICT_INCLUDE_DIRS} ) + SET( _dict_includes "${_dict_includes}\t-I${_inc}") #fg: the \t fixes a wired string expansion + ENDFOREACH() # We modify the list of headers to be given to ROOTCINT command. # We must remove/clean the full path from the main header - list(GET ROOT_DICT_INPUT_HEADERS 0 MAIN_HEADER) - get_filename_component(MAIN_HEADER_CLEAN ${MAIN_HEADER} NAME) - list(GET ROOT_DICT_INPUT_HEADERS 1 LINKDEF_HEADER) - set(ROOT_DICT_INPUT_HEADERS_CLEAN ${MAIN_HEADER_CLEAN} ${LINKDEF_HEADER}) - - STRING(REPLACE "/" "_" _dict_src_filename_nosc ${_dict_src_filename}) - SET(_dict_src_file ${ROOT_DICT_OUTPUT_DIR}/${_dict_src_filename_nosc}) - STRING(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" _dict_hdr_file "${_dict_src_file}") + list ( GET ROOT_DICT_INPUT_HEADERS 0 MAIN_HEADER) + get_filename_component( MAIN_HEADER_CLEAN ${MAIN_HEADER} NAME) + list ( GET ROOT_DICT_INPUT_HEADERS 1 LINKDEF_HEADER ) + set( ROOT_DICT_INPUT_HEADERS_CLEAN ${MAIN_HEADER_CLEAN} ${LINKDEF_HEADER} ) + + STRING( REPLACE "/" "_" _dict_src_filename_nosc ${_dict_src_filename} ) + SET( _dict_src_file ${ROOT_DICT_OUTPUT_DIR}/${_dict_src_filename_nosc} ) + STRING( REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" _dict_hdr_file "${_dict_src_file}" ) ADD_CUSTOM_COMMAND( - OUTPUT ${_dict_src_file} - COMMAND ${ROOT_CINT_WRAPPER} -f "${_dict_src_file}" ${_dict_includes} ${ROOT_DICT_INPUT_HEADERS_CLEAN} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - DEPENDS ${ROOT_DICT_INPUT_HEADERS} ${_input_depend} - COMMENT "generating: ${_dict_src_file} with ${ROOT_DICT_INPUT_HEADERS}" + OUTPUT ${_dict_src_file} + COMMAND ${ROOT_CINT_WRAPPER} -f "${_dict_src_file}" ${_dict_includes} ${ROOT_DICT_INPUT_HEADERS_CLEAN} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + DEPENDS ${ROOT_DICT_INPUT_HEADERS} ${_input_depend} + COMMENT "generating: ${_dict_src_file} with ${ROOT_DICT_INPUT_HEADERS}" ) - LIST(APPEND ROOT_DICT_OUTPUT_SOURCES ${_dict_src_file}) + LIST( APPEND ROOT_DICT_OUTPUT_SOURCES ${_dict_src_file} ) ENDMACRO() # for backwards compatibility -MACRO(GEN_ROOT_DICT_SOURCES _dict_src_filename) +MACRO( GEN_ROOT_DICT_SOURCES _dict_src_filename ) #MESSAGE( "USING DEPRECATED GEN_ROOT_DICT_SOURCES. PLEASE USE GEN_ROOT_DICT_SOURCE instead." ) - SET(ROOT_DICT_OUTPUT_SOURCES) - GEN_ROOT_DICT_SOURCE(${_dict_src_filename}) + SET( ROOT_DICT_OUTPUT_SOURCES ) + GEN_ROOT_DICT_SOURCE( ${_dict_src_filename} ) ENDMACRO() # ============================================================================ + # ============================================================================ # Macro to compile the whole directories into a single library # @@ -200,141 +208,144 @@ ENDMACRO() # form, set them in this argument to include them. # # ---------------------------------------------------------------------------- -MACRO(COMPILEDIR libname) +MACRO( COMPILEDIR libname ) - message(STATUS "making build files for ${CMAKE_CURRENT_SOURCE_DIR}, schema evolution: ${local_SE}") + message(STATUS "making build files for ${CMAKE_CURRENT_SOURCE_DIR}, schema evolution: ${local_SE}") # We need to define the include paths relative to the compilation directory - set(REAL_SOURCE_DIR "${CMAKE_SOURCE_DIR}/source") - string(REPLACE ${REAL_SOURCE_DIR} "" RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}) + set ( REAL_SOURCE_DIR "${CMAKE_SOURCE_DIR}/source" ) + string( REPLACE ${REAL_SOURCE_DIR} "" RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ) set(RELATIVE_PATH "..${RELATIVE}") - set(contentfiles) - - if (DEFINED contents) - message("specified sub-dirs: ${contents}") - foreach (content ${contents}) - set(local_include_dirs ${local_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR}/${content} ${CMAKE_CURRENT_SOURCE_DIR}/${content}/inc) - endforeach (content) - set(local_include_dirs ${local_include_dirs} PARENT_SCOPE) - - foreach (content ${contents}) - file(GLOB_RECURSE files ${content}/*.cxx) - foreach (file ${files}) - - string(REGEX MATCH "[^/\\]*cxx" temp ${file}) - string(REPLACE ".cxx" "" class ${temp}) - - set(SKIP "FALSE") - if (DEFINED excludes) - foreach (exclude ${excludes}) - if ("${exclude}" STREQUAL "${class}") - set(SKIP "TRUE") - # message( STATUS "Skipping ${class}" ) - endif () - endforeach (exclude) - endif () - - if (${SKIP} STREQUAL "FALSE") - set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - if (NOT header) - message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") - else () - set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - if (${SCHEMA_EVOLUTION} MATCHES "ON") - GEN_ROOT_DICT_LINKDEF_HEADER(${class} ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - else () - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) - endif () - - set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) - endif () - endif (${SKIP} STREQUAL "FALSE") - - endforeach (file) - # message( STATUS "contentfiles: ${contentfiles}" ) - endforeach (content) - else () - message("using inc/src folders in root directory") - set(local_include_dirs ${local_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) - set(local_include_dirs ${local_include_dirs} PARENT_SCOPE) - - file(GLOB_RECURSE files src/*.cxx) - foreach (file ${files}) - string(REGEX MATCH "[^/\\]*cxx" temp ${file}) - string(REPLACE ".cxx" "" class ${temp}) - - set(SKIP "FALSE") - if (DEFINED excludes) - # message ( STATUS "EXCLUDES: ${excludes}" ) - foreach (exclude ${excludes}) - if ("${exclude}" STREQUAL "${class}") - set(SKIP "TRUE") - # message( STATUS "Skipping ${class}" ) - endif () - endforeach (exclude) - endif () - - if (${SKIP} STREQUAL "FALSE") - set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - if (NOT header) - message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") - else () - set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - if (${SCHEMA_EVOLUTION} MATCHES "ON") - GEN_ROOT_DICT_LINKDEF_HEADER(${class} ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - else () - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) - endif () - set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) - endif () - endif (${SKIP} STREQUAL "FALSE") - endforeach (file) - endif () - - - foreach (src ${addon_CINT}) - string(REGEX MATCH "[^/\\]+$" filename ${src}) - set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) - set(ROOT_DICT_INPUT_HEADERS ${src}) - GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) - set(contentfiles ${contentfiles} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) - endforeach (src) - - include_directories(${local_include_dirs}) - add_library(${libname} SHARED ${contentfiles} ${addon_src}) - - if (CMAKE_SYSTEM_NAME MATCHES "Windows") - set_target_properties(${libname} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - target_link_libraries(${libname} ${local_libraries} ${external_libs}) - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION bin - ARCHIVE DESTINATION lib) - else () - target_link_libraries(${libname} ${local_libraries} ${external_libs}) - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static) - endif () - set(local_libraries ${local_libraries} ${libname}) - set(local_libraries ${local_libraries} PARENT_SCOPE) + set(contentfiles) + + if(DEFINED contents) + message("specified sub-dirs: ${contents}") + foreach(content ${contents}) + set(local_include_dirs ${local_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR}/${content} ${CMAKE_CURRENT_SOURCE_DIR}/${content}/inc) + endforeach(content) + set(local_include_dirs ${local_include_dirs} PARENT_SCOPE) + + foreach(content ${contents}) + file(GLOB_RECURSE files ${content}/*.cxx) + foreach (file ${files}) + + string(REGEX MATCH "[^/\\]*cxx" temp ${file}) + string(REPLACE ".cxx" "" class ${temp}) + + set ( SKIP "FALSE" ) + if(DEFINED excludes) + foreach(exclude ${excludes}) + if ( "${exclude}" STREQUAL "${class}" ) + set ( SKIP "TRUE" ) + # message( STATUS "Skipping ${class}" ) + endif() + endforeach(exclude) + endif() + + if( ${SKIP} STREQUAL "FALSE" ) + set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) + file(GLOB_RECURSE header ${class}.h) + if(NOT header) + message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") + else() + set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + if(${SCHEMA_EVOLUTION} MATCHES "ON") + GEN_ROOT_DICT_LINKDEF_HEADER( ${class} ${header}) + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + else() + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) + endif() + + set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) + endif() + endif( ${SKIP} STREQUAL "FALSE" ) + + endforeach (file) + + # message( STATUS "contentfiles: ${contentfiles}" ) + endforeach(content) + else() + message("using inc/src folders in root directory") + set(local_include_dirs ${local_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) + set(local_include_dirs ${local_include_dirs} PARENT_SCOPE) + + file(GLOB_RECURSE files src/*.cxx) + foreach (file ${files}) + string(REGEX MATCH "[^/\\]*cxx" temp ${file}) + string(REPLACE ".cxx" "" class ${temp}) + + set ( SKIP "FALSE" ) + if(DEFINED excludes) + # message ( STATUS "EXCLUDES: ${excludes}" ) + foreach(exclude ${excludes}) + if ( "${exclude}" STREQUAL "${class}" ) + set ( SKIP "TRUE" ) + # message( STATUS "Skipping ${class}" ) + endif() + endforeach(exclude) + endif() + + if( ${SKIP} STREQUAL "FALSE" ) + set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) + file(GLOB_RECURSE header ${class}.h) + if(NOT header) + message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") + else() + set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + if(${SCHEMA_EVOLUTION} MATCHES "ON") + GEN_ROOT_DICT_LINKDEF_HEADER( ${class} ${header}) + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + else() + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) + endif() + + set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) + endif() + endif( ${SKIP} STREQUAL "FALSE" ) + endforeach (file) + endif() + + + foreach(src ${addon_CINT}) + string(REGEX MATCH "[^/\\]+$" filename ${src}) + set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs}) + set(ROOT_DICT_INPUT_HEADERS ${src}) + GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) + set(contentfiles ${contentfiles} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) + endforeach(src) + + include_directories(${local_include_dirs}) + add_library(${libname} SHARED ${contentfiles} ${addon_src}) + + + if(CMAKE_SYSTEM_NAME MATCHES "Windows") + set_target_properties(${libname} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + target_link_libraries(${libname} ${local_libraries} ${external_libs}) + install(TARGETS ${libname} + RUNTIME DESTINATION bin + LIBRARY DESTINATION bin + ARCHIVE DESTINATION lib) + else() + target_link_libraries(${libname} ${local_libraries} ${external_libs}) + install(TARGETS ${libname} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static) + endif() + set(local_libraries ${local_libraries} ${libname}) + set(local_libraries ${local_libraries} PARENT_SCOPE) ENDMACRO() 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}) + 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() # ============================================================================ @@ -342,10 +353,10 @@ ENDMACRO() # e.g. axion --> RestAxion # e.g. detector --> RestDetector MACRO(DIRNAME2LIBNAME result dirname) - string(SUBSTRING ${dirname} 0 1 firstletter) - string(TOUPPER ${firstletter} firstlettercapital) - string(SUBSTRING ${dirname} 1 -1 remainingletter) - set(${result} "Rest${firstlettercapital}${remainingletter}") + string(SUBSTRING ${dirname} 0 1 firstletter) + string(TOUPPER ${firstletter} firstlettercapital) + string(SUBSTRING ${dirname} 1 -1 remainingletter) + set(${result} "Rest${firstlettercapital}${remainingletter}") ENDMACRO() # ============================================================================ @@ -356,20 +367,21 @@ ENDMACRO() # result: the converted option string. Will be empty if error # dirname: the relative path from CMAKE_CURRENT_SOURCE_DIR to the target dir macro(DIRNAME2OPTION result dirname) - set(${result} "") - if (${dirname} MATCHES "libraries/") - string(REPLACE "libraries/" "" purename ${dirname}) - string(TOUPPER ${purename} uppername) - set(${result} "RESTLIB_${uppername}") - endif () - - if (${dirname} MATCHES "packages/") - string(REPLACE "packages/rest" "" purename ${dirname}) - set(${result} "REST_${purename}") - endif () + set(${result} "") + if(${dirname} MATCHES "libraries/") + string(REPLACE "libraries/" "" purename ${dirname}) + string(TOUPPER ${purename} uppername) + set(${result} "RESTLIB_${uppername}") + endif() + + if(${dirname} MATCHES "packages/") + string(REPLACE "packages/rest" "" purename ${dirname}) + set(${result} "REST_${purename}") + endif() ENDMACRO() + # ============================================================================ # Macro to compile REST libraries sub-dir into a single library # @@ -419,94 +431,94 @@ ENDMACRO() # form, set them in this argument to include them. # # ---------------------------------------------------------------------------- -MACRO(COMPILELIB dependency) - - string(REGEX MATCH "[^/\\]*$" puredirname ${CMAKE_CURRENT_SOURCE_DIR}) - DIRNAME2LIBNAME(libname ${puredirname}) - - message(STATUS "making build files in ${CMAKE_CURRENT_SOURCE_DIR}, dependency: ${${dependency}}") - - set(files_cxx) - set(files_to_compile_cxx) - set(files_to_compile_cint) - set(dirs_to_include ${rest_framework_include_dirs}) - set(libs_to_link ${rest_framework_libraries}) - - # check dependency - foreach (dep ${${dependency}}) - set(dirs_to_include ${dirs_to_include} "${CMAKE_CURRENT_SOURCE_DIR}/../${dep}/inc") - DIRNAME2LIBNAME(deplibname ${dep}) - set(libs_to_link ${libs_to_link} ${deplibname}) - endforeach () - - # include dir - set(dirs_to_include ${dirs_to_include} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) - - # generate CINT files - file(GLOB_RECURSE files_cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cxx) - foreach (file ${files_cxx}) - string(REGEX MATCH "[^/\\]*cxx$" temp ${file}) # get pure file name - string(REPLACE ".cxx" "" class ${temp}) # get file name without extension, i.e. class name - - set(SKIP "FALSE") - if (DEFINED excludes) - foreach (exclude ${excludes}) - if ("${exclude}" STREQUAL "${class}") - set(SKIP "TRUE") - # message( STATUS "Skipping ${class}" ) - endif () - endforeach (exclude) - endif () - - if (${SKIP} STREQUAL "FALSE") - set(ROOT_DICT_INCLUDE_DIRS ${dirs_to_include} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - if (NOT header) - message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") - else () - set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - if (${SCHEMA_EVOLUTION} MATCHES "ON") - GEN_ROOT_DICT_LINKDEF_HEADER(${class} ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - else () - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) - endif () - - set(files_to_compile_cxx ${files_to_compile_cxx} ${file}) - set(files_to_compile_cint ${files_to_compile_cint} ${ROOT_DICT_OUTPUT_SOURCES}) - endif () - endif (${SKIP} STREQUAL "FALSE") - endforeach (file) - - foreach (src ${addon_CINT}) - string(REGEX MATCH "[^/\\]+$" filename ${src}) - set(ROOT_DICT_INCLUDE_DIRS ${dirs_to_include} ${external_include_dirs}) - set(ROOT_DICT_INPUT_HEADERS ${src}) - GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) - set(files_to_compile ${files_to_compile} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) - endforeach (src) - - list(LENGTH files_cxx Nfiles_cxx) - list(LENGTH files_to_compile_cint Nfiles_cint) - list(LENGTH addon_src Nfiles_add) - - message(STATUS "${Nfiles_cxx} source files in total, ${Nfiles_cint} classes to generete, ${Nfiles_add} additional source files") - - # start compile - include_directories(${dirs_to_include} ${external_include_dirs}) - add_library(${libname} SHARED ${files_to_compile_cxx} ${files_to_compile_cint} ${addon_src}) - target_link_libraries(${libname} ${libs_to_link} ${external_libs}) - - # install - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static) - - file(GLOB_RECURSE Headers "${CMAKE_CURRENT_SOURCE_DIR}/inc/*.h") - INSTALL(FILES ${Headers} DESTINATION include) - - set(dirs_included ${dirs_to_include} PARENT_SCOPE) - set(library_added ${libname}) - set(library_added ${library_added} PARENT_SCOPE) -ENDMACRO() +MACRO( COMPILELIB dependency) + + string(REGEX MATCH "[^/\\]*$" puredirname ${CMAKE_CURRENT_SOURCE_DIR}) + DIRNAME2LIBNAME(libname ${puredirname}) + + message(STATUS "making build files in ${CMAKE_CURRENT_SOURCE_DIR}, dependency: ${${dependency}}") + + set(files_cxx) + set(files_to_compile_cxx) + set(files_to_compile_cint) + set(dirs_to_include ${rest_framework_include_dirs}) + set(libs_to_link ${rest_framework_libraries}) + + # check dependency + foreach(dep ${${dependency}}) + set(dirs_to_include ${dirs_to_include} "${CMAKE_CURRENT_SOURCE_DIR}/../${dep}/inc") + DIRNAME2LIBNAME(deplibname ${dep}) + set(libs_to_link ${libs_to_link} ${deplibname}) + endforeach() + + # include dir + set(dirs_to_include ${dirs_to_include} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) + + # generate CINT files + file(GLOB_RECURSE files_cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cxx) + foreach (file ${files_cxx}) + string(REGEX MATCH "[^/\\]*cxx$" temp ${file}) # get pure file name + string(REPLACE ".cxx" "" class ${temp}) # get file name without extension, i.e. class name + + set ( SKIP "FALSE" ) + if(DEFINED excludes) + foreach(exclude ${excludes}) + if ( "${exclude}" STREQUAL "${class}" ) + set ( SKIP "TRUE" ) + # message( STATUS "Skipping ${class}" ) + endif() + endforeach(exclude) + endif() + + if( ${SKIP} STREQUAL "FALSE" ) + set(ROOT_DICT_INCLUDE_DIRS ${dirs_to_include} ${external_include_dirs}) + file(GLOB_RECURSE header ${class}.h) + if(NOT header) + message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()") + else() + set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + if(${SCHEMA_EVOLUTION} MATCHES "ON") + GEN_ROOT_DICT_LINKDEF_HEADER( ${class} ${header}) + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + else() + GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) + endif() + + set(files_to_compile_cxx ${files_to_compile_cxx} ${file}) + set(files_to_compile_cint ${files_to_compile_cint} ${ROOT_DICT_OUTPUT_SOURCES}) + endif() + endif( ${SKIP} STREQUAL "FALSE" ) + endforeach (file) + + foreach(src ${addon_CINT}) + string(REGEX MATCH "[^/\\]+$" filename ${src}) + set(ROOT_DICT_INCLUDE_DIRS ${dirs_to_include} ${external_include_dirs}) + set(ROOT_DICT_INPUT_HEADERS ${src}) + GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) + set(files_to_compile ${files_to_compile} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) + endforeach(src) + + list(LENGTH files_cxx Nfiles_cxx) + list(LENGTH files_to_compile_cint Nfiles_cint) + list(LENGTH addon_src Nfiles_add) + + message(STATUS "${Nfiles_cxx} source files in total, ${Nfiles_cint} classes to generete, ${Nfiles_add} additional source files") + + # start compile + include_directories(${dirs_to_include} ${external_include_dirs}) + add_library(${libname} SHARED ${files_to_compile_cxx} ${files_to_compile_cint} ${addon_src}) + target_link_libraries(${libname} ${libs_to_link} ${external_libs}) + + # install + install(TARGETS ${libname} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static) + + file(GLOB_RECURSE Headers "${CMAKE_CURRENT_SOURCE_DIR}/inc/*.h") + INSTALL(FILES ${Headers} DESTINATION include) + + set(dirs_included ${dirs_to_include} PARENT_SCOPE) + set(library_added ${libname}) + set(library_added ${library_added} PARENT_SCOPE) +ENDMACRO() \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index f788b4b10..433ed717d 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -5,9 +5,6 @@ set(rest_macros) set(rest_macros_str) add_subdirectory(framework) - -return() - add_subdirectory(../macros tasks.out) set(rest_framework_include_dirs ${local_include_dirs}) @@ -33,76 +30,76 @@ add_subdirectory(bin) # clear the cache first SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/libraries") -foreach (subdir ${subdirs}) - DIRNAME2LIBNAME(libname ${subdir}) - set("${libname}_COMPILED" "FALSE") -endforeach () +foreach(subdir ${subdirs}) + DIRNAME2LIBNAME(libname ${subdir}) + set("${libname}_COMPILED" "FALSE") +endforeach() # loop all the dirs and set the option set(dirs "libraries" "packages") -foreach (dir ${dirs}) - SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") - foreach (subdir ${subdirs}) - set(fullname "${dir}/${subdir}") - DIRNAME2OPTION(option ${fullname}) - - file(GLOB ff "*/${subdir}/CMakeLists.txt") - if (ff) # if dir not empty, set the option to ON - if (NOT DEFINED ${option}) - IF (${REST_ALL_LIBS} MATCHES "ON") - set(${option} ON) - else () - set(${option} OFF) - endif () - endif () - message("Submodule found: ${fullname}. Option: ${option}=${${option}}") - else () - set(${option} OFF) - message("Empty submodule dir: ${fullname}. Option: ${option}=${${option}}") - endif () - endforeach () -endforeach () - -if (${REST_G4} MATCHES ON) - set(RESTLIB_GEANT4 ON) -endif () - -if (${RESTLIB_DETECTOR} MATCHES ON) - if (${RESTLIB_RAW} MATCHES ON) - set(RESTLIB_CONNECTORS ON) - endif () -endif () +foreach(dir ${dirs}) + SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") + foreach(subdir ${subdirs}) + set(fullname "${dir}/${subdir}") + DIRNAME2OPTION(option ${fullname}) + + file(GLOB ff "*/${subdir}/CMakeLists.txt") + if(ff) # if dir not empty, set the option to ON + if (NOT DEFINED ${option}) + IF(${REST_ALL_LIBS} MATCHES "ON") + set(${option} ON) + else() + set(${option} OFF) + endif() + endif() + message("Submodule found: ${fullname}. Option: ${option}=${${option}}") + else() + set(${option} OFF) + message("Empty submodule dir: ${fullname}. Option: ${option}=${${option}}") + endif() + endforeach() +endforeach() + +if( ${REST_G4} MATCHES ON ) + set( RESTLIB_GEANT4 ON ) +endif() + +if( ${RESTLIB_DETECTOR} MATCHES ON ) + if( ${RESTLIB_RAW} MATCHES ON) + set( RESTLIB_CONNECTORS ON ) + endif() +endif() # loop all the dirs and compile if option is ON -foreach (dir ${dirs}) - SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") - foreach (subdir ${subdirs}) - set(fullname "${dir}/${subdir}") - DIRNAME2OPTION(option ${fullname}) - - if (${${option}} MATCHES "ON") - add_subdirectory(${fullname}) - set(rest_include_dirs ${rest_include_dirs} ${dirs_included}) - set(rest_libraries ${rest_libraries} ${library_added}) - set(rest_packages ${rest_packages} ${package_added}) - set(rest_features ${rest_features} ${feature_added}) - endif () - endforeach () -endforeach () +foreach(dir ${dirs}) + SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") + foreach(subdir ${subdirs}) + set(fullname "${dir}/${subdir}") + DIRNAME2OPTION(option ${fullname}) + + if(${${option}} MATCHES "ON") + add_subdirectory(${fullname}) + set(rest_include_dirs ${rest_include_dirs} ${dirs_included}) + set(rest_libraries ${rest_libraries} ${library_added}) + set(rest_packages ${rest_packages} ${package_added}) + set(rest_features ${rest_features} ${feature_added}) + endif() + endforeach() +endforeach() # remove duplicates -if (DEFINED rest_include_dirs) - list(REMOVE_DUPLICATES rest_include_dirs) -endif () -if (DEFINED rest_libraries) - list(REMOVE_DUPLICATES rest_libraries) -endif () -if (DEFINED rest_packages) - list(REMOVE_DUPLICATES rest_packages) -endif () -if (DEFINED rest_features) - list(REMOVE_DUPLICATES rest_features) -endif () +if(DEFINED rest_include_dirs) + list(REMOVE_DUPLICATES rest_include_dirs) +endif() +if(DEFINED rest_libraries) + list(REMOVE_DUPLICATES rest_libraries) +endif() +if(DEFINED rest_packages) + list(REMOVE_DUPLICATES rest_packages) +endif() +if(DEFINED rest_features) + list(REMOVE_DUPLICATES rest_features) +endif() # set REST compilation flags to main cmake set(rest_include_dirs ${rest_include_dirs} PARENT_SCOPE) @@ -111,16 +108,16 @@ set(rest_packages ${rest_packages} PARENT_SCOPE) set(rest_features ${rest_features} PARENT_SCOPE) set(rest_libraries_regular "-L${CMAKE_INSTALL_PREFIX}/lib ") -foreach (lib ${rest_libraries}) - set(rest_libraries_regular "${rest_libraries_regular} -l${lib} ") -endforeach (lib) +foreach(lib ${rest_libraries}) + set(rest_libraries_regular "${rest_libraries_regular} -l${lib} ") +endforeach(lib) set(rest_libraries_regular ${rest_libraries_regular} PARENT_SCOPE) set(rest_exes ${rest_exes} PARENT_SCOPE) set(rest_macros ${rest_macros} PARENT_SCOPE) -# construct REST macros string (separate with blank) +# construct REST macros string(separate with blank) set(rest_macros_str) -foreach (mac ${rest_macros}) +foreach(mac ${rest_macros}) set(rest_macros_str "${rest_macros_str}${mac} ") -endforeach (mac ${rest_macros}) +endforeach(mac ${rest_macros}) set(rest_macros_str ${rest_macros_str} PARENT_SCOPE) diff --git a/source/framework/CMakeLists.txt b/source/framework/CMakeLists.txt index b72e5a214..50f36a7bf 100644 --- a/source/framework/CMakeLists.txt +++ b/source/framework/CMakeLists.txt @@ -1,26 +1,11 @@ -add_subdirectory(external) - set(contents external/tinyxml tools core analysis) file(GLOB_RECURSE addon_src - "tiny*cpp" - "startup.cpp") + "tiny*cpp" + "startup.cpp") if (NOT ${REST_EVE} MATCHES "ON") - set(excludes TRestEveEventViewer) + set( excludes TRestEveEventViewer) endif (NOT ${REST_EVE} MATCHES "ON") COMPILEDIR(RestFramework) - -# Setup testing for all framework -if (NOT DEFINED TEST OR NOT TEST) - set(TEST OFF) - message(STATUS "Testing disabled (Disabled by default, enabled via -DTEST=ON flag)") -endif () -if (TEST) - message(STATUS "Testing enabled (Disabled by default, enabled via -DTEST=ON flag)") - enable_testing() -endif () - -# Add framework tests -ADD_TEST() From a67220847be262f4275ebf3f7d6729229fca1d50 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 9 Feb 2022 10:14:27 +0100 Subject: [PATCH 07/61] updated image --- .gitlab-ci.yml | 90 +++++++++++++------------- cmake/{AddTest.cmake => Testing.cmake} | 0 2 files changed, 45 insertions(+), 45 deletions(-) rename cmake/{AddTest.cmake => Testing.cmake} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d62d1b4de..31a20e659 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,50 +1,50 @@ -#image: lobis/root-geant4-garfieldpp:cxx14_ROOTv6-25-01_Geant4v10.4.3 -image: nkx1231/root6-geant4-garfield:0.6 +image: ghcr.io/lobis/root-geant4-garfield:cpp17_ROOT-v6-25-01_Geant4-v10.4.3_Garfield-4.0 +# image: nkx1231/root6-geant4-garfield:0.6 variables: # GIT_SUBMODULE_STRATEGY: recursive stages: - # Basic checks to verify correctness of code + # Basic checks to verify correctness of code - pre-build - # Project compilation validation + # Project compilation validation - build - # REST libraries installed as sub-modules + # REST libraries installed as sub-modules - libraries - # Basic validation tests of installation + # Basic validation tests of installation - install - # Basic core validation tests + # Basic core validation tests - core - # Stage dedicated to validate metadata classes. gas, readout, g4Metadata, etc + # Stage dedicated to validate metadata classes. gas, readout, g4Metadata, etc - metadata - # Stage to validate restG4 package examples + # Stage to validate restG4 package examples - restG4 - # Stage to validate data chain processing constructions (TREX-DM data, PandaX-III topology, etc). + # Stage to validate data chain processing constructions (TREX-DM data, PandaX-III topology, etc). - restManager_process - # Stage to validate tasks or executions over preprocessed data filesx + # Stage to validate tasks or executions over preprocessed data filesx - postProcessing - # Stage to validate other restManager tasks (metadata generation, script loading, etc). + # Stage to validate other restManager tasks (metadata generation, script loading, etc). - restManager_generate - # Scripts to launch more complete tests. TRestGas file generation, Geant4 physics validation, etc. + # Scripts to launch more complete tests. TRestGas file generation, Geant4 physics validation, etc. - deploy before_script: - pwd - export USER="test" - # - export GIT_SSL_NO_VERIFY=1 + # - export GIT_SSL_NO_VERIFY=1 - echo $CI_SERVER_HOST - echo $CRONJOB - # We redefine the HOME + # We redefine the HOME - export HOME=${CI_PROJECT_DIR}/install_latest/ - if [ -d $HOME/.rest ]; then rm -Rf $HOME/.rest; fi - if [ -f "/opt/root/install/bin/thisroot.sh" ]; then source /opt/root/install/bin/thisroot.sh; fi @@ -73,11 +73,11 @@ clang-format: - $CRONJOB == "YES" validateCode: - stage: pre-build - script: - - cd ${CI_PROJECT_DIR}/ - - python3 pull-submodules.py --force --dontask - - python3 pipeline/validateProcesses.py source/libraries/ + stage: pre-build + script: + - cd ${CI_PROJECT_DIR}/ + - python3 pull-submodules.py --force --dontask + - python3 pipeline/validateProcesses.py source/libraries/ #axionLib: # stage: libraries @@ -124,19 +124,19 @@ build_latest: - if [ -d ${CI_PROJECT_DIR}/install_latest ]; then rm -Rf ${CI_PROJECT_DIR}/install_latest; fi - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install_latest - make install -j2 - # - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + # - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh artifacts: paths: - ${CI_PROJECT_DIR}/install_latest expire_in: 1 day - #build_latest_root622_geant4v1042: - # image: lobis/root-geant4-garfieldpp:cxx14_ROOTv6-22-08_Geant4v10.4.2 - # type: build - # script: - # - cd ${CI_PROJECT_DIR}/ - # - python3 pull-submodules.py --force --dontask --latest - # - if [ -d ${CI_PROJECT_DIR}/build_latest2 ]; then rm -Rf ${CI_PROJECT_DIR}/build_latest2; fi + #build_latest_root622_geant4v1042: + # image: lobis/root-geant4-garfieldpp:cxx14_ROOTv6-22-08_Geant4v10.4.2 + # type: build + # script: + # - cd ${CI_PROJECT_DIR}/ + # - python3 pull-submodules.py --force --dontask --latest + # - if [ -d ${CI_PROJECT_DIR}/build_latest2 ]; then rm -Rf ${CI_PROJECT_DIR}/build_latest2; fi # - mkdir ${CI_PROJECT_DIR}/build_latest2 && cd ${CI_PROJECT_DIR}/build_latest2/ # - if [ -d ${CI_PROJECT_DIR}/install_latest2 ]; then rm -Rf ${CI_PROJECT_DIR}/install_latest2; fi # - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install_latest2 @@ -144,7 +144,7 @@ build_latest: # - . ${CI_PROJECT_DIR}/install_latest2/thisREST.sh # except: # variables: - # - $CRONJOB == "YES" + # - $CRONJOB == "YES" #build_nkx: # image: nkx1231/root6-geant4-garfield:0.6 @@ -202,24 +202,24 @@ listRESTMacros: expire_in: 1 day LoadGas: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/gas/ - restRoot -b -q LoadGasFromServerAndValidate.C only: - variables: - - $CI_SERVER_HOST == "lfna.unizar.es" + variables: + - $CI_SERVER_HOST == "lfna.unizar.es" GenerateGas: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/gas/ - restRoot -b -q GenerateDummyGas.C only: - variables: - - $CI_SERVER_HOST == "lfna.unizar.es" + variables: + - $CI_SERVER_HOST == "lfna.unizar.es" AnalysisTree: type: core @@ -229,17 +229,17 @@ AnalysisTree: - restRoot -b -q simpleTree.cpp GenerateReadout: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/readout/ - restManager --c generateReadout.rml --o readout.root - restRoot -b -q PrintReadout.C'("readout.root")' > /dev/null # We need to introduce basic validation here - # - diff validation.txt print.txt + # - diff validation.txt print.txt BasicReadout: - type: metadata + type: metadata script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - cd ${CI_PROJECT_DIR}/projects/basic-readouts/ @@ -260,7 +260,7 @@ testMeta: - ${CI_PROJECT_DIR}/install_latest/examples/meta.root expire_in: 1 day -trexDM_data_latest: +trexDM_data_latest: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -279,7 +279,7 @@ trexDM_data_latest: - ${CI_PROJECT_DIR}/pipeline/trex/Hits_01928.root expire_in: 1 day -pandaXIII_Topological: +pandaXIII_Topological: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -293,7 +293,7 @@ pandaXIII_Topological: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/trackParameter.png expire_in: 1 week -pandaXIII_Topological_fromG4: +pandaXIII_Topological_fromG4: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -307,7 +307,7 @@ pandaXIII_Topological_fromG4: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/testOutput.root expire_in: 1 week -pandaXIII_data: +pandaXIII_data: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -319,8 +319,8 @@ pandaXIII_data: paths: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_data/TriggerRate.png expire_in: 1 week - -EventSelection: + +EventSelection: type: restManager_process script: - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh @@ -328,7 +328,7 @@ EventSelection: - restManager --c g4Analysis.rml --f "${CI_PROJECT_DIR}/install_latest/examples/restG4/01.NLDBD/Run00001_NLDBD_Test.root" - restManager --c g4OnSelection.rml --f Run00001_NLDBD_Test_g4Analysis.root - restRoot -b -q Validate.C'("Run00001_NLDBD_Test_EvSelection.root")' - + artifacts: paths: - ${CI_PROJECT_DIR}/pipeline/selection/IDs.txt diff --git a/cmake/AddTest.cmake b/cmake/Testing.cmake similarity index 100% rename from cmake/AddTest.cmake rename to cmake/Testing.cmake From 6446b825bdc03f1c91c6c7897626fe209c1c2522 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 9 Feb 2022 10:16:19 +0100 Subject: [PATCH 08/61] updated cmake --- CMakeLists.txt | 7 ++++++- source/framework/CMakeLists.txt | 8 +++++--- source/framework/tools/CMakeLists.txt | 0 3 files changed, 11 insertions(+), 4 deletions(-) delete mode 100644 source/framework/tools/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index a047571b3..d02033a39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ -PROJECT(REST) +PROJECT(REST LANGUAGES CXX HOMEPAGE_URL https://github.com/rest-for-physics/framework) + CMAKE_MINIMUM_REQUIRED(VERSION 3.5) # Minimum compiler version @@ -115,6 +116,10 @@ message(STATUS "external libraries to link: " ${external_libs}) # Gather some information string(TIMESTAMP date "%Y-%m-%d %H:%M") +# Enable testing (-DTEST=ON flag) +include(Testing) +ENABLE_TESTING_CONDITIONALLY() + # Start compile include(MacroRootDict) add_subdirectory(source) diff --git a/source/framework/CMakeLists.txt b/source/framework/CMakeLists.txt index 50f36a7bf..5f2f8b8f7 100644 --- a/source/framework/CMakeLists.txt +++ b/source/framework/CMakeLists.txt @@ -1,11 +1,13 @@ +add_subdirectory(external) + set(contents external/tinyxml tools core analysis) file(GLOB_RECURSE addon_src - "tiny*cpp" - "startup.cpp") + "tiny*cpp" + "startup.cpp") if (NOT ${REST_EVE} MATCHES "ON") - set( excludes TRestEveEventViewer) + set(excludes TRestEveEventViewer) endif (NOT ${REST_EVE} MATCHES "ON") COMPILEDIR(RestFramework) diff --git a/source/framework/tools/CMakeLists.txt b/source/framework/tools/CMakeLists.txt deleted file mode 100644 index e69de29bb..000000000 From d85d5509119000d5638d94cb9ea5e1a4efa4fb62 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 9 Feb 2022 10:22:48 +0100 Subject: [PATCH 09/61] formatting cmake, added testing macro --- cmake/Testing.cmake | 11 ++++ source/CMakeLists.txt | 136 +++++++++++++++++++++--------------------- 2 files changed, 79 insertions(+), 68 deletions(-) diff --git a/cmake/Testing.cmake b/cmake/Testing.cmake index 34715b399..43e164049 100644 --- a/cmake/Testing.cmake +++ b/cmake/Testing.cmake @@ -1,3 +1,14 @@ +macro(ENABLE_TESTING_CONDITIONALLY) + if (NOT DEFINED TEST OR NOT TEST) + set(TEST OFF) + message(STATUS "Testing disabled (Disabled by default, enabled via -DTEST=ON flag)") + endif () + if (TEST) + message(STATUS "Testing enabled (Disabled by default, enabled via -DTEST=ON flag)") + enable_testing() + endif () +endmacro() + macro(ADD_TEST) if (TEST) message(STATUS "Adding tests at ${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 433ed717d..d487a9360 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -30,76 +30,76 @@ add_subdirectory(bin) # clear the cache first SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/libraries") -foreach(subdir ${subdirs}) - DIRNAME2LIBNAME(libname ${subdir}) - set("${libname}_COMPILED" "FALSE") -endforeach() +foreach (subdir ${subdirs}) + DIRNAME2LIBNAME(libname ${subdir}) + set("${libname}_COMPILED" "FALSE") +endforeach () # loop all the dirs and set the option set(dirs "libraries" "packages") -foreach(dir ${dirs}) - SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") - foreach(subdir ${subdirs}) - set(fullname "${dir}/${subdir}") - DIRNAME2OPTION(option ${fullname}) - - file(GLOB ff "*/${subdir}/CMakeLists.txt") - if(ff) # if dir not empty, set the option to ON - if (NOT DEFINED ${option}) - IF(${REST_ALL_LIBS} MATCHES "ON") - set(${option} ON) - else() - set(${option} OFF) - endif() - endif() - message("Submodule found: ${fullname}. Option: ${option}=${${option}}") - else() - set(${option} OFF) - message("Empty submodule dir: ${fullname}. Option: ${option}=${${option}}") - endif() - endforeach() -endforeach() - -if( ${REST_G4} MATCHES ON ) - set( RESTLIB_GEANT4 ON ) -endif() - -if( ${RESTLIB_DETECTOR} MATCHES ON ) - if( ${RESTLIB_RAW} MATCHES ON) - set( RESTLIB_CONNECTORS ON ) - endif() -endif() +foreach (dir ${dirs}) + SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") + foreach (subdir ${subdirs}) + set(fullname "${dir}/${subdir}") + DIRNAME2OPTION(option ${fullname}) + + file(GLOB ff "*/${subdir}/CMakeLists.txt") + if (ff) # if dir not empty, set the option to ON + if (NOT DEFINED ${option}) + IF (${REST_ALL_LIBS} MATCHES "ON") + set(${option} ON) + else () + set(${option} OFF) + endif () + endif () + message("Submodule found: ${fullname}. Option: ${option}=${${option}}") + else () + set(${option} OFF) + message("Empty submodule dir: ${fullname}. Option: ${option}=${${option}}") + endif () + endforeach () +endforeach () + +if (${REST_G4} MATCHES ON) + set(RESTLIB_GEANT4 ON) +endif () + +if (${RESTLIB_DETECTOR} MATCHES ON) + if (${RESTLIB_RAW} MATCHES ON) + set(RESTLIB_CONNECTORS ON) + endif () +endif () # loop all the dirs and compile if option is ON -foreach(dir ${dirs}) - SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") - foreach(subdir ${subdirs}) - set(fullname "${dir}/${subdir}") - DIRNAME2OPTION(option ${fullname}) - - if(${${option}} MATCHES "ON") - add_subdirectory(${fullname}) - set(rest_include_dirs ${rest_include_dirs} ${dirs_included}) - set(rest_libraries ${rest_libraries} ${library_added}) - set(rest_packages ${rest_packages} ${package_added}) - set(rest_features ${rest_features} ${feature_added}) - endif() - endforeach() -endforeach() +foreach (dir ${dirs}) + SUBDIRLIST(subdirs "${CMAKE_CURRENT_SOURCE_DIR}/${dir}") + foreach (subdir ${subdirs}) + set(fullname "${dir}/${subdir}") + DIRNAME2OPTION(option ${fullname}) + + if (${${option}} MATCHES "ON") + add_subdirectory(${fullname}) + set(rest_include_dirs ${rest_include_dirs} ${dirs_included}) + set(rest_libraries ${rest_libraries} ${library_added}) + set(rest_packages ${rest_packages} ${package_added}) + set(rest_features ${rest_features} ${feature_added}) + endif () + endforeach () +endforeach () # remove duplicates -if(DEFINED rest_include_dirs) - list(REMOVE_DUPLICATES rest_include_dirs) -endif() -if(DEFINED rest_libraries) - list(REMOVE_DUPLICATES rest_libraries) -endif() -if(DEFINED rest_packages) - list(REMOVE_DUPLICATES rest_packages) -endif() -if(DEFINED rest_features) - list(REMOVE_DUPLICATES rest_features) -endif() +if (DEFINED rest_include_dirs) + list(REMOVE_DUPLICATES rest_include_dirs) +endif () +if (DEFINED rest_libraries) + list(REMOVE_DUPLICATES rest_libraries) +endif () +if (DEFINED rest_packages) + list(REMOVE_DUPLICATES rest_packages) +endif () +if (DEFINED rest_features) + list(REMOVE_DUPLICATES rest_features) +endif () # set REST compilation flags to main cmake set(rest_include_dirs ${rest_include_dirs} PARENT_SCOPE) @@ -108,16 +108,16 @@ set(rest_packages ${rest_packages} PARENT_SCOPE) set(rest_features ${rest_features} PARENT_SCOPE) set(rest_libraries_regular "-L${CMAKE_INSTALL_PREFIX}/lib ") -foreach(lib ${rest_libraries}) - set(rest_libraries_regular "${rest_libraries_regular} -l${lib} ") -endforeach(lib) +foreach (lib ${rest_libraries}) + set(rest_libraries_regular "${rest_libraries_regular} -l${lib} ") +endforeach (lib) set(rest_libraries_regular ${rest_libraries_regular} PARENT_SCOPE) set(rest_exes ${rest_exes} PARENT_SCOPE) set(rest_macros ${rest_macros} PARENT_SCOPE) # construct REST macros string(separate with blank) set(rest_macros_str) -foreach(mac ${rest_macros}) +foreach (mac ${rest_macros}) set(rest_macros_str "${rest_macros_str}${mac} ") -endforeach(mac ${rest_macros}) +endforeach (mac ${rest_macros}) set(rest_macros_str ${rest_macros_str} PARENT_SCOPE) From 9701337cf693a1f9f7dc7e5d51ad4a556238e9d4 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 9 Feb 2022 10:30:20 +0100 Subject: [PATCH 10/61] added test example --- source/framework/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/framework/CMakeLists.txt b/source/framework/CMakeLists.txt index 5f2f8b8f7..ebccdfb4d 100644 --- a/source/framework/CMakeLists.txt +++ b/source/framework/CMakeLists.txt @@ -11,3 +11,5 @@ if (NOT ${REST_EVE} MATCHES "ON") endif (NOT ${REST_EVE} MATCHES "ON") COMPILEDIR(RestFramework) + +ADD_TEST() From e2660bdfccb29a8f9d118735358750e29a396a40 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 9 Feb 2022 10:41:51 +0100 Subject: [PATCH 11/61] Added quick fix for testing, TODO: fix startup.cpp (or whatever is causing problem) --- cmake/Testing.cmake | 1 + source/framework/core/src/startup.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/cmake/Testing.cmake b/cmake/Testing.cmake index 43e164049..27faf90eb 100644 --- a/cmake/Testing.cmake +++ b/cmake/Testing.cmake @@ -6,6 +6,7 @@ macro(ENABLE_TESTING_CONDITIONALLY) if (TEST) message(STATUS "Testing enabled (Disabled by default, enabled via -DTEST=ON flag)") enable_testing() + add_compile_definitions(REST_TESTING_ENABLED) endif () endmacro() diff --git a/source/framework/core/src/startup.cpp b/source/framework/core/src/startup.cpp index c6976bee1..607a2c912 100644 --- a/source/framework/core/src/startup.cpp +++ b/source/framework/core/src/startup.cpp @@ -25,6 +25,10 @@ map RESTConverterMethodBase = {}; struct __REST_CONST_INIT { public: __REST_CONST_INIT() { +// TODO: fix to avoid this dirty fix +#ifdef REST_TESTING_ENABLED + return; +#endif REST_COMMIT = TRestTools::Execute("rest-config --commit"); char* _REST_PATH = getenv("REST_PATH"); From 7a9bc582a6e5607414307e83e1c96684051431cb Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 10:17:28 +0100 Subject: [PATCH 12/61] CMakeLists.txt - Updated website to GH pages (https://github.com/rest-for-physics/framework/pull/129/files#r802477416) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a80a3b7cf..d5e496ce4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -PROJECT(REST LANGUAGES CXX HOMEPAGE_URL https://github.com/rest-for-physics/framework) +PROJECT(REST LANGUAGES CXX HOMEPAGE_URL https://rest-for-physics.github.io) CMAKE_MINIMUM_REQUIRED(VERSION 3.5) From f177abc01d773188d68a33a58e50a94452e00f6c Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 10:46:38 +0100 Subject: [PATCH 13/61] external/CMakeLists.txt - Added more comments --- source/framework/external/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/framework/external/CMakeLists.txt b/source/framework/external/CMakeLists.txt index 152fb236f..39a5c87a6 100644 --- a/source/framework/external/CMakeLists.txt +++ b/source/framework/external/CMakeLists.txt @@ -7,6 +7,7 @@ include(FetchContent) # Google Test if (TEST) + # https://google.github.io/googletest/quickstart-cmake.html message(STATUS "- Google Test") FetchContent_Declare( googletest @@ -17,7 +18,9 @@ if (TEST) endif () return() -# These are useful dependencies, we don't use them right now + +# Here it is shown how to use CMake FetchContent to use external git repositories as dependencies. +# These are useful dependencies that we may use in the future. # YAML parser message(STATUS "- yaml-cpp") From 3e82b099d098280323949fc4fbede41eb3ab33dc Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 11:04:37 +0100 Subject: [PATCH 14/61] CMakeLists.txt - Removed optional settings from `PROJECT`, for some reason it causes problems on cmake (why?) --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5e496ce4..bb1fb8409 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ PROJECT(REST LANGUAGES CXX HOMEPAGE_URL https://rest-for-physics.github.io) -CMAKE_MINIMUM_REQUIRED(VERSION 3.5) +PROJECT(REST) # Minimum compiler version if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") @@ -15,7 +15,6 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") endif () endif () - if (CMAKE_SYSTEM_NAME MATCHES "Darwin") SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-stdlib=libc++") endif (CMAKE_SYSTEM_NAME MATCHES "Darwin") From 3c0d4f3fd36c2dd2f85199ce1a5c92dd497fc5a1 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 11:05:19 +0100 Subject: [PATCH 15/61] CMakeLists.txt - Bumped minimum `cmake` version to 3.16 to prevent issues. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb1fb8409..300912767 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -PROJECT(REST LANGUAGES CXX HOMEPAGE_URL https://rest-for-physics.github.io) +CMAKE_MINIMUM_REQUIRED(VERSION 3.16) PROJECT(REST) From 7de333e072286082d65a253e99723466814544b9 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 11:07:00 +0100 Subject: [PATCH 16/61] framework/test - renamed TRestRun test --- .../framework/test/src/{ExampleTest.cxx => FrameworkCore.cxx} | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) rename source/framework/test/src/{ExampleTest.cxx => FrameworkCore.cxx} (78%) diff --git a/source/framework/test/src/ExampleTest.cxx b/source/framework/test/src/FrameworkCore.cxx similarity index 78% rename from source/framework/test/src/ExampleTest.cxx rename to source/framework/test/src/FrameworkCore.cxx index 450b5714f..168eb4532 100644 --- a/source/framework/test/src/ExampleTest.cxx +++ b/source/framework/test/src/FrameworkCore.cxx @@ -2,9 +2,8 @@ #include #include -TEST(Framework, example) { +TEST(FrameworkCore, TRestRun) { auto run = TRestRun(); run.PrintAllMetadata(); EXPECT_TRUE(&run != nullptr); - return; } From 3d33f1c79ab1a3bb264be42d33e821eabc895d32 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 11:29:18 +0100 Subject: [PATCH 17/61] Framework/test - Added basic test rml for TRestRun, using filesystem to read files in testing. --- source/framework/test/files/TRestRunBasic.rml | 31 +++++++++++++++++++ source/framework/test/src/FrameworkCore.cxx | 19 ++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 source/framework/test/files/TRestRunBasic.rml diff --git a/source/framework/test/files/TRestRunBasic.rml b/source/framework/test/files/TRestRunBasic.rml new file mode 100644 index 000000000..86185fa7b --- /dev/null +++ b/source/framework/test/files/TRestRunBasic.rml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/framework/test/src/FrameworkCore.cxx b/source/framework/test/src/FrameworkCore.cxx index 168eb4532..daaf91b10 100644 --- a/source/framework/test/src/FrameworkCore.cxx +++ b/source/framework/test/src/FrameworkCore.cxx @@ -2,7 +2,26 @@ #include #include +#include + +namespace fs = std::filesystem; + +using namespace std; + +#define FILES_PATH fs::path(__FILE__).parent_path().parent_path() / "files" + +TEST(FrameworkCore, TestFiles) { + cout << "FrameworkCore test files path: " << FILES_PATH << endl; + + // Check dir exists and is a directory + EXPECT_TRUE(fs::is_directory(FILES_PATH)); + // Check it's not empty + EXPECT_TRUE(!fs::is_empty(FILES_PATH)); +} + TEST(FrameworkCore, TRestRun) { + const auto basicRunRml = FILES_PATH / "TRestRunBasic.rml"; + auto run = TRestRun(); run.PrintAllMetadata(); EXPECT_TRUE(&run != nullptr); From 9d1a9d0da52f2554441ddbfd7dc23357267e7040 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 12:14:13 +0100 Subject: [PATCH 18/61] framework/test - added test to initialize TRestRun from config file --- source/framework/test/CMakeLists.txt | 1 + source/framework/test/src/FrameworkCore.cxx | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/source/framework/test/CMakeLists.txt b/source/framework/test/CMakeLists.txt index a7b15614f..8d9766ced 100644 --- a/source/framework/test/CMakeLists.txt +++ b/source/framework/test/CMakeLists.txt @@ -14,6 +14,7 @@ target_link_libraries( ${TESTING_EXECUTABLE} PUBLIC gtest_main RestFramework + stdc++fs # ) include(GoogleTest) diff --git a/source/framework/test/src/FrameworkCore.cxx b/source/framework/test/src/FrameworkCore.cxx index daaf91b10..469798eca 100644 --- a/source/framework/test/src/FrameworkCore.cxx +++ b/source/framework/test/src/FrameworkCore.cxx @@ -22,7 +22,21 @@ TEST(FrameworkCore, TestFiles) { TEST(FrameworkCore, TRestRun) { const auto basicRunRml = FILES_PATH / "TRestRunBasic.rml"; - auto run = TRestRun(); + auto run = TRestRun(basicRunRml); + run.PrintAllMetadata(); - EXPECT_TRUE(&run != nullptr); + + EXPECT_TRUE(run.GetExperimentName() == "TRestRun Basic Test"); + + EXPECT_TRUE(run.GetRunType() == "Test"); + + EXPECT_TRUE(run.GetRunNumber() == 1); + + EXPECT_TRUE(run.GetRunTag() == "Test"); + + // EXPECT_TRUE(run.GetOutputFileName() == "Run1_Test_[fExperimentName].root"); + + EXPECT_TRUE(run.GetRunDescription() == "This is a test for TRestRun"); + + // EXPECT_TRUE(run.GetVerboseLevel() == 3); } From dd44a9666030b472677de959fb7c394a60412327 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 12:20:59 +0100 Subject: [PATCH 19/61] .gitlab-ci.yml - cleaned file, removed comments and unnecessary lines --- .gitlab-ci.yml | 48 +++--------------------------------------------- 1 file changed, 3 insertions(+), 45 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2bd3d9ba8..fbb5139dc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,3 @@ - image: ghcr.io/lobis/root-geant4-garfield:cpp17_ROOT-v6-26-00_Geant4-v10.4.3_Garfield-af4a1451 #image: nkx1231/root6-geant4-garfield:0.6 @@ -42,22 +41,15 @@ stages: before_script: - pwd - export USER="test" - # - export GIT_SSL_NO_VERIFY=1 - echo $CI_SERVER_HOST - echo $CRONJOB # We redefine the HOME - export HOME=${CI_PROJECT_DIR}/install_latest/ - - if [ -d $HOME/.rest ]; then rm -Rf $HOME/.rest; fi - - if [ -f "/opt/root/install/bin/thisroot.sh" ]; then source /opt/root/install/bin/thisroot.sh; fi + # Check versions - root-config --version - - if [ -f "/opt/geant4/install/bin/geant4.sh" ]; then source /opt/geant4/install/bin/geant4.sh; fi - geant4-config --version - - if [ -d "/opt/garfieldpp/install" ]; then export GARFIELD_HOME=/opt/garfieldpp/install; fi - - if [ -d "/opt/garfieldpp/install" ]; then export HEED_DATABASE=$GARFIELD_HOME/Heed/heed++/database; fi - - if [ -d "/opt/garfieldpp/install" ]; then export LD_LIBRARY_PATH=$GARFIELD_HOME/lib:$LD_LIBRARY_PATH; fi - - ls $GARFIELD_HOME + - ls $GARFIELD_INSTALL - python3 --version - - apt update && apt install -y wget clang-format: stage: pre-build @@ -125,46 +117,12 @@ build_latest: - if [ -d ${CI_PROJECT_DIR}/install_latest ]; then rm -Rf ${CI_PROJECT_DIR}/install_latest; fi - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install_latest - make install -j2 - # - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + artifacts: paths: - ${CI_PROJECT_DIR}/install_latest expire_in: 1 day - #build_latest_root622_geant4v1042: - # image: lobis/root-geant4-garfieldpp:cxx14_ROOTv6-22-08_Geant4v10.4.2 - # type: build - # script: - # - cd ${CI_PROJECT_DIR}/ - # - python3 pull-submodules.py --force --dontask --latest - # - if [ -d ${CI_PROJECT_DIR}/build_latest2 ]; then rm -Rf ${CI_PROJECT_DIR}/build_latest2; fi - # - mkdir ${CI_PROJECT_DIR}/build_latest2 && cd ${CI_PROJECT_DIR}/build_latest2/ - # - if [ -d ${CI_PROJECT_DIR}/install_latest2 ]; then rm -Rf ${CI_PROJECT_DIR}/install_latest2; fi - # - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install_latest2 - # - make install -j2 - # - . ${CI_PROJECT_DIR}/install_latest2/thisREST.sh - # except: - - # variables: - # - $CRONJOB == "YES" - - #build_nkx: - # image: nkx1231/root6-geant4-garfield:0.6 - # type: build - # script: - # - cd ${CI_PROJECT_DIR}/ - # - python3 pull-submodules.py --force --dontask - # - if [ -d ${CI_PROJECT_DIR}/build_nkx ]; then rm -Rf ${CI_PROJECT_DIR}/build_nkx; fi - # - mkdir ${CI_PROJECT_DIR}/build_nkx && cd ${CI_PROJECT_DIR}/build_nkx/ - # - if [ -d ${CI_PROJECT_DIR}/install_nkx]; then rm -Rf ${CI_PROJECT_DIR}/install_nkx; fi - # - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install_nkx - # - make install -j2 - # - cat ${CI_PROJECT_DIR}/install_nkx/thisREST.sh -# - . ${CI_PROJECT_DIR}/install_nkx/thisREST.sh -# except: -# variables: -# - $CRONJOB == "YES" - loadRESTLibs: type: install script: From 0e8c7ef392467e270e3dc08c257f05928e2af1c2 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 12:31:54 +0100 Subject: [PATCH 20/61] framework/test - skip test until fix --- source/framework/test/src/FrameworkCore.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/framework/test/src/FrameworkCore.cxx b/source/framework/test/src/FrameworkCore.cxx index 469798eca..1c881929a 100644 --- a/source/framework/test/src/FrameworkCore.cxx +++ b/source/framework/test/src/FrameworkCore.cxx @@ -20,6 +20,8 @@ TEST(FrameworkCore, TestFiles) { } TEST(FrameworkCore, TRestRun) { + GTEST_SKIP(); + const auto basicRunRml = FILES_PATH / "TRestRunBasic.rml"; auto run = TRestRun(basicRunRml); From 4ff2fdf54285fe605e236ec86450f982d81b260f Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 12:34:49 +0100 Subject: [PATCH 21/61] .gitlab-ci.yml - now pipeline will first build with tests, run tests, and build and install without tests --- .gitlab-ci.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fbb5139dc..b37fe4560 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -107,13 +107,22 @@ validateCode: # - ${CI_PROJECT_DIR}/install # expire_in: 1 day # -build_latest: + +build_and_test: type: build script: - - cd ${CI_PROJECT_DIR}/ + - cd ${CI_PROJECT_DIR} - python3 pull-submodules.py --force --dontask --latest:${CI_COMMIT_BRANCH} - - if [ -d ${CI_PROJECT_DIR}/build_latest ]; then rm -Rf ${CI_PROJECT_DIR}/build_latest; fi - - mkdir ${CI_PROJECT_DIR}/build_latest && cd ${CI_PROJECT_DIR}/build_latest/ + - mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build + - cmake ${CI_PROJECT_DIR} -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON + - make -j2 + - ctest + +build_latest: + type: build + script: + - cd ${CI_PROJECT_DIR} + - rm -rf ${CI_PROJECT_DIR}/build && mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - if [ -d ${CI_PROJECT_DIR}/install_latest ]; then rm -Rf ${CI_PROJECT_DIR}/install_latest; fi - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install_latest - make install -j2 From e663d1213310f8a0f8b18309659d5140bf9da1e2 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 12:54:34 +0100 Subject: [PATCH 22/61] .gitlab-ci.yml - running install AFTER tests --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b37fe4560..6a1cfa632 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,9 @@ stages: # Basic checks to verify correctness of code - pre-build + # Build and run tests + - test + # Project compilation validation - build @@ -109,7 +112,7 @@ validateCode: # build_and_test: - type: build + type: test script: - cd ${CI_PROJECT_DIR} - python3 pull-submodules.py --force --dontask --latest:${CI_COMMIT_BRANCH} From e73f72adbc2b86eabf33f746177ae5e6bebe8c63 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 17:50:04 +0100 Subject: [PATCH 23/61] .gitlab-ci.yml - formatting changes, replaced '.' by 'source'. --- .gitlab-ci.yml | 107 +++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 62 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6a1cfa632..05cb96c0a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,11 +47,11 @@ before_script: - echo $CI_SERVER_HOST - echo $CRONJOB # We redefine the HOME - - export HOME=${CI_PROJECT_DIR}/install_latest/ + - export HOME=${CI_PROJECT_DIR}/install/ # Check versions - root-config --version - geant4-config --version - - ls $GARFIELD_INSTALL + - echo $GARFIELD_INSTALL - python3 --version clang-format: @@ -91,80 +91,63 @@ validateCode: # variables: # - $CI_SERVER_HOST == "lfna.unizar.es" -#build: -# type: build -# script: -# - cd ${CI_PROJECT_DIR}/ -# - python3 pull-submodules.py --force --dontask -# - if [ -d ${CI_PROJECT_DIR}/build ]; then rm -Rf ${CI_PROJECT_DIR}/build; fi -# - mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build/ -# - if [ -d ${CI_PROJECT_DIR}/install ]; then rm -Rf ${CI_PROJECT_DIR}/install; fi -# - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install -# - make install -j2 -# # - . ${CI_PROJECT_DIR}/install/thisREST.sh -# except: -# variables: -# - $CRONJOB == "YES" -# artifacts: -# paths: -# - ${CI_PROJECT_DIR}/install -# expire_in: 1 day -# - -build_and_test: +Build and Test: type: test script: - cd ${CI_PROJECT_DIR} - python3 pull-submodules.py --force --dontask --latest:${CI_COMMIT_BRANCH} - mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - - cmake ${CI_PROJECT_DIR} -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON + - cmake ${CI_PROJECT_DIR} \ + -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON - make -j2 - ctest -build_latest: +Build and Install: type: build script: - cd ${CI_PROJECT_DIR} - rm -rf ${CI_PROJECT_DIR}/build && mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - - if [ -d ${CI_PROJECT_DIR}/install_latest ]; then rm -Rf ${CI_PROJECT_DIR}/install_latest; fi - - cmake ${CI_PROJECT_DIR} -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install_latest + - if [ -d ${CI_PROJECT_DIR}/install ]; then rm -rf ${CI_PROJECT_DIR}/install; fi + - cmake ${CI_PROJECT_DIR} -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install \ + -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON - make install -j2 artifacts: paths: - - ${CI_PROJECT_DIR}/install_latest + - ${CI_PROJECT_DIR}/install expire_in: 1 day loadRESTLibs: type: install script: - - cat ${CI_PROJECT_DIR}/install_latest/thisREST.sh - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - echo ${CI_PROJECT_DIR}/install/thisREST.sh + - cat ${CI_PROJECT_DIR}/install/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - restRoot -b -q listRESTMacros: type: install script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - restManager ListMacros 01_NLDBD: type: restG4 script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - - cd ${CI_PROJECT_DIR}/install_latest/examples/restG4/01.NLDBD/ + - source ${CI_PROJECT_DIR}/install/thisREST.sh + - cd ${CI_PROJECT_DIR}/install/examples/restG4/01.NLDBD/ - restG4 NLDBD.rml - geant4-config --version - restRoot -b -q Validate.C'("Run00001_NLDBD_Test.root")' artifacts: paths: - - ${CI_PROJECT_DIR}/install_latest/examples/restG4/01.NLDBD/Run00001_NLDBD_Test.root + - ${CI_PROJECT_DIR}/install/examples/restG4/01.NLDBD/Run00001_NLDBD_Test.root expire_in: 1 day 02_PandaXiiiMC: type: restG4 script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC - restG4 Xe136bb0n.rml - restRoot -b -q ValidateG4.C'("Xe136bb0n_n2E06.root")' @@ -176,7 +159,7 @@ listRESTMacros: LoadGas: type: metadata script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/gas/ - restRoot -b -q LoadGasFromServerAndValidate.C only: @@ -186,7 +169,7 @@ LoadGas: GenerateGas: type: metadata script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/gas/ - restRoot -b -q GenerateDummyGas.C only: @@ -196,14 +179,14 @@ GenerateGas: AnalysisTree: type: core script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/analysistree/ - restRoot -b -q simpleTree.cpp -GenerateReadout: +Generate Readout: type: metadata script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/readout/ - restManager --c generateReadout.rml --o readout.root - restRoot -b -q PrintReadout.C'("readout.root")' > /dev/null @@ -211,10 +194,10 @@ GenerateReadout: # We need to introduce basic validation here # - diff validation.txt print.txt -BasicReadout: +Basic Readout: type: metadata script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/projects/basic-readouts/ - ls - git status @@ -222,21 +205,21 @@ BasicReadout: - restRoot --m 1 -b -q GenerateReadouts.C'("basic.root")' - restRoot -b -q BasicValidation.C'("basic.root", "pixelDecoding")' -testMeta: +Test Metadata: type: restManager_generate script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh - - cd ${CI_PROJECT_DIR}/install_latest/examples + - source ${CI_PROJECT_DIR}/install/thisREST.sh + - cd ${CI_PROJECT_DIR}/install/examples - restManager --c saveMetadataFile.rml --o meta.root artifacts: paths: - - ${CI_PROJECT_DIR}/install_latest/examples/meta.root + - ${CI_PROJECT_DIR}/install/examples/meta.root expire_in: 1 day -trexDM_data_latest: +TREX-DM Latest Data: type: restManager_process script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/trex - wget https://sultan.unizar.es/trexdm-readouts/readouts_v2.3.root - restManager --c 01_raw.rml --f R01928_tagTest_Vm_250_Vd_160_Pr_6_Gain_0x0_Shape_0xF_Clock_0x4-068.aqs @@ -252,10 +235,10 @@ trexDM_data_latest: - ${CI_PROJECT_DIR}/pipeline/trex/Hits_01928.root expire_in: 1 day -pandaXIII_Topological: +pandaXIII Topological: type: restManager_process script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC - restManager --c AllProcesses.rml --i testInput.root --o testOutput.root --j 1 --e 10 - restRoot -b -q ../MakeBasicTree.C'("testOutput.root")' @@ -266,10 +249,10 @@ pandaXIII_Topological: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/trackParameter.png expire_in: 1 week -pandaXIII_Topological_fromG4: +pandaXIII Topological from Geant4: type: restManager_process script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC - echo "using just-generated g4 file" - restManager --c AllProcesses.rml --i Xe136bb0n_n2E06.root --o testOutput.root --j 1 --e 10 @@ -280,10 +263,10 @@ pandaXIII_Topological_fromG4: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/testOutput.root expire_in: 1 week -pandaXIII_data: +pandaXIII data: type: restManager_process script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/pandaxiii_data - restManager --c P3AutoChain.rml --i CoBo_AsAd0_2019-03-15.graw --o testOutput.root --j 1 - restRoot -b -q ../MakeBasicTree.C'("testOutput.root")' @@ -293,12 +276,12 @@ pandaXIII_data: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_data/TriggerRate.png expire_in: 1 week -EventSelection: +Event Selection: type: restManager_process script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/selection - - restManager --c g4Analysis.rml --f "${CI_PROJECT_DIR}/install_latest/examples/restG4/01.NLDBD/Run00001_NLDBD_Test.root" + - restManager --c g4Analysis.rml --f "${CI_PROJECT_DIR}/install/examples/restG4/01.NLDBD/Run00001_NLDBD_Test.root" - restManager --c g4OnSelection.rml --f Run00001_NLDBD_Test_g4Analysis.root - restRoot -b -q Validate.C'("Run00001_NLDBD_Test_EvSelection.root")' @@ -310,25 +293,25 @@ EventSelection: AnalysisPlot: type: postProcessing script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/analysisPlot/ - restManager --c summary.rml --f ${CI_PROJECT_DIR}/pipeline/trex/Hits_01928.root AnalysisPlot2: type: postProcessing script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/analysisPlot/ - restManager --batch --c classify.rml - restRoot -b -q ValidateClassify.C -deploy: +Deploy: type: deploy only: - tags script: - - . ${CI_PROJECT_DIR}/install_latest/thisREST.sh + - source ${CI_PROJECT_DIR}/install/thisREST.sh - rest-config --welcome artifacts: paths: - - ${CI_PROJECT_DIR}/install_latest + - ${CI_PROJECT_DIR}/install From 8b8e5eb00e53514291e24d556dfa90a1b788ce93 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 17:54:30 +0100 Subject: [PATCH 24/61] .gitlab-ci.yml - small formatting changes --- .gitlab-ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 05cb96c0a..c8995b0b3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,7 +68,7 @@ clang-format: - $CRONJOB - $CRONJOB == "YES" -validateCode: +Validate Code: stage: pre-build script: - cd ${CI_PROJECT_DIR}/ @@ -117,7 +117,7 @@ Build and Install: - ${CI_PROJECT_DIR}/install expire_in: 1 day -loadRESTLibs: +Load REST Libraries: type: install script: - echo ${CI_PROJECT_DIR}/install/thisREST.sh @@ -125,7 +125,7 @@ loadRESTLibs: - source ${CI_PROJECT_DIR}/install/thisREST.sh - restRoot -b -q -listRESTMacros: +List REST Macros: type: install script: - source ${CI_PROJECT_DIR}/install/thisREST.sh @@ -156,7 +156,7 @@ listRESTMacros: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/Xe136bb0n_n2E06.root expire_in: 1 day -LoadGas: +Load Gas: type: metadata script: - source ${CI_PROJECT_DIR}/install/thisREST.sh @@ -166,7 +166,7 @@ LoadGas: variables: - $CI_SERVER_HOST == "lfna.unizar.es" -GenerateGas: +Generate Gas: type: metadata script: - source ${CI_PROJECT_DIR}/install/thisREST.sh @@ -235,7 +235,7 @@ TREX-DM Latest Data: - ${CI_PROJECT_DIR}/pipeline/trex/Hits_01928.root expire_in: 1 day -pandaXIII Topological: +PandaXIII Topological: type: restManager_process script: - source ${CI_PROJECT_DIR}/install/thisREST.sh @@ -249,7 +249,7 @@ pandaXIII Topological: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/trackParameter.png expire_in: 1 week -pandaXIII Topological from Geant4: +PandaXIII Topological from Geant4: type: restManager_process script: - source ${CI_PROJECT_DIR}/install/thisREST.sh @@ -263,7 +263,7 @@ pandaXIII Topological from Geant4: - ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/testOutput.root expire_in: 1 week -pandaXIII data: +PandaXIII Data: type: restManager_process script: - source ${CI_PROJECT_DIR}/install/thisREST.sh From 572c99b28eeefd868b195c883217326a8d6f8a25 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 17:55:34 +0100 Subject: [PATCH 25/61] .gitlab-ci.yml - removed '\' --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c8995b0b3..72d9a189b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -97,7 +97,7 @@ Build and Test: - cd ${CI_PROJECT_DIR} - python3 pull-submodules.py --force --dontask --latest:${CI_COMMIT_BRANCH} - mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - - cmake ${CI_PROJECT_DIR} \ + - cmake ${CI_PROJECT_DIR} -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON - make -j2 - ctest @@ -108,7 +108,7 @@ Build and Install: - cd ${CI_PROJECT_DIR} - rm -rf ${CI_PROJECT_DIR}/build && mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - if [ -d ${CI_PROJECT_DIR}/install ]; then rm -rf ${CI_PROJECT_DIR}/install; fi - - cmake ${CI_PROJECT_DIR} -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install \ + - cmake ${CI_PROJECT_DIR} -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON - make install -j2 From 10e03d0549dd503e5f807ab02271bbc236f66ae6 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 18:35:31 +0100 Subject: [PATCH 26/61] .gitlab-ci.yml - added debug msg --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 72d9a189b..ef5148a84 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -123,6 +123,7 @@ Load REST Libraries: - echo ${CI_PROJECT_DIR}/install/thisREST.sh - cat ${CI_PROJECT_DIR}/install/thisREST.sh - source ${CI_PROJECT_DIR}/install/thisREST.sh + - echo $REST_PATH" - restRoot -b -q List REST Macros: From 73534c1b9f80c997294a2e8193e5f82007523f83 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 18:36:37 +0100 Subject: [PATCH 27/61] .gitlab-ci.yml - added back rm .rest dir --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef5148a84..1b463d7b8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,6 +48,7 @@ before_script: - echo $CRONJOB # We redefine the HOME - export HOME=${CI_PROJECT_DIR}/install/ + - rm -rf $HOME/.rest # Check versions - root-config --version - geant4-config --version From 689db50d80d47a55c6b8ccf61de59aef801f64d3 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 18:39:48 +0100 Subject: [PATCH 28/61] .gitlab-ci.yml - removed unecessary if --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1b463d7b8..947554cf3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,7 +108,7 @@ Build and Install: script: - cd ${CI_PROJECT_DIR} - rm -rf ${CI_PROJECT_DIR}/build && mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - - if [ -d ${CI_PROJECT_DIR}/install ]; then rm -rf ${CI_PROJECT_DIR}/install; fi + - rm -rf ${CI_PROJECT_DIR}/install - cmake ${CI_PROJECT_DIR} -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON - make install -j2 From 2b3588970cd2dafa1b8030d0d09e239e98604426 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 18:40:39 +0100 Subject: [PATCH 29/61] .gitlab-ci.yml - removed old commented code --- .gitlab-ci.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 947554cf3..b132f19d9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -76,22 +76,6 @@ Validate Code: - python3 pull-submodules.py --force --dontask - python3 pipeline/validateProcesses.py source/libraries/ -#axionLib: -# stage: libraries -# script: -# - "curl -k -X POST -F token=bd53c38cdd1395ffeb14d297ebe202 -F ref=master https://lfna.unizar.es/api/v4/projects/31/trigger/pipeline" -# only: -# variables: -# - $CI_SERVER_HOST == "lfna.unizar.es" - -#modelLib: -# stage: libraries -# script: -# - "curl -k -X POST -F token=a244698329647e96d55908d75f3f0e -F ref=master https://lfna.unizar.es/api/v4/projects/11/trigger/pipeline" -# only: -# variables: -# - $CI_SERVER_HOST == "lfna.unizar.es" - Build and Test: type: test script: From 1f253584b66919b06fec33a0313a25c34d55f542 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 19:16:40 +0100 Subject: [PATCH 30/61] .gitlab-ci.yml - fix typo --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b132f19d9..6a8fb7a28 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,7 +108,7 @@ Load REST Libraries: - echo ${CI_PROJECT_DIR}/install/thisREST.sh - cat ${CI_PROJECT_DIR}/install/thisREST.sh - source ${CI_PROJECT_DIR}/install/thisREST.sh - - echo $REST_PATH" + - echo $REST_PATH - restRoot -b -q List REST Macros: From a62f47dd83ec430408dfbed2d1c7dfd707aed4ec Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 19:17:35 +0100 Subject: [PATCH 31/61] .gitlab-ci.yml - added `printenv` for debugging --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6a8fb7a28..f7eea0a6c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,6 +108,7 @@ Load REST Libraries: - echo ${CI_PROJECT_DIR}/install/thisREST.sh - cat ${CI_PROJECT_DIR}/install/thisREST.sh - source ${CI_PROJECT_DIR}/install/thisREST.sh + - printenv - echo $REST_PATH - restRoot -b -q From af08e3d659b0a656cfac9cf46bf4c6f9f23bd5d8 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 19:54:53 +0100 Subject: [PATCH 32/61] .gitlab-ci.yml - added restRoot without alias --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f7eea0a6c..95dc230c9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -110,6 +110,7 @@ Load REST Libraries: - source ${CI_PROJECT_DIR}/install/thisREST.sh - printenv - echo $REST_PATH + - root -l $REST_PATH/scripts/LoadRESTScripts.C -b -q - restRoot -b -q List REST Macros: From 2c4a202ad787e2abc710ef84c43fae746735dc3d Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 20:00:49 +0100 Subject: [PATCH 33/61] .gitlab-ci.yml - added ls for $REST_PATH/bin --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 95dc230c9..a7759edfc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -110,6 +110,7 @@ Load REST Libraries: - source ${CI_PROJECT_DIR}/install/thisREST.sh - printenv - echo $REST_PATH + - ls $REST_PATH/bin - root -l $REST_PATH/scripts/LoadRESTScripts.C -b -q - restRoot -b -q From 846bb01293daf97e678b61380ef202d221d0b708 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Wed, 23 Mar 2022 20:02:34 +0100 Subject: [PATCH 34/61] .gitlab-ci.yml - using explicit path --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a7759edfc..7304ba612 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -111,7 +111,7 @@ Load REST Libraries: - printenv - echo $REST_PATH - ls $REST_PATH/bin - - root -l $REST_PATH/scripts/LoadRESTScripts.C -b -q + - $REST_PATH/bin/restRoot -b -q - restRoot -b -q List REST Macros: From 9b7c21736eda6478db52c14389b1e8912067fd70 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 20:49:52 +0100 Subject: [PATCH 35/61] .gitlab-ci.yml - removed some debugging commands --- .gitlab-ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7304ba612..d456e6c8a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,10 +108,6 @@ Load REST Libraries: - echo ${CI_PROJECT_DIR}/install/thisREST.sh - cat ${CI_PROJECT_DIR}/install/thisREST.sh - source ${CI_PROJECT_DIR}/install/thisREST.sh - - printenv - - echo $REST_PATH - - ls $REST_PATH/bin - - $REST_PATH/bin/restRoot -b -q - restRoot -b -q List REST Macros: From ab03caf8e37b86c047d5f74e796e5c2b5c8a4a08 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Wed, 23 Mar 2022 20:51:11 +0100 Subject: [PATCH 36/61] .gitlab-ci.yml - added test output as artifact --- .gitlab-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d456e6c8a..5cf4c80b4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -85,7 +85,12 @@ Build and Test: - cmake ${CI_PROJECT_DIR} -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON - make -j2 - - ctest + - ctest --verbose -O ${CI_PROJECT_DIR}/build/Testing/summary.txt + + artifacts: + paths: + - ${CI_PROJECT_DIR}/build/Testing + expire_in: 1 day Build and Install: type: build From 8ea86f265d1fdefaee7dfb0b6fa685a804848285 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Thu, 24 Mar 2022 10:05:03 +0100 Subject: [PATCH 37/61] TRestMetadata.h - minor comment updates --- source/framework/core/inc/TRestMetadata.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/framework/core/inc/TRestMetadata.h b/source/framework/core/inc/TRestMetadata.h index 752e9ea4a..e2587739f 100644 --- a/source/framework/core/inc/TRestMetadata.h +++ b/source/framework/core/inc/TRestMetadata.h @@ -24,6 +24,7 @@ #define RestCore_TRestMetadata #define TIXML_USE_STL + #include #include #include @@ -291,7 +292,7 @@ class TRestMetadata : public TNamed { /// returns the verboselevel in type of REST_Verbose_Level enumerator REST_Verbose_Level GetVerboseLevel() { return fVerboseLevel; } - /// returns the verboselevel in type of TString + /// returns the verbose level in type of TString TString GetVerboseLevelString(); /// Gets a string with the path used for data storage @@ -313,12 +314,12 @@ class TRestMetadata : public TNamed { void SetSectionName(std::string sName) { fSectionName = sName; } /// set config file path from external void SetConfigFile(std::string cfgFileName) { fConfigFileName = cfgFileName; } - /// Set the hoster manager for this class. + /// Set the host manager for this class. void SetHostmgr(TRestManager* m) { fHostmgr = m; } - /// sets the verboselevel + /// sets the verbose level void SetVerboseLevel(REST_Verbose_Level v) { fVerboseLevel = v; } /// overwriting the write() method with fStore considered - virtual Int_t Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0); + virtual Int_t Write(const char* name = nullptr, Int_t option = 0, Int_t bufsize = 0); ~TRestMetadata(); From 182ae7881997a69bf06b81ab95ca55c09e64b054 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Thu, 24 Mar 2022 10:05:38 +0100 Subject: [PATCH 38/61] framework/test - Updated test thanks to feedback on https://github.com/rest-for-physics/framework/issues/160#issuecomment-1077030999 --- source/framework/test/src/FrameworkCore.cxx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/source/framework/test/src/FrameworkCore.cxx b/source/framework/test/src/FrameworkCore.cxx index 1c881929a..b6f0ecca1 100644 --- a/source/framework/test/src/FrameworkCore.cxx +++ b/source/framework/test/src/FrameworkCore.cxx @@ -20,25 +20,19 @@ TEST(FrameworkCore, TestFiles) { } TEST(FrameworkCore, TRestRun) { - GTEST_SKIP(); - const auto basicRunRml = FILES_PATH / "TRestRunBasic.rml"; - auto run = TRestRun(basicRunRml); + TRestRun run; + + run.LoadConfigFromFile(basicRunRml); run.PrintAllMetadata(); EXPECT_TRUE(run.GetExperimentName() == "TRestRun Basic Test"); - EXPECT_TRUE(run.GetRunType() == "Test"); - EXPECT_TRUE(run.GetRunNumber() == 1); - EXPECT_TRUE(run.GetRunTag() == "Test"); - - // EXPECT_TRUE(run.GetOutputFileName() == "Run1_Test_[fExperimentName].root"); - + // EXPECT_TRUE(run.GetOutputFileName() == "Run[fRunNumber]_[fRunTag]_[fExperimentName].root"); EXPECT_TRUE(run.GetRunDescription() == "This is a test for TRestRun"); - - // EXPECT_TRUE(run.GetVerboseLevel() == 3); + EXPECT_TRUE(run.GetVerboseLevelString() == "debug"); } From a3aaa2cc2a04fc6b11bada5a97755f9144b93e72 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Thu, 24 Mar 2022 10:18:08 +0100 Subject: [PATCH 39/61] framework/source/bin - formatting CMakeLists.txt --- source/bin/CMakeLists.txt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 721e135ac..ae3818d10 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -1,20 +1,21 @@ -#set(target_libraries ${rest_libraries} -lGui ${ROOT_LIBRARIES} -lEve -lGeom) + include_directories(${rest_include_dirs}) include_directories(${external_include_dirs}) set(rest_exes) set(files restManager.cxx restRoot.cxx) -foreach(file ${files}) -#get file name without extension -string(REGEX MATCH "[^/\\]*cxx" temp ${file}) -string(REPLACE ".cxx" "" name ${temp}) -ADD_EXECUTABLE(${name} ${file} ) -TARGET_LINK_LIBRARIES(${name} ${rest_libraries} ${external_libs} ) -install(TARGETS ${name} RUNTIME DESTINATION bin) -set(rest_exes "${rest_exes}${name} ") +foreach (file ${files}) + # Get file name without extension + string(REGEX MATCH "[^/\\]*cxx" temp ${file}) + string(REPLACE ".cxx" "" name ${temp}) + + ADD_EXECUTABLE(${name} ${file}) + TARGET_LINK_LIBRARIES(${name} ${rest_libraries} ${external_libs}) + install(TARGETS ${name} RUNTIME DESTINATION bin) + set(rest_exes "${rest_exes}${name} ") -endforeach(file) +endforeach (file) set(rest_exes ${rest_exes} PARENT_SCOPE) From f387dabc09f2b143f073db5aa0e806b35eff7c79 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Thu, 24 Mar 2022 10:37:21 +0100 Subject: [PATCH 40/61] removed old `testing` directory --- testing/dockerfiles/README.md | 22 ---------------- testing/dockerfiles/REST/Dockerfile | 9 ------- testing/dockerfiles/ROOT/Dockerfile | 41 ----------------------------- testing/tests/README.md | 3 --- 4 files changed, 75 deletions(-) delete mode 100644 testing/dockerfiles/README.md delete mode 100644 testing/dockerfiles/REST/Dockerfile delete mode 100644 testing/dockerfiles/ROOT/Dockerfile delete mode 100644 testing/tests/README.md diff --git a/testing/dockerfiles/README.md b/testing/dockerfiles/README.md deleted file mode 100644 index cede7cf9a..000000000 --- a/testing/dockerfiles/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Introduction - -This section will contain everything necessary to build the docker containers used in the CI/CD pipeline. - -The base image for all other images is an ubuntu:18.04 image containing an installation of root and basic dependencies. All other images (e.g. REST image) will be built on top of this base image. - -This image's `Dockerfile` is under the *ROOT* directory. This image can be build with any version of ROOT via environment variable passing, to build this image run the following command (if no version is specified it defaults to ROOT version `6.16.00`): - -``` -ROOT_VERSION=6.16.00 -docker build -t root:${ROOT_VERSION} --build-arg ROOT_VERSION=${ROOT_VERSION} --build-arg MAKE_N_JOBS=3 . -``` - -Where the `-t` option is used to give the image a name (`root_v6.16.00` in this case) and `--build-arg ROOT_VERSION` is to assign a value to the `ROOT_VERSION` variable inside the `Dockerfile`. In this example we used an environment variable to keep the naming of the image consistent with the installed ROOT version. Remember you need to be on the directory of the `Dockerfile` (or use the `-f PATH_TO_DOCKERFILE` option) and have superuser privileges. - -# Container Registry - -In the near future we will use a feature called the GitLab container registry to upload our images built using the dockerfiles contained here. It is important to use this registry and not a public one (for example https://hub.docker.com/) because our images may contain sensitive information. - -For example the ROOT image could be public since it does not contain any sensitive information but in order to build the REST image one needs to pass a deployment key in order for the container to clone the REST repository. This is considered sensitive information therefor this image has to be kept private. - -We would pass the deployment key (and any other sensitive information) via `--build-arg` flag when building locally and then upload the image to the GitLab registry. it is important to mention that someone with access to the image still could recover this information unless we do a multi-stage build (and the sensitive information is not on the last stage). \ No newline at end of file diff --git a/testing/dockerfiles/REST/Dockerfile b/testing/dockerfiles/REST/Dockerfile deleted file mode 100644 index 989ff26ca..000000000 --- a/testing/dockerfiles/REST/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -# -# author: Luis Obis (lobis@unizar.es) -# - -# TODO: implement this image from the gitlab container registry root base image once its running - -FROM ubuntu:18.04 - -CMD ["/bin/bash"] \ No newline at end of file diff --git a/testing/dockerfiles/ROOT/Dockerfile b/testing/dockerfiles/ROOT/Dockerfile deleted file mode 100644 index 2520cb262..000000000 --- a/testing/dockerfiles/ROOT/Dockerfile +++ /dev/null @@ -1,41 +0,0 @@ -# -# author: Luis Obis (lobis@unizar.es) -# - -FROM ubuntu:18.04 - -RUN apt-get update -# root dependencies -RUN apt-get install -y git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev -RUN apt-get install -y gfortran libssl-dev libpcre3-dev \ - xlibmesa-glu-dev libglew1.5-dev libftgl-dev \ - libmysqlclient-dev libfftw3-dev libcfitsio-dev \ - graphviz-dev libavahi-compat-libdnssd-dev \ - libldap2-dev python-dev libxml2-dev libkrb5-dev \ - libgsl0-dev libqt4-dev -RUN apt-get install -y curl - -# download and build ROOT with provided options -ARG ROOT_VERSION="6.16.00" -RUN curl -o /tmp/root.tar.gz https://root.cern/download/root_v${ROOT_VERSION}.source.tar.gz -RUN tar xzfv /tmp/root.tar.gz -C /opt && rm -rf /tmp/root.tar.gz -WORKDIR /opt/root-${ROOT_VERSION}/build - -ARG ROOT_INSTALL_PREFIX=/opt/root -ARG MAKE_N_JOBS="" -# $((`nproc` + 1)) = number of cores + 1 for the fastest make -# MAKE_N_JOBS can be passed as argument in --build-arg -RUN if [ -z "$MAKE_N_JOBS" ]; then MAKE_N_JOBS=$((`nproc` + 1)); fi -RUN cmake -DCMAKE_INSTALL_PREFIX=$ROOT_INSTALL_PREFIX -DCXX17=ON -DGDML=ON .. -RUN make install -j$MAKE_N_JOBS -# remove downloaded sources - -WORKDIR / -RUN rm -rf /opt/root-${ROOT_VERSION}/ - -# set environment variables -ENV ROOTSYS "${ROOT_INSTALL_PREFIX}" -ENV PATH "${ROOTSYS}/bin:${PATH}" -ENV LD_LIBRARY_PATH "${ROOTSYS}/lib:${LD_LIBRARY_PATH}" - -CMD ["/bin/bash"] diff --git a/testing/tests/README.md b/testing/tests/README.md deleted file mode 100644 index 118f06fa8..000000000 --- a/testing/tests/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Introduction - -This section will contain all the unit tests and related files. \ No newline at end of file From edef6d999de9f097af07ef5526d0f6e8bb0c13fb Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Thu, 24 Mar 2022 10:49:16 +0100 Subject: [PATCH 41/61] framework/external - remove comment for unused external dependencies --- source/framework/external/CMakeLists.txt | 27 ------------------------ 1 file changed, 27 deletions(-) diff --git a/source/framework/external/CMakeLists.txt b/source/framework/external/CMakeLists.txt index 39a5c87a6..e272e3ce7 100644 --- a/source/framework/external/CMakeLists.txt +++ b/source/framework/external/CMakeLists.txt @@ -16,30 +16,3 @@ if (TEST) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Windows only FetchContent_MakeAvailable(googletest) endif () - -return() - -# Here it is shown how to use CMake FetchContent to use external git repositories as dependencies. -# These are useful dependencies that we may use in the future. - -# YAML parser -message(STATUS "- yaml-cpp") -FetchContent_Declare( - yaml-cpp - GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git - GIT_TAG yaml-cpp-0.7.0 -) -FetchContent_MakeAvailable(yaml-cpp) -install(DIRECTORY ${yaml-cpp_SOURCE_DIR}/include DESTINATION .) -install(TARGETS yaml-cpp DESTINATION lib) - -# Logging library -message(STATUS "- spdlog") -FetchContent_Declare( - spdlog - GIT_REPOSITORY https://github.com/gabime/spdlog.git - GIT_TAG v1.9.2 -) -FetchContent_MakeAvailable(spdlog) -install(DIRECTORY ${spdlog_SOURCE_DIR}/include DESTINATION .) -install(TARGETS spdlog DESTINATION lib) From 17ad3b9e0be32c7456182218336b42c6acdfba63 Mon Sep 17 00:00:00 2001 From: lobis Date: Thu, 24 Mar 2022 12:42:56 +0100 Subject: [PATCH 42/61] CMakeLists.txt - removed unreachable external dependencies --- source/framework/external/CMakeLists.txt | 30 +----------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/source/framework/external/CMakeLists.txt b/source/framework/external/CMakeLists.txt index 39a5c87a6..fe25ae2b7 100644 --- a/source/framework/external/CMakeLists.txt +++ b/source/framework/external/CMakeLists.txt @@ -1,9 +1,8 @@ message(STATUS "External dependencies:") -set(FETCHCONTENT_QUIET ON) - include(FetchContent) +set(FETCHCONTENT_QUIET ON) # Google Test if (TEST) @@ -16,30 +15,3 @@ if (TEST) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Windows only FetchContent_MakeAvailable(googletest) endif () - -return() - -# Here it is shown how to use CMake FetchContent to use external git repositories as dependencies. -# These are useful dependencies that we may use in the future. - -# YAML parser -message(STATUS "- yaml-cpp") -FetchContent_Declare( - yaml-cpp - GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git - GIT_TAG yaml-cpp-0.7.0 -) -FetchContent_MakeAvailable(yaml-cpp) -install(DIRECTORY ${yaml-cpp_SOURCE_DIR}/include DESTINATION .) -install(TARGETS yaml-cpp DESTINATION lib) - -# Logging library -message(STATUS "- spdlog") -FetchContent_Declare( - spdlog - GIT_REPOSITORY https://github.com/gabime/spdlog.git - GIT_TAG v1.9.2 -) -FetchContent_MakeAvailable(spdlog) -install(DIRECTORY ${spdlog_SOURCE_DIR}/include DESTINATION .) -install(TARGETS spdlog DESTINATION lib) From 7cfa5d34fdbe9d604492240118d6c067d08c7bb7 Mon Sep 17 00:00:00 2001 From: lobis Date: Thu, 24 Mar 2022 12:43:55 +0100 Subject: [PATCH 43/61] CMakeLists.txt - simplified cmake testing --- CMakeLists.txt | 6 +++--- cmake/Testing.cmake | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 300912767..a120d866f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,7 @@ endif () set(external_include_dirs ${external_include_dirs} ${ROOT_INCLUDE_DIRS}) -# This is to enable linking of SQL libraries. I.e. for process TRestSQLToAnalysisProccess. +# This is to enable linking of SQL libraries. I.e. for process TRestSQLToAnalysisProcess. if (NOT DEFINED SQL) set(SQL OFF) endif () @@ -123,13 +123,13 @@ message(STATUS "external libraries to link: " ${external_libs}) # Gather some information string(TIMESTAMP date "%Y-%m-%d %H:%M") -# Enable testing (-DTEST=ON flag) +# Enable testing (-DTEST=ON flag, it is OFF by default) include(Testing) -ENABLE_TESTING_CONDITIONALLY() # Start compile include(MacroRootDict) add_subdirectory(source) + message("") message(STATUS "rest Libraries: " ${rest_libraries_regular}) message(STATUS "rest executables: " ${rest_exes}) diff --git a/cmake/Testing.cmake b/cmake/Testing.cmake index 27faf90eb..4f20c346e 100644 --- a/cmake/Testing.cmake +++ b/cmake/Testing.cmake @@ -1,14 +1,13 @@ -macro(ENABLE_TESTING_CONDITIONALLY) - if (NOT DEFINED TEST OR NOT TEST) - set(TEST OFF) - message(STATUS "Testing disabled (Disabled by default, enabled via -DTEST=ON flag)") - endif () - if (TEST) - message(STATUS "Testing enabled (Disabled by default, enabled via -DTEST=ON flag)") - enable_testing() - add_compile_definitions(REST_TESTING_ENABLED) - endif () -endmacro() + +if (NOT DEFINED TEST OR NOT TEST) + set(TEST OFF) + message(STATUS "Testing disabled (Disabled by default, enabled via -DTEST=ON flag)") +endif () +if (TEST) + message(STATUS "Testing enabled (Disabled by default, enabled via -DTEST=ON flag)") + enable_testing() + add_compile_definitions(REST_TESTING_ENABLED) +endif () macro(ADD_TEST) if (TEST) From 848f2da8d77c520512e697478f14e6b67b00c4c9 Mon Sep 17 00:00:00 2001 From: lobis Date: Thu, 24 Mar 2022 13:00:40 +0100 Subject: [PATCH 44/61] CMakeLists.txt - reverted minimum version to 3.5, since it has some unexpected side effects... --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a120d866f..956b88d35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.16) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(REST) From 95551792c63e111511a6d53046cb2212c29d7bd3 Mon Sep 17 00:00:00 2001 From: lobis Date: Thu, 24 Mar 2022 13:18:10 +0100 Subject: [PATCH 45/61] .gitlab-ci.yml - named artifacts --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5cf4c80b4..6d87cfc6e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -88,6 +88,7 @@ Build and Test: - ctest --verbose -O ${CI_PROJECT_DIR}/build/Testing/summary.txt artifacts: + name: "Testing" paths: - ${CI_PROJECT_DIR}/build/Testing expire_in: 1 day @@ -103,6 +104,7 @@ Build and Install: - make install -j2 artifacts: + name: "Install" paths: - ${CI_PROJECT_DIR}/install expire_in: 1 day From 45797b7e22bd1b105bef68a8dfbd76a2b3e0a6f9 Mon Sep 17 00:00:00 2001 From: Luis Obis <35803280+lobis@users.noreply.github.com> Date: Thu, 24 Mar 2022 15:18:24 +0100 Subject: [PATCH 46/61] .gitlab-ci.yml - fix multiline command not working --- .gitlab-ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6d87cfc6e..67d8954f5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -82,8 +82,7 @@ Build and Test: - cd ${CI_PROJECT_DIR} - python3 pull-submodules.py --force --dontask --latest:${CI_COMMIT_BRANCH} - mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - - cmake ${CI_PROJECT_DIR} - -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON + - cmake ${CI_PROJECT_DIR} -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON - make -j2 - ctest --verbose -O ${CI_PROJECT_DIR}/build/Testing/summary.txt @@ -99,8 +98,7 @@ Build and Install: - cd ${CI_PROJECT_DIR} - rm -rf ${CI_PROJECT_DIR}/build && mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - rm -rf ${CI_PROJECT_DIR}/install - - cmake ${CI_PROJECT_DIR} -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install - -DREST_WELCOME=OFF -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON + - cmake ${CI_PROJECT_DIR} -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install -DREST_WELCOME=OFF - make install -j2 artifacts: From e58bdf43282a40febc52c6454faa48eae37bb707 Mon Sep 17 00:00:00 2001 From: lobis Date: Thu, 24 Mar 2022 15:47:46 +0100 Subject: [PATCH 47/61] cmake - removed old `FindGarfieldOld.cmake` --- cmake/FindGarfieldOld.cmake | 51 ------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 cmake/FindGarfieldOld.cmake diff --git a/cmake/FindGarfieldOld.cmake b/cmake/FindGarfieldOld.cmake deleted file mode 100644 index c1271368a..000000000 --- a/cmake/FindGarfieldOld.cmake +++ /dev/null @@ -1,51 +0,0 @@ -# - Try to find Garfield++ installation -# This module sets up Garfield information -# It defines: -# Garfield_FOUND If Garfield++ is found -# Garfield_INCLUDE_DIRS PATH to the include directories -# Garfield_LIBRARIES the libraries needed to use Garfield++ - -message(STATUS "Looking for Garfield using 'FindGarfieldOld.cmake'") - -set(Garfield_DIR $ENV{GARFIELD_HOME}) - -find_path(Garfield_INCLUDE_DIRS Sensor.hh - HINTS ${Garfield_DIR}/Include ${Garfield_DIR}/Include/Garfield - ${Garfield_DIR}/include ${Garfield_DIR}/include/Garfield) - -find_path(Garfield_INCLUDE_Heed_DIRS HeedChamber.hh - HINTS ${Garfield_DIR}/Heed) - -find_library(Garfield_LIBRARIES NAMES libGarfield.so Garfield - HINTS ${Garfield_DIR}/lib ${Garfield_LIB_DIR}) - -if (Garfield_INCLUDE_DIRS AND Garfield_LIBRARIES) - set(Garfield_FOUND TRUE) -endif () - -if (NOT DEFINED ENV{GARFIELD_HOME}) - message("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nError : GARFIELD HOME is not defined! - \nCheck Garfield is installed and GARFIELD_HOME is pointing to install directory - \nHINT : GARFIELD_HOME/lib/libGarfield.so should exist. - \nIf you do not need Garfield++ interface in your REST installation, then, - \nplease, run cmake disabling REST_GARFIELD variable - \n\ni.e. : cmake -DREST_GARFIELD=OFF ../ - \n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n") -endif () - -if (Garfield_FOUND) - if (NOT Garfield_FIND_QUIETLY) - message(STATUS "Found Garfield includes in ${Garfield_INCLUDE_DIRS}") - message(STATUS "Found Garfield libraries ${Garfield_LIBRARIES}") - endif (NOT Garfield_FIND_QUIETLY) -else (Garfield_FOUND) - if (Garfield_FIND_REQUIRED) - message(FATAL_ERROR "Garfield required, but not found!\ntry to run \"./scripts/installation/v2.2/installGarfield.sh\" to install it. - ") - endif (Garfield_FIND_REQUIRED) -endif (Garfield_FOUND) - -# Make variables changeable to the advanced user -mark_as_advanced(Garfield_INCLUDE_DIRS) -mark_as_advanced(Garfield_LIBRARIES) -mark_as_advanced(Garfield_LIBRARY_DIR) From 4c962f038e8a3cd639d835ba4dc25bb795198942 Mon Sep 17 00:00:00 2001 From: lobis Date: Thu, 24 Mar 2022 16:08:41 +0100 Subject: [PATCH 48/61] .gitlab-ci.yml - pulling submodules twice, for the time being --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 67d8954f5..ea1e19966 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -80,7 +80,7 @@ Build and Test: type: test script: - cd ${CI_PROJECT_DIR} - - python3 pull-submodules.py --force --dontask --latest:${CI_COMMIT_BRANCH} + - yes | python3 pull-submodules.py --force --latest:${CI_COMMIT_BRANCH} - mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - cmake ${CI_PROJECT_DIR} -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON - make -j2 @@ -96,6 +96,7 @@ Build and Install: type: build script: - cd ${CI_PROJECT_DIR} + - yes | python3 pull-submodules.py --force --latest:${CI_COMMIT_BRANCH} - rm -rf ${CI_PROJECT_DIR}/build && mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - rm -rf ${CI_PROJECT_DIR}/install - cmake ${CI_PROJECT_DIR} -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install -DREST_WELCOME=OFF From 8bb32822aeeea48f5c697c51fbf9c76344bfa6d6 Mon Sep 17 00:00:00 2001 From: lobis Date: Thu, 24 Mar 2022 16:11:20 +0100 Subject: [PATCH 49/61] .gitlab-ci.yml - cmake now is multiline for better readability --- .gitlab-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea1e19966..4225595a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -82,7 +82,8 @@ Build and Test: - cd ${CI_PROJECT_DIR} - yes | python3 pull-submodules.py --force --latest:${CI_COMMIT_BRANCH} - mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - - cmake ${CI_PROJECT_DIR} -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON + - cmake ${CI_PROJECT_DIR} + -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON - make -j2 - ctest --verbose -O ${CI_PROJECT_DIR}/build/Testing/summary.txt @@ -99,7 +100,8 @@ Build and Install: - yes | python3 pull-submodules.py --force --latest:${CI_COMMIT_BRANCH} - rm -rf ${CI_PROJECT_DIR}/build && mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - rm -rf ${CI_PROJECT_DIR}/install - - cmake ${CI_PROJECT_DIR} -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install -DREST_WELCOME=OFF + - cmake ${CI_PROJECT_DIR} -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install + -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON -DREST_WELCOME=OFF - make install -j2 artifacts: From 15d0f83119018c683a932edab2efe310ea0fad2c Mon Sep 17 00:00:00 2001 From: lobis Date: Thu, 24 Mar 2022 16:16:15 +0100 Subject: [PATCH 50/61] .gitlab-ci.yml - reverted change to `pull-submodules` --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4225595a8..045ea92ed 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -80,7 +80,7 @@ Build and Test: type: test script: - cd ${CI_PROJECT_DIR} - - yes | python3 pull-submodules.py --force --latest:${CI_COMMIT_BRANCH} + - python3 pull-submodules.py --force --dontask --latest:${CI_COMMIT_BRANCH} - mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - cmake ${CI_PROJECT_DIR} -DTEST=ON -DREST_GARFIELD=ON -DREST_G4=ON -DRESTLIB_DETECTOR=ON -DRESTLIB_RAW=ON -DRESTLIB_TRACK=ON @@ -97,7 +97,7 @@ Build and Install: type: build script: - cd ${CI_PROJECT_DIR} - - yes | python3 pull-submodules.py --force --latest:${CI_COMMIT_BRANCH} + - python3 pull-submodules.py --force --dontask --latest:${CI_COMMIT_BRANCH} - rm -rf ${CI_PROJECT_DIR}/build && mkdir ${CI_PROJECT_DIR}/build && cd ${CI_PROJECT_DIR}/build - rm -rf ${CI_PROJECT_DIR}/install - cmake ${CI_PROJECT_DIR} -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install From dc2019086c6c723bbe04082cf9b16a917e8966c1 Mon Sep 17 00:00:00 2001 From: lobis Date: Fri, 25 Mar 2022 12:14:21 +0100 Subject: [PATCH 51/61] Revert "cmake - removed old `FindGarfieldOld.cmake`" This reverts commit e58bdf43282a40febc52c6454faa48eae37bb707. --- cmake/FindGarfieldOld.cmake | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 cmake/FindGarfieldOld.cmake diff --git a/cmake/FindGarfieldOld.cmake b/cmake/FindGarfieldOld.cmake new file mode 100644 index 000000000..c1271368a --- /dev/null +++ b/cmake/FindGarfieldOld.cmake @@ -0,0 +1,51 @@ +# - Try to find Garfield++ installation +# This module sets up Garfield information +# It defines: +# Garfield_FOUND If Garfield++ is found +# Garfield_INCLUDE_DIRS PATH to the include directories +# Garfield_LIBRARIES the libraries needed to use Garfield++ + +message(STATUS "Looking for Garfield using 'FindGarfieldOld.cmake'") + +set(Garfield_DIR $ENV{GARFIELD_HOME}) + +find_path(Garfield_INCLUDE_DIRS Sensor.hh + HINTS ${Garfield_DIR}/Include ${Garfield_DIR}/Include/Garfield + ${Garfield_DIR}/include ${Garfield_DIR}/include/Garfield) + +find_path(Garfield_INCLUDE_Heed_DIRS HeedChamber.hh + HINTS ${Garfield_DIR}/Heed) + +find_library(Garfield_LIBRARIES NAMES libGarfield.so Garfield + HINTS ${Garfield_DIR}/lib ${Garfield_LIB_DIR}) + +if (Garfield_INCLUDE_DIRS AND Garfield_LIBRARIES) + set(Garfield_FOUND TRUE) +endif () + +if (NOT DEFINED ENV{GARFIELD_HOME}) + message("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nError : GARFIELD HOME is not defined! + \nCheck Garfield is installed and GARFIELD_HOME is pointing to install directory + \nHINT : GARFIELD_HOME/lib/libGarfield.so should exist. + \nIf you do not need Garfield++ interface in your REST installation, then, + \nplease, run cmake disabling REST_GARFIELD variable + \n\ni.e. : cmake -DREST_GARFIELD=OFF ../ + \n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n") +endif () + +if (Garfield_FOUND) + if (NOT Garfield_FIND_QUIETLY) + message(STATUS "Found Garfield includes in ${Garfield_INCLUDE_DIRS}") + message(STATUS "Found Garfield libraries ${Garfield_LIBRARIES}") + endif (NOT Garfield_FIND_QUIETLY) +else (Garfield_FOUND) + if (Garfield_FIND_REQUIRED) + message(FATAL_ERROR "Garfield required, but not found!\ntry to run \"./scripts/installation/v2.2/installGarfield.sh\" to install it. + ") + endif (Garfield_FIND_REQUIRED) +endif (Garfield_FOUND) + +# Make variables changeable to the advanced user +mark_as_advanced(Garfield_INCLUDE_DIRS) +mark_as_advanced(Garfield_LIBRARIES) +mark_as_advanced(Garfield_LIBRARY_DIR) From 8902794f6bc0a97f61ebeb31e845b2da2065429a Mon Sep 17 00:00:00 2001 From: lobis Date: Fri, 25 Mar 2022 14:54:04 +0100 Subject: [PATCH 52/61] Testing - better structure for test file --- source/framework/test/src/FrameworkCore.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/framework/test/src/FrameworkCore.cxx b/source/framework/test/src/FrameworkCore.cxx index b6f0ecca1..d92eb31de 100644 --- a/source/framework/test/src/FrameworkCore.cxx +++ b/source/framework/test/src/FrameworkCore.cxx @@ -9,6 +9,7 @@ namespace fs = std::filesystem; using namespace std; #define FILES_PATH fs::path(__FILE__).parent_path().parent_path() / "files" +#define BASIC_TRESTRUN_RML FILES_PATH / "TRestRunBasic.rml" TEST(FrameworkCore, TestFiles) { cout << "FrameworkCore test files path: " << FILES_PATH << endl; @@ -17,14 +18,14 @@ TEST(FrameworkCore, TestFiles) { EXPECT_TRUE(fs::is_directory(FILES_PATH)); // Check it's not empty EXPECT_TRUE(!fs::is_empty(FILES_PATH)); + // Check required files exist + EXPECT_TRUE(fs::exists(BASIC_TRESTRUN_RML)); } TEST(FrameworkCore, TRestRun) { - const auto basicRunRml = FILES_PATH / "TRestRunBasic.rml"; - TRestRun run; - run.LoadConfigFromFile(basicRunRml); + run.LoadConfigFromFile(BASIC_TRESTRUN_RML); run.PrintAllMetadata(); From ddf1a6d53f80b977895128d00ad64b993ada5a7a Mon Sep 17 00:00:00 2001 From: lobis Date: Fri, 25 Mar 2022 18:06:22 +0100 Subject: [PATCH 53/61] Testing - updated executable name --- source/framework/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/framework/test/CMakeLists.txt b/source/framework/test/CMakeLists.txt index 8d9766ced..b8550d017 100644 --- a/source/framework/test/CMakeLists.txt +++ b/source/framework/test/CMakeLists.txt @@ -1,4 +1,4 @@ -set(TESTING_EXECUTABLE testFramework) +set(TESTING_EXECUTABLE testRestFramework) enable_testing() From 8acb4689338f8bb93abe67b4950aefb63f6f29c5 Mon Sep 17 00:00:00 2001 From: lobis Date: Fri, 25 Mar 2022 18:44:14 +0100 Subject: [PATCH 54/61] Removed old `testing` directory as it is now obsolete --- testing/dockerfiles/README.md | 22 ---------------- testing/dockerfiles/REST/Dockerfile | 9 ------- testing/dockerfiles/ROOT/Dockerfile | 41 ----------------------------- testing/tests/README.md | 3 --- 4 files changed, 75 deletions(-) delete mode 100644 testing/dockerfiles/README.md delete mode 100644 testing/dockerfiles/REST/Dockerfile delete mode 100644 testing/dockerfiles/ROOT/Dockerfile delete mode 100644 testing/tests/README.md diff --git a/testing/dockerfiles/README.md b/testing/dockerfiles/README.md deleted file mode 100644 index cede7cf9a..000000000 --- a/testing/dockerfiles/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Introduction - -This section will contain everything necessary to build the docker containers used in the CI/CD pipeline. - -The base image for all other images is an ubuntu:18.04 image containing an installation of root and basic dependencies. All other images (e.g. REST image) will be built on top of this base image. - -This image's `Dockerfile` is under the *ROOT* directory. This image can be build with any version of ROOT via environment variable passing, to build this image run the following command (if no version is specified it defaults to ROOT version `6.16.00`): - -``` -ROOT_VERSION=6.16.00 -docker build -t root:${ROOT_VERSION} --build-arg ROOT_VERSION=${ROOT_VERSION} --build-arg MAKE_N_JOBS=3 . -``` - -Where the `-t` option is used to give the image a name (`root_v6.16.00` in this case) and `--build-arg ROOT_VERSION` is to assign a value to the `ROOT_VERSION` variable inside the `Dockerfile`. In this example we used an environment variable to keep the naming of the image consistent with the installed ROOT version. Remember you need to be on the directory of the `Dockerfile` (or use the `-f PATH_TO_DOCKERFILE` option) and have superuser privileges. - -# Container Registry - -In the near future we will use a feature called the GitLab container registry to upload our images built using the dockerfiles contained here. It is important to use this registry and not a public one (for example https://hub.docker.com/) because our images may contain sensitive information. - -For example the ROOT image could be public since it does not contain any sensitive information but in order to build the REST image one needs to pass a deployment key in order for the container to clone the REST repository. This is considered sensitive information therefor this image has to be kept private. - -We would pass the deployment key (and any other sensitive information) via `--build-arg` flag when building locally and then upload the image to the GitLab registry. it is important to mention that someone with access to the image still could recover this information unless we do a multi-stage build (and the sensitive information is not on the last stage). \ No newline at end of file diff --git a/testing/dockerfiles/REST/Dockerfile b/testing/dockerfiles/REST/Dockerfile deleted file mode 100644 index 989ff26ca..000000000 --- a/testing/dockerfiles/REST/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -# -# author: Luis Obis (lobis@unizar.es) -# - -# TODO: implement this image from the gitlab container registry root base image once its running - -FROM ubuntu:18.04 - -CMD ["/bin/bash"] \ No newline at end of file diff --git a/testing/dockerfiles/ROOT/Dockerfile b/testing/dockerfiles/ROOT/Dockerfile deleted file mode 100644 index 2520cb262..000000000 --- a/testing/dockerfiles/ROOT/Dockerfile +++ /dev/null @@ -1,41 +0,0 @@ -# -# author: Luis Obis (lobis@unizar.es) -# - -FROM ubuntu:18.04 - -RUN apt-get update -# root dependencies -RUN apt-get install -y git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev -RUN apt-get install -y gfortran libssl-dev libpcre3-dev \ - xlibmesa-glu-dev libglew1.5-dev libftgl-dev \ - libmysqlclient-dev libfftw3-dev libcfitsio-dev \ - graphviz-dev libavahi-compat-libdnssd-dev \ - libldap2-dev python-dev libxml2-dev libkrb5-dev \ - libgsl0-dev libqt4-dev -RUN apt-get install -y curl - -# download and build ROOT with provided options -ARG ROOT_VERSION="6.16.00" -RUN curl -o /tmp/root.tar.gz https://root.cern/download/root_v${ROOT_VERSION}.source.tar.gz -RUN tar xzfv /tmp/root.tar.gz -C /opt && rm -rf /tmp/root.tar.gz -WORKDIR /opt/root-${ROOT_VERSION}/build - -ARG ROOT_INSTALL_PREFIX=/opt/root -ARG MAKE_N_JOBS="" -# $((`nproc` + 1)) = number of cores + 1 for the fastest make -# MAKE_N_JOBS can be passed as argument in --build-arg -RUN if [ -z "$MAKE_N_JOBS" ]; then MAKE_N_JOBS=$((`nproc` + 1)); fi -RUN cmake -DCMAKE_INSTALL_PREFIX=$ROOT_INSTALL_PREFIX -DCXX17=ON -DGDML=ON .. -RUN make install -j$MAKE_N_JOBS -# remove downloaded sources - -WORKDIR / -RUN rm -rf /opt/root-${ROOT_VERSION}/ - -# set environment variables -ENV ROOTSYS "${ROOT_INSTALL_PREFIX}" -ENV PATH "${ROOTSYS}/bin:${PATH}" -ENV LD_LIBRARY_PATH "${ROOTSYS}/lib:${LD_LIBRARY_PATH}" - -CMD ["/bin/bash"] diff --git a/testing/tests/README.md b/testing/tests/README.md deleted file mode 100644 index 118f06fa8..000000000 --- a/testing/tests/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Introduction - -This section will contain all the unit tests and related files. \ No newline at end of file From 2f3b4b7640435aa66ce4c07b98d65a83ea164a16 Mon Sep 17 00:00:00 2001 From: lobis Date: Fri, 25 Mar 2022 18:45:18 +0100 Subject: [PATCH 55/61] Updated testing cmake to reduce code replication --- cmake/Testing.cmake | 41 ++++++++++++++++++++++++++++ source/framework/CMakeLists.txt | 2 +- source/framework/test/CMakeLists.txt | 22 --------------- 3 files changed, 42 insertions(+), 23 deletions(-) delete mode 100644 source/framework/test/CMakeLists.txt diff --git a/cmake/Testing.cmake b/cmake/Testing.cmake index 4f20c346e..24186b00b 100644 --- a/cmake/Testing.cmake +++ b/cmake/Testing.cmake @@ -15,3 +15,44 @@ macro(ADD_TEST) add_subdirectory(test) endif () endmacro() + +macro(ADD_LIBRARY_TEST) + if (TEST) + message(STATUS "Adding tests at ${CMAKE_CURRENT_SOURCE_DIR}") + set(TESTING_EXECUTABLE testRestGeant4) + + get_filename_component(DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) + + string(SUBSTRING ${DIR_NAME} 0 1 FIRST_LETTER) + string(TOUPPER ${FIRST_LETTER} FIRST_LETTER) + string(REGEX REPLACE "^.(.*)" "${FIRST_LETTER}\\1" DIR_NAME_CAPITALIZED "${DIR_NAME}") + + set(LIBRARY_NAME "Rest${DIR_NAME_CAPITALIZED}") + message(STATUS "TESTING: ${LIBRARY_NAME}") + + set(TESTING_EXECUTABLE "test${LIBRARY_NAME}") + + enable_testing() + + add_executable(${TESTING_EXECUTABLE}) + + FILE(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test/src/*.cxx) + target_sources( + ${TESTING_EXECUTABLE} PUBLIC + ${SOURCES} + ) + + target_link_libraries( + ${TESTING_EXECUTABLE} PUBLIC + ${LIBRARY_NAME} + gtest_main + RestFramework + stdc++fs # + ) + + include(GoogleTest) + + gtest_discover_tests(${TESTING_EXECUTABLE}) + + endif () +endmacro() diff --git a/source/framework/CMakeLists.txt b/source/framework/CMakeLists.txt index ebccdfb4d..cec32bb4d 100644 --- a/source/framework/CMakeLists.txt +++ b/source/framework/CMakeLists.txt @@ -12,4 +12,4 @@ endif (NOT ${REST_EVE} MATCHES "ON") COMPILEDIR(RestFramework) -ADD_TEST() +ADD_LIBRARY_TEST() diff --git a/source/framework/test/CMakeLists.txt b/source/framework/test/CMakeLists.txt deleted file mode 100644 index b8550d017..000000000 --- a/source/framework/test/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -set(TESTING_EXECUTABLE testRestFramework) - -enable_testing() - -add_executable(${TESTING_EXECUTABLE}) - -FILE(GLOB SOURCES src/*.cxx) -target_sources( - ${TESTING_EXECUTABLE} PUBLIC - ${SOURCES} -) - -target_link_libraries( - ${TESTING_EXECUTABLE} PUBLIC - gtest_main - RestFramework - stdc++fs # -) - -include(GoogleTest) - -gtest_discover_tests(${TESTING_EXECUTABLE}) From b7ca972a9a3daa4e0f13f8f49d30ad42efdc3fc8 Mon Sep 17 00:00:00 2001 From: DavidDiezIb Date: Sat, 26 Mar 2022 20:34:35 +0100 Subject: [PATCH 56/61] New Test for TRestMetadata --- source/framework/test/files/metadata.rml | 1 + source/framework/test/src/FrameworkCore.cxx | 25 +++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 source/framework/test/files/metadata.rml diff --git a/source/framework/test/files/metadata.rml b/source/framework/test/files/metadata.rml new file mode 100644 index 000000000..6172b3576 --- /dev/null +++ b/source/framework/test/files/metadata.rml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/framework/test/src/FrameworkCore.cxx b/source/framework/test/src/FrameworkCore.cxx index d92eb31de..b6b9aef21 100644 --- a/source/framework/test/src/FrameworkCore.cxx +++ b/source/framework/test/src/FrameworkCore.cxx @@ -1,5 +1,6 @@ #include +#include #include #include @@ -10,6 +11,7 @@ using namespace std; #define FILES_PATH fs::path(__FILE__).parent_path().parent_path() / "files" #define BASIC_TRESTRUN_RML FILES_PATH / "TRestRunBasic.rml" +#define BASIC_TRESTMETADATA_RML FILES_PATH / "metadata.rml" TEST(FrameworkCore, TestFiles) { cout << "FrameworkCore test files path: " << FILES_PATH << endl; @@ -37,3 +39,26 @@ TEST(FrameworkCore, TRestRun) { EXPECT_TRUE(run.GetRunDescription() == "This is a test for TRestRun"); EXPECT_TRUE(run.GetVerboseLevelString() == "debug"); } + +TEST(FrameworkCore, TRestMetadata) { + // Check required files exist + EXPECT_TRUE(fs::exists(BASIC_TRESTMETADATA_RML)); + + // Create new TRestMetadata class + class metadataTestClass: public TRestMetadata{ + int fP1; + double fP2; + string fP3; + }; + + metadataTestClass meta; + meta.LoadConfigFromFile(BASIC_TRESTMETADATA_RML, "metadata"); + + meta.PrintMetadata(); + //cout << meta.GetParameter("p1") << endl; + + EXPECT_TRUE(meta.GetParameter("p1") == "75"); + EXPECT_TRUE(meta.GetParameter("p2") == "12.32"); + EXPECT_TRUE(meta.GetParameter("p3") == "Aloha"); + +} From b3c32b41c3728498f2b4ad768d9dac3a4dd9a7b1 Mon Sep 17 00:00:00 2001 From: DavidDiezIb Date: Sat, 26 Mar 2022 20:35:54 +0100 Subject: [PATCH 57/61] Remove commented line --- source/framework/test/src/FrameworkCore.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/source/framework/test/src/FrameworkCore.cxx b/source/framework/test/src/FrameworkCore.cxx index b6b9aef21..98d7e5928 100644 --- a/source/framework/test/src/FrameworkCore.cxx +++ b/source/framework/test/src/FrameworkCore.cxx @@ -55,7 +55,6 @@ TEST(FrameworkCore, TRestMetadata) { meta.LoadConfigFromFile(BASIC_TRESTMETADATA_RML, "metadata"); meta.PrintMetadata(); - //cout << meta.GetParameter("p1") << endl; EXPECT_TRUE(meta.GetParameter("p1") == "75"); EXPECT_TRUE(meta.GetParameter("p2") == "12.32"); From d06a89fd84b64cab08b0a2c3d2789a64d3807995 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Sun, 27 Mar 2022 12:04:25 +0200 Subject: [PATCH 58/61] Testing - formatting --- source/framework/test/files/metadata.rml | 2 +- source/framework/test/src/FrameworkCore.cxx | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/source/framework/test/files/metadata.rml b/source/framework/test/files/metadata.rml index 6172b3576..b854944da 100644 --- a/source/framework/test/files/metadata.rml +++ b/source/framework/test/files/metadata.rml @@ -1 +1 @@ - \ No newline at end of file + diff --git a/source/framework/test/src/FrameworkCore.cxx b/source/framework/test/src/FrameworkCore.cxx index 98d7e5928..88b769146 100644 --- a/source/framework/test/src/FrameworkCore.cxx +++ b/source/framework/test/src/FrameworkCore.cxx @@ -1,6 +1,6 @@ -#include #include +#include #include #include @@ -22,6 +22,7 @@ TEST(FrameworkCore, TestFiles) { EXPECT_TRUE(!fs::is_empty(FILES_PATH)); // Check required files exist EXPECT_TRUE(fs::exists(BASIC_TRESTRUN_RML)); + EXPECT_TRUE(fs::exists(BASIC_TRESTMETADATA_RML)); } TEST(FrameworkCore, TRestRun) { @@ -41,16 +42,13 @@ TEST(FrameworkCore, TRestRun) { } TEST(FrameworkCore, TRestMetadata) { - // Check required files exist - EXPECT_TRUE(fs::exists(BASIC_TRESTMETADATA_RML)); - // Create new TRestMetadata class - class metadataTestClass: public TRestMetadata{ + class metadataTestClass : public TRestMetadata { int fP1; double fP2; string fP3; }; - + metadataTestClass meta; meta.LoadConfigFromFile(BASIC_TRESTMETADATA_RML, "metadata"); @@ -59,5 +57,4 @@ TEST(FrameworkCore, TRestMetadata) { EXPECT_TRUE(meta.GetParameter("p1") == "75"); EXPECT_TRUE(meta.GetParameter("p2") == "12.32"); EXPECT_TRUE(meta.GetParameter("p3") == "Aloha"); - } From 410460498ce5412277ab73bf47e668a047f3ea96 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Sun, 27 Mar 2022 12:07:14 +0200 Subject: [PATCH 59/61] Testing - refactored testings by @DavidDiezIb --- .../framework/test/files/TRestMetadataTest.rml | 1 + source/framework/test/files/metadata.rml | 1 - source/framework/test/src/FrameworkCore.cxx | 16 ++++++++-------- 3 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 source/framework/test/files/TRestMetadataTest.rml delete mode 100644 source/framework/test/files/metadata.rml diff --git a/source/framework/test/files/TRestMetadataTest.rml b/source/framework/test/files/TRestMetadataTest.rml new file mode 100644 index 000000000..b4c1b8857 --- /dev/null +++ b/source/framework/test/files/TRestMetadataTest.rml @@ -0,0 +1 @@ + diff --git a/source/framework/test/files/metadata.rml b/source/framework/test/files/metadata.rml deleted file mode 100644 index b854944da..000000000 --- a/source/framework/test/files/metadata.rml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/source/framework/test/src/FrameworkCore.cxx b/source/framework/test/src/FrameworkCore.cxx index 88b769146..1adac057c 100644 --- a/source/framework/test/src/FrameworkCore.cxx +++ b/source/framework/test/src/FrameworkCore.cxx @@ -11,7 +11,7 @@ using namespace std; #define FILES_PATH fs::path(__FILE__).parent_path().parent_path() / "files" #define BASIC_TRESTRUN_RML FILES_PATH / "TRestRunBasic.rml" -#define BASIC_TRESTMETADATA_RML FILES_PATH / "metadata.rml" +#define BASIC_TRESTMETADATA_RML FILES_PATH / "TRestMetadataTest.rml" TEST(FrameworkCore, TestFiles) { cout << "FrameworkCore test files path: " << FILES_PATH << endl; @@ -43,18 +43,18 @@ TEST(FrameworkCore, TRestRun) { TEST(FrameworkCore, TRestMetadata) { // Create new TRestMetadata class - class metadataTestClass : public TRestMetadata { + class TRestMetadataTest : public TRestMetadata { int fP1; double fP2; string fP3; }; - metadataTestClass meta; - meta.LoadConfigFromFile(BASIC_TRESTMETADATA_RML, "metadata"); + TRestMetadataTest restMetadataTest; + restMetadataTest.LoadConfigFromFile(BASIC_TRESTMETADATA_RML, "metadata"); - meta.PrintMetadata(); + restMetadataTest.PrintMetadata(); - EXPECT_TRUE(meta.GetParameter("p1") == "75"); - EXPECT_TRUE(meta.GetParameter("p2") == "12.32"); - EXPECT_TRUE(meta.GetParameter("p3") == "Aloha"); + EXPECT_TRUE(restMetadataTest.GetParameter("p1") == "75"); + EXPECT_TRUE(restMetadataTest.GetParameter("p2") == "12.32"); + EXPECT_TRUE(restMetadataTest.GetParameter("p3") == "Aloha"); } From 337138aabbec64cf2cdc85d663872732969356d3 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Sun, 27 Mar 2022 12:27:16 +0200 Subject: [PATCH 60/61] cmake/Testing.cmake - removed msg --- cmake/Testing.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/Testing.cmake b/cmake/Testing.cmake index 24186b00b..41fe65f74 100644 --- a/cmake/Testing.cmake +++ b/cmake/Testing.cmake @@ -28,7 +28,6 @@ macro(ADD_LIBRARY_TEST) string(REGEX REPLACE "^.(.*)" "${FIRST_LETTER}\\1" DIR_NAME_CAPITALIZED "${DIR_NAME}") set(LIBRARY_NAME "Rest${DIR_NAME_CAPITALIZED}") - message(STATUS "TESTING: ${LIBRARY_NAME}") set(TESTING_EXECUTABLE "test${LIBRARY_NAME}") From b6efb43d445be515714a4b11434e4b36b87de758 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Sun, 27 Mar 2022 12:41:28 +0200 Subject: [PATCH 61/61] Testing - fixed error in test --- source/framework/test/src/FrameworkCore.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/framework/test/src/FrameworkCore.cxx b/source/framework/test/src/FrameworkCore.cxx index 1adac057c..960663bba 100644 --- a/source/framework/test/src/FrameworkCore.cxx +++ b/source/framework/test/src/FrameworkCore.cxx @@ -50,7 +50,7 @@ TEST(FrameworkCore, TRestMetadata) { }; TRestMetadataTest restMetadataTest; - restMetadataTest.LoadConfigFromFile(BASIC_TRESTMETADATA_RML, "metadata"); + restMetadataTest.LoadConfigFromFile(BASIC_TRESTMETADATA_RML, "TRestMetadataTest"); restMetadataTest.PrintMetadata();