[Cmake-commits] CMake branch, next, updated. v3.3.2-3203-g95c3902
Rolf Eike Beer
eike at sf-mail.de
Tue Sep 22 11:58:53 EDT 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 95c39028ede8b8ba988f6d0f6964b0f7ce2bf76b (commit)
via 49f11b9e51506c26a019685c153ee54dee3a0c0e (commit)
via f135fafd934a5e12507c8c97cfc7c0fce990fd0d (commit)
via 9a97251d3771512962d21c4237b5c3d56b232e5b (commit)
via e652087a0118d580cb45df4a34bffb79e537c13a (commit)
via 10a06618949302bba33e04347b2d072d804dbeaf (commit)
from eb99bf2d6861ba6cfc282265a5947453032c68dc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=95c39028ede8b8ba988f6d0f6964b0f7ce2bf76b
commit 95c39028ede8b8ba988f6d0f6964b0f7ce2bf76b
Merge: eb99bf2 49f11b9
Author: Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Tue Sep 22 11:58:52 2015 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Sep 22 11:58:52 2015 -0400
Merge topic 'Threads-CXX' into next
49f11b9e FindThreads: officially announce it works with only C++ enabled
f135fafd FindThreads: fix printing a pointer value in test code
9a97251d FindThreads: make the call to try_run() work also if only C++ is enabled
e652087a FindThreads: replace CheckIncludeFiles by CheckIncludeFile
10a06618 Check(Function|Library|Symbol)Exists: make it work if only C++ is enabled
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49f11b9e51506c26a019685c153ee54dee3a0c0e
commit 49f11b9e51506c26a019685c153ee54dee3a0c0e
Author: Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Tue Sep 22 17:50:59 2015 +0200
Commit: Rolf Eike Beer <eike at sf-mail.de>
CommitDate: Tue Sep 22 17:55:33 2015 +0200
FindThreads: officially announce it works with only C++ enabled
diff --git a/Help/release/dev/Threads-CXX.rst b/Help/release/dev/Threads-CXX.rst
index 0f40ae9..2e34a01 100644
--- a/Help/release/dev/Threads-CXX.rst
+++ b/Help/release/dev/Threads-CXX.rst
@@ -1,6 +1,6 @@
Threads-CXX
------------
-* The :module:`CheckFunctionExists`, :module:`CheckLibraryExists`, and
- :module:`CheckSymbolExists` modules learned to work in environments where
- only CXX is enabled.
+* The :module:`CheckFunctionExists`, :module:`CheckLibraryExists`,
+ :module:`CheckSymbolExists`, and :module:`FindThreads` modules learned to
+ work in environments where only CXX is enabled.
diff --git a/Tests/FindThreads/CMakeLists.txt b/Tests/FindThreads/CMakeLists.txt
index 36518a3..aa9499b 100644
--- a/Tests/FindThreads/CMakeLists.txt
+++ b/Tests/FindThreads/CMakeLists.txt
@@ -1,9 +1,11 @@
-add_test(NAME FindThreads.C-only COMMAND ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/FindThreads/C-only"
- "${CMake_BINARY_DIR}/Tests/FindThreads/C-only"
- ${build_generator_args}
- --build-project FindThreads_C-only
- --build-options ${build_options}
- --test-command ${CMAKE_CTEST_COMMAND} -V
- )
+foreach (_lang IN ITEMS C CXX)
+ add_test(NAME FindThreads.${_lang}-only COMMAND ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindThreads/${_lang}-only"
+ "${CMake_BINARY_DIR}/Tests/FindThreads/${_lang}-only"
+ ${build_generator_args}
+ --build-project FindThreads_${_lang}-only
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V
+ )
+endforeach ()
diff --git a/Tests/FindThreads/CXX-only/CMakeLists.txt b/Tests/FindThreads/CXX-only/CMakeLists.txt
new file mode 100644
index 0000000..9993123
--- /dev/null
+++ b/Tests/FindThreads/CXX-only/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
+project(FindThreads_CXX-only CXX)
+
+set(CMAKE_THREAD_PREFER_PTHREAD On)
+find_package(Threads REQUIRED)
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules/CheckForPthreads.c
+ ${CMAKE_CURRENT_BINARY_DIR}/CheckForPthreads.cxx)
+
+if (NOT WIN32)
+ add_executable(thr ${CMAKE_CURRENT_BINARY_DIR}/CheckForPthreads.cxx)
+ target_link_libraries(thr Threads::Threads)
+endif ()
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f135fafd934a5e12507c8c97cfc7c0fce990fd0d
commit f135fafd934a5e12507c8c97cfc7c0fce990fd0d
Author: Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Tue Sep 22 06:46:28 2015 +0200
Commit: Rolf Eike Beer <eike at sf-mail.de>
CommitDate: Tue Sep 22 17:55:33 2015 +0200
FindThreads: fix printing a pointer value in test code
This causes a warning in C mode, and entirely fails in C++ mode:
CMake/Modules/CheckForPthreads.c: In function ‘runner’:
CMake/Modules/CheckForPthreads.c:34:27: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
printf("%d CC: %d\n", (int)args, cc);
^
Use %p to print out a pointer value, which will not cause any problems. While
at it, use std::cout for C++ mode.
diff --git a/Modules/CheckForPthreads.c b/Modules/CheckForPthreads.c
index 7250fbf..4101552 100644
--- a/Modules/CheckForPthreads.c
+++ b/Modules/CheckForPthreads.c
@@ -1,6 +1,9 @@
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
+#ifdef __cplusplus
+#include <iostream>
+#endif /* C++ */
void* runner(void*);
@@ -31,7 +34,11 @@ void* runner(void* args)
int cc;
for ( cc = 0; cc < 10; cc ++ )
{
- printf("%d CC: %d\n", (int)args, cc);
+#ifdef __cplusplus
+ std::cout << args << cc;
+#else
+ printf("%p CC: %d\n", args, cc);
+#endif /* C++ */
}
res ++;
return 0;
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9a97251d3771512962d21c4237b5c3d56b232e5b
commit 9a97251d3771512962d21c4237b5c3d56b232e5b
Author: Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Tue Sep 22 05:46:56 2015 +0200
Commit: Rolf Eike Beer <eike at sf-mail.de>
CommitDate: Tue Sep 22 17:55:32 2015 +0200
FindThreads: make the call to try_run() work also if only C++ is enabled
This isn't enough to make the whole module work with only C++ enabled.
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index 88da7c5..c607923 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -91,11 +91,18 @@ macro(_check_pthreads_flag)
# If we did not found -lpthread, -lpthread, or -lthread, look for -pthread
if(NOT DEFINED THREADS_HAVE_PTHREAD_ARG)
message(STATUS "Check if compiler accepts -pthread")
+ if(CMAKE_C_COMPILER_LOADED)
+ set(_threads_src ${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c)
+ elseif(CMAKE_CXX_COMPILER_LOADED)
+ set(_threads_src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindThreads/CheckForPthreads.cxx)
+ configure_file(${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c "${_threads_src}" COPYONLY)
+ endif()
try_run(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
${CMAKE_BINARY_DIR}
- ${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c
+ ${_threads_src}
CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread
COMPILE_OUTPUT_VARIABLE OUTPUT)
+ unset(_threads_src)
if(THREADS_HAVE_PTHREAD_ARG)
if(THREADS_PTHREAD_ARG STREQUAL "2")
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e652087a0118d580cb45df4a34bffb79e537c13a
commit e652087a0118d580cb45df4a34bffb79e537c13a
Author: Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Tue Sep 22 05:23:12 2015 +0200
Commit: Rolf Eike Beer <eike at sf-mail.de>
CommitDate: Tue Sep 22 17:55:32 2015 +0200
FindThreads: replace CheckIncludeFiles by CheckIncludeFile
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.
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index a0bc4d1..88da7c5 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -39,7 +39,7 @@
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
-# Copyright 2011-2014 Rolf Eike Beer <eike at sf-mail.de>
+# Copyright 2011-2015 Rolf Eike Beer <eike at sf-mail.de>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@@ -51,15 +51,23 @@
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
-include (CheckIncludeFiles)
include (CheckLibraryExists)
include (CheckSymbolExists)
set(Threads_FOUND FALSE)
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
set(CMAKE_REQUIRED_QUIET ${Threads_FIND_QUIETLY})
+if(CMAKE_C_COMPILER_LOADED)
+ include (CheckIncludeFile)
+elseif(CMAKE_CXX_COMPILER_LOADED)
+ include (CheckIncludeFileCXX)
+else()
+ message(FATAL_ERROR "FindThreads only works if either C or CXX language is enabled")
+endif()
+
# Do we have sproc?
if(CMAKE_SYSTEM_NAME MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD)
+ include (CheckIncludeFiles)
CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H)
endif()
@@ -120,7 +128,11 @@ if(CMAKE_HAVE_SPROC_H AND NOT CMAKE_THREAD_PREFER_PTHREAD)
set(CMAKE_USE_SPROC_INIT 1)
else()
# Do we have pthreads?
- CHECK_INCLUDE_FILES("pthread.h" CMAKE_HAVE_PTHREAD_H)
+ if(CMAKE_C_COMPILER_LOADED)
+ CHECK_INCLUDE_FILE("pthread.h" CMAKE_HAVE_PTHREAD_H)
+ else()
+ CHECK_INCLUDE_FILE_CXX("pthread.h" CMAKE_HAVE_PTHREAD_H)
+ endif()
if(CMAKE_HAVE_PTHREAD_H)
#
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=10a06618949302bba33e04347b2d072d804dbeaf
commit 10a06618949302bba33e04347b2d072d804dbeaf
Author: Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Tue Sep 22 06:11:50 2015 +0200
Commit: Rolf Eike Beer <eike at sf-mail.de>
CommitDate: Tue Sep 22 17:55:32 2015 +0200
Check(Function|Library|Symbol)Exists: make it work if only C++ is enabled
diff --git a/Help/release/dev/Threads-CXX.rst b/Help/release/dev/Threads-CXX.rst
new file mode 100644
index 0000000..0f40ae9
--- /dev/null
+++ b/Help/release/dev/Threads-CXX.rst
@@ -0,0 +1,6 @@
+Threads-CXX
+------------
+
+* The :module:`CheckFunctionExists`, :module:`CheckLibraryExists`, and
+ :module:`CheckSymbolExists` modules learned to work in environments where
+ only CXX is enabled.
diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake
index d277c32..5dd3751 100644
--- a/Modules/CheckFunctionExists.cmake
+++ b/Modules/CheckFunctionExists.cmake
@@ -57,14 +57,26 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
else()
set(CHECK_FUNCTION_EXISTS_ADD_INCLUDES)
endif()
+
+ if(CMAKE_C_COMPILER_LOADED)
+ set(_cfe_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c)
+ elseif(CMAKE_CXX_COMPILER_LOADED)
+ set(_cfe_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckFunctionExists/CheckFunctionExists.cxx)
+ configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cfe_source}" COPYONLY)
+ else()
+ message(FATAL_ERROR "CHECK_FUNCTION_EXISTS needs either C or CXX language enabled")
+ endif()
+
try_compile(${VARIABLE}
${CMAKE_BINARY_DIR}
- ${CMAKE_ROOT}/Modules/CheckFunctionExists.c
+ ${_cfe_source}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
"${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
+ unset(_cfe_source)
+
if(${VARIABLE})
set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}")
if(NOT CMAKE_REQUIRED_QUIET)
diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake
index 95c595a..6b53823 100644
--- a/Modules/CheckLibraryExists.cmake
+++ b/Modules/CheckLibraryExists.cmake
@@ -53,15 +53,26 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
set(CHECK_LIBRARY_EXISTS_LIBRARIES
${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES})
endif()
+
+ if(CMAKE_C_COMPILER_LOADED)
+ set(_cle_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c)
+ elseif(CMAKE_CXX_COMPILER_LOADED)
+ set(_cle_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckLibraryExists/CheckFunctionExists.cxx)
+ configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cle_source}" COPYONLY)
+ else()
+ message(FATAL_ERROR "CHECK_FUNCTION_EXISTS needs either C or CXX language enabled")
+ endif()
+
try_compile(${VARIABLE}
${CMAKE_BINARY_DIR}
- ${CMAKE_ROOT}/Modules/CheckFunctionExists.c
+ ${_cle_source}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
-DLINK_DIRECTORIES:STRING=${LOCATION}
OUTPUT_VARIABLE OUTPUT)
+ unset(_cle_source)
if(${VARIABLE})
if(NOT CMAKE_REQUIRED_QUIET)
diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake
index 79c5ba7..c4dff3f 100644
--- a/Modules/CheckSymbolExists.cmake
+++ b/Modules/CheckSymbolExists.cmake
@@ -44,10 +44,14 @@
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
-
-
macro(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE)
- _CHECK_SYMBOL_EXISTS("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" "${SYMBOL}" "${FILES}" "${VARIABLE}" )
+ if(CMAKE_C_COMPILER_LOADED)
+ _CHECK_SYMBOL_EXISTS("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" "${SYMBOL}" "${FILES}" "${VARIABLE}" )
+ elseif(CMAKE_CXX_COMPILER_LOADED)
+ _CHECK_SYMBOL_EXISTS("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" )
+ else()
+ message(FATAL_ERROR "CHECK_SYMBOL_EXISTS needs either C or CXX language enabled")
+ endif()
endmacro()
macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
-----------------------------------------------------------------------
Summary of changes:
Help/release/dev/Threads-CXX.rst | 6 ++++++
Modules/CheckForPthreads.c | 9 ++++++++-
Modules/CheckFunctionExists.cmake | 14 +++++++++++++-
Modules/CheckLibraryExists.cmake | 13 ++++++++++++-
Modules/CheckSymbolExists.cmake | 10 +++++++---
Modules/FindThreads.cmake | 27 +++++++++++++++++++++++----
Tests/FindThreads/CMakeLists.txt | 20 +++++++++++---------
Tests/FindThreads/CXX-only/CMakeLists.txt | 13 +++++++++++++
8 files changed, 93 insertions(+), 19 deletions(-)
create mode 100644 Help/release/dev/Threads-CXX.rst
create mode 100644 Tests/FindThreads/CXX-only/CMakeLists.txt
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list