Logo AND Algorithmique Numérique Distribuée

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