Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into smpi
[simgrid.git] / buildtools / Cmake / Modules / FindPCRE.cmake
1 find_library(PATH_PCRE_LIB 
2         NAMES pcre
3     HINTS
4     $ENV{SIMGRID_PCRE_LIBRARY_PATH}
5     $ENV{LD_LIBRARY_PATH}
6     $ENV{PCRE_LIBRARY_PATH}
7     PATH_SUFFIXES lib/ GnuWin32/lib
8     PATHS
9     /opt
10     /opt/local
11     /opt/csw
12     /sw
13     /usr)
14     
15 find_path(PATH_PCRE_H "pcre.h"
16     HINTS
17     $ENV{SIMGRID_PCRE_LIBRARY_PATH}
18     $ENV{LD_LIBRARY_PATH}
19     $ENV{PCRE_LIBRARY_PATH}
20     PATH_SUFFIXES include/ GnuWin32/include
21     PATHS
22     /opt
23     /opt/local
24     /opt/csw
25     /sw
26     /usr)
27        
28 set(HAVE_PCRE_LIB 0)
29
30 message(STATUS "Looking for pcre.h")
31 if(PATH_PCRE_H)
32 message(STATUS "Looking for pcre.h - found")
33 else(PATH_PCRE_H)
34 message(STATUS "Looking for pcre.h - not found")
35 endif(PATH_PCRE_H)
36
37 message(STATUS "Looking for lib pcre")
38 if(PATH_PCRE_LIB)
39 message(STATUS "Looking for lib pcre - found")
40 else(PATH_PCRE_LIB)
41 message(STATUS "Looking for lib pcre - not found")
42 endif(PATH_PCRE_LIB)
43
44 if(WIN32)
45     find_path(PATH_PCRE_LICENCE "LICENCE"
46         HINTS
47         $ENV{SIMGRID_PCRE_LIBRARY_PATH}
48         $ENV{LD_LIBRARY_PATH}
49         $ENV{PCRE_LIBRARY_PATH}
50         PATH_SUFFIXES GnuWin32
51         PATHS
52         /opt
53         /opt/local
54         /opt/csw
55         /sw
56         /usr)
57     message(STATUS "Looking for pcre licence")
58     if(PATH_PCRE_LICENCE)
59     message(STATUS "Looking for pcre licence - found")
60     else(PATH_PCRE_LICENCE)
61     message(STATUS "Looking for pcre licence - not found")
62     endif(PATH_PCRE_LICENCE)
63 endif(WIN32)
64
65 if(PATH_PCRE_LIB AND PATH_PCRE_H)
66        string(REGEX REPLACE "/libpcre.*[.]${LIB_EXE}$" "" PATHLIBPCRE "${PATH_PCRE_LIB}")
67        string(REGEX REPLACE "/pcre.h" "" PATH_PCRE_H "${PATH_PCRE_H}")
68        string(REGEX MATCH "-L${PATHLIBPCRE} " operation "${CMAKE_C_FLAGS}")
69            if(NOT operation)
70                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${PATHLIBPCRE} ")
71            endif(NOT operation)
72            string(REGEX MATCH "-I${PATH_PCRE_H} " operation "${CMAKE_C_FLAGS}")
73            if(NOT operation)
74                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${PATH_PCRE_H} ")
75            endif(NOT operation)    
76        set(HAVE_PCRE_LIB 1)
77 else(PATH_PCRE_LIB)
78                 if(enable_pcre STREQUAL "ON")
79                         message(FATAL_ERROR "Please install the libpcre3-dev package or equivalent before using it.")
80                 else(enable_pcre STREQUAL "ON")
81                         message(STATUS "Warning: You should install libpcre (please install the libpcre3-dev package or equivalent).")
82                 endif(enable_pcre STREQUAL "ON")
83 endif(PATH_PCRE_LIB AND PATH_PCRE_H)
84     
85 mark_as_advanced(PATH_PCRE_H)
86 mark_as_advanced(PATH_PCRE_LIB)