Salome HOME
Revert "Synchronize adm files"
[modules/kernel.git] / salome_adm / cmake_files / deprecated / FindPTHREADS.cmake
1 # Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 # ------
24
25 MESSAGE(STATUS "Check for pthreads ...")
26
27 # ------
28
29 IF(PTHREADS_IS_MANDATORY STREQUAL 0)
30   SET(PTHREADS_IS_MANDATORY 0)
31   SET(PTHREADS_IS_OPTIONAL 1)
32 ENDIF(PTHREADS_IS_MANDATORY STREQUAL 0)
33 IF(PTHREADS_IS_OPTIONAL STREQUAL 0)
34   SET(PTHREADS_IS_MANDATORY 1)
35   SET(PTHREADS_IS_OPTIONAL 0)
36 ENDIF(PTHREADS_IS_OPTIONAL STREQUAL 0)
37 IF(NOT PTHREADS_IS_MANDATORY AND NOT PTHREADS_IS_OPTIONAL)
38   SET(PTHREADS_IS_MANDATORY 1)
39   SET(PTHREADS_IS_OPTIONAL 0)
40 ENDIF(NOT PTHREADS_IS_MANDATORY AND NOT PTHREADS_IS_OPTIONAL)
41
42 # ------
43
44 SET(PTHREADS_STATUS 1)
45 IF(WITHOUT_PTHREADS OR WITH_PTHREADS STREQUAL 0)
46   SET(PTHREADS_STATUS 0)
47   MESSAGE(STATUS "pthreads disabled from command line.")
48 ENDIF(WITHOUT_PTHREADS OR WITH_PTHREADS STREQUAL 0)
49
50 # ------
51
52 IF(PTHREADS_STATUS)
53   IF(WITH_PTHREADS)
54     SET(PTHREADS_ROOT_USER ${WITH_PTHREADS})
55   ELSE(WITH_PTHREADS)
56     SET(PTHREADS_ROOT_USER $ENV{PTHREADS_ROOT})
57   ENDIF(WITH_PTHREADS)
58 ENDIF(PTHREADS_STATUS)
59
60 # -----
61
62 IF(PTHREADS_STATUS)
63   IF(PTHREADS_ROOT_USER)
64     SET(PTHREADS_FIND_PATHS_OPTION NO_DEFAULT_PATH)
65   ELSE(PTHREADS_ROOT_USER)
66     SET(PTHREADS_FIND_PATHS_OPTION)
67   ENDIF(PTHREADS_ROOT_USER)
68 ENDIF(PTHREADS_STATUS)
69
70 # -----
71
72 IF(PTHREADS_STATUS)
73   IF(PTHREADS_ROOT_USER)
74     SET(PTHREADS_INCLUDE_PATHS ${PTHREADS_ROOT_USER}/include)
75   ELSE(PTHREADS_ROOT_USER)
76     SET(PTHREADS_INCLUDE_PATHS)
77   ENDIF(PTHREADS_ROOT_USER)
78   SET(PTHREADS_INCLUDE_TO_FIND pthread.h)
79   FIND_PATH(PTHREADS_INCLUDE_DIR ${PTHREADS_INCLUDE_TO_FIND} PATHS ${PTHREADS_INCLUDE_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
80   IF(PTHREADS_INCLUDE_DIR)
81     IF(PTHREADS_ROOT_USER)
82       SET(PTHREAD_CFLAGS -I${PTHREADS_INCLUDE_DIR}) # to remove
83       SET(PTHREAD_INCLUDE_DIRS ${PTHREADS_INCLUDE_DIR})
84     ENDIF(PTHREADS_ROOT_USER)
85     MESSAGE(STATUS "${PTHREADS_INCLUDE_TO_FIND} found in ${PTHREADS_INCLUDE_DIR}")
86   ELSE(PTHREADS_INCLUDE_DIR)
87     SET(PTHREADS_STATUS 0)
88     IF(PTHREADS_ROOT_USER)
89       MESSAGE(STATUS "${PTHREADS_INCLUDE_TO_FIND} not found in ${PTHREADS_INCLUDE_PATHS}, check your PTHREADS installation.")
90     ELSE(PTHREADS_ROOT_USER)
91       MESSAGE(STATUS "${PTHREADS_INCLUDE_TO_FIND} not found on system, try to use WITH_PTHREADS option or PTHREADS_ROOT environment variable.")
92     ENDIF(PTHREADS_ROOT_USER)
93   ENDIF(PTHREADS_INCLUDE_DIR)
94 ENDIF(PTHREADS_STATUS)
95
96 # ----
97
98 IF(PTHREADS_STATUS)
99   IF(PTHREADS_ROOT_USER)
100     SET(PTHREADS_LIB_PATHS ${PTHREADS_ROOT_USER}/lib)
101   ELSE(PTHREADS_ROOT_USER)
102     SET(PTHREADS_LIB_PATHS)
103   ENDIF(PTHREADS_ROOT_USER)
104 ENDIF(PTHREADS_STATUS)
105
106 IF(PTHREADS_STATUS)
107   IF(WINDOWS)
108     IF(CMAKE_BUILD_TYPE STREQUAL Release)
109       FIND_LIBRARY(PTHREAD_LIB pthreadVSE2 pthreadVC2 PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
110     ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
111       FIND_LIBRARY(PTHREAD_LIB pthreadVSE2d pthreadVC2d PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
112     ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
113   ELSE(WINDOWS)
114     FIND_LIBRARY(PTHREAD_LIB pthread PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
115   ENDIF(WINDOWS)
116   SET(PTHREAD_LIBS)
117   IF(PTHREAD_LIB)
118     SET(PTHREAD_LIBS ${PTHREAD_LIBS} ${PTHREAD_LIB})
119     MESSAGE(STATUS "pthread lib found: ${PTHREAD_LIB}")
120   ELSE(PTHREAD_LIB)
121     SET(PTHREADS_STATUS 0)
122     IF(PTHREADS_ROOT_USER)
123       MESSAGE(STATUS "pthread lib not found in ${PTHREADS_LIB_PATHS}, check your PTHREADS installation.")
124     ELSE(PTHREADS_ROOT_USER)
125       MESSAGE(STATUS "pthread lib not found on system, try to use WITH_PTHREADS option or PTHREADS_ROOT environment variable.")
126     ENDIF(PTHREADS_ROOT_USER)
127   ENDIF(PTHREAD_LIB)
128 ENDIF(PTHREADS_STATUS)
129
130 # ----
131
132 IF(PTHREADS_STATUS)
133 ELSE(PTHREADS_STATUS)
134   IF(PTHREADS_IS_MANDATORY)
135     MESSAGE(FATAL_ERROR "pthreads not found ... mandatory ... abort")
136   ELSE(PTHREADS_IS_MANDATORY)
137     MESSAGE(STATUS "pthreads not found ... optional ... disabled")
138   ENDIF(PTHREADS_IS_MANDATORY)
139 ENDIF(PTHREADS_STATUS)