[Cmake-commits] CMake branch, next, updated. v3.3.0-2015-g3f834d0

James Johnston johnstonj.public at codenest.com
Thu Aug 6 14:02:06 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  3f834d0477db40bfb619b19ca66969e04d36a323 (commit)
       via  d035e9687a2d28e2f64ec3a316f8abea57e49d63 (commit)
       via  38ed5866ed212effe0217f193f728ee54ea7378b (commit)
       via  772ca69f803a8f294d6e04f9e258becc35179233 (commit)
      from  925cb2ee6c3614195fc1786a3c909ec3092f3b89 (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=3f834d0477db40bfb619b19ca66969e04d36a323
commit 3f834d0477db40bfb619b19ca66969e04d36a323
Merge: 925cb2e d035e96
Author:     James Johnston <johnstonj.public at codenest.com>
AuthorDate: Thu Aug 6 14:02:05 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Aug 6 14:02:05 2015 -0400

    Merge topic 'fix-get-filename-component' into next
    
    d035e968 get_filename_component: Fix bug where CACHE was ignored.
    38ed5866 get_filename_component: Added initial tests for PROGRAM component.
    772ca69f get_filename_component: Tests now check for proper CACHE usage.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d035e9687a2d28e2f64ec3a316f8abea57e49d63
commit d035e9687a2d28e2f64ec3a316f8abea57e49d63
Author:     James Johnston <johnstonj.public at codenest.com>
AuthorDate: Wed Aug 5 00:33:59 2015 -0400
Commit:     James Johnston <johnstonj.public at codenest.com>
CommitDate: Thu Aug 6 17:53:34 2015 +0000

    get_filename_component: Fix bug where CACHE was ignored.
    
    If PROGRAM_ARGS is provided to get_filename_component, fix bug where the
    command failed to honor the CACHE argument.
    
    Added test cases to RunCMake.get_filename_component that fail when the
    bug is not fixed to prevent regressions.
    
    Signed-off-by: James Johnston <johnstonj.public at codenest.com>

diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index 67f9f2d..13a9afb 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -24,7 +24,7 @@ bool cmGetFilenameComponentCommand
 
   // Check and see if the value has been stored in the cache
   // already, if so use that value
-  if(args.size() == 4 && args[3] == "CACHE")
+  if(args.size() >= 4 && args[args.size() - 1] == "CACHE")
     {
     const char* cacheValue = this->Makefile->GetDefinition(args[0]);
     if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue))
@@ -111,7 +111,7 @@ bool cmGetFilenameComponentCommand
     return false;
     }
 
-  if(args.size() == 4 && args[3] == "CACHE")
+  if(args.size() >= 4 && args[args.size() - 1] == "CACHE")
     {
     if(!programArgs.empty() && !storeArgs.empty())
       {
diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
index 1532792..386109f 100644
--- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake
+++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
@@ -62,6 +62,38 @@ check("CACHE 3" "${test_cache}" "/path/to/other")
 
 list(APPEND cache_vars test_cache)
 
+# Test the PROGRAM component type with CACHE specified.
+
+# 1. Make sure it makes a cache variable in the first place for basic usage:
+get_filename_component(test_cache_program_name_1 "/ arg1 arg2" PROGRAM CACHE)
+check("PROGRAM CACHE 1 with no args output" "${test_cache_program_name_1}" "/")
+list(APPEND cache_vars test_cache_program_name_1)
+
+# 2. Set some existing cache variables & make sure the function returns them:
+set(test_cache_program_name_2 DummyProgramName CACHE FILEPATH "")
+get_filename_component(test_cache_program_name_2 "/ arg1 arg2" PROGRAM CACHE)
+check("PROGRAM CACHE 2 with no args output" "${test_cache_program_name_2}"
+  "DummyProgramName")
+list(APPEND cache_vars test_cache_program_name_2)
+
+# 3. Now test basic usage when PROGRAM_ARGS is used:
+get_filename_component(test_cache_program_name_3 "/ arg1 arg2" PROGRAM
+  PROGRAM_ARGS test_cache_program_args_3 CACHE)
+check("PROGRAM CACHE 3 name" "${test_cache_program_name_3}" "/")
+check("PROGRAM CACHE 3 args" "${test_cache_program_args_3}" " arg1 arg2")
+list(APPEND cache_vars test_cache_program_name_3)
+list(APPEND cache_vars test_cache_program_args_3)
+
+# 4. Test that existing cache variables are returned when PROGRAM_ARGS is used:
+set(test_cache_program_name_4 DummyPgm CACHE FILEPATH "")
+set(test_cache_program_args_4 DummyArgs CACHE STRING "")
+get_filename_component(test_cache_program_name_4 "/ arg1 arg2" PROGRAM
+  PROGRAM_ARGS test_cache_program_args_4 CACHE)
+check("PROGRAM CACHE 4 name" "${test_cache_program_name_4}" "DummyPgm")
+check("PROGRAM CACHE 4 args" "${test_cache_program_args_4}" "DummyArgs")
+list(APPEND cache_vars test_cache_program_name_4)
+list(APPEND cache_vars test_cache_program_name_4)
+
 # Test that ONLY the expected cache variables were created.
 get_cmake_property(current_cache_vars CACHE_VARIABLES)
 get_cmake_property(current_vars VARIABLES)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=38ed5866ed212effe0217f193f728ee54ea7378b
commit 38ed5866ed212effe0217f193f728ee54ea7378b
Author:     James Johnston <johnstonj.public at codenest.com>
AuthorDate: Wed Aug 5 00:30:58 2015 -0400
Commit:     James Johnston <johnstonj.public at codenest.com>
CommitDate: Thu Aug 6 17:53:25 2015 +0000

    get_filename_component: Added initial tests for PROGRAM component.
    
    The RunCMake.get_filename_component test now tests basic functionality
    of the PROGRAM component argument of get_filename_component.
    
    Signed-off-by: James Johnston <johnstonj.public at codenest.com>

diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
index 3f20e1a..1532792 100644
--- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake
+++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
@@ -38,6 +38,18 @@ check("ABSOLUTE .. in windows root" "${test_absolute}" "c:/path/to/filename.ext.
 
 list(APPEND non_cache_vars test_absolute)
 
+# Test the PROGRAM component type.
+get_filename_component(test_program_name "/ arg1 arg2" PROGRAM)
+check("PROGRAM with no args output" "${test_program_name}" "/")
+
+get_filename_component(test_program_name "/ arg1 arg2" PROGRAM
+  PROGRAM_ARGS test_program_args)
+check("PROGRAM with args output: name" "${test_program_name}" "/")
+check("PROGRAM with args output: args" "${test_program_args}" " arg1 arg2")
+
+list(APPEND non_cache_vars test_program_name)
+list(APPEND non_cache_vars test_program_args)
+
 # Test CACHE parameter for most component types.
 get_filename_component(test_cache "/path/to/filename.ext.in" DIRECTORY CACHE)
 check("CACHE 1" "${test_cache}" "/path/to")

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=772ca69f803a8f294d6e04f9e258becc35179233
commit 772ca69f803a8f294d6e04f9e258becc35179233
Author:     James Johnston <johnstonj.public at codenest.com>
AuthorDate: Tue Aug 4 23:47:38 2015 -0400
Commit:     James Johnston <johnstonj.public at codenest.com>
CommitDate: Thu Aug 6 17:53:12 2015 +0000

    get_filename_component: Tests now check for proper CACHE usage.
    
    The RunCMake.get_filename_component test was improved to assert that
    each test variable outputted by get_filename_component is or is not
    a cache variable, as per the particular test.
    
    Signed-off-by: James Johnston <johnstonj.public at codenest.com>

diff --git a/Tests/RunCMake/get_filename_component/CMakeLists.txt b/Tests/RunCMake/get_filename_component/CMakeLists.txt
index 12cd3c7..74b3ff8 100644
--- a/Tests/RunCMake/get_filename_component/CMakeLists.txt
+++ b/Tests/RunCMake/get_filename_component/CMakeLists.txt
@@ -1,3 +1,3 @@
-cmake_minimum_required(VERSION 2.8.4)
+cmake_minimum_required(VERSION 3.3)
 project(${RunCMake_TEST} NONE)
 include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
index 9d7cf90..3f20e1a 100644
--- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake
+++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
@@ -1,9 +1,11 @@
+# Assertion macro
 macro(check desc actual expect)
   if(NOT "x${actual}" STREQUAL "x${expect}")
     message(SEND_ERROR "${desc}: got \"${actual}\", not \"${expect}\"")
   endif()
 endmacro()
 
+# General test of all component types given an absolute path.
 set(filename "/path/to/filename.ext.in")
 set(expect_DIRECTORY "/path/to")
 set(expect_NAME "filename.ext.in")
@@ -13,14 +15,19 @@ set(expect_PATH "/path/to")
 foreach(c DIRECTORY NAME EXT NAME_WE PATH)
   get_filename_component(actual_${c} "${filename}" ${c})
   check("${c}" "${actual_${c}}" "${expect_${c}}")
+  list(APPEND non_cache_vars actual_${c})
 endforeach()
 
+# Test Windows paths with DIRECTORY component and an absolute Windows path.
 get_filename_component(test_slashes "c:\\path\\to\\filename.ext.in" DIRECTORY)
 check("DIRECTORY from backslashes" "${test_slashes}" "c:/path/to")
+list(APPEND non_cache_vars test_slashes)
 
 get_filename_component(test_winroot "c:\\filename.ext.in" DIRECTORY)
 check("DIRECTORY in windows root" "${test_winroot}" "c:/")
+list(APPEND non_cache_vars test_winroot)
 
+# Test finding absolute paths.
 get_filename_component(test_absolute "/path/to/a/../filename.ext.in" ABSOLUTE)
 check("ABSOLUTE" "${test_absolute}" "/path/to/filename.ext.in")
 
@@ -29,10 +36,36 @@ check("ABSOLUTE .. in root" "${test_absolute}" "/path/to/filename.ext.in")
 get_filename_component(test_absolute "c:/../path/to/filename.ext.in" ABSOLUTE)
 check("ABSOLUTE .. in windows root" "${test_absolute}" "c:/path/to/filename.ext.in")
 
+list(APPEND non_cache_vars test_absolute)
+
+# Test CACHE parameter for most component types.
 get_filename_component(test_cache "/path/to/filename.ext.in" DIRECTORY CACHE)
 check("CACHE 1" "${test_cache}" "/path/to")
+# Make sure that the existing CACHE entry from previous is honored:
 get_filename_component(test_cache "/path/to/other/filename.ext.in" DIRECTORY CACHE)
 check("CACHE 2" "${test_cache}" "/path/to")
 unset(test_cache CACHE)
 get_filename_component(test_cache "/path/to/other/filename.ext.in" DIRECTORY CACHE)
 check("CACHE 3" "${test_cache}" "/path/to/other")
+
+list(APPEND cache_vars test_cache)
+
+# Test that ONLY the expected cache variables were created.
+get_cmake_property(current_cache_vars CACHE_VARIABLES)
+get_cmake_property(current_vars VARIABLES)
+
+foreach(thisVar ${cache_vars})
+  if(NOT thisVar IN_LIST current_cache_vars)
+    message(SEND_ERROR "${thisVar} expected in cache but was not found.")
+  endif()
+endforeach()
+
+foreach(thisVar ${non_cache_vars})
+  if(thisVar IN_LIST current_cache_vars)
+    message(SEND_ERROR "${thisVar} unexpectedly found in cache.")
+  endif()
+  if(NOT thisVar IN_LIST current_vars)
+    # Catch likely typo when appending to non_cache_vars:
+    message(SEND_ERROR "${thisVar} not found in regular variable list.")
+  endif()
+endforeach()

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

Summary of changes:
 Source/cmGetFilenameComponentCommand.cxx           |    4 +-
 .../RunCMake/get_filename_component/CMakeLists.txt |    2 +-
 .../get_filename_component/KnownComponents.cmake   |   77 ++++++++++++++++++++
 3 files changed, 80 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list