1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2025-01-03 01:56:13 +01:00

[WIP] better FindTREXIO module (following FindSDL2 example)

This commit is contained in:
q-posev 2021-11-16 11:37:11 +01:00
parent 6f499ea58d
commit f389ba2952

View File

@ -1,45 +1,77 @@
#=========================================== #===========================================
# Try to find TREXIO library;
# If found, it will define the following variables (note the plural form):
# TREXIO_FOUND - System has libtrexio;
# TREXIO_INCLUDE_DIRS - The TREXIO include directories;
# TREXIO_LIBRARIES - The libraries needed to use TREXIO;
# If TREXIO has been installed in a non-standard location, one can set an
# environment variable $TREXIO_DIR in the current shell:
# $ export TREXIO_DIR=<custom_path>
# to indicate the prefix used during the TREXIO installation
# (typically `./configure prefix=<custom_path> ..` or `cmake -DCMAKE_INSTALL_DIR=<custom_path> ..`)
# This file should be located WITHIN your project source tree. # This file should be located WITHIN your project source tree.
# (e.g. in cmake/FindTREXIO.cmake file) # (e.g. in cmake/FindTREXIO.cmake)
# How to use it in your project CMakeLists.txt:
# usage in CMakeLists.txt # This is needed to locate FindTREXIO.cmake file, modify it according to your source tree.
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") # list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
#find_package(TREXIO)
#include_directories("${TREXIO_INCLUDE_DIR}") # find_package(TREXIO)
#target_link_libraries(your_target ${TREXIO_LIBRARY}) # if (TREXIO_FOUND)
# include_directories(${TREXIO_INCLUDE_DIRS})
# target_link_libraries(your_target ${TREXIO_LIBRARIES})
# endif()
#=========================================== #===========================================
# If already in cache, be silent # This file is distirbuted under the BSD 3-Clause License.
if (TREXIO_INCLUDE_DIR AND TREXIO_LIBRARY) # Copyright (c) 2021, TREX Center of Excellence
set(TREXIO_FIND_QUIETLY TRUE)
endif()
set(TREXIO_FOUND OFF) #===========================================
set(TREXIO_LIBRARY)
set(TREXIO_NAMES "libtrexio.so") message("<FindTREXIO.cmake>")
#set(TREXIO_NAMES "libtrexio.so" "libtrexio.dylib" "libtrexio.la")
set(TREXIO_SEARCH_PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
find_path(TREXIO_INCLUDE_DIR find_path(TREXIO_INCLUDE_DIR
NAMES trexio.h NAMES trexio.h
HINTS /usr/include HINTS $ENV{TREXIO_DIR}
/usr/local/include PATH_SUFFIXES include/trexio include
$ENV{HOME}/include) PATHS ${TREXIO_SEARCH_PATHS}
)
# No need to specify platform-specific prefix (e.g. libtrexio on Unix) or
# suffix (e.g. .so on Unix or .dylib on MacOS) in NAMES. CMake takes care of that.
find_library(TREXIO_LIBRARY find_library(TREXIO_LIBRARY
NAMES ${TREXIO_NAMES} NAMES trexio
PATHS /usr/lib HINTS $ENV{TREXIO_DIR}
/usr/local/lib PATH_SUFFIXES lib64 lib
$ENV{HOME}/lib PATHS ${TREXIO_SEARCH_PATHS}
NO_DEFAULT_PATH) )
message("<FindTREXIO.cmake>")
# Handle the QUIETLY and REQUIRED arguments and set TREXIO_FOUND to TRUE if # Handle the QUIETLY and REQUIRED arguments and set TREXIO_FOUND to TRUE if
# all listed variables are TRUE. # all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs) INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TREXIO DEFAULT_MSG TREXIO_LIBRARY TREXIO_INCLUDE_DIR ) FIND_PACKAGE_HANDLE_STANDARD_ARGS(TREXIO DEFAULT_MSG TREXIO_LIBRARY TREXIO_INCLUDE_DIR )
MARK_AS_ADVANCED(TREXIO_INCLUDE_DIR TREXIO_LIBRARY) MARK_AS_ADVANCED(TREXIO_INCLUDE_DIR TREXIO_LIBRARY)
# Mot setting _INCLUDE_DIR and _LIBRARIES is considered a bug,
# see https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/How-To-Find-Libraries
set(TREXIO_LIBRARIES ${TREXIO_LIBRARY})
set(TREXIO_INCLUDE_DIRS ${TREXIO_INCLUDE_DIR})