2022-07-05 11:26:52 +00:00
|
|
|
# Copyright (C) 2022 The Qt Company Ltd.
|
2022-08-19 13:21:34 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
2022-07-05 11:26:52 +00:00
|
|
|
|
2019-06-05 12:28:31 +00:00
|
|
|
# We can't create the same interface imported target multiple times, CMake will complain if we do
|
|
|
|
# that. This can happen if the find_package call is done in multiple different subdirectories.
|
2020-04-28 15:33:29 +00:00
|
|
|
if(TARGET WrapRt::WrapRt)
|
2019-06-05 12:28:31 +00:00
|
|
|
set(WrapRt_FOUND ON)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2020-02-24 13:34:15 +00:00
|
|
|
set(WrapRt_FOUND OFF)
|
|
|
|
|
2018-11-05 13:18:57 +00:00
|
|
|
include(CheckCXXSourceCompiles)
|
2019-02-12 15:04:57 +00:00
|
|
|
include(CMakePushCheckState)
|
2018-11-05 13:18:57 +00:00
|
|
|
|
|
|
|
find_library(LIBRT rt)
|
|
|
|
|
2019-02-12 15:04:57 +00:00
|
|
|
cmake_push_check_state()
|
2020-09-11 17:45:40 +00:00
|
|
|
if(LIBRT)
|
2018-11-05 13:18:57 +00:00
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBRT}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <time.h>
|
Improve FindWrapRt, and SHM detection
Apparently, more and more librt functionality are being moved to glibc
these days, e.g., clock_gettime, clock_getres, clock_settime,
clock_getcpuclockid, clock_nanosleep. As Thiago mentioned, in face,
all librt functions are moving into glibc, but unlike the clock_*
functions that I can see are ported from 2.17+, I cannot find out when
and what functions are already ported. So, here, I added a second test
which tries to explicitly look for shm_* functions, if they are there,
as well as the clock_* function, then we are more confident that we
actually have a useful the libRt in the system.
Also, making the FEATURE_posix_SHM depends on UNIX.
Pick-to: 6.5
Fixes: QTBUG-111049
Change-Id: I08b7f4656ecd9313b552fb05ca7096f5b987b95a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 15:13:30 +00:00
|
|
|
#include <unistd.h>
|
2018-11-05 13:18:57 +00:00
|
|
|
|
2022-02-21 12:40:27 +00:00
|
|
|
int main(int, char **) {
|
Improve FindWrapRt, and SHM detection
Apparently, more and more librt functionality are being moved to glibc
these days, e.g., clock_gettime, clock_getres, clock_settime,
clock_getcpuclockid, clock_nanosleep. As Thiago mentioned, in face,
all librt functions are moving into glibc, but unlike the clock_*
functions that I can see are ported from 2.17+, I cannot find out when
and what functions are already ported. So, here, I added a second test
which tries to explicitly look for shm_* functions, if they are there,
as well as the clock_* function, then we are more confident that we
actually have a useful the libRt in the system.
Also, making the FEATURE_posix_SHM depends on UNIX.
Pick-to: 6.5
Fixes: QTBUG-111049
Change-Id: I08b7f4656ecd9313b552fb05ca7096f5b987b95a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 15:13:30 +00:00
|
|
|
struct timespec ts;
|
|
|
|
clock_gettime(CLOCK_REALTIME, &ts);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" HAVE_GETTIME)
|
2018-11-05 13:18:57 +00:00
|
|
|
|
Improve FindWrapRt, and SHM detection
Apparently, more and more librt functionality are being moved to glibc
these days, e.g., clock_gettime, clock_getres, clock_settime,
clock_getcpuclockid, clock_nanosleep. As Thiago mentioned, in face,
all librt functions are moving into glibc, but unlike the clock_*
functions that I can see are ported from 2.17+, I cannot find out when
and what functions are already ported. So, here, I added a second test
which tries to explicitly look for shm_* functions, if they are there,
as well as the clock_* function, then we are more confident that we
actually have a useful the libRt in the system.
Also, making the FEATURE_posix_SHM depends on UNIX.
Pick-to: 6.5
Fixes: QTBUG-111049
Change-Id: I08b7f4656ecd9313b552fb05ca7096f5b987b95a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 15:13:30 +00:00
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <fcntl.h>
|
2018-11-05 13:18:57 +00:00
|
|
|
|
Improve FindWrapRt, and SHM detection
Apparently, more and more librt functionality are being moved to glibc
these days, e.g., clock_gettime, clock_getres, clock_settime,
clock_getcpuclockid, clock_nanosleep. As Thiago mentioned, in face,
all librt functions are moving into glibc, but unlike the clock_*
functions that I can see are ported from 2.17+, I cannot find out when
and what functions are already ported. So, here, I added a second test
which tries to explicitly look for shm_* functions, if they are there,
as well as the clock_* function, then we are more confident that we
actually have a useful the libRt in the system.
Also, making the FEATURE_posix_SHM depends on UNIX.
Pick-to: 6.5
Fixes: QTBUG-111049
Change-Id: I08b7f4656ecd9313b552fb05ca7096f5b987b95a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 15:13:30 +00:00
|
|
|
int main(int, char **) {
|
|
|
|
shm_open(\"test\", O_RDWR | O_CREAT | O_EXCL, 0666);
|
|
|
|
shm_unlink(\"test\");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" HAVE_SHM_OPEN_SHM_UNLINK)
|
|
|
|
|
|
|
|
cmake_pop_check_state()
|
2018-11-05 13:18:57 +00:00
|
|
|
|
Improve FindWrapRt, and SHM detection
Apparently, more and more librt functionality are being moved to glibc
these days, e.g., clock_gettime, clock_getres, clock_settime,
clock_getcpuclockid, clock_nanosleep. As Thiago mentioned, in face,
all librt functions are moving into glibc, but unlike the clock_*
functions that I can see are ported from 2.17+, I cannot find out when
and what functions are already ported. So, here, I added a second test
which tries to explicitly look for shm_* functions, if they are there,
as well as the clock_* function, then we are more confident that we
actually have a useful the libRt in the system.
Also, making the FEATURE_posix_SHM depends on UNIX.
Pick-to: 6.5
Fixes: QTBUG-111049
Change-Id: I08b7f4656ecd9313b552fb05ca7096f5b987b95a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 15:13:30 +00:00
|
|
|
if(HAVE_GETTIME OR HAVE_SHM_OPEN_SHM_UNLINK)
|
2020-02-24 13:34:15 +00:00
|
|
|
set(WrapRt_FOUND ON)
|
2020-04-28 15:33:29 +00:00
|
|
|
add_library(WrapRt::WrapRt INTERFACE IMPORTED)
|
2020-09-18 16:53:30 +00:00
|
|
|
if (LIBRT)
|
2020-04-28 15:33:29 +00:00
|
|
|
target_link_libraries(WrapRt::WrapRt INTERFACE "${LIBRT}")
|
2020-02-24 13:34:15 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2020-06-26 16:32:53 +00:00
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(WrapRt DEFAULT_MSG WrapRt_FOUND)
|