Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot//simgrid/simgrid
[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 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 else(PATH_PCRE_LIB)
54            message(FATAL_ERROR "Please install the libpcre3-dev package or equivalent before using SimGrid.")
55 endif(PATH_PCRE_LIB AND PATH_PCRE_H)
56
57 set(PCRE_LIBRARY_PATH $ENV{PCRE_LIBRARY_PATH})
58
59 mark_as_advanced(PATH_PCRE_H)
60 mark_as_advanced(PATH_PCRE_LIB)