1#   BAREOS® - Backup Archiving REcovery Open Sourced
2#
3#   Copyright (C) 2019-2019 Bareos GmbH & Co. KG
4#
5#   This program is Free Software; you can redistribute it and/or
6#   modify it under the terms of version three of the GNU Affero General Public
7#   License as published by the Free Software Foundation and included
8#   in the file LICENSE.
9#
10#   This program is distributed in the hope that it will be useful, but
11#   WITHOUT ANY WARRANTY; without even the implied warranty of
12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13#   Affero General Public License for more details.
14#
15#   You should have received a copy of the GNU Affero General Public License
16#   along with this program; if not, write to the Free Software
17#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18#   02110-1301, USA.
19
20include(CheckIncludeFiles)
21include(CheckCSourceCompiles)
22include(CMakePushCheckState)
23
24# check for extra non-portable header-file
25check_include_files("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
26
27# pthread_attr_get_np - e.g. on FreeBSD
28cmake_push_check_state()
29set(CMAKE_REQUIRED_LIBRARIES ${PTHREAD_LIBRARIES})
30if(HAVE_PTHREAD_NP_H)
31  check_c_source_compiles(
32    "
33    #include <pthread.h>
34    #include <pthread_np.h>
35    int main() { pthread_attr_t a; pthread_attr_get_np(pthread_self(), &a); }
36    "
37    HAVE_PTHREAD_ATTR_GET_NP
38  )
39else()
40  check_c_source_compiles(
41    "
42    #include <pthread.h>
43    int main() { pthread_attr_t a; pthread_attr_get_np(pthread_self(), &a); }
44    "
45    HAVE_PTHREAD_ATTR_GET_NP
46  )
47endif()
48cmake_pop_check_state()
49