1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 00:45:36 +00:00
LatAnalyze/CMakeLists.txt

90 lines
2.7 KiB
CMake
Raw Normal View History

2024-02-08 14:00:09 +00:00
# package config
cmake_minimum_required(VERSION 3.11.0)
project(
LatAnalyze
VERSION 3.6
LANGUAGES C CXX)
2024-02-08 14:00:09 +00:00
# includes
2024-02-10 11:58:23 +00:00
include(CheckCXXCompilerFlag)
2024-02-08 18:08:44 +00:00
include(CMakePackageConfigHelpers)
include(FetchContent)
include(FindPackageMessage)
2024-02-08 13:50:29 +00:00
include(GNUInstallDirs)
2024-02-10 11:58:23 +00:00
# C++ compile flags
2024-02-08 14:00:09 +00:00
set(CMAKE_CXX_STANDARD 14)
2024-02-10 09:55:22 +00:00
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)
2024-02-10 11:58:23 +00:00
check_cxx_compiler_flag("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
set(MARCH_FLAG "-march=native")
endif()
check_cxx_compiler_flag("-mtune=native" COMPILER_SUPPORTS_MTUNE_NATIVE)
if(COMPILER_SUPPORTS_MTUNE_NATIVE)
set(MTUNE_FLAG "-mtune=native")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG ${MARCH_FLAG} ${MTUNE_FLAG}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG ${MARCH_FLAG} ${MTUNE_FLAG}")
set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
add_library(compiler_flags INTERFACE)
target_compile_features(compiler_flags INTERFACE cxx_std_14)
target_compile_options(
compiler_flags
INTERFACE "$<${gcc_like_cxx}:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused>")
2024-02-10 09:55:22 +00:00
# installation rpath setup
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
2024-02-08 14:00:09 +00:00
# fetch and create symbolic link to Eigen headers
set(FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/deps)
FetchContent_Declare(
Eigen3
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3.4.0)
FetchContent_GetProperties(Eigen3)
if(NOT eigen3_POPULATED)
FetchContent_Populate(Eigen3)
message(STATUS "Eigen3 fetched")
endif()
2024-02-10 11:58:23 +00:00
file(CREATE_LINK ${eigen3_SOURCE_DIR}/Eigen
${CMAKE_SOURCE_DIR}/lib/LatAnalyze/Eigen SYMBOLIC)
2024-02-08 14:00:09 +00:00
# dependencies
find_package(GSL REQUIRED)
find_package(HDF5 REQUIRED COMPONENTS C CXX)
2024-02-08 18:08:44 +00:00
find_package(Minuit2 QUIET)
if(Minuit2_FOUND)
2024-02-08 13:50:29 +00:00
set(Minuit2_MSG "yes")
find_package_message(
Minuit2
"Found Minuit2: ${Minuit2_DIR} (found version \"${Minuit2_VERSION}\")" " ")
else()
2024-02-08 13:50:29 +00:00
set(Minuit2_MSG "no")
message(STATUS "Minuit2 not found")
endif()
2024-02-08 18:08:44 +00:00
find_package(NLopt QUIET)
if(NLopt_FOUND)
2024-02-08 13:50:29 +00:00
set(NLopt_MSG "yes")
find_package_message(
NLopt "Found NLopt: ${NLopt_DIR} (found version \"${NLopt_VERSION}\")" " ")
else()
2024-02-08 13:50:29 +00:00
set(NLopt_MSG "no")
message(STATUS "NLopt not found")
endif()
2024-02-08 14:00:09 +00:00
# subdirectories
add_subdirectory(lib)
2024-02-10 09:55:22 +00:00
add_subdirectory(examples)
add_subdirectory(physics)
add_subdirectory(utils)
2024-02-08 13:50:29 +00:00
2024-02-08 14:00:09 +00:00
# summary
2024-02-08 13:50:29 +00:00
message(STATUS "---------------------------")
message(STATUS "LatAnalyze v${PROJECT_VERSION} configured")
message(STATUS "---------------------------")
message(STATUS " install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Minuit2 minimisers: ${Minuit2_MSG}")
message(STATUS " NLopt minimisers: ${NLopt_MSG}")
message(STATUS "---------------------------")