Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The pcre library is static on win32
[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(PATH_PCRE_LIB AND PATH_PCRE_H)
45        string(REGEX REPLACE "/libpcre.*[.]${LIB_EXE}$" "" PATHLIBPCRE "${PATH_PCRE_LIB}")
46        string(REGEX REPLACE "/pcre.h" "" PATH_PCRE_H "${PATH_PCRE_H}")
47        string(REGEX MATCH "-L${PATHLIBPCRE} " operation "${CMAKE_C_FLAGS}")
48            if(NOT operation)
49                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${PATHLIBPCRE} ")
50            endif(NOT operation)
51            string(REGEX MATCH "-I${PATH_PCRE_H} " operation "${CMAKE_C_FLAGS}")
52            if(NOT operation)
53                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${PATH_PCRE_H} ")
54            endif(NOT operation)    
55        set(HAVE_PCRE_LIB 1)
56 else(PATH_PCRE_LIB)
57                 if(enable_pcre STREQUAL "ON")
58                         message(FATAL_ERROR "Please install the libpcre3-dev package or equivalent before using it.")
59                 else(enable_pcre STREQUAL "ON")
60                         message(STATUS "Warning: You should install libpcre (please install the libpcre3-dev package or equivalent).")
61                 endif(enable_pcre STREQUAL "ON")
62 endif(PATH_PCRE_LIB AND PATH_PCRE_H)
63     
64 mark_as_advanced(PATH_PCRE_H)
65 mark_as_advanced(PATH_PCRE_LIB)