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

102 lines
3.7 KiB
CMake
Raw Normal View History

2024-02-08 14:00:09 +00:00
# config.h header for package version and name
2024-02-10 09:55:49 +00:00
execute_process(
COMMAND git rev-parse --short HEAD
OUTPUT_VARIABLE LATAN_SHORT_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND git rev-parse HEAD
OUTPUT_VARIABLE LATAN_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE LATAN_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
2024-02-08 14:00:09 +00:00
# find bison & flex
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
2024-02-08 14:00:09 +00:00
# ASCII parser
bison_target(
AsciiParser LatAnalyze/Io/AsciiParser.ypp
${CMAKE_CURRENT_BINARY_DIR}/AsciiParser.cpp COMPILE_FLAGS "-Wno-deprecated")
flex_target(AsciiLexer LatAnalyze/Io/AsciiLexer.lpp
${CMAKE_CURRENT_BINARY_DIR}/AsciiLexer.cpp)
add_flex_bison_dependency(AsciiLexer AsciiParser)
2024-02-08 14:00:09 +00:00
# math parser
bison_target(
MathParser LatAnalyze/Core/MathParser.ypp
${CMAKE_CURRENT_BINARY_DIR}/MathParser.cpp COMPILE_FLAGS "-Wno-deprecated")
flex_target(MathLexer LatAnalyze/Core/MathLexer.lpp
${CMAKE_CURRENT_BINARY_DIR}/MathLexer.cpp)
add_flex_bison_dependency(MathLexer MathParser)
2024-02-10 11:58:23 +00:00
# intermediate libraries
add_library(parsers STATIC)
target_include_directories(parsers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(
parsers PRIVATE ${BISON_AsciiParser_OUTPUTS} ${FLEX_AsciiLexer_OUTPUTS}
${BISON_MathParser_OUTPUTS} ${FLEX_MathLexer_OUTPUTS})
add_library(tinyxml2 STATIC)
target_include_directories(parsers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(tinyxml2 PRIVATE LatAnalyze/Io/Xml/tinyxml2.hpp
LatAnalyze/Io/Xml/tinyxml2.cpp)
2024-02-08 14:00:09 +00:00
# library target
add_library(LatAnalyze SHARED)
2024-02-08 13:50:29 +00:00
file(GLOB_RECURSE EIGEN_HEADERS LatAnalyze/Eigen/*)
target_include_directories(LatAnalyze PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
2024-02-08 13:50:29 +00:00
include(source-list.cmake)
target_sources(
LatAnalyze
2024-02-10 11:58:23 +00:00
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/config.h ${LATAN_SOURCES}
PUBLIC FILE_SET
public_headers
TYPE
HEADERS
FILES
${EIGEN_HEADERS}
2024-02-08 13:50:29 +00:00
${LATAN_HEADERS})
2024-02-10 11:58:23 +00:00
target_link_libraries(LatAnalyze PRIVATE compiler_flags parsers tinyxml2)
2024-02-10 18:12:59 +00:00
target_link_libraries(LatAnalyze PUBLIC GSL::gsl hdf5::hdf5 hdf5::hdf5_cpp
${CMAKE_THREAD_LIBS_INIT})
2024-02-08 13:50:29 +00:00
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}>)
2024-02-08 18:08:44 +00:00
# installation
2024-02-08 13:50:29 +00:00
install(
TARGETS LatAnalyze
2024-02-08 18:08:44 +00:00
EXPORT LatAnalyzeTargets
2024-02-08 13:50:29 +00:00
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
2024-02-08 18:08:44 +00:00
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
2024-02-08 13:50:29 +00:00
FILE_SET public_headers
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
2024-02-08 18:08:44 +00:00
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)