File: FindPThreads.cmake

package info (click to toggle)
s3d 0.2.2.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,356 kB
  • sloc: ansic: 21,128; python: 488; perl: 98; makefile: 31; sh: 29
file content (39 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# SPDX-License-Identifier: BSD-3-Clause
# SPDX-FileCopyrightText: 2007-2015  Sven Eckelmann <sven@narfation.org>

if (PTHREADS_LIBRARIES AND PTHREADS_INCLUDE_DIRS)
	# path set by user or was found in the past
	set(PTHREADS_FOUND TRUE)
else (PTHREADS_LIBRARIES AND PTHREADS_INCLUDE_DIRS)
	find_path(PTHREADS_INCLUDE_DIRS
		NAMES pthread.h
	)

	find_library(PTHREADS_LIBRARIES
		NAMES pthread
	)

	if (NOT PTHREADS_LIBRARIES)
		find_library(PTHREADS_LIBRARIES
			NAMES pthreads
		)
	endif (NOT PTHREADS_LIBRARIES)

	if (PTHREADS_INCLUDE_DIRS AND PTHREADS_LIBRARIES)
		set(PTHREADS_FOUND TRUE)
	endif (PTHREADS_INCLUDE_DIRS AND PTHREADS_LIBRARIES)

	if (PTHREADS_FOUND)
		if (NOT PTHREADS_FIND_QUIETLY)
			message(STATUS "Found PThreads: ${PTHREADS_LIBRARIES}")
		endif (NOT PTHREADS_FIND_QUIETLY)
	else (PTHREADS_FOUND)
		if (PTHREADS_FIND_REQUIRED)
			message(FATAL_ERROR "Could not find PThreads")
		endif (PTHREADS_FIND_REQUIRED)
	endif (PTHREADS_FOUND)

	# set visibility in cache
	mark_as_advanced(PTHREADS_INCLUDE_DIRS PTHREADS_LIBRARIES)

endif (PTHREADS_LIBRARIES AND PTHREADS_INCLUDE_DIRS)