Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update nsis script.
[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 string(REGEX MATCH ".dll.a" operation "${PATH_PCRE_LIB}")
16
17 if(NOT operation)
18     if(WIN32)
19            set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-DPCRE_STATIC ")
20     endif(WIN32)
21 endif(NOT operation)
22
23
24 find_path(PATH_PCRE_H "pcre.h"
25     HINTS
26     $ENV{SIMGRID_PCRE_LIBRARY_PATH}
27     $ENV{LD_LIBRARY_PATH}
28     $ENV{PCRE_LIBRARY_PATH}
29     PATH_SUFFIXES include/ GnuWin32/include
30     PATHS
31     /opt
32     /opt/local
33     /opt/csw
34     /sw
35     /usr)
36
37 message(STATUS "Looking for pcre.h")
38 if(PATH_PCRE_H)
39 message(STATUS "Looking for pcre.h - found")
40 else(PATH_PCRE_H)
41 message(STATUS "Looking for pcre.h - not found")
42 endif(PATH_PCRE_H)
43
44 message(STATUS "Looking for lib pcre")
45 if(PATH_PCRE_LIB)
46 message(STATUS "Looking for lib pcre - found")
47 else(PATH_PCRE_LIB)
48 message(STATUS "Looking for lib pcre - not found")
49 endif(PATH_PCRE_LIB)
50
51 if(WIN32)
52     find_path(PATH_PCRE_LICENCE "LICENCE"
53         HINTS
54         $ENV{SIMGRID_PCRE_LIBRARY_PATH}
55         $ENV{LD_LIBRARY_PATH}
56         $ENV{PCRE_LIBRARY_PATH}
57         PATH_SUFFIXES GnuWin32
58         PATHS
59         /opt
60         /opt/local
61         /opt/csw
62         /sw
63         /usr)
64     message(STATUS "Looking for pcre licence")
65     if(PATH_PCRE_LICENCE)
66     message(STATUS "Looking for pcre licence - found")
67     else(PATH_PCRE_LICENCE)
68     message(STATUS "Looking for pcre licence - not found")
69     endif(PATH_PCRE_LICENCE)
70 endif(WIN32)
71
72 if(PATH_PCRE_LIB AND PATH_PCRE_H)
73        string(REGEX REPLACE "/libpcre.*[.]${LIB_EXE}$" "" PATHLIBPCRE "${PATH_PCRE_LIB}")
74        string(REGEX REPLACE "/pcre.h" "" PATH_PCRE_H "${PATH_PCRE_H}")
75        string(REGEX MATCH "-L${PATHLIBPCRE} " operation "${CMAKE_C_FLAGS}")
76            if(NOT operation)
77                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${PATHLIBPCRE} ")
78            endif(NOT operation)
79            string(REGEX MATCH "-I${PATH_PCRE_H} " operation "${CMAKE_C_FLAGS}")
80            if(NOT operation)
81                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${PATH_PCRE_H} ")
82            endif(NOT operation)    
83 else(PATH_PCRE_LIB)
84            message(FATAL_ERROR "Please install the libpcre3-dev package or equivalent before using SimGrid.")
85 endif(PATH_PCRE_LIB AND PATH_PCRE_H)
86
87 set(PCRE_LIBRARY_PATH $ENV{PCRE_LIBRARY_PATH})
88
89 mark_as_advanced(PATH_PCRE_H)
90 mark_as_advanced(PATH_PCRE_LIB)