Navigation Menu

Skip to content

Commit

Permalink
find Himalaya Libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Apr 4, 2018
1 parent 5aa33cd commit f1b6823
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -26,6 +26,7 @@ if(ENABLE_COMPILE)
find_package(Eigen3 3.1 REQUIRED NO_MODULE)
find_package(GSL REQUIRED)
# optional packages
find_himalaya()
find_lapack()
find_looptools()
find_threads()
Expand Down
142 changes: 142 additions & 0 deletions cmake/FindHimalaya.cmake
@@ -0,0 +1,142 @@
# Distributed under the GPLv3 License.
# Author: Alexander Voigt
#
# FindHimalaya
# -------------
#
# Finds the Himalaya library.
# [https://github.com/Himalaya-Library/Himalaya]
#
# This module reads the following variables:
#
# Himalaya_LIBRARY - Himalaya library directory
# Himalaya_INCLUDE_DIR - Himalaya include directory
#
# This module defines the following variables:
#
# Himalaya_FOUND - set if Himalaya has been found
# Himalaya_VERSION - Himalaya version
# Himalaya_INCLUDE_DIRS - Himalaya include directory
# Himalaya_LIBRARIES - Himalaya library
# DSZ_LIBRARIES - Library with MSSM 2-loop corrections O(at*as)
# G. Degrassi, P. Slavich and F. Zwirner,
# Nucl. Phys. B611 (2001) 403 [hep-ph/0105096]
#
# and defines the following imported targets:
#
# Himalaya::Himalaya
# Himalaya::DSZ

# search Himalaya_interface.hpp first in ${Himalaya_INCLUDE_DIR}
find_path(Himalaya_INCLUDE_DIRS
NAMES Himalaya_interface.hpp
PATHS
${Himalaya_INCLUDE_DIR}
PATH_SUFFIXES
include
source
source/include
NO_DEFAULT_PATH
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
NO_CMAKE_FIND_ROOT_PATH
)

find_path(Himalaya_INCLUDE_DIRS
NAMES Himalaya_interface.hpp
)

# search Himalaya library first in ${Himalaya_LIBRARY}
find_library(Himalaya_LIBRARIES
NAMES Himalaya
PATHS
${Himalaya_LIBRARY}
PATH_SUFFIXES
build
NO_DEFAULT_PATH
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
NO_CMAKE_FIND_ROOT_PATH
)

find_library(Himalaya_LIBRARIES
NAMES Himalaya
)

# search DSZ library first in ${Himalaya_LIBRARY}
find_library(DSZ_LIBRARIES
NAMES DSZ
PATHS
${Himalaya_LIBRARY}
PATH_SUFFIXES
build
NO_DEFAULT_PATH
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
NO_CMAKE_FIND_ROOT_PATH
)

find_library(DSZ_LIBRARIES
NAMES DSZ
)

# find version
if(Himalaya_INCLUDE_DIRS)
file(READ "${Himalaya_INCLUDE_DIRS}/version.hpp" _himalaya_version_header)

string(REGEX MATCH "define[ \t]+Himalaya_VERSION_MAJOR[ \t]+([0-9]+)" _himalaya_version_major_match "${_himalaya_version_header}")
set(Himalaya_VERSION_MAJOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+Himalaya_VERSION_MINOR[ \t]+([0-9]+)" _himalaya_version_minor_match "${_himalaya_version_header}")
set(Himalaya_VERSION_MINOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+Himalaya_VERSION_RELEASE[ \t]+([0-9]+)" _himalaya_version_release_match "${_himalaya_version_header}")
set(Himalaya_VERSION_RELEASE "${CMAKE_MATCH_1}")

set(Himalaya_VERSION ${Himalaya_VERSION_MAJOR}.${Himalaya_VERSION_MINOR}.${Himalaya_VERSION_RELEASE})

if(Himalaya_FIND_VERSION)
if(Himalaya_FIND_VERSION_EXACT AND NOT ${Himalaya_VERSION} VERSION_EQUAL ${Himalaya_FIND_VERSION})
message(FATAL_ERROR "Himalaya version ${Himalaya_VERSION} found in ${Himalaya_INCLUDE_DIRS}, "
"but exact version ${Himalaya_FIND_VERSION} is required.")
elseif(${Himalaya_VERSION} VERSION_LESS ${Himalaya_FIND_VERSION})
message(FATAL_ERROR "Himalaya version ${Himalaya_VERSION} found in ${Himalaya_INCLUDE_DIRS}, "
"but at least version ${Himalaya_FIND_VERSION} is required.")
endif()
endif()
endif()

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(Himalaya
FOUND_VAR Himalaya_FOUND
REQUIRED_VARS
Himalaya_LIBRARIES
Himalaya_INCLUDE_DIRS
DSZ_LIBRARIES
)

if(Himalaya_FOUND AND NOT TARGET Himalaya::Himalaya)
add_library(Himalaya::Himalaya UNKNOWN IMPORTED)
set_target_properties(Himalaya::Himalaya PROPERTIES
IMPORTED_LOCATION "${Himalaya_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${Himalaya_INCLUDE_DIRS}"
)
endif()

if(Himalaya_FOUND AND NOT TARGET Himalaya::DSZ)
add_library(Himalaya::DSZ UNKNOWN IMPORTED)
set_target_properties(Himalaya::DSZ PROPERTIES
IMPORTED_LOCATION "${DSZ_LIBRARIES}"
)
endif()

mark_as_advanced(
Himalaya_INCLUDE_DIRS
Himalaya_LIBRARIES
DSZ_LIBRARIES
)
2 changes: 1 addition & 1 deletion cmake/FlexibleSUSYBuildOptions.cmake
Expand Up @@ -24,7 +24,7 @@ option(WARNINGS_AS_ERRORS "Treat all warnings as errors" OFF)

# enable/disable external packages
option(ENABLE_FFLITE "Enable use of the FFLite loop functions (default: no)" OFF)
# option(ENABLE_HIMALAYA "Enable use of the Himalaya library (default: yes)" ON)
option(ENABLE_HIMALAYA "Enable use of the Himalaya library (default: no)" OFF)
option(ENABLE_LAPACK "Enable use of the LAPACK library (default: yes)" ON)
option(ENABLE_LOOPTOOLS "Enable use of the LoopTools library (default: no)" OFF)
option(ENABLE_SQLITE "Enable use of the SQLite3 library (default: ON)" ON)
18 changes: 18 additions & 0 deletions cmake/FlexibleSUSYOptionalPackages.cmake
Expand Up @@ -34,6 +34,24 @@ function(find_threads)
endif()
endfunction()

# ==================== Himalaya ====================
function(find_himalaya)
if(ENABLE_HIMALAYA)
find_package(Himalaya 1.0 REQUIRED)
fs_package_status_message("Enabling use of Himalaya.")
else()
fs_package_status_message("Disabling use of Himalaya.")
endif()
if(NOT TARGET Himalaya::Himalaya)
add_library(fs_himalaya INTERFACE)
add_library(Himalaya::Himalaya ALIAS fs_himalaya)
endif()
if(NOT TARGET Himalaya::DSZ)
add_library(fs_dsz INTERFACE)
add_library(Himalaya::DSZ ALIAS fs_dsz)
endif()
endfunction()

# ==================== LAPACK ====================
function(find_lapack)
find_optional_package(LAPACK ENABLE_LAPACK)
Expand Down

0 comments on commit f1b6823

Please sign in to comment.