Debian Codegraph @

packages/kokkos/cmake/tpls/FindTPLPthread.cmake

raw
1 #@HEADER
2 # ************************************************************************
3 #
4 # Kokkos v. 4.0
5 # Copyright (2022) National Technology & Engineering
6 # Solutions of Sandia, LLC (NTESS).
7 #
8 # Under the terms of Contract DE-NA0003525 with NTESS,
9 # the U.S. Government retains certain rights in this software.
10 #
11 # Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12 #
13 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 #
15 # ************************************************************************
16 # @HEADER
17
18 set(USE_THREADS FALSE)
19
20 if(NOT TPL_Pthread_INCLUDE_DIRS AND NOT TPL_Pthread_LIBRARY_DIRS AND NOT TPL_Pthread_LIBRARIES)
21 # Use CMake's Thread finder since it is a bit smarter in determining
22 # whether pthreads is already built into the compiler and doesn't need
23 # a library to link.
24 find_package(Threads)
25 #If Threads found a copy of pthreads make sure it is one of the cases the tribits
26 #tpl system cannot handle.
27 if(Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
28 if(CMAKE_THREAD_LIBS_INIT STREQUAL "" OR CMAKE_THREAD_LIBS_INIT STREQUAL "-pthread")
29 set(USE_THREADS TRUE)
30 endif()
31 endif()
32 endif()
33
34 if(USE_THREADS)
35 set(TPL_Pthread_INCLUDE_DIRS "")
36 set(TPL_Pthread_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
37 set(TPL_Pthread_LIBRARY_DIRS "")
38 else()
39 kokkos_tpl_find_include_dirs_and_libraries(Pthread REQUIRED_HEADERS pthread.h REQUIRED_LIBS_NAMES pthread)
40 endif()