Skip to content

Commit

Permalink
moving in sub cmake files
Browse files Browse the repository at this point in the history
  • Loading branch information
nadrino committed Dec 2, 2023
1 parent 66b5039 commit 1bdec6a
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 174 deletions.
62 changes: 16 additions & 46 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,41 @@ cmake_minimum_required( VERSION 3.12 FATAL_ERROR )

project( GUNDAM )

# necessary ?
include( CTest )

# colored messages
include( ${CMAKE_SOURCE_DIR}/cmake/utils/cmessage.cmake )

cmessage(STATUS "Setting up CMake files...")

# define cmake options
include( ${CMAKE_SOURCE_DIR}/cmake/options.cmake )
include( ${CMAKE_SOURCE_DIR}/cmake/version.cmake )

# ?
include( CTest )


################################################################################
# Check Dependencies
################################################################################
# git version checking
include( ${CMAKE_SOURCE_DIR}/cmake/version.cmake )

# checking dependencies
include( ${CMAKE_SOURCE_DIR}/cmake/dependencies.cmake )
include( ${CMAKE_SOURCE_DIR}/cmake/compiler.cmake )
include( ${CMAKE_SOURCE_DIR}/cmake/submodules.cmake )

################################################################################
# Specify Target Subdirs
################################################################################

message("")
cmessage(STATUS "Defining modules...")

set( MODULES Utils )
# setup compiler options
include( ${CMAKE_SOURCE_DIR}/cmake/compiler.cmake )

# Add the basic modules
list( APPEND MODULES DialDictionary)
list( APPEND MODULES ParametersManager)
list( APPEND MODULES SamplesManager)
list( APPEND MODULES DatasetManager)
list( APPEND MODULES Propagator)
list( APPEND MODULES Fitter)
# setting up submodule libraries
include( ${CMAKE_SOURCE_DIR}/cmake/submodules.cmake )

if(WITH_CACHE_MANAGER)
list( APPEND MODULES CacheManager )
endif()
# defining GUNDAM modules
include( ${CMAKE_SOURCE_DIR}/cmake/modules.cmake )

foreach(mod ${MODULES})
cmessage( STATUS "Adding cmake module: ${mod}" )
add_subdirectory( ${CMAKE_SOURCE_DIR}/src/${mod} )
endforeach()
# defining GUNDAM applications
include( ${CMAKE_SOURCE_DIR}/cmake/applications.cmake )


message("")
cmessage(STATUS "Defining applications...")

add_subdirectory( ${CMAKE_SOURCE_DIR}/src/Applications )
add_subdirectory( ${CMAKE_SOURCE_DIR}/tests )

configure_file(cmake/build_setup.sh.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh" @ONLY)
install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh"
DESTINATION ${CMAKE_INSTALL_PREFIX})

cmessage( STATUS "Identified GUNDAM version: ${GUNDAM_VERSION_STRING}" )
cmessage( WARNING "Identified GUNDAM version: ${GUNDAM_VERSION_STRING}+${GUNDAM_VERSION_POST_NB}-${GUNDAM_VERSION_POST_COMMIT}/${GUNDAM_VERSION_BRANCH}" )

# A command that works to compile gundam from any sub-directory. You
# can get this aliased to "gundam-build" by sourcing
#
# . "$(git rev-parse --show-toplevel)/cmake/gundam-setup.sh"
# . "$(git rev-parse --show-toplevel)/cmake/scripts/gundam-setup.sh"
#
# That runs:
# Local Variables:
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ SHELL ["/bin/bash", "-c"]

RUN apt-get dist-upgrade -y
RUN apt-get update && apt-get upgrade -y
RUN apt-get install git libyaml-cpp-dev nlohmann-json3-dev -y
RUN apt-get install git libyaml-cpp-dev -y
RUN #apt-get install git libyaml-cpp-dev nlohmann-json3-dev -y

ENV WORK_DIR /home/work
ENV REPO_DIR $WORK_DIR/repo
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ a new release is available, simply use the same command.

```bash
cd $REPO_DIR/gundam
cd cmake
cd cmake/scripts
./gundam-setup.sh
./gundam-build.sh
```
Expand Down
69 changes: 0 additions & 69 deletions cmake/CMakeSetup.sh

This file was deleted.

12 changes: 12 additions & 0 deletions cmake/applications.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

message("")
cmessage( WARNING "Defining applications...")

