/usr/share/dune/cmake/modules/FindPsurface.cmake is in libdune-grid-dev 2.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | #
# Module that checks whether psurface is available and usable.
#
# Variables used by this module which you may want to set:
# PSURFACE_ROOT Path list to search for psurface
#
# Sets the follwing variable:
#
# PSURFACE_FOUND True if PSurface available and usable.
# PSURFACE_INCLUDE_DIRS Path to the PSurface include dirs.
# PSURFACE_LIBRARIES Name to the PSurface library.
#
# look for header files, only at positions given by the user
find_path(PSURFACE_INCLUDE_DIR
NAMES "psurface/PSurface.h"
PATHS ${PSURFACE_PREFIX} ${PSURFACE_ROOT}
PATH_SUFFIXES "include"
NO_DEFAULT_PATH
)
# look for header files, including default paths
find_path(PSURFACE_INCLUDE_DIR
NAMES "psurface/PSurface.h"
PATH_SUFFIXES "include"
)
# look for library, only at positions given by the user
find_library(PSURFACE_LIBRARY
NAMES "psurface"
PATHS ${PSURFACE_PREFIX} ${PSURFACE_ROOT}
PATH_SUFFIXES "lib" "lib32" "lib64"
NO_DEFAULT_PATH
)
# look for library files, including default paths
find_library(PSURFACE_LIBRARY
NAMES "psurface"
PATH_SUFFIXES "lib" "lib32" "lib64"
)
# check version specific macros
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
cmake_push_check_state()
# we need if clauses here because variable is set variable-NOTFOUND
# if the searches above were not successful
# Without them CMake print errors like:
# "CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
# Please set them or make sure they are set and tested correctly in the CMake files:"
#
if(PSURFACE_INCLUDE_DIR)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${PSURFACE_INCLUDE_DIR})
endif(PSURFACE_INCLUDE_DIR)
if(PSURFACE_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${PSURFACE_LIBRARY})
endif(PSURFACE_LIBRARY)
# Try to link to the library (for libpsurface-1.3 and newer)
CHECK_CXX_SOURCE_COMPILES("
#include <psurface/PSurface.h>
int main(void)
{
psurface::PSurface<2,double> foo;
return 0;
}"
PSURFACE_MIN_VERSION_1_3)
cmake_pop_check_state()
if(PSURFACE_MIN_VERSION_1_3)
set(PSURFACE_WITH_VERSION "psurface >= 1.3" CACHE STRING
"Human readable string containing psurface version information.")
set(PSURFACE_NAMESPACE "psurface::")
else()
set(PSURFACE_WITH_VERSION "psurface <= 1.2" CACHE STRING
"Human readable string containing psurface version information.")
set(PSURFACE_NAMESPACE "")
endif(PSURFACE_MIN_VERSION_1_3)
# Try to find psurface with pkg-config (for psurface 2.0 or newer)
include(FindPkgConfig)
pkg_search_module(PKG_PSURFACE psurface)
if(NOT PKG_PSURFACE_FOUND)
# first only at positions given by the user
find_file(PATH_PKG_PSURFACE
NAMES "psurface.pc"
PATHS ${PSURFACE_ROOT}
PATH_SUFFIXES lib/pkgconfig lib32/pkgconfig lib64/pkgconfig
NO_DEFAULT_PATH)
# including default paths
find_file(PATH_PKG_PSURFACE
NAMES "psurface.pc"
PATH_SUFFIXES lib/pkgconfig lib32/pkgconfig lib64/pkgconfig)
# try again with path temporarilly added to PKG_CONFIG_PATH
set(REM_PKG_CONFIG_PATH "$ENV{PKG_CONFIG_PATH}")
get_filename_component(DIR_PKG_PSURFACE "${PATH_PKG_PSURFACE}" PATH)
set(ENV{PKG_CONFIG_PATH} "${PSURFACE_ROOT}:${DIR_PKG_PSURFACE}:${PKG_CONFIG_PATH}")
pkg_check_modules(PKG_PSURFACE psurface)
set(ENV{PKG_CONFIG_PATH} REM_PKG_CONFIG_PATH)
endif()
if(PKG_PSURFACE_FOUND)
set(HAVE_PSURFACE_2_0 1)
set(PSURFACE_WITH_VERSION "psurface >= 2.0" CACHE STRING
"Human readable string containing psurface version information.")
endif()
# re-set PKG_CONFIG_PATH
set(PKG_CONFIG_PATH ${PKG_CONFIG_PATH_STORE})
# behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
"psurface"
DEFAULT_MSG
PSURFACE_INCLUDE_DIR
PSURFACE_LIBRARY
)
mark_as_advanced(PSURFACE_INCLUDE_DIR PSURFACE_LIBRARY PKG_PSURFACE_FOUND)
# if both headers and library are found, store results
if(PSURFACE_FOUND)
set(PSURFACE_INCLUDE_DIRS ${PSURFACE_INCLUDE_DIR})
set(PSURFACE_LIBRARIES ${PSURFACE_LIBRARY})
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determing location of ${PSURFACE_WITH_VERSION} succeded:\n"
"Include directory: ${PSURFACE_INCLUDE_DIRS}\n"
"Library directory: ${PSURFACE_LIBRARIES}\n\n")
set(PSURFACE_DUNE_COMPILE_FLAGS "-I${PSURFACE_INCLUDE_DIRS}"
CACHE STRING "Compile flags used by DUNE when compiling psurface programs")
set(PSURFACE_DUNE_LIBRARIES ${PSURFACE_LIBRARIES}
CACHE STRING "Libraries used by DUNE when linking psurface programs")
else(PSURFACE_FOUND)
# log errornous result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determing location of psurface failed:\n"
"Include directory: ${PSURFACE_INCLUDE_DIRS}\n"
"Library directory: ${PSURFACE_LIBRARIES}\n\n")
endif(PSURFACE_FOUND)
# set HAVE_PSURFACE for config.h
set(HAVE_PSURFACE ${PSURFACE_FOUND})
#add all psurface related flags to ALL_PKG_FLAGS, this must happen regardless of a target using add_dune_psurface_flags
if(PSURFACE_FOUND)
foreach(dir ${PSURFACE_INCLUDE_DIRS})
set_property(GLOBAL APPEND PROPERTY ALL_PKG_FLAGS "-I${dir}")
endforeach()
endif()
|