Salome HOME
CMake: Exposed PThread root directory in config file.
[tools/libbatch.git] / CMakeModules / FindPThread.cmake
1 # - Find PThread
2 # This module finds an installed PThread using the variable PTHREAD_ROOT_DIR 
3 # as a lookup path.
4 # It sets the following variables:
5 #  PTHREAD_FOUND       - set to true if PThread is found
6 #  PTHREAD_INCLUDE_DIR - the directory where the include files are located
7 #  PTHREAD_LIBRARY     - the path to PThread library
8 #
9 # The file "pthread.h" is looked for PTHREAD_INCLUDE_DIR.
10 # Libraries are searched with following names: 
11 #    pthread
12 # On Win32:
13 #    pthreadVSE2 pthreadVC2
14 # or in Debug mode:
15 #    pthreadVSE2d pthreadVC2d
16 #
17
18
19 #############################################################
20 #  Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
21 #
22 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
23 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
24 #
25 #  This library is free software; you can redistribute it and/or
26 #  modify it under the terms of the GNU Lesser General Public
27 #  License as published by the Free Software Foundation; either
28 #  version 2.1 of the License.
29 #
30 #  This library is distributed in the hope that it will be useful,
31 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
32 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
33 #  Lesser General Public License for more details.
34 #
35 #  You should have received a copy of the GNU Lesser General Public
36 #  License along with this library; if not, write to the Free Software
37 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
38 #
39 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
40 #
41 #############################################################
42
43 IF (NOT PThread_FIND_QUIETLY)
44     MESSAGE(STATUS "Looking for PThread...")
45 ENDIF ()
46
47 IF(WIN32)
48     SET(PTHREADS_FIND_PATHS_OPTION NO_DEFAULT_PATH)
49     SET(PTHREADS_INCLUDE_TO_FIND pthread.h)
50     SET(PTHREADS_INCLUDE_PATHS ${PTHREAD_ROOT_DIR}/include)
51     FIND_PATH(PTHREAD_INCLUDE_DIR ${PTHREADS_INCLUDE_TO_FIND}
52               PATHS ${PTHREADS_INCLUDE_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
53     SET(PTHREADS_LIB_PATHS ${PTHREAD_ROOT_DIR}/lib)
54     # Default build type is assumed to be Release:
55     IF(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
56         FIND_LIBRARY(PTHREAD_LIBRARY pthreadVSE2 pthreadVC2
57                      PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
58     ELSE()
59         FIND_LIBRARY(PTHREAD_LIBRARY pthreadVSE2d pthreadVC2d
60                      PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
61     ENDIF()
62 ELSE(WIN32)
63     FIND_PATH(PTHREAD_INCLUDE_DIR pthread.h)
64     FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread)
65 ENDIF(WIN32)
66
67 INCLUDE(FindPackageHandleStandardArgs)
68 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PThread REQUIRED_VARS PTHREAD_INCLUDE_DIR PTHREAD_LIBRARY)
69
70 IF (PTHREAD_FOUND)
71     IF (NOT PThread_FIND_QUIETLY)
72         MESSAGE(STATUS "PThread library: ${PTHREAD_LIBRARY}")
73     ENDIF (NOT PThread_FIND_QUIETLY)
74 ENDIF()