[Cmake-commits] CMake branch, next, updated. v2.8.4-1218-g030f83d

Brad King brad.king at kitware.com
Fri Mar 18 14:04:46 EDT 2011


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  030f83de8ad285ddc6eb0d1726a0de8c0f117e52 (commit)
       via  93c56a7040a1080811494c4d69fc62041fc8caeb (commit)
       via  4f252abea5f1d17c60f6ff115c9c44cc0b6f1df6 (commit)
      from  9557b369693c272cd27593e81c59ec881ceab9ca (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=030f83de8ad285ddc6eb0d1726a0de8c0f117e52
commit 030f83de8ad285ddc6eb0d1726a0de8c0f117e52
Merge: 9557b36 93c56a7
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Mar 18 14:04:43 2011 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Mar 18 14:04:43 2011 -0400

    Merge topic 'asn_check_proto' into next
    
    93c56a7 Tests: Added test for check_prototype_definition.
    4f252ab Modules: Added CheckPrototypeDefinition module.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=93c56a7040a1080811494c4d69fc62041fc8caeb
commit 93c56a7040a1080811494c4d69fc62041fc8caeb
Author:     Andreas Schneider <asn at cryptomilk.org>
AuthorDate: Fri Mar 4 16:36:29 2011 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Mar 18 14:03:37 2011 -0400

    Tests: Added test for check_prototype_definition.

diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index 90c2cfc..938c092 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/Tests/TryCompile/CMakeLists.txt
@@ -232,3 +232,16 @@ IF("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
   CHECK_C_COMPILER_FLAG("-Werror;-Wstrict-prototypes" C_STRICT_PROTOTYPES)
   TEST_ASSERT(C_STRICT_PROTOTYPES "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes")
 ENDIF()
+
+#######################################################################
+#
+# also test that the check_prototype_definition macro works
+
+include(CheckPrototypeDefinition)
+
+check_prototype_definition(remove
+  "int remove(const char *pathname)"
+  "0"
+  "stdio.h"
+  TEST_REMOVE_PROTO)
+test_assert(TEST_REMOVE_PROTO "check_prototype_definition for remove() failed")

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4f252abea5f1d17c60f6ff115c9c44cc0b6f1df6
commit 4f252abea5f1d17c60f6ff115c9c44cc0b6f1df6
Author:     Andreas Schneider <asn at cryptomilk.org>
AuthorDate: Thu Feb 10 19:28:04 2011 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Mar 18 14:03:35 2011 -0400

    Modules: Added CheckPrototypeDefinition module.
    
    This check if the function exists and the prototype we want to use is
    correct. There are still functions which have different prototypes on
    different UNIX systems.

diff --git a/Modules/CheckPrototypeDefinition.c.in b/Modules/CheckPrototypeDefinition.c.in
new file mode 100644
index 0000000..a97344a
--- /dev/null
+++ b/Modules/CheckPrototypeDefinition.c.in
@@ -0,0 +1,29 @@
+ at CHECK_PROTOTYPE_DEFINITION_HEADER@
+
+static void cmakeRequireSymbol(int dummy, ...) {
+  (void) dummy;
+}
+
+static void checkSymbol(void) {
+#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@
+  cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@);
+#endif
+}
+
+ at CHECK_PROTOTYPE_DEFINITION_PROTO@ {
+  return @CHECK_PROTOTYPE_DEFINITION_RETURN@;
+}
+
+#ifdef __CLASSIC_C__
+int main() {
+  int ac;
+  char*av[];
+#else
+int main(int ac, char *av[]) {
+#endif
+  checkSymbol();
+  if (ac > 1000) {
+    return *av[0];
+  }
+  return 0;
+}
diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake
new file mode 100644
index 0000000..244b9b5
--- /dev/null
+++ b/Modules/CheckPrototypeDefinition.cmake
@@ -0,0 +1,96 @@
+# - Check if the protoype we expect is correct.
+# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE)
+#  FUNCTION - The name of the function (used to check if prototype exists)
+#  PROTOTYPE- The prototype to check.
+#  RETURN - The return value of the function.
+#  HEADER - The header files required.
+#  VARIABLE - The variable to store the result.
+# Example:
+#  check_prototype_definition(getpwent_r
+#   "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)"
+#   "NULL"
+#   "unistd.h;pwd.h"
+#   SOLARIS_GETPWENT_R)
+# The following variables may be set before calling this macro to
+# modify the way the check is run:
+#
+#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
+#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+#  CMAKE_REQUIRED_INCLUDES = list of include directories
+#  CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+
+#=============================================================================
+# Copyright 2005-2009 Kitware, Inc.
+# Copyright 2010-2011 Andreas Schneider <asn at cryptomilk.org>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+#
+
+get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
+
+  if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
+    set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n")
+
+    set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
+    if (CMAKE_REQUIRED_LIBRARIES)
+      set(CHECK_PROTOTYPE_DEFINITION_LIBS
+        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+    else(CMAKE_REQUIRED_LIBRARIES)
+      set(CHECK_PROTOTYPE_DEFINITION_LIBS)
+    endif(CMAKE_REQUIRED_LIBRARIES)
+    if (CMAKE_REQUIRED_INCLUDES)
+      set(CMAKE_SYMBOL_EXISTS_INCLUDES
+        "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+    else(CMAKE_REQUIRED_INCLUDES)
+      set(CMAKE_SYMBOL_EXISTS_INCLUDES)
+    endif(CMAKE_REQUIRED_INCLUDES)
+
+    foreach(_FILE ${_HEADER})
+      set(CHECK_PROTOTYPE_DEFINITION_HEADER
+        "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n")
+    endforeach(_FILE)
+
+    set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION})
+    set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE})
+    set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN})
+
+    configure_file("${__check_proto_def_dir}/CheckPrototypeDefinition.c.in"
+      "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY)
+
+    file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE)
+
+    try_compile(${_VARIABLE}
+      ${CMAKE_BINARY_DIR}
+      ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c
+      COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+      CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS}
+      "${CHECK_PROTOTYPE_DEFINITION_LIBS}"
+      "${CMAKE_SYMBOL_EXISTS_INCLUDES}"
+      OUTPUT_VARIABLE OUTPUT)
+
+    if (${_VARIABLE})
+      set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
+      message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
+      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+        "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n"
+        "${OUTPUT}\n\n")
+    else (${_VARIABLE})
+      message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
+      set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
+      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+        "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n"
+        "${OUTPUT}\n\n${_SOURCE}\n\n")
+    endif (${_VARIABLE})
+  endif("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
+
+endfunction(CHECK_PROTOTYPE_DEFINITION)

-----------------------------------------------------------------------

Summary of changes:
 Modules/CheckPrototypeDefinition.c.in  |   29 ++++++++++
 Modules/CheckPrototypeDefinition.cmake |   96 ++++++++++++++++++++++++++++++++
 Tests/TryCompile/CMakeLists.txt        |   13 ++++
 3 files changed, 138 insertions(+), 0 deletions(-)
 create mode 100644 Modules/CheckPrototypeDefinition.c.in
 create mode 100644 Modules/CheckPrototypeDefinition.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list