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

Compare commits

...

4 Commits

Author SHA1 Message Date
d786524508 proper cmake package config 2024-02-08 19:08:44 +01:00
534013fd87 source list fix 2024-02-08 19:08:17 +01:00
1c8add56ef cmake comments 2024-02-08 15:00:09 +01:00
cce9faaba6 fix and cleanup of library compilation 2024-02-08 14:50:29 +01:00
4 changed files with 208 additions and 107 deletions

View File

@ -1,13 +1,20 @@
# package config
cmake_minimum_required(VERSION 3.11.0)
project(
LatAnalyze
VERSION 3.6
LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 14)
# includes
include(CMakePackageConfigHelpers)
include(FetchContent)
include(FindPackageMessage)
include(GNUInstallDirs)
# C++ standard
set(CMAKE_CXX_STANDARD 14)
# fetch and create symbolic link to Eigen headers
set(FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/deps)
FetchContent_Declare(
Eigen3
@ -21,22 +28,37 @@ endif()
file(CREATE_LINK ${eigen3_SOURCE_DIR}/Eigen ${CMAKE_SOURCE_DIR}/lib/LatAnalyze/Eigen
SYMBOLIC)
# dependencies
find_package(GSL REQUIRED)
find_package(HDF5 REQUIRED COMPONENTS C CXX)
find_package(Minuit2)
find_package(Minuit2 QUIET)
if(Minuit2_FOUND)
set(Minuit2_MSG "yes")
find_package_message(
Minuit2
"Found Minuit2: ${Minuit2_DIR} (found version \"${Minuit2_VERSION}\")" " ")
else()
set(Minuit2_MSG "no")
message(STATUS "Minuit2 not found")
endif()
find_package(NLopt)
find_package(NLopt QUIET)
if(NLopt_FOUND)
set(NLopt_MSG "yes")
find_package_message(
NLopt "Found NLopt: ${NLopt_DIR} (found version \"${NLopt_VERSION}\")" " ")
else()
set(NLopt_MSG "no")
message(STATUS "NLopt not found")
endif()
# subdirectories
add_subdirectory(lib)
# summary
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 "---------------------------")

View File

@ -1,13 +1,15 @@
# rpath config
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
# config.h header for package version and name
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
include(FindBISON)
include(FindFLEX)
# find bison & flex
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
# ASCII parser
bison_target(
AsciiParser LatAnalyze/Io/AsciiParser.ypp
${CMAKE_CURRENT_BINARY_DIR}/AsciiParser.cpp COMPILE_FLAGS "-Wno-deprecated")
@ -15,6 +17,7 @@ flex_target(AsciiLexer LatAnalyze/Io/AsciiLexer.lpp
${CMAKE_CURRENT_BINARY_DIR}/AsciiLexer.cpp)
add_flex_bison_dependency(AsciiLexer AsciiParser)
# math parser
bison_target(
MathParser LatAnalyze/Core/MathParser.ypp
${CMAKE_CURRENT_BINARY_DIR}/MathParser.cpp COMPILE_FLAGS "-Wno-deprecated")
@ -22,115 +25,57 @@ flex_target(MathLexer LatAnalyze/Core/MathLexer.lpp
${CMAKE_CURRENT_BINARY_DIR}/MathLexer.cpp)
add_flex_bison_dependency(MathLexer MathParser)
# library target
add_library(LatAnalyze SHARED)
file(GLOB_RECURSE EIGEN_HEADERS Eigen/*)
file(GLOB_RECURSE EIGEN_HEADERS LatAnalyze/Eigen/*)
target_include_directories(LatAnalyze PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
include(source-list.cmake)
target_sources(
LatAnalyze
PRIVATE ${BISON_AsciiParser_OUTPUTS}
${FLEX_AsciiLexer_OUTPUTS}
${BISON_MathParser_OUTPUTS}
${FLEX_MathLexer_OUTPUTS}
${CMAKE_CURRENT_BINARY_DIR}/config.h
LatAnalyze/Core/Exceptions.cpp
LatAnalyze/Core/Mat.cpp
LatAnalyze/Core/Math.cpp
LatAnalyze/Core/MathInterpreter.cpp
LatAnalyze/Core/OptParser.cpp
LatAnalyze/Core/Plot.cpp
LatAnalyze/Core/ThreadPool.cpp
LatAnalyze/Core/Utilities.cpp
LatAnalyze/Functional/CompiledFunction.cpp
LatAnalyze/Functional/CompiledModel.cpp
LatAnalyze/Functional/Function.cpp
LatAnalyze/Functional/Model.cpp
LatAnalyze/Functional/TabFunction.cpp
LatAnalyze/Global.cpp
LatAnalyze/Io/AsciiFile.cpp
LatAnalyze/Io/BinReader.cpp
LatAnalyze/Io/File.cpp
LatAnalyze/Io/Hdf5File.cpp
LatAnalyze/Io/Io.cpp
LatAnalyze/Io/Xml/tinyxml2.cpp
LatAnalyze/Io/XmlReader.cpp
LatAnalyze/Numerical/DWT.cpp
LatAnalyze/Numerical/DWTFilters.cpp
LatAnalyze/Numerical/Derivative.cpp
LatAnalyze/Numerical/GslFFT.cpp
LatAnalyze/Numerical/GslHybridRootFinder.cpp
LatAnalyze/Numerical/GslMinimizer.cpp
LatAnalyze/Numerical/GslQagsIntegrator.cpp
LatAnalyze/Numerical/Minimizer.cpp
LatAnalyze/Numerical/MinuitMinimizer.cpp
LatAnalyze/Numerical/NloptMinimizer.cpp
LatAnalyze/Numerical/RootFinder.cpp
LatAnalyze/Numerical/Solver.cpp
LatAnalyze/Physics/CorrelatorFitter.cpp
LatAnalyze/Physics/DataFilter.cpp
LatAnalyze/Physics/EffectiveMass.cpp
LatAnalyze/Statistics/FitInterface.cpp
LatAnalyze/Statistics/Histogram.cpp
LatAnalyze/Statistics/Random.cpp
LatAnalyze/Statistics/StatArray.cpp
LatAnalyze/Statistics/XYSampleData.cpp
LatAnalyze/Statistics/XYStatData.cpp
PRIVATE ${BISON_AsciiParser_OUTPUTS} ${FLEX_AsciiLexer_OUTPUTS}
${BISON_MathParser_OUTPUTS} ${FLEX_MathLexer_OUTPUTS}
${CMAKE_CURRENT_BINARY_DIR}/config.h ${LATAN_SOURCES}
PUBLIC FILE_SET
public_headers
TYPE
HEADERS
FILES
${EIGEN_HEADERS}
LatAnalyze/Core/Eigen.hpp
LatAnalyze/Core/EigenPlugin.hpp
LatAnalyze/Core/Exceptions.hpp
LatAnalyze/Core/Mat.hpp
LatAnalyze/Core/Math.hpp
LatAnalyze/Core/MathInterpreter.hpp
LatAnalyze/Core/OptParser.hpp
LatAnalyze/Core/ParserState.hpp
LatAnalyze/Core/Plot.hpp
LatAnalyze/Core/ThreadPool.hpp
LatAnalyze/Core/Utilities.hpp
LatAnalyze/Core/stdincludes.hpp
LatAnalyze/Functional/CompiledFunction.hpp
LatAnalyze/Functional/CompiledModel.hpp
LatAnalyze/Functional/Function.hpp
LatAnalyze/Functional/Model.hpp
LatAnalyze/Functional/TabFunction.hpp
LatAnalyze/Global.hpp
LatAnalyze/Io/AsciiFile.hpp
LatAnalyze/Io/BinReader.hpp
LatAnalyze/Io/File.hpp
LatAnalyze/Io/Hdf5File.hpp
LatAnalyze/Io/Io.hpp
LatAnalyze/Io/IoObject.hpp
LatAnalyze/Io/Xml/tinyxml2.hpp
LatAnalyze/Io/XmlReader.hpp
LatAnalyze/Numerical/DWT.hpp
LatAnalyze/Numerical/DWTFilters.hpp
LatAnalyze/Numerical/Derivative.hpp
LatAnalyze/Numerical/FFT.hpp
LatAnalyze/Numerical/GslFFT.hpp
LatAnalyze/Numerical/GslHybridRootFinder.hpp
LatAnalyze/Numerical/GslMinimizer.hpp
LatAnalyze/Numerical/GslQagsIntegrator.hpp
LatAnalyze/Numerical/Integrator.hpp
LatAnalyze/Numerical/Minimizer.hpp
LatAnalyze/Numerical/MinuitMinimizer.hpp
LatAnalyze/Numerical/NloptMinimizer.hpp
LatAnalyze/Numerical/RootFinder.hpp
LatAnalyze/Numerical/Solver.hpp
LatAnalyze/Physics/CorrelatorFitter.hpp
LatAnalyze/Physics/DataFilter.hpp
LatAnalyze/Physics/EffectiveMass.hpp
LatAnalyze/Statistics/Dataset.hpp
LatAnalyze/Statistics/FitInterface.hpp
LatAnalyze/Statistics/Histogram.hpp
LatAnalyze/Statistics/MatSample.hpp
LatAnalyze/Statistics/Random.hpp
LatAnalyze/Statistics/StatArray.hpp
LatAnalyze/Statistics/XYSampleData.hpp
LatAnalyze/Statistics/XYStatData.hpp
LatAnalyze/includes.hpp)
target_link_libraries(LatAnalyze PUBLIC GSL::gsl hdf5::hdf5 hdf5::hdf5_cpp
Minuit2::Minuit2 NLopt::nlopt)
${LATAN_HEADERS})
target_link_libraries(LatAnalyze PUBLIC GSL::gsl hdf5::hdf5 hdf5::hdf5_cpp)
if(Minuit2_FOUND)
target_link_libraries(LatAnalyze PUBLIC Minuit2::Minuit2)
endif()
if(NLopt_FOUND)
target_link_libraries(LatAnalyze PUBLIC NLopt::nlopt)
endif()
set_target_properties(LatAnalyze PROPERTIES VERSION ${PROJECT_VERSION})
target_include_directories(
LatAnalyze PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
# installation
install(
TARGETS LatAnalyze
EXPORT LatAnalyzeTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FILE_SET public_headers
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(
EXPORT LatAnalyzeTargets
FILE LatAnalyzeTargets.cmake
NAMESPACE LatAnalyze::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LatAnalyze)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/LatAnalyzeConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LatAnalyze)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/LatAnalyzeConfigVersion.cmake"
VERSION "${PROJECT_VERSION}"
COMPATIBILITY AnyNewerVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LatAnalyzeConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/LatAnalyzeConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LatAnalyze)

28
lib/Config.cmake.in Normal file
View File

@ -0,0 +1,28 @@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(GSL REQUIRED)
find_dependency(HDF5 REQUIRED COMPONENTS C CXX)
set(HAVE_Minuit2 @Minuit2_FOUND@)
set(HAVE_NLopt @NLopt_FOUND@)
if(HAVE_Minuit2)
find_dependency(Minuit2 REQUIRED)
list(APPEND _LatAnalyze_supported_components MINUIT2)
set(LatAnalyze_MINUIT2_FOUND True)
endif()
if(HAVE_NLopt)
find_dependency(NLopt REQUIRED)
list(APPEND _LatAnalyze_supported_components NLOPT)
set(LatAnalyze_NLOPT_FOUND True)
endif()
foreach(_comp ${LatAnalyze_FIND_COMPONENTS})
if (NOT ";${_LatAnalyze_supported_components};" MATCHES ";${_comp};")
set(LatAnalyze_FOUND False)
set(LatAnalyze_NOT_FOUND_MESSAGE "Unsupported LatAnalyze component: ${_comp}")
endif()
endforeach()
include("${CMAKE_CURRENT_LIST_DIR}/LatAnalyzeTargets.cmake")
check_required_components(LatAnalyze)

106
lib/source-list.cmake Normal file
View File

@ -0,0 +1,106 @@
set(LATAN_HEADERS
LatAnalyze/Core/Eigen.hpp
LatAnalyze/Core/EigenPlugin.hpp
LatAnalyze/Core/Exceptions.hpp
LatAnalyze/Core/Mat.hpp
LatAnalyze/Core/Math.hpp
LatAnalyze/Core/MathInterpreter.hpp
LatAnalyze/Core/OptParser.hpp
LatAnalyze/Core/ParserState.hpp
LatAnalyze/Core/Plot.hpp
LatAnalyze/Core/ThreadPool.hpp
LatAnalyze/Core/Utilities.hpp
LatAnalyze/Core/stdincludes.hpp
LatAnalyze/Functional/CompiledFunction.hpp
LatAnalyze/Functional/CompiledModel.hpp
LatAnalyze/Functional/Function.hpp
LatAnalyze/Functional/Model.hpp
LatAnalyze/Functional/TabFunction.hpp
LatAnalyze/Global.hpp
LatAnalyze/Io/AsciiFile.hpp
LatAnalyze/Io/BinReader.hpp
LatAnalyze/Io/File.hpp
LatAnalyze/Io/Hdf5File.hpp
LatAnalyze/Io/Io.hpp
LatAnalyze/Io/IoObject.hpp
LatAnalyze/Io/Xml/tinyxml2.hpp
LatAnalyze/Io/XmlReader.hpp
LatAnalyze/Numerical/DWT.hpp
LatAnalyze/Numerical/DWTFilters.hpp
LatAnalyze/Numerical/Derivative.hpp
LatAnalyze/Numerical/FFT.hpp
LatAnalyze/Numerical/GslFFT.hpp
LatAnalyze/Numerical/GslHybridRootFinder.hpp
LatAnalyze/Numerical/GslMinimizer.hpp
LatAnalyze/Numerical/GslQagsIntegrator.hpp
LatAnalyze/Numerical/Integrator.hpp
LatAnalyze/Numerical/Minimizer.hpp
LatAnalyze/Numerical/RootFinder.hpp
LatAnalyze/Numerical/Solver.hpp
LatAnalyze/Physics/CorrelatorFitter.hpp
LatAnalyze/Physics/DataFilter.hpp
LatAnalyze/Physics/EffectiveMass.hpp
LatAnalyze/Statistics/Dataset.hpp
LatAnalyze/Statistics/FitInterface.hpp
LatAnalyze/Statistics/Histogram.hpp
LatAnalyze/Statistics/MatSample.hpp
LatAnalyze/Statistics/Random.hpp
LatAnalyze/Statistics/StatArray.hpp
LatAnalyze/Statistics/XYSampleData.hpp
LatAnalyze/Statistics/XYStatData.hpp)
if(Minuit2_FOUND)
list(APPEND LATAN_HEADERS LatAnalyze/Numerical/MinuitMinimizer.hpp)
endif()
if(NLopt_FOUND)
list(APPEND LATAN_HEADERS LatAnalyze/Numerical/NloptMinimizer.hpp)
endif()
set(LATAN_SOURCES
LatAnalyze/Core/Exceptions.cpp
LatAnalyze/Core/Mat.cpp
LatAnalyze/Core/Math.cpp
LatAnalyze/Core/MathInterpreter.cpp
LatAnalyze/Core/OptParser.cpp
LatAnalyze/Core/Plot.cpp
LatAnalyze/Core/ThreadPool.cpp
LatAnalyze/Core/Utilities.cpp
LatAnalyze/Functional/CompiledFunction.cpp
LatAnalyze/Functional/CompiledModel.cpp
LatAnalyze/Functional/Function.cpp
LatAnalyze/Functional/Model.cpp
LatAnalyze/Functional/TabFunction.cpp
LatAnalyze/Global.cpp
LatAnalyze/Io/AsciiFile.cpp
LatAnalyze/Io/BinReader.cpp
LatAnalyze/Io/File.cpp
LatAnalyze/Io/Hdf5File.cpp
LatAnalyze/Io/Io.cpp
LatAnalyze/Io/Xml/tinyxml2.cpp
LatAnalyze/Io/XmlReader.cpp
LatAnalyze/Numerical/DWT.cpp
LatAnalyze/Numerical/DWTFilters.cpp
LatAnalyze/Numerical/Derivative.cpp
LatAnalyze/Numerical/GslFFT.cpp
LatAnalyze/Numerical/GslHybridRootFinder.cpp
LatAnalyze/Numerical/GslMinimizer.cpp
LatAnalyze/Numerical/GslQagsIntegrator.cpp
LatAnalyze/Numerical/Minimizer.cpp
LatAnalyze/Numerical/RootFinder.cpp
LatAnalyze/Numerical/Solver.cpp
LatAnalyze/Physics/CorrelatorFitter.cpp
LatAnalyze/Physics/DataFilter.cpp
LatAnalyze/Physics/EffectiveMass.cpp
LatAnalyze/Statistics/FitInterface.cpp
LatAnalyze/Statistics/Histogram.cpp
LatAnalyze/Statistics/Random.cpp
LatAnalyze/Statistics/StatArray.cpp
LatAnalyze/Statistics/XYSampleData.cpp
LatAnalyze/Statistics/XYStatData.cpp)
if(Minuit2_FOUND)
list(APPEND LATAN_SOURCES LatAnalyze/Numerical/MinuitMinimizer.cpp)
endif()
if(NLopt_FOUND)
list(APPEND LATAN_SOURCES LatAnalyze/Numerical/NloptMinimizer.cpp)
endif()