add_subdirectory( ${CMAKE_SOURCE_DIR}/src/Applications )
add_subdirectory( ${CMAKE_SOURCE_DIR}/tests )

configure_file(cmake/generated/build_setup.sh.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh" @ONLY)
install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh"
DESTINATION ${CMAKE_INSTALL_PREFIX})

16 changes: 8 additions & 8 deletions cmake/compiler.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


message("")
cmessage(STATUS "Configuring compiler options...")
cmessage( WARNING "Configuring compiler options...")

# Changes default install path to be a subdirectory of the build dir.
# Should set the installation dir at configure time with
Expand All @@ -28,7 +28,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" )
cmessage(FATAL_ERROR "Clang version must be at least 3.3" )
endif()
else()
cmessage(WARNING "You are using an untested compiler." )
cmessage( ALERT "You are using an untested compiler." )
endif()

# CXX standard is required and must match the version ROOT was compiled with.
Expand All @@ -48,7 +48,7 @@ elseif ( ROOT_cxx20_FOUND )
cmessage(STATUS "ROOT compiled with C++20")
set(CMAKE_CXX_STANDARD 20)
else ( ROOT_cxx14_FOUND )
cmessage(WARNING "ROOT C++ standard not set, use ROOT minimum (C++14)")
cmessage( ALERT "ROOT C++ standard not set, use ROOT minimum (C++14)")
set(CMAKE_CXX_STANDARD 14)
endif ( ROOT_cxx14_FOUND)

Expand Down Expand Up @@ -80,9 +80,9 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIC -g")
# CMake Generated
###############################################################################

cmessage (STATUS "C++ Compiler : ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
cmessage (STATUS "C++ Standard : ${CMAKE_CXX_STANDARD}")
cmessage (STATUS "C++ Release flags : ${CMAKE_CXX_FLAGS_RELEASE}")
cmessage (STATUS "C++ Debug flags : ${CMAKE_CXX_FLAGS_DEBUG}")
cmessage (STATUS "Build type : ${CMAKE_BUILD_TYPE}")
cmessage( STATUS "C++ Compiler : ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" )
cmessage( STATUS "C++ Standard : ${CMAKE_CXX_STANDARD}" )
cmessage( STATUS "C++ Release flags : ${CMAKE_CXX_FLAGS_RELEASE}" )
cmessage( STATUS "C++ Debug flags : ${CMAKE_CXX_FLAGS_DEBUG}" )
cmessage( STATUS "Build type : ${CMAKE_BUILD_TYPE}" )

66 changes: 37 additions & 29 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@


message("")
cmessage(STATUS "Checking dependencies...")
cmessage( WARNING "Checking dependencies...")


cmessage( STATUS "Looking for JSON install..." )
find_package( nlohmann_json QUIET )

if( nlohmann_json_FOUND )
cmessage( STATUS "nlohmann JSON library found.")
link_libraries( nlohmann_json::nlohmann_json )
else()
cmessage( ALERT "nlohmann JSON library not found. Using fetch content... (CMake version >= 3.11)")
cmake_minimum_required( VERSION 3.11 FATAL_ERROR )
include( FetchContent )

FetchContent_Declare( json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz )
FetchContent_MakeAvailable( json )

include_directories( ${nlohmann_json_SOURCE_DIR}/include )
cmessage( STATUS "nlohmann JSON library fetched: ${nlohmann_json_SOURCE_DIR}/include")
endif()


##########
Expand All @@ -11,17 +30,22 @@ cmessage(STATUS "Checking dependencies...")
#If you want to try an use the terminally buggy ROOT CMake scripts
# ROOTConfig.cmake -> usually in /install/dir/of/root/6.26.06_2/share/root/cmake

cmessage( WARNING "Looking for ROOT install..." )
cmessage( STATUS "Looking for ROOT install..." )
find_package(
ROOT
REQUIRED COMPONENTS
Geom Physics Matrix MathCore Tree RIO
OPTIONAL_COMPONENTS
REQUIRED
COMPONENTS
Matrix
Tree
Minuit2
Physics
Matrix
MathCore
RIO
)

if(ROOT_FOUND)
cmessage(STATUS "[ROOT]: ROOT found")
cmessage( STATUS "[ROOT]: ROOT found" )
include(${ROOT_USE_FILE})
# cmessage(STATUS "[ROOT]: ROOT packages found ${ROOT_LIBRARIES}")
cmessage( STATUS "[ROOT]: ROOT include directory: ${ROOT_INCLUDE_DIRS}")
Expand Down Expand Up @@ -99,30 +123,13 @@ endif(NOT ROOT_minuit2_FOUND)
# NLOHMANN JSON
####################

find_package(nlohmann_json)

if (nlohmann_json_FOUND)
cmessage( STATUS "nlohmann JSON library found")
# Additional actions for when the library is found
else()
# sometimes the header can be found in ROOT...
find_path(NLOHMANN_JSON_INCLUDE_DIR NAMES nlohmann/json.hpp)

if (NLOHMANN_JSON_INCLUDE_DIR)
cmessage( STATUS "nlohmann JSON header found: ${NLOHMANN_JSON_INCLUDE_DIR}/nlohmann/json.hpp")
# Additional actions for when the library is found
else()
cmessage( FATAL_ERROR "nlohmann JSON library not found")
# Additional actions for when the library is not found
endif()
endif()


####################
# YAML-CPP
####################

cmessage( WARNING "Looking for YAML install..." )
cmessage( STATUS "Looking for YAML install..." )
find_package( yaml-cpp REQUIRED HINTS ${YAMLCPP_DIR} )
if(NOT yaml-cpp_FOUND)
cmessage(FATAL_ERROR "yaml-cpp library not found.")
Expand All @@ -133,8 +140,8 @@ cmessage( STATUS "yaml-cpp include directory: ${YAML_CPP_INCLUDE_DIR}")
cmessage( STATUS "yaml-cpp lib: ${YAML_CPP_LIBRARIES}")
if( "${YAML_CPP_INCLUDE_DIR} " STREQUAL " ")
# WORKAROUND FOR CCLYON (old cmake version/pkg)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils )
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils )
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils )
set( CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils )
set(YAMLCPP_INSTALL_DIR ${YAMLCPP_DIR})
find_package( YAMLCPP REQUIRED )
if( NOT YAMLCPP_FOUND )
Expand All @@ -155,14 +162,15 @@ endif()
# ZLIB (optional)
####################

