diff --git a/cmake/FindAEC.cmake b/cmake/FindAEC.cmake new file mode 100644 index 000000000..ae1d7ffad --- /dev/null +++ b/cmake/FindAEC.cmake @@ -0,0 +1,39 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. + +# - Try to find AEC (Adaptive Entropy Coding library) +# See https://www.dkrz.de/redmine/projects/aec/wiki + +# Once done this will define +# AEC_FOUND - System has AEC +# AEC_INCLUDE_DIRS - The AEC include directories +# AEC_LIBRARIES - The libraries needed to use AEC +# +# The following paths will be searched with priority if set in CMake or env +# +# AEC_DIR - prefix path of the AEC installation +# AEC_PATH - prefix path of the AEC installation + +find_path( AEC_INCLUDE_DIR szlib.h + PATHS ${AEC_DIR} ${AEC_PATH} ENV AEC_DIR ENV AEC_PATH + PATH_SUFFIXES include include/aec NO_DEFAULT_PATH ) +find_path( AEC_INCLUDE_DIR szlib.h PATH_SUFFIXES include include/aec ) + +find_library( AEC_LIBRARY NAMES aec + PATHS ${AEC_DIR} ${AEC_PATH} ENV AEC_DIR ENV AEC_PATH + PATH_SUFFIXES lib lib64 lib/aec lib64/aec NO_DEFAULT_PATH ) +find_library( AEC_LIBRARY NAMES aec PATH_SUFFIXES lib lib64 lib/aec lib64/aec ) + +set( AEC_LIBRARIES ${AEC_LIBRARY} ) +set( AEC_INCLUDE_DIRS ${AEC_INCLUDE_DIR} ) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(AEC DEFAULT_MSG AEC_LIBRARY AEC_INCLUDE_DIR) + +mark_as_advanced(AEC_INCLUDE_DIR AEC_LIBRARY ) diff --git a/cmake/FindNumPy.cmake b/cmake/FindNumPy.cmake new file mode 100644 index 000000000..ba02cec57 --- /dev/null +++ b/cmake/FindNumPy.cmake @@ -0,0 +1,101 @@ +# - Find the NumPy libraries +# This module finds if NumPy is installed, and sets the following variables +# indicating where it is. +# +# TODO: Update to provide the libraries and paths for linking npymath lib. +# +# NUMPY_FOUND - was NumPy found +# NUMPY_VERSION - the version of NumPy found as a string +# NUMPY_VERSION_MAJOR - the major version number of NumPy +# NUMPY_VERSION_MINOR - the minor version number of NumPy +# NUMPY_VERSION_PATCH - the patch version number of NumPy +# NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601 +# NUMPY_INCLUDE_DIRS - path to the NumPy include files + +#============================================================================ +# Copyright 2012 Continuum Analytics, Inc. +# +# MIT License +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +#============================================================================ + +# Finding NumPy involves calling the Python interpreter +if(NumPy_FIND_REQUIRED) + find_package(PythonInterp REQUIRED) +else() + find_package(PythonInterp) +endif() + +if(NOT PYTHONINTERP_FOUND) + set(NUMPY_FOUND FALSE) + return() +endif() + +execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" + "import numpy as n; print(n.__version__); print(n.get_include());" + RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS + OUTPUT_VARIABLE _NUMPY_VALUES_OUTPUT + ERROR_VARIABLE _NUMPY_ERROR_VALUE + OUTPUT_STRIP_TRAILING_WHITESPACE) + +if(NOT _NUMPY_SEARCH_SUCCESS MATCHES 0) + if(NumPy_FIND_REQUIRED) + message(FATAL_ERROR + "NumPy import failure:\n${_NUMPY_ERROR_VALUE}") + endif() + set(NUMPY_FOUND FALSE) + return() +endif() + +# Convert the process output into a list +string(REGEX REPLACE ";" "\\\\;" _NUMPY_VALUES ${_NUMPY_VALUES_OUTPUT}) +string(REGEX REPLACE "\n" ";" _NUMPY_VALUES ${_NUMPY_VALUES}) +# Just in case there is unexpected output from the Python command. +list(GET _NUMPY_VALUES -2 NUMPY_VERSION) +list(GET _NUMPY_VALUES -1 NUMPY_INCLUDE_DIRS) + +string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" _VER_CHECK "${NUMPY_VERSION}") +if("${_VER_CHECK}" STREQUAL "") + # The output from Python was unexpected. Raise an error always + # here, because we found NumPy, but it appears to be corrupted somehow. + message(FATAL_ERROR + "Requested version and include path from NumPy, got instead:\n${_NUMPY_VALUES_OUTPUT}\n") + return() +endif() + +# Make sure all directory separators are '/' +string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) + +# Get the major and minor version numbers +string(REGEX REPLACE "\\." ";" _NUMPY_VERSION_LIST ${NUMPY_VERSION}) +list(GET _NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR) +list(GET _NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR) +list(GET _NUMPY_VERSION_LIST 2 NUMPY_VERSION_PATCH) +string(REGEX MATCH "[0-9]*" NUMPY_VERSION_PATCH ${NUMPY_VERSION_PATCH}) +math(EXPR NUMPY_VERSION_DECIMAL + "(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}") + +find_package_message(NUMPY + "Found NumPy: version \"${NUMPY_VERSION}\" ${NUMPY_INCLUDE_DIRS}" + "${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}") + +set(NUMPY_FOUND TRUE) \ No newline at end of file diff --git a/cmake/FindOpenJPEG.cmake b/cmake/FindOpenJPEG.cmake new file mode 100644 index 000000000..2e26ade26 --- /dev/null +++ b/cmake/FindOpenJPEG.cmake @@ -0,0 +1,54 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation nor +# does it submit to any jurisdiction. + +# - Try to find the OpenJPEG includes and library (version 1.5.x or 2.1.x) +# This module defines +# +# OPENJPEG_FOUND - System has OpenJPEG +# OPENJPEG_INCLUDE_DIRS - the OpenJPEG include directories +# OPENJPEG_LIBRARIES - the libraries needed to use OpenJPEG +# +# The following paths will be searched with priority if set in CMake or env +# +# OPENJPEG_DIR - root folder of the OpenJPEG installation +# OPENJPEG_PATH - root folder of the OpenJPEG installation + +# Note: OpenJPEG has a version-specific subdirectory in the include +# e.g. include/openjpeg-2.0 or include/openjpeg-2.1. +# Only version 1.5.x and 2.1.x are supported. +# The library name is different for 1.x (libopenjpeg) and 2.x (libopenjp2). + +set( _suff include include/openjpeg include/openjpeg-1.5 include/openjpeg-2.1 ) +find_path( OPENJPEG_INCLUDE_DIR openjpeg.h + PATHS ${OPENJPEG_PATH} ENV OPENJPEG_PATH + ${OPENJPEG_DIR} ENV OPENJPEG_DIR + PATH_SUFFIXES ${_suff} + NO_DEFAULT_PATH ) +find_path( OPENJPEG_INCLUDE_DIR openjpeg.h + PATH_SUFFIXES ${_suff} ) +unset( _suff ) + +find_library( OPENJPEG_LIBRARY NAMES openjpeg openjp2 + PATHS ${OPENJPEG_PATH} ENV OPENJPEG_PATH + ${OPENJPEG_DIR} ENV OPENJPEG_DIR + PATH_SUFFIXES lib lib/openjpeg + NO_DEFAULT_PATH ) +find_library( OPENJPEG_LIBRARY NAMES openjpeg openjp2 + PATH_SUFFIXES lib lib/openjpeg ) + +set( OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARY} ) +set( OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIR} ) + +include(FindPackageHandleStandardArgs) + +# handle the QUIETLY and REQUIRED arguments and set OPENJPEG_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(OpenJPEG DEFAULT_MSG + OPENJPEG_LIBRARY OPENJPEG_INCLUDE_DIR) + +mark_as_advanced( OPENJPEG_INCLUDE_DIR OPENJPEG_LIBRARY )