Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge remote-tracking branch 'origin/master'
[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 string(REGEX MATCH ".dll.a" operation "${PATH_PCRE_LIB}")
16
17 if(NOT operation)
18     if(WIN32)
19            set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-DPCRE_STATIC ")
20     endif(WIN32)
21 endif(NOT operation)
22
23
24 find_path(PATH_PCRE_H "pcre.h"
25     HINTS
26     $ENV{SIMGRID_PCRE_LIBRARY_PATH}
27     $ENV{LD_LIBRARY_PATH}
28     $ENV{PCRE_LIBRARY_PATH}
29     PATH_SUFFIXES include/ GnuWin32/include
30     PATHS
31     /opt
32     /opt/local
33     /opt/csw
34     /sw
35     /usr)
36        
37 set(HAVE_PCRE_LIB 0)
38
39 message(STATUS "Looking for pcre.h")
40 if(PATH_PCRE_H)
41 message(STATUS "Looking for pcre.h - found")
42 else(PATH_PCRE_H)
43 message(STATUS "Looking for pcre.h - not found")
44 endif(PATH_PCRE_H)
45
46 message(STATUS "Looking for lib pcre")
47 if(PATH_PCRE_LIB)
48 message(STATUS "Looking for lib pcre - found")
49 else(PATH_PCRE_LIB)
50 message(STATUS "Looking for lib pcre - not found")
51 endif(PATH_PCRE_LIB)
52
53 if(WIN32)
54     find_path(PATH_PCRE_LICENCE "LICENCE"
55         HINTS
56         $ENV{SIMGRID_PCRE_LIBRARY_PATH}
57         $ENV{LD_LIBRARY_PATH}
58         $ENV{PCRE_LIBRARY_PATH}
59         PATH_SUFFIXES GnuWin32
60         PATHS
61         /opt
62         /opt/local
63         /opt/csw
64         /sw
65         /usr)
66     message(STATUS "Looking for pcre licence")
67     if(PATH_PCRE_LICENCE)
68     message(STATUS "Looking for pcre licence - found")
69     else(PATH_PCRE_LICENCE)
70     message(STATUS "Looking for pcre licence - not found")
71     endif(PATH_PCRE_LICENCE)
72 endif(WIN32)
73
74 if(PATH_PCRE_LIB AND PATH_PCRE_H)
75        string(REGEX REPLACE "/libpcre.*[.]${LIB_EXE}$" "" PATHLIBPCRE "${PATH_PCRE_LIB}")
76        string(REGEX REPLACE "/pcre.h" "" PATH_PCRE_H "${PATH_PCRE_H}")
77        string(REGEX MATCH "-L${PATHLIBPCRE} " operation "${CMAKE_C_FLAGS}")
78            if(NOT operation)
79                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${PATHLIBPCRE} ")
80            endif(NOT operation)
81            string(REGEX MATCH "-I${PATH_PCRE_H} " operation "${CMAKE_C_FLAGS}")
82            if(NOT operation)
83                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${PATH_PCRE_H} ")
84            endif(NOT operation)    
85        set(HAVE_PCRE_LIB 1)
86 else(PATH_PCRE_LIB)
87                 if(enable_pcre STREQUAL "ON")
88                         message(FATAL_ERROR "Please install the libpcre3-dev package or equivalent before using it.")
89                 else(enable_pcre STREQUAL "ON")
90                         message(STATUS "Warning: You should install libpcre (please install the libpcre3-dev package or equivalent).")
91                 endif(enable_pcre STREQUAL "ON")
92 endif(PATH_PCRE_LIB AND PATH_PCRE_H)
93     
94 mark_as_advanced(PATH_PCRE_H)
95 mark_as_advanced(PATH_PCRE_LIB)