cmessage( WARNING "Looking for optional ZLib install..." )
cmessage( STATUS "Looking for optional ZLib install..." )
find_package(ZLIB)
if (${ZLIB_FOUND})
cmessage( STATUS "ZLIB found : ${ZLIB_VERSION_STRING}")
cmessage( STATUS "ZLIB_INCLUDE_DIRS = ${ZLIB_INCLUDE_DIRS}")
cmessage( STATUS "ZLIB_LIBRARIES = ${ZLIB_LIBRARIES}")
add_definitions( -D USE_ZLIB=1 )
else()
cmessage( WARNING "ZLib not found. Will compile without the associated features." )
add_definitions( -D USE_ZLIB=0 )
endif ()

Expand Down Expand Up @@ -191,9 +199,9 @@ if( ENABLE_CUDA )
endif()
endif()
cmessage( STATUS "CUDA compilation architectures: \"${CMAKE_CUDA_ARCHITECTURES}\"")
cmessage(WARNING "The \"--cache-manager\" option requires a GPU")
cmessage( ALERT "The \"--cache-manager\" option requires a GPU" )
else(CMAKE_CUDA_COMPILER)
cmessage(WARNING "CUDA not present -- Cache::Manager use the CPU")
cmessage( ALERT "CUDA not present -- Cache::Manager use the CPU")
endif(CMAKE_CUDA_COMPILER)
else( ENABLE_CUDA )
cmessage( ALERT "CUDA support disabled" )
Expand Down
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions cmake/modules.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

message("")
cmessage( WARNING "Defining modules...")

set( MODULES Utils )

# Add the basic modules
list( APPEND MODULES DialDictionary)
list( APPEND MODULES ParametersManager)
list( APPEND MODULES SamplesManager)
list( APPEND MODULES DatasetManager)
list( APPEND MODULES Propagator)
list( APPEND MODULES Fitter)

if(WITH_CACHE_MANAGER)
list( APPEND MODULES CacheManager )
endif()

foreach(mod ${MODULES})
cmessage( STATUS "Adding cmake module: ${mod}" )
add_subdirectory( ${CMAKE_SOURCE_DIR}/src/${mod} )
endforeach()
Loading

0 comments on commit 1bdec6a

Please sign in to comment.