[Cmake-commits] CMake branch, next, updated. v2.8.11.2-3439-g109cb22

Alexander Neundorf neundorf at kde.org
Sat Jul 27 15:36:38 EDT 2013


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  109cb22d598c6c9b9e79a502f50c8506d64145ab (commit)
       via  e32ff9666c3b5c3b0c0d6d28c4cec76e84ffc1dc (commit)
      from  95c9df413a1b9348bef03c288bd4bf2c42384ab7 (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=109cb22d598c6c9b9e79a502f50c8506d64145ab
commit 109cb22d598c6c9b9e79a502f50c8506d64145ab
Merge: 95c9df4 e32ff96
Author:     Alexander Neundorf <neundorf at kde.org>
AuthorDate: Sat Jul 27 15:36:37 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat Jul 27 15:36:37 2013 -0400

    Merge topic 'PrintHelperFunctions' into next
    
    e32ff96 add macros cmake_print_properties() and cmake_print_variables()


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e32ff9666c3b5c3b0c0d6d28c4cec76e84ffc1dc
commit e32ff9666c3b5c3b0c0d6d28c4cec76e84ffc1dc
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Sat Jul 27 21:27:56 2013 +0200
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Sat Jul 27 21:37:05 2013 +0200

    add macros cmake_print_properties() and cmake_print_variables()
    
    This patch adds the file CMakePrintHelpers.cmake, which provides
    the macros (functions) cmake_print_properties() and cmake_print_variables(),
    which are useful e.g. for debugging and make inspecting target (or other)
    properties easier.
    
    Alex

diff --git a/Modules/CMakePrintHelpers.cmake b/Modules/CMakePrintHelpers.cmake
new file mode 100644
index 0000000..ef5d857
--- /dev/null
+++ b/Modules/CMakePrintHelpers.cmake
@@ -0,0 +1,146 @@
+# - Convenience macros for printing properties and variables, useful e.g. for debugging.
+#
+#
+# CMAKE_PRINT_PROPERTIES([TARGETS target1 .. targetN]
+#                        [SOURCES source1 .. sourceN]
+#                        [DIRECTORIES dir1 .. dirN]
+#                        [TESTS test1 .. testN]
+#                        [CACHE_ENTRIES entry1 .. entryN]
+#                        PROPERTIES prop1 .. propN )
+#
+# This macro prints the values of the properties of the given targets,
+# source files, directories, tests or cache entries. Exactly one of the
+# scope keywords must be used.
+# Example:
+#   cmake_print_properties(TARGETS foo bar PROPERTIES LOCATION INTERFACE_INCLUDE_DIRS)
+# This will print the LOCATION and INTERFACE_INCLUDE_DIRS properties for both
+# targets foo and bar.
+#
+#
+# CMAKE_PRINT_VARIABLES(var1 var2 .. varN)
+#
+# This macro will print the name of each variable followed by its value.
+# Example:
+#   cmake_print_variables(CMAKE_C_COMPILER CMAKE_MAJOR_VERSION THIS_ONE_DOES_NOT_EXIST)
+# Gives:
+#   -- CMAKE_C_COMPILER="/usr/bin/gcc" ; CMAKE_MAJOR_VERSION="2" ; THIS_ONE_DOES_NOT_EXIST=""
+
+#=============================================================================
+# Copyright 2013 Alexander Neundorf, <neundorf at kde.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.)
+
+include(CMakeParseArguments)
+
+function(CMAKE_PRINT_VARIABLES)
+   set(msg "")
+   foreach(var ${ARGN})
+      if(msg)
+         set(msg "${msg} ; ")
+      endif()
+      set(msg "${msg}${var}=\"${${var}}\"")
+   endforeach()
+   message(STATUS "${msg}")
+endfunction()
+
+
+function(CMAKE_PRINT_PROPERTIES )
+  set(options )
+  set(oneValueArgs )
+  set(multiValueArgs TARGETS SOURCES TESTS DIRECTORIES CACHE_ENTRIES PROPERTIES )
+
+  cmake_parse_arguments(CPP "${options}" "${oneValueArgs}" "${multiValueArgs}"  ${ARGN})
+
+  if(CPP_UNPARSED_ARGUMENTS)
+    message(FATAL_ERROR "Unknown keywords given to cmake_print_properties(): \"${CPP_UNPARSED_ARGUMENTS}\"")
+    return()
+  endif()
+
+  if(NOT CPP_PROPERTIES)
+    message(FATAL_ERROR "Required argument PROPERTIES missing in cmake_print_properties() call")
+    return()
+  endif()
+
+  set(mode)
+  set(items)
+  set(keyword)
+
+  if(CPP_TARGETS)
+    set(items ${CPP_TARGETS})
+    set(mode ${mode} TARGETS)
+    set(keyword TARGET)
+  endif()
+
+  if(CPP_SOURCES)
+    set(items ${CPP_SOURCES})
+    set(mode ${mode} SOURCES)
+    set(keyword SOURCE)
+  endif()
+
+  if(CPP_TESTS)
+    set(items ${CPP_TESTS})
+    set(mode ${mode} TESTS)
+    set(keyword TEST)
+  endif()
+
+  if(CPP_DIRECTORIES)
+    set(items ${CPP_DIRECTORIES})
+    set(mode ${mode} DIRECTORIES)
+    set(keyword DIRECTORY)
+  endif()
+
+  if(CPP_CACHE_ENTRIES)
+    set(items ${CPP_CACHE_ENTRIES})
+    set(mode ${mode} CACHE_ENTRIES)
+    set(keyword CACHE)
+  endif()
+
+  if(NOT mode)
+    message(FATAL_ERROR "Mode keyword missing in cmake_print_properties() call, must be one of TARGETS SOURCES TESTS DIRECTORIES CACHE_ENTRIES PROPERTIES")
+    return()
+  endif()
+
+  list(LENGTH mode modeLength)
+  if("${modeLength}" GREATER 1)
+    message(FATAL_ERROR "Multiple mode keyword used in cmake_print_properties() call, it must be exactly one of TARGETS SOURCES TESTS DIRECTORIES CACHE_ENTRIES PROPERTIES")
+    return()
+  endif()
+
+  set(msg "\n")
+  foreach(item ${items})
+
+    set(itemExists TRUE)
+    if(keyword STREQUAL "TARGET")
+      if(NOT TARGET ${item})
+      set(itemExists FALSE)
+      set(msg "${msg}\n No such TARGET \"${item}\" !\n\n")
+      endif()
+    endif()
+
+    if (itemExists)
+      set(msg "${msg} Properties for ${keyword} ${item}:\n")
+      foreach(prop ${CPP_PROPERTIES})
+
+        get_property(propertySet ${keyword} ${item} PROPERTY "${prop}" SET)
+
+        if(propertySet)
+          get_property(property ${keyword} ${item} PROPERTY "${prop}")
+          set(msg "${msg}   ${item}.${prop} = \"${property}\"\n")
+        else()
+          set(msg "${msg}   ${item}.${prop} = <NOTFOUND>\n")
+        endif()
+      endforeach()
+    endif()
+
+  endforeach()
+  message(STATUS "${msg}")
+
+endfunction()

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

Summary of changes:
 Modules/CMakePrintHelpers.cmake |  146 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 146 insertions(+), 0 deletions(-)
 create mode 100644 Modules/CMakePrintHelpers.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list