summaryrefslogtreecommitdiff
path: root/Modules/FindThreads.cmake
Commit message (Collapse)AuthorAgeFilesLines
* FindThreads: Filter -pthread out for compatibility with Swift linkerHarry Mallon2023-01-311-1/+1
|
* Modules: Drop redundant check logging to CMakeOutput.log and CMakeError.logBrad King2023-01-181-9/+1
| | | | | | | | | | `try_compile` and `try_run` now automatically log checks using them to `CMakeConfigureLog.yaml`. Add `LOG_DESCRIPTION` arguments to some `try_compile` calls to replace the description previously written to the old logs. Issue: #23200
* Modules: Use new SOURCES_FROM_* try_compile (1/2)Matthew Woehlke2022-09-271-4/+3
| | | | | | | | | | | Modify some modules that ship with CMake to use the new SOURCES_FROM_* arguments to try_compile / try_run as added by commits cb14ae2b87 (try_compile: Add SOURCE_FROM_{ARG,VAR}, 2022-09-21) and 611d801790 (try_compile: Add SOURCE_FROM_FILE, 2022-09-22). This covers users which previously either used an existing file (but sometimes needed to rename it), or which wrote out their source in entirety. It does NOT cover users that actually need configure_file functionality, as those will be more involved to update and will thus be tackled in part 2.
* Modules: Use new keyword-dispatched try_compile signatureMatthew Woehlke2022-09-141-2/+1
| | | | | | | | | | | Modify most of the modules that ship with CMake to use the new try_compile / try_run signatures added by commit aa9220d3a0 (try_compile: Add keyword-dispatched signature, 2022-09-02). This improves debugging by each invocation using its own directory so that the results of multiple invocations can be retained. This does not cover any invocations which provide an entire project, as that flavor of try_compile has not yet been updated.
* FindThreads: Skip check for -pthread flag when targeting the MSVC ABIBrad King2022-08-081-1/+5
| | | | | | | | | | Since commit 3257c34073 (FindThreads: avoid failing in AIX when using -D_XOPEN_SOURCE=500, 2022-04-30, v3.24.0-rc1~197^2) we no longer check for `pthreads.h` before checking for the `-pthread` flag. Compilers targeting the MSVC ABI do not have such a flag, so avoid performing the check unnecessarily. Fixes: #23829
* FindThreads: avoid failing in AIX when using -D_XOPEN_SOURCE=500Carlo Marcelo Arenas Belón2022-05-031-33/+19
| | | | | | | | | | | | Current FindThreads fails in AIX (tested on 7.1 and 7.2) when using additional compilation flags (ex: -D_XOPEN_SOURCE=500) because the linker might need additional flags to link and those aren't yet known by the time check_include("pthread.h") is run (which is also the first test). Remove the check for it and all supporting code and rely instead on the compilation test that will be done later to find the correct syntax to use, and that confirms it exists implicitly.
* FindThreads: Factor out helper macro for libc checkBrad King2022-04-261-9/+17
|
* FindThreads: Avoid repeating check for -pthread flagBrad King2022-04-261-1/+3
| | | | | When `THREADS_PREFER_PTHREAD_FLAG` is enabled, we check for it before the thread libraries. We do not need to check after them too.
* FindThreads: Simplify conditions for not-in-libc checksBrad King2022-04-261-13/+13
| | | | | If `CMAKE_HAVE_LIBC_PTHREAD` is true, we also set `Threads_FOUND` to true, which blocks all the other checks from running.
* FindThreads: Remove unnecessary conditionBrad King2022-04-261-26/+25
| | | | | | | | The `THREADS_HAVE_PTHREAD_ARG` cache entry cannot be defined unless FindThreads has already been executed, perhaps by a previous run of CMake, or a previous `find_package(Threads)` call. In that case, the other alternatives will also already have been checked and results cached.
* FindThreads: Clarify internal helper macro namesBrad King2022-04-261-7/+7
|
* FindThreads: Drop strange SunOS+pthread.h+thr_create combinationBrad King2022-04-261-4/+0
| | | | | Solaris has provided pthreads for a long time, so we probably never get to this combination anyway.
* FindThreads: Drop unused internal CMAKE_HAVE_THREADS_LIBRARY variableBrad King2022-04-261-3/+0
| | | | | | | This internal variable has not been used since commit 46368eddfd (FindThreads: move checking of the -pthread compiler flag into a macro, 2014-10-06, v3.1.0-rc1~21^2~2). It has never been documented for public use.
* Merge topic 'FindThreads-revert-libc-pthread-flag'Brad King2022-03-011-11/+8
|\ | | | | | | | | | | | | | | c6da90bd39 FindThreads: Revert "Honor THREADS_PREFER_PTHREAD_FLAG when ... in libc" Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !7025
| * FindThreads: Revert "Honor THREADS_PREFER_PTHREAD_FLAG when ... in libc"Brad King2022-02-281-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revert commit 5efb6fb516 (FindThreads: Honor THREADS_PREFER_PTHREAD_FLAG when pthread is found in libc, 2021-11-03, v3.21.5~4^2). The check for the `-pthread` flag can pass on compilers like XL, that interprets it as `-p -t hread` and returns zero. Prior to that commit, we did not use the check in the `CMAKE_HAVE_LIBC_PTHREAD` code path. Now we do, it succeeds, and we incorrectly add the `-pthread` flag for XL. This change was backported to the 3.21 and 3.22 release series long after they initially came out. Since there may be more cases where we now add `-pthread` incorrectly, it is simplest to revert the change in all release series pending further investigation. Fixes: #23270
| * FindThreads: Honor THREADS_PREFER_PTHREAD_FLAG when pthread is found in libcMattias Ellert2022-01-261-8/+11
| | | | | | | | | | | | | | | | The `-pthread` flag tells the compiler/linker to link to additional libraries needed for thread support (e.g. libatomic on riscv64). The flag therefore should be used if requested using `THREADS_PREFER_PTHREAD_FLAG` also when the pthread functions are found in libc.
* | FindThreads: Honor THREADS_PREFER_PTHREAD_FLAG when pthread is found in libcMattias Ellert2021-11-101-8/+11
| | | | | | | | | | | | | | | | The `-pthread` flag tells the compiler/linker to link to additional libraries needed for thread support (e.g. libatomic on riscv64). The flag therefore should be used if requested using `THREADS_PREFER_PTHREAD_FLAG` also when the pthread functions are found in libc.
* | Fix typo in commentMattias Ellert2021-09-061-1/+1
|/ | | | | The comment lists -lpthread twice, when "-lpthreads, -lpthread" is meant. Also the grammar (did not found) is incorrect.
* MSYS: Add support for running under MSYS runtime environmentOrgad Shaneh2021-04-261-1/+1
| | | | Detect MSYS as CYGWIN, with the required adaptations.
* FindThreads: Reduce amount of false positive error loggingRobert Maynard2021-04-061-4/+10
| | | | | | | | | | | When a CMake based project fails, users start looking at CMakeError.log and think that the FindThread output is the problem, but it is a false positive. Now FindThreads only logs to `CMakeError.log` when it fails to find a suitable flag, reducing the amount of false positives in `CMakeError.log`. Fixes #16540, Fixes #19344
* Help: Add `.. versionadded` directives to module docsNikita Nemkin2020-12-021-0/+4
| | | | Issue: #19715
* FindThreads: Add missing static keyword in pthread test codePavel Otchertsov2020-09-181-1/+1
| | | | | | | When CMAKE_C_FLAGS contains '-Werror -Wmissing-prototypes' the pthread test code check fails with error: "src.c:3:7: error: no previous prototype for 'test_func' [-Werror=missing-prototypes]". Adding 'static' keyword to 'test_func' fixes it.
* Find{Threads,MPI}: Add support for CUDA with ClangTobias Ribizel2020-05-251-2/+2
| | | | | | Currently CMake passes `-Xcompiler -pthread` flags to CUDA compilers irrespective of the actual CUDA compiler ID. This makes sure the additional `-Xcompiler` flag is only used with nvcc.
* FindThreads: Improve documentationRolf Eike Beer2020-03-161-16/+29
| | | | Issue: #19823
* FindThreads: Add pthread_cancel to program to test for pthreads in libcCristian Morales Vega2019-12-111-0/+1
| | | | | | | | | When using ThreadSanitizer our existing CMAKE_HAVE_LIBC_PTHREAD test program links using symbols from the tsan library. Among the symbols not provided by that library, `pthread_cancel()` seems to be the less risky symbol to add to the check. Fixes: #19981
* Merge topic 'FindThreads-lib-flag'Brad King2019-12-051-4/+4
|\ | | | | | | | | | | | | f7ffefea7c FindThreads: Restore hard-coded '-l' flag on library name Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4112
| * FindThreads: Restore hard-coded '-l' flag on library nameBrad King2019-12-041-4/+4
| | | | | | | | | | | | | | | | Revert commit de5f123d3a (FindThreads: Do not hard-code '-l' flag on library name, 2019-09-23, v3.16.0-rc1~71^2). Some clients depend on the value of `CMAKE_THREAD_LIBS_INIT` to contain a valid flag. Fixes: #20061, #20065
* | Refactor: Use added message types in various modulesAlex Turbov2019-11-021-3/+3
|/ | | | Co-Authored-By: Craig Scott <craig.scott@crascit.com>
* FindThreads: Do not hard-code '-l' flag on library nameAlan W. Irwin2019-09-231-4/+4
| | | | | | | | | | | | When not using the `-pthread` flag we instead return a library to link by name. Previously we hard-coded the `-l` flag before the library name. When used with `target_link_libraries`, the hard-coded `-l` flag is preserved rather than transformed into the link option preferred by the toolchain in use. Drop the explicit `-l` part to let CMake's generators produce the proper way to link the threads library for the current toolchain. Fixes: #19747
* Merge topic 'FindThreads-doc-c++'Brad King2019-05-281-3/+0
|\ | | | | | | | | | | | | a38b63c1bb FindThreads: Drop incorrect docs about usage with C++ Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3391
| * FindThreads: Drop incorrect docs about usage with C++Brad King2019-05-281-3/+0
| | | | | | | | | | | | | | | | Drop the sentence added by commit 5a5a1d90f0 (Help: FindThreads not needed with modern C++., 2019-01-09, v3.14.0-rc1~186^2) about not needing the module with modern C++. The module is often still needed. Fixes: #19297
* | FindThreads: Fix pthread library check in GHS Multi GeneratorNaren Manimohan2019-03-211-0/+3
| |
* | FindThreads: Use complete program to test for pthreads in libcJerryShih2019-03-061-6/+35
|/ | | | | | | | | | | | | | | Our check for just `pthread_create` is not sufficient because there are cases where that symbol may be found in libc but not all of pthreads. We first tried to address this in commit e9a1ddc594 (FindThreads: Replace the pthread symbol checking in libc., 2018-11-18, v3.14.0-rc1~292^2) by switching to `pthread_kill`, but that had to be reverted by commit 18320230ec (FindThreads: Revert libc symbol check to pthread_create, 2019-02-27, v3.14.0-rc3~6^2) because there are other cases where `pthread_kill` is in libc but the rest of pthreads is not. Update our check to try a complete program using pthreads as an actual application might. Fixes: #18994
* FindThreads: Revert libc symbol check to pthread_createBrad King2019-02-271-13/+3
| | | | | | | | | | | | | Since commit e9a1ddc594 (FindThreads: Replace the pthread symbol checking in libc., 2018-11-18, v3.14.0-rc1~292^2) we check libc for `pthread_kill` instead of `pthread_create`. However, on FreeBSD `pthread_kill` is in libc but not `pthread_create`. Discussion in the original merge request for the above commit also considered `pthread_key_create`, `pthread_self`, and `pthread_attr_init`. Every symbol seems to have some reason it is not an appropriate choice. Revert to the pre-3.14 behavior of using `pthread_create` pending further investigation.
* FindThreads: Fix libc check to use proper header for pthread_killBrad King2019-02-261-2/+4
| | | | | | | | | | | In commit e9a1ddc594 (FindThreads: Replace the pthread symbol checking in libc., 2018-11-18, v3.14.0-rc1~292^2) we switched to checking for `pthread_kill` in libc but did not update the symbol check's header file to match. Add `signal.h` to get `pthread_kill`. Keep `pthread.h` anyway since the purpose of the check is to verify that the pthread API works. Fixes: #18984
* Help: FindThreads not needed with modern C++.Joachim Wuttke (o)2019-01-091-1/+4
|
* FindThreads: Drop IRIX-specific options and resultsBrad King2018-12-071-61/+43
| | | | | | | | | We do not need to support IRIX anymore, so drop relevant parts. In particular, the `CMAKE_THREAD_PREFER_PTHREAD` is frequently confused with `THREADS_PREFER_PTHREAD_FLAG`. Also remove references to the IRIX-specific options and results from other modules and tests.
* FindThreads: Replace the pthread symbol checking in libc.JerryShih2018-12-031-4/+12
| | | | | | | With asan build, we will have the pthread_create() symbol in libc. However, libasan doesn't have full pthread implementation. We can't assume that we have the pthread implementation in libc using pthread_create() symbol. Replace the pthread_create() with pthread_kill() as a quick fix.
* Merge topic 'cuda-thread-flags'Brad King2018-10-251-1/+3
|\ | | | | | | | | | | | | | | | | | | | | 2cc050b53b CUDA: Add test for device linking when host linking uses threads 83c13ca44f FindThreads: Pass -pthread to CUDA compiler through -Xcompiler cf92fd9ae9 Merge branch 'cuda-filter-device-link-items' into cuda-thread-flags e768d96c74 CUDA: Filter out host link flags during device linking Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Kelly (KT) Thompson <kgt@lanl.gov> Merge-request: !2512
| * FindThreads: Pass -pthread to CUDA compiler through -XcompilerRolf Eike Beer2018-10-241-1/+3
| | | | | | | | Fixes: #18008
* | Help: Convert remaining modules to block-style commentsKitware Robot2018-10-221-38/+39
|/
* FindThreads: Drop try_run to improve cross-compiling supportSteffen Dettmer2017-08-301-11/+4
| | | | | | | | | | | Use `try_compile` instead of `try_run`. It is not clear why `try_run` was ever needed, and it does not work during cross-compiling. Update the check's source file to remove code associated with actually running things. Also remove the ancient `__CLASSIC_C__` code path and use a simple `int main(void)` as in `Modules/CheckIncludeFile.c.in`. Fixes: #16920
* Simplify CMake per-source license noticesBrad King2016-09-271-14/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
* Fix spelling typos in comments and documentation (#16037)Felix Geyer2016-03-291-1/+1
| | | | | The Debian package checker tool (lintian) detected several typos in CMake.
* FindThreads: make the call to try_run() work also if only C++ is enabledRolf Eike Beer2015-09-251-1/+8
| | | | This isn't enough to make the whole module work with only C++ enabled.
* FindThreads: replace CheckIncludeFiles by CheckIncludeFileRolf Eike Beer2015-09-251-3/+15
| | | | | | While at it, also add a branch using CheckIncludeFileCXX. Also give a better error message if no supported language is enabled. C++ support isn't working yet, but it has never worked.
* FindThreads: introduce THREADS_PREFER_PTHREAD_FLAG (#14767)Rolf Eike Beer2014-10-081-0/+18
|
* FindThreads: introduce an imported target to link toTimo Rothenpieler2014-10-081-0/+18
| | | | | | This not only holds the library, but can also hold compiler flags needed, e.g. the -pthread flag preferred by gcc on some platforms. There was no clean way to get that compiler flag from the module until now.
* FindThreads: move checking of the -pthread compiler flag into a macroRolf Eike Beer2014-10-061-36/+42
| | | | | | This allows a following commit to introduce a switch to prefer that check over searching for the explicit library names without breaking backward compatibility.
* Merge topic 'FindThreads-macro'Brad King2014-10-061-23/+17
|\ | | | | | | | | 94a061d3 FindThreads: use a macro for the repetitive thread library checks