WSL/SLF GitLab Repository

Commit 747b48fd authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Added missing cmake files

parent 6270a54a
#SPDX-License-Identifier: LGPL-3.0-or-later
INCLUDE(LibFindMacros)
# Where can we find something that looks like a MeteoIO source tree?
FILE(GLOB mio_local_src LIST_DIRECTORIES TRUE ../[mM]eteo[iI][oO] ../../../[mM]eteo[iI][oO] ../[mM]eteo[iI][oO]-[0-9]* ../../../[mM]eteo[iI][oO]-[0-9]*)
LIST(LENGTH mio_local_src n)
IF("${n}" EQUAL "0")
SET(SRC_DIR ".")
ELSE("${n}" EQUAL "0")
LIST(GET mio_local_src 0 SRC_DIR) #only keep the first match
ENDIF("${n}" EQUAL "0")
IF(WIN32)
GET_FILENAME_COMPONENT(METEOIO_ROOT1 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MeteoIO;UninstallString]" PATH CACHE INTERNAL)
GET_FILENAME_COMPONENT(METEOIO_ROOT2 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MeteoIO;UninstallString]" PATH CACHE INTERNAL)
GET_FILENAME_COMPONENT(METEOIO_ROOT3 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WSL Institute for Snow and Avalanche Research\\MeteoIO]" ABSOLUTE CACHE INTERNAL)
GET_FILENAME_COMPONENT(METEOIO_ROOT4 "C:/Progra~1/MeteoI*" ABSOLUTE CACHE INTERNAL)
SET(SEARCH_PATH
ENV LIB
./lib ./bin
./lib/Debug ./bin/Debug
./lib/Release ./bin/Release
../../lib ../../bin
../../lib/Debug ../../bin/Debug
../../lib/Release ../../bin/Release
${SRC_DIR}/lib ${SRC_DIR}/bin
${SRC_DIR}/lib/Debug ${SRC_DIR}/bin/Debug
${SRC_DIR}/lib/Release ${SRC_DIR}/bin/Release
${SRC_DIR}/../../lib ${SRC_DIR}/../../bin
${SRC_DIR}/../../lib/Debug ${SRC_DIR}/../../bin/Debug
${SRC_DIR}/../../lib/Release ${SRC_DIR}/../../bin/Release
${SRC_DIR}/bin ${SRC_DIR}/lib
${METEOIO_ROOT1}/bin ${METEOIO_ROOT1}/lib
${METEOIO_ROOT2}/bin ${METEOIO_ROOT2}/lib
${METEOIO_ROOT3}/bin ${METEOIO_ROOT3}/lib
${METEOIO_ROOT4}/bin ${METEOIO_ROOT4}/lib)
IF(MSVC)
FIND_LIBRARY(METEOIO_LIBRARY
NAMES libmeteoio.lib
HINTS ${SEARCH_PATH}
DOC "Location of the libmeteoio, like c:/Program Files/MeteoIO-2.4.0/lib/libmeteoio.lib"
)
ELSE(MSVC)
FIND_LIBRARY(METEOIO_LIBRARY
NAMES libmeteoio.dll.a libmeteoio.a
HINTS ${SEARCH_PATH}
DOC "Location of the libmeteoio, like c:/Program Files/MeteoIO-2.4.0/lib/libmeteoio.dll.a"
)
ENDIF(MSVC)
ELSE(WIN32)
IF(APPLE)
FIND_LIBRARY(METEOIO_LIBRARY
NAMES meteoio
HINTS
ENV LD_LIBRARY_PATH
ENV DYLD_FALLBACK_LIBRARY_PATH
./lib
../../lib
../../../lib
${SRC_DIR}/lib
"~/usr/lib"
"/Applications/MeteoIO/lib"
"/usr/local/lib"
"/usr/lib"
"/opt/lib"
DOC "Location of the libmeteoio, like /usr/lib/libmeteoio.dylib"
)
ELSE(APPLE)
FIND_LIBRARY(METEOIO_LIBRARY
NAMES meteoio
HINTS
ENV LD_LIBRARY_PATH
./lib
../../lib
../../../lib
${SRC_DIR}/lib
"~/usr/lib"
"/usr/local/lib"
"/usr/lib"
"/opt/lib"
DOC "Location of the libmeteoio, like /usr/lib/libmeteoio.so"
)
ENDIF(APPLE)
ENDIF(WIN32)
IF(METEOIO_LIBRARY)
#build METEOIO_ROOT so we can provide a hint for searching for the header file
IF(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
GET_FILENAME_COMPONENT(METEOIO_ROOT ${METEOIO_LIBRARY} DIRECTORY) #get PATH
GET_FILENAME_COMPONENT(MSVC_TARGET ${METEOIO_ROOT} NAME) #special directory name for some MSVC
IF(("${MSVC_TARGET}" STREQUAL "Debug") OR ("${MSVC_TARGET}" STREQUAL "Release"))
GET_FILENAME_COMPONENT(METEOIO_ROOT ${METEOIO_ROOT} DIRECTORY) #go up one level
ENDIF(("${MSVC_TARGET}" STREQUAL "Debug") OR ("${MSVC_TARGET}" STREQUAL "Release"))
GET_FILENAME_COMPONENT(METEOIO_ROOT ${METEOIO_ROOT} DIRECTORY) #go up one level
ELSE(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
GET_FILENAME_COMPONENT(meteoio_libs_root ${METEOIO_LIBRARY} PATH)
SET(METEOIO_ROOT "${meteoio_libs_root}/../")
STRING(REPLACE " " "\\ " METEOIO_ROOT ${METEOIO_ROOT})
ENDIF(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
# locate main header file
FIND_PATH(METEOIO_INCLUDE_DIR
NAMES meteoio/MeteoIO.h
HINTS
"${METEOIO_ROOT}/include"
"${METEOIO_ROOT}"
"~/usr/include"
"/usr/local/include"
"/usr/include"
"/opt/include"
DOC "Location of the meteoio headers, like /usr/include"
)
ENDIF(METEOIO_LIBRARY)
# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
SET(METEOIO_PROCESS_INCLUDES METEOIO_INCLUDE_DIR)
SET(METEOIO_PROCESS_LIBS METEOIO_LIBRARY)
libfind_process(METEOIO)
# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
# used for the current package. For this to work, the first parameter must be the
# prefix of the current package, then the prefix of the new package etc, which are
# passed to find_package.
macro (libfind_package PREFIX)
set (LIBFIND_PACKAGE_ARGS ${ARGN})
if (${PREFIX}_FIND_QUIETLY)
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
endif (${PREFIX}_FIND_QUIETLY)
if (${PREFIX}_FIND_REQUIRED)
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
endif (${PREFIX}_FIND_REQUIRED)
find_package(${LIBFIND_PACKAGE_ARGS})
endmacro (libfind_package)
# Damn CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
# where they added pkg_check_modules. Consequently I need to support both in my scripts
# to avoid those deprecated warnings. Here's a helper that does just that.
# Works identically to pkg_check_modules, except that no checks are needed prior to use.
macro (libfind_pkg_check_modules PREFIX PKGNAME)
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
include(UsePkgConfig)
pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(${PREFIX} ${PKGNAME})
endif (PKG_CONFIG_FOUND)
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
endmacro (libfind_pkg_check_modules)
# Do the final processing once the paths have been detected.
# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
# all the variables, each of which contain one include directory.
# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
# Also handles errors in case library detection was required, etc.
macro (libfind_process PREFIX)
# Skip processing if already processed during this run
if (NOT ${PREFIX}_FOUND)
# Start with the assumption that the library was found
set (${PREFIX}_FOUND TRUE)
# Process all includes and set _FOUND to false if any are missing
foreach (i ${${PREFIX}_PROCESS_INCLUDES})
if (${i})
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
mark_as_advanced(${i})
else (${i})
set (${PREFIX}_FOUND FALSE)
endif (${i})
endforeach (i)
# Process all libraries and set _FOUND to false if any are missing
foreach (i ${${PREFIX}_PROCESS_LIBS})
if (${i})
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
mark_as_advanced(${i})
else (${i})
set (${PREFIX}_FOUND FALSE)
endif (${i})
endforeach (i)
# Print message and/or exit on fatal error
if (${PREFIX}_FOUND)
if (NOT ${PREFIX}_FIND_QUIETLY)
message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
endif (NOT ${PREFIX}_FIND_QUIETLY)
else (${PREFIX}_FOUND)
if (${PREFIX}_FIND_REQUIRED)
foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
message("${i}=${${i}}")
endforeach (i)
message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
endif (${PREFIX}_FIND_REQUIRED)
endif (${PREFIX}_FOUND)
endif (NOT ${PREFIX}_FOUND)
endmacro (libfind_process)
macro(libfind_library PREFIX basename)
set(TMP "")
if(MSVC80)
set(TMP -vc80)
endif(MSVC80)
if(MSVC90)
set(TMP -vc90)
endif(MSVC90)
set(${PREFIX}_LIBNAMES ${basename}${TMP})
if(${ARGC} GREATER 2)
set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
endif(${ARGC} GREATER 2)
find_library(${PREFIX}_LIBRARY
NAMES ${${PREFIX}_LIBNAMES}
PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
)
endmacro(libfind_library)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment