Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cmake: better error message
[simgrid.git] / tools / cmake / Modules / FindPAPI.cmake
1 # Try to find PAPI headers and LIBRARY.
2 #
3 # Usage of this module as follows:
4 #
5 #     find_package(PAPI)
6 #
7 # Variables used by this module, they can change the default behaviour and need
8 # to be set before calling find_package:
9 #
10 #  PAPI_PREFIX         Set this variable to the root installation of
11 #                      libpapi if the module has problems finding the
12 #                      proper installation path.
13 #
14 # Variables defined by this module:
15 #
16 #  PAPI_FOUND              System has PAPI LIBRARY and headers
17 #  PAPI_LIBRARY          The PAPI library
18 #  PAPI_INCLUDE_DIRS       The location of PAPI headers
19
20 set(HAVE_PAPI 0)
21 set(PAPI_HINT ${papi_path} CACHE PATH "Path to search for PAPI headers and library")
22
23 find_path(PAPI_PREFIX
24     NAMES include/papi.h
25         PATHS
26         ${PAPI_HINT}
27 )
28
29 message(STATUS "Looking for libpapi")
30 find_library(PAPI_LIBRARY
31     NAMES libpapi papi
32     PATH_SUFFIXES lib64 lib 
33     # HINTS gets searched before PATHS
34     HINTS 
35     ${PAPI_PREFIX}/lib 
36 )
37 if(PAPI_LIBRARY)
38   message(STATUS "Looking for libpapi - found at ${PAPI_LIBRARY}")
39 else()
40   message(STATUS "Looking for libpapi - not found")
41 endif()
42
43 message(STATUS "Looking for papi.h")
44 find_path(PAPI_INCLUDE_DIRS
45     NAMES papi.h
46     # HINTS gets searched before PATHS
47     HINTS ${PAPI_PREFIX}/include 
48 )
49 if(PAPI_INCLUDE_DIRS)
50   message(STATUS "Looking for papi.h - found at ${PAPI_INCLUDE_DIRS}")
51 else()
52   message(STATUS "Looking for papi.h - not found")
53 endif()
54
55
56 if (PAPI_LIBRARY)
57   if(PAPI_INCLUDE_DIRS)
58     set(HAVE_PAPI 1)
59     mark_as_advanced(HAVE_PAPI)
60   endif()
61 endif()
62 if(NOT HAVE_PAPI)
63   message(FATAL_ERROR, "Could not find PAPI LIBRARY and/or papi.h. Make sure they are correctly installed!")
64 endif()
65
66 #include(FindPackageHandleStandardArgs)
67 #find_package_handle_standard_args(PAPI DEFAULT_MSG
68 #    PAPI_LIBRARY
69 #    PAPI_INCLUDE_DIRS
70 #)
71
72 mark_as_advanced(
73     PAPI_PREFIX_DIRS
74     PAPI_LIBRARY
75     PAPI_INCLUDE_DIRS
76 )
77