Salome HOME
e9e9faedf530d0ca43540e3f38765c6a405e9417
[tools/libbatch.git] / CMakeModules / FindPThread.cmake
1 #  Copyright (C) 2007-2013  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.
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 IF (NOT PThread_FIND_QUIETLY)
24     MESSAGE(STATUS "Looking for PThread...")
25 ENDIF (NOT PThread_FIND_QUIETLY)
26
27 IF(WIN32)
28     SET(PTHREADS_ROOT_USER $ENV{PTHREADS_ROOT})
29     SET(PTHREADS_FIND_PATHS_OPTION NO_DEFAULT_PATH)
30     SET(PTHREADS_INCLUDE_TO_FIND pthread.h)
31     SET(PTHREADS_INCLUDE_PATHS ${PTHREADS_ROOT_USER}/include)
32     FIND_PATH(PTHREAD_INCLUDE_DIR ${PTHREADS_INCLUDE_TO_FIND}
33               PATHS ${PTHREADS_INCLUDE_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
34     SET(PTHREADS_LIB_PATHS ${PTHREADS_ROOT_USER}/lib)
35     IF(CMAKE_BUILD_TYPE STREQUAL Release)
36         FIND_LIBRARY(PTHREAD_LIBRARY pthreadVSE2 pthreadVC2
37                      PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
38     ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
39         FIND_LIBRARY(PTHREAD_LIBRARY pthreadVSE2d pthreadVC2d
40                      PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
41     ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
42 ELSE(WIN32)
43     FIND_PATH(PTHREAD_INCLUDE_DIR pthread.h)
44     FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread)
45 ENDIF(WIN32)
46
47 IF (PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
48     SET(PThread_FOUND True)
49 ENDIF (PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
50
51 IF (PThread_FOUND)
52
53     IF (NOT PThread_FIND_QUIETLY)
54         MESSAGE(STATUS "Found PThread:")
55         MESSAGE(STATUS "PThread include directory: ${PTHREAD_INCLUDE_DIR}")
56         MESSAGE(STATUS "PThread library: ${PTHREAD_LIBRARY}")
57     ENDIF (NOT PThread_FIND_QUIETLY)
58
59 ELSE (PThread_FOUND)
60
61     IF (PThread_FIND_REQUIRED)
62         MESSAGE(FATAL_ERROR "PThread not found")
63     ELSE (PThread_FIND_REQUIRED)
64         IF (NOT PThread_FIND_QUIETLY)
65             MESSAGE(STATUS "PThread not found")
66         ENDIF (NOT PThread_FIND_QUIETLY)
67     ENDIF (PThread_FIND_REQUIRED)
68
69 ENDIF (PThread_FOUND)