IAP GITLAB

Skip to content
Snippets Groups Projects
CMakeLists.txt 2.78 KiB
Newer Older
ralfulrich's avatar
ralfulrich committed
cmake_minimum_required (VERSION 3.4.3)
ralfulrich's avatar
ralfulrich committed

project (
  corsika
  VERSION 8.0.0
  DESCRIPTION "CORSIKA C++ project"
  LANGUAGES CXX
  )
ralfulrich's avatar
ralfulrich committed
# as long as there still are modules using it:
ralfulrich's avatar
ralfulrich committed
enable_language (Fortran)

# ignore many irrelevant Up-to-date messages during install
ralfulrich's avatar
ralfulrich committed
set (CMAKE_INSTALL_MESSAGE LAZY)

# directory for local cmake modules
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
include (CorsikaUtilities) # a few cmake function
set (CMAKE_CXX_EXTENSIONS OFF)
ralfulrich's avatar
ralfulrich committed
enable_testing ()
set (CTEST_OUTPUT_ON_FAILURE 1)

# Set a default build type if none was specified
set(default_build_type "Release")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
  set(default_build_type "Debug")
endif()
 
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to '${default_build_type}' as no other was specified.")
  set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
      STRING "Choose the type of build." FORCE)
  # Set the possible values of build type for cmake-gui
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
    "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
ralfulrich's avatar
ralfulrich committed
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
ralfulrich's avatar
ralfulrich committed
# enable warnings and disallow non-standard language
set(CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra -Wno-ignored-qualifiers")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g") # -O2 would not trade speed for size, neither O2/3 use fast-math 
# clang produces a lot of unecessary warnings without this:
Lukas Nellen's avatar
Lukas Nellen committed
add_compile_options("$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-nonportable-include-path>")
# COAST - interface
if (WITH_COAST)
  message(STATUS "Compiling CORSIKA8 for the use with COAST/corsika7.")
  add_compile_options("-fPIC")
endif()


# unit testing coverage, does not work yet
#include (CodeCoverage)
##set(COVERAGE_LCOV_EXCLUDES 'Documentation/*')
##setup_target_for_coverage(${PROJECT_NAME}_coverage ${PROJECT_TEST_NAME} coverage)
#SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML (
#  NAME corsika_coverage
#  EXECUTABLE ctest
#  #-j ${PROCESSOR_COUNT}
#  #     DEPENDENCIES corsika
#  )
ralfulrich's avatar
ralfulrich committed
#add_custom_target (corsika_pre_build)
#add_custom_command (TARGET corsika_pre_build PRE_BUILD COMMAND "${PROJECT_SOURCE_DIR}/pre_compile.py")
Hans Dembinski's avatar
Hans Dembinski committed
find_package (Boost 1.60 REQUIRED)
Lukas Nellen's avatar
Lukas Nellen committed
if (Boost_FOUND)
  include_directories(${Boost_INCLUDE_DIRS})
endif (Boost_FOUND)

find_package (Eigen3 REQUIRED)
#find_package (HDF5) # not yet needed
Hans Dembinski's avatar
Hans Dembinski committed
# order of subdirectories
add_subdirectory (ThirdParty)
ralfulrich's avatar
ralfulrich committed
add_subdirectory (Framework)
add_subdirectory (Environment)
add_subdirectory (Stack)
add_subdirectory (Documentation)
add_subdirectory (Main)
add_subdirectory (Tools)
if (WITH_COAST)
  add_subdirectory (COAST)
endif()