Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Prefer check size of void* against write 4 or 8
[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{LD_LIBRARY_PATH}
17     $ENV{PCRE_LIBRARY_PATH}
18     PATH_SUFFIXES lib/ GnuWin32/lib
19     PATHS
20     /opt
21     /opt/local
22     /opt/csw
23     /sw
24     /usr)
25     
26 find_path(PATH_PCRE_H "pcre.h"
27     HINTS
28     $ENV{LD_LIBRARY_PATH}
29     $ENV{PCRE_LIBRARY_PATH}
30     PATH_SUFFIXES include/ GnuWin32/include
31     PATHS
32     /opt
33     /opt/local
34     /opt/csw
35     /sw
36     /usr)
37     
38 set(HAVE_PCRE_LIB 0)
39
40 message(STATUS "Looking for pcre.h")
41 if(PATH_PCRE_H)
42 message(STATUS "Looking for pcre.h - found")
43 else(PATH_PCRE_H)
44 message(STATUS "Looking for pcre.h - not found")
45 endif(PATH_PCRE_H)
46
47 message(STATUS "Looking for lib pcre")
48 if(PATH_PCRE_LIB)
49 message(STATUS "Looking for lib pcre - found")
50 else(PATH_PCRE_LIB)
51 message(STATUS "Looking for lib pcre - not found")
52 endif(PATH_PCRE_LIB)
53
54 if(PATH_PCRE_LIB AND PATH_PCRE_H)
55     string(REGEX REPLACE "/libpcre.*[.]${LIB_EXE}$" "" PATHLIBPCRE "${PATH_PCRE_LIB}")
56     string(REGEX REPLACE "/pcre.h" "" PATH_PCRE_H "${PATH_PCRE_H}")
57     string(REGEX MATCH "-L${PATHLIBPCRE} " operation "${CMAKE_C_FLAGS}")
58         if(NOT operation)
59             SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${PATHLIBPCRE} ")
60         endif(NOT operation)
61         string(REGEX MATCH "-I${PATH_PCRE_H} " operation "${CMAKE_C_FLAGS}")
62         if(NOT operation)
63             SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${PATH_PCRE_H} ")
64         endif(NOT operation)       
65     set(HAVE_PCRE_LIB 1)
66 else(PATH_PCRE_LIB)
67     message(FATAL_ERROR "Please install the libpcre3-dev package or equivalent before using it.")
68 endif(PATH_PCRE_LIB AND PATH_PCRE_H)
69     
70 mark_as_advanced(PATH_PCRE_H)
71 mark_as_advanced(PATH_PCRE_LIB)