mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-10 00:45:36 +00:00
proper cmake package config
This commit is contained in:
parent
534013fd87
commit
d786524508
@ -6,6 +6,7 @@ project(
|
||||
LANGUAGES C CXX)
|
||||
|
||||
# includes
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(FetchContent)
|
||||
include(FindPackageMessage)
|
||||
include(GNUInstallDirs)
|
||||
@ -30,7 +31,7 @@ file(CREATE_LINK ${eigen3_SOURCE_DIR}/Eigen ${CMAKE_SOURCE_DIR}/lib/LatAnalyze/E
|
||||
# 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(
|
||||
@ -40,7 +41,7 @@ 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(
|
||||
|
@ -53,8 +53,29 @@ 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
28
lib/Config.cmake.in
Normal 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)
|
Loading…
Reference in New Issue
Block a user