Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update the documentation about installing simgrid.
[simgrid.git] / doc / HelloWorld / FindPCRE.cmake
1 ### SET THE LIBRARY EXTENSION AND GCC VERSION
2 if(APPLE) #MAC
3         set(LIB_EXE "dylib")
4 else(APPLE)
5     if(WIN32) #WINDOWS
6         set(LIB_EXE "a")
7         set(BIN_EXE ".exe")
8     else(WIN32) #UNIX
9             set(LIB_EXE "so")
10     endif(WIN32)
11 endif(APPLE)
12
13 find_library(PATH_PCRE_LIB 
14         NAMES pcre
15     HINTS
16     $ENV{SIMGRID_PCRE_LIBRARY_PATH}
17     $ENV{LD_LIBRARY_PATH}
18     $ENV{PCRE_LIBRARY_PATH}
19     PATH_SUFFIXES lib/ GnuWin32/lib
20     PATHS
21     /opt
22     /opt/local
23     /opt/csw
24     /sw
25     /usr)
26     
27 string(REGEX MATCH ".dll.a" operation "${PATH_PCRE_LIB}")
28
29 if(NOT operation)
30     if(WIN32)
31            set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-DPCRE_STATIC ")
32     endif(WIN32)
33 endif(NOT operation)
34
35 find_path(PATH_PCRE_H "pcre.h"
36     HINTS
37     $ENV{SIMGRID_PCRE_LIBRARY_PATH}
38     $ENV{LD_LIBRARY_PATH}
39     $ENV{PCRE_LIBRARY_PATH}
40     PATH_SUFFIXES include/ GnuWin32/include
41     PATHS
42     /opt
43     /opt/local
44     /opt/csw
45     /sw
46     /usr)
47     
48 set(HAVE_PCRE_LIB 0)
49
50 message(STATUS "Looking for pcre.h")
51 if(PATH_PCRE_H)
52 message(STATUS "Looking for pcre.h - found")
53 else(PATH_PCRE_H)
54 message(STATUS "Looking for pcre.h - not found")
55 endif(PATH_PCRE_H)
56
57 message(STATUS "Looking for lib pcre")
58 if(PATH_PCRE_LIB)
59 message(STATUS "Looking for lib pcre - found")
60 else(PATH_PCRE_LIB)
61 message(STATUS "Looking for lib pcre - not found")
62 endif(PATH_PCRE_LIB)
63
64 if(WIN32)
65     find_path(PATH_PCRE_LICENCE "LICENCE"
66         HINTS
67         $ENV{SIMGRID_PCRE_LIBRARY_PATH}
68         $ENV{LD_LIBRARY_PATH}
69         $ENV{PCRE_LIBRARY_PATH}
70         PATH_SUFFIXES GnuWin32
71         PATHS
72         /opt
73         /opt/local
74         /opt/csw
75         /sw
76         /usr)
77     message(STATUS "Looking for pcre licence")
78     if(PATH_PCRE_LICENCE)
79     message(STATUS "Looking for pcre licence - found")
80     else(PATH_PCRE_LICENCE)
81     message(STATUS "Looking for pcre licence - not found")
82     endif(PATH_PCRE_LICENCE)
83 endif(WIN32)
84
85 if(PATH_PCRE_LIB AND PATH_PCRE_H)
86     string(REGEX REPLACE "/libpcre.*[.]${LIB_EXE}$" "" PATHLIBPCRE "${PATH_PCRE_LIB}")
87     string(REGEX REPLACE "/pcre.h" "" PATH_PCRE_H "${PATH_PCRE_H}")
88     string(REGEX MATCH "-L${PATHLIBPCRE} " operation "${CMAKE_C_FLAGS}")
89         if(NOT operation)
90             SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${PATHLIBPCRE} ")
91         endif(NOT operation)
92         string(REGEX MATCH "-I${PATH_PCRE_H} " operation "${CMAKE_C_FLAGS}")
93         if(NOT operation)
94             SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${PATH_PCRE_H} ")
95         endif(NOT operation)       
96     set(HAVE_PCRE_LIB 1)
97 else(PATH_PCRE_LIB)
98     message(FATAL_ERROR "Please install the libpcre3-dev package or equivalent before using it.")
99 endif(PATH_PCRE_LIB AND PATH_PCRE_H)
100     
101 mark_as_advanced(PATH_PCRE_H)
102 mark_as_advanced(PATH_PCRE_LIB)