[Cmake-commits] CMake branch, master, updated. v3.9.0-rc5-179-g0552747
Kitware Robot
kwrobot at kitware.com
Wed Jun 28 08:55:08 EDT 2017
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, master has been updated
via 0552747b58799afd6cb23db1cc5296a605cfde18 (commit)
via 45ca0403ac11a78550997a38d9d55a06439220c9 (commit)
via b425ef07ff271948c5862eeed0746c45385e45a4 (commit)
via e7936751ee8e0ade7810df97434c985552cf8a7c (commit)
via 5801751709974f873bc668d06b4020e92efe8cec (commit)
via c96f43b7dd1d41379fe63b4e8b508b2b034520b6 (commit)
via 80f1221f5088bb7ea7864a819c36d03e96f21155 (commit)
via 85b52a04bd225d04f54cabccc4cbd10f788c1bf0 (commit)
via d44bd1c25f3a1cba977eee5a6b2f5bd14c46c73d (commit)
from a5ce7df589b43f0f6cdea73f98dac26f753c9e53 (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 -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0552747b58799afd6cb23db1cc5296a605cfde18
commit 0552747b58799afd6cb23db1cc5296a605cfde18
Merge: 45ca040 c96f43b
Author: Brad King <brad.king at kitware.com>
AuthorDate: Wed Jun 28 12:53:21 2017 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Jun 28 08:53:30 2017 -0400
Merge topic 'feature/include_guard'
c96f43b7 include_guard: add tests for the feature
80f1221f include_guard: add doc pages and a release note
85b52a04 include_guard: add vim syntax highlighting rules
d44bd1c2 include_guard: implement new command
Acked-by: Kitware Robot <kwrobot at kitware.com>
Reviewed-by: Craig Scott <craig.scott at crascit.com>
Merge-request: !928
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=45ca0403ac11a78550997a38d9d55a06439220c9
commit 45ca0403ac11a78550997a38d9d55a06439220c9
Merge: b425ef0 5801751
Author: Brad King <brad.king at kitware.com>
AuthorDate: Wed Jun 28 12:46:00 2017 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Jun 28 08:46:07 2017 -0400
Merge topic 'fix-windows-ninja-solink'
58017517 Ninja: Fix generated command lines for cmake_symlink_* on Windows
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !1003
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b425ef07ff271948c5862eeed0746c45385e45a4
commit b425ef07ff271948c5862eeed0746c45385e45a4
Merge: a5ce7df e793675
Author: Brad King <brad.king at kitware.com>
AuthorDate: Wed Jun 28 12:45:05 2017 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Jun 28 08:45:08 2017 -0400
Merge topic 'curl-haiku'
e7936751 curl: Fix build on Haiku
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !1006
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e7936751ee8e0ade7810df97434c985552cf8a7c
commit e7936751ee8e0ade7810df97434c985552cf8a7c
Author: Jérôme Duval <jerome.duval at gmail.com>
AuthorDate: Mon Jun 26 07:26:03 2017 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Wed Jun 28 08:41:49 2017 -0400
curl: Fix build on Haiku
On Haiku the network functions are in libnetwork, so use it when it
exists.
diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt
index 45ae3de..d85f366 100644
--- a/Utilities/cmcurl/CMakeLists.txt
+++ b/Utilities/cmcurl/CMakeLists.txt
@@ -929,6 +929,8 @@ if(HAVE_LIBWS2_32)
set(CMAKE_REQUIRED_LIBRARIES ws2_32)
elseif(HAVE_LIBSOCKET)
set(CMAKE_REQUIRED_LIBRARIES socket)
+elseif(HAVE_LIBNETWORK)
+ set(CMAKE_REQUIRED_LIBRARIES network)
endif()
check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME)
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5801751709974f873bc668d06b4020e92efe8cec
commit 5801751709974f873bc668d06b4020e92efe8cec
Author: Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Fri Jun 23 10:58:39 2017 +0200
Commit: Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Fri Jun 23 10:58:39 2017 +0200
Ninja: Fix generated command lines for cmake_symlink_* on Windows
CMake generates multiple commands cojoined with &&.
On Windows this only works when executing the commands through
the Windows shell.
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 14a4ef8..1e0bf8d 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -409,10 +409,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
this->GetLocalGenerator()->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
if (targetType == cmStateEnums::EXECUTABLE) {
+ std::vector<std::string> commandLines;
+ commandLines.push_back(cmakeCommand +
+ " -E cmake_symlink_executable $in $out");
+ commandLines.push_back("$POST_BUILD");
+
this->GetGlobalGenerator()->AddRule(
"CMAKE_SYMLINK_EXECUTABLE",
- cmakeCommand + " -E cmake_symlink_executable"
- " $in $out && $POST_BUILD",
+ this->GetLocalGenerator()->BuildCommandLine(commandLines),
"Creating executable symlink $out", "Rule for creating "
"executable symlink.",
/*depfile*/ "",
@@ -422,10 +426,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
/*restat*/ "",
/*generator*/ false);
} else {
+ std::vector<std::string> commandLines;
+ commandLines.push_back(cmakeCommand +
+ " -E cmake_symlink_library $in $SONAME $out");
+ commandLines.push_back("$POST_BUILD");
+
this->GetGlobalGenerator()->AddRule(
"CMAKE_SYMLINK_LIBRARY",
- cmakeCommand + " -E cmake_symlink_library"
- " $in $SONAME $out && $POST_BUILD",
+ this->GetLocalGenerator()->BuildCommandLine(commandLines),
"Creating library symlink $out", "Rule for creating "
"library symlink.",
/*depfile*/ "",
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c96f43b7dd1d41379fe63b4e8b508b2b034520b6
commit c96f43b7dd1d41379fe63b4e8b508b2b034520b6
Author: Pavel Solodovnikov <hellyeahdominate at gmail.com>
AuthorDate: Thu Jun 22 11:13:26 2017 +0300
Commit: Pavel Solodovnikov <hellyeahdominate at gmail.com>
CommitDate: Thu Jun 22 11:13:26 2017 +0300
include_guard: add tests for the feature
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 0369fa4..978e553 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -215,6 +215,7 @@ add_RunCMake_test(get_property)
add_RunCMake_test(if)
add_RunCMake_test(include)
add_RunCMake_test(include_directories)
+add_RunCMake_test(include_guard)
add_RunCMake_test(list)
add_RunCMake_test(message)
add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES})
diff --git a/Tests/RunCMake/include_guard/CMakeLists.txt b/Tests/RunCMake/include_guard/CMakeLists.txt
new file mode 100644
index 0000000..d3137f6
--- /dev/null
+++ b/Tests/RunCMake/include_guard/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.9)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/include_guard/DirectoryScope.cmake b/Tests/RunCMake/include_guard/DirectoryScope.cmake
new file mode 100644
index 0000000..d6c5a3c
--- /dev/null
+++ b/Tests/RunCMake/include_guard/DirectoryScope.cmake
@@ -0,0 +1,19 @@
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Scripts")
+
+# Test include_guard with DIRECTORY scope
+
+# Add subdirectory which includes DirScript three times:
+# 1. Include at inner function scope
+# 2. At directory scope
+# 3. At another subdirectory to check that the guard is checked
+# against parent directories
+add_subdirectory(sub_dir_script1)
+# Add another directory which includes DirScript
+add_subdirectory(sub_dir_script2)
+
+# check inclusions count
+get_property(dir_count GLOBAL PROPERTY DIR_SCRIPT_COUNT)
+if(NOT dir_count EQUAL 2)
+ message(FATAL_ERROR
+ "Wrong DIR_SCRIPT_COUNT value: ${dir_count}, expected: 2")
+endif()
diff --git a/Tests/RunCMake/include_guard/GlobalScope.cmake b/Tests/RunCMake/include_guard/GlobalScope.cmake
new file mode 100644
index 0000000..02137fa
--- /dev/null
+++ b/Tests/RunCMake/include_guard/GlobalScope.cmake
@@ -0,0 +1,11 @@
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Scripts")
+
+# Test GLOBAL include guard
+add_subdirectory(global_script_dir)
+include(GlobScript)
+
+get_property(glob_count GLOBAL PROPERTY GLOB_SCRIPT_COUNT)
+if(NOT glob_count EQUAL 1)
+ message(FATAL_ERROR
+ "Wrong GLOB_SCRIPT_COUNT value: ${glob_count}, expected: 1")
+endif()
diff --git a/Tests/RunCMake/include_guard/InvalidArgumentsNumber-result.txt b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/include_guard/InvalidArgumentsNumber-stderr.txt b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-stderr.txt
new file mode 100644
index 0000000..cdd33ac
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at InvalidArgumentsNumber.cmake:1 \(include_guard\):
+ include_guard given an invalid number of arguments. The command takes at
+ most 1 argument.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/include_guard/InvalidArgumentsNumber.cmake b/Tests/RunCMake/include_guard/InvalidArgumentsNumber.cmake
new file mode 100644
index 0000000..a63a395
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidArgumentsNumber.cmake
@@ -0,0 +1 @@
+include_guard(ARG1 ARG2)
diff --git a/Tests/RunCMake/include_guard/InvalidScope-result.txt b/Tests/RunCMake/include_guard/InvalidScope-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidScope-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/include_guard/InvalidScope-stderr.txt b/Tests/RunCMake/include_guard/InvalidScope-stderr.txt
new file mode 100644
index 0000000..456709d
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidScope-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at InvalidScope.cmake:1 \(include_guard\):
+ include_guard given an invalid scope: INVALID
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/include_guard/InvalidScope.cmake b/Tests/RunCMake/include_guard/InvalidScope.cmake
new file mode 100644
index 0000000..f69f9fd
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidScope.cmake
@@ -0,0 +1 @@
+include_guard(INVALID)
diff --git a/Tests/RunCMake/include_guard/RunCMakeTest.cmake b/Tests/RunCMake/include_guard/RunCMakeTest.cmake
new file mode 100644
index 0000000..e87bddd
--- /dev/null
+++ b/Tests/RunCMake/include_guard/RunCMakeTest.cmake
@@ -0,0 +1,7 @@
+include(RunCMake)
+
+run_cmake(VariableScope)
+run_cmake(DirectoryScope)
+run_cmake(GlobalScope)
+run_cmake(InvalidScope)
+run_cmake(InvalidArgumentsNumber)
diff --git a/Tests/RunCMake/include_guard/Scripts/DirScript.cmake b/Tests/RunCMake/include_guard/Scripts/DirScript.cmake
new file mode 100644
index 0000000..e61d180
--- /dev/null
+++ b/Tests/RunCMake/include_guard/Scripts/DirScript.cmake
@@ -0,0 +1,12 @@
+include_guard(DIRECTORY)
+
+set(prop_name DIR_SCRIPT_COUNT)
+get_property(count_is_set GLOBAL PROPERTY ${prop_name} SET)
+
+if(NOT count_is_set)
+ set_property(GLOBAL PROPERTY ${prop_name} 1)
+else()
+ get_property(count GLOBAL PROPERTY ${prop_name})
+ math(EXPR count "${count} + 1")
+ set_property(GLOBAL PROPERTY ${prop_name} ${count})
+endif()
diff --git a/Tests/RunCMake/include_guard/Scripts/GlobScript.cmake b/Tests/RunCMake/include_guard/Scripts/GlobScript.cmake
new file mode 100644
index 0000000..c26bf40
--- /dev/null
+++ b/Tests/RunCMake/include_guard/Scripts/GlobScript.cmake
@@ -0,0 +1,12 @@
+include_guard(GLOBAL)
+
+set(prop_name GLOB_SCRIPT_COUNT)
+get_property(count_is_set GLOBAL PROPERTY ${prop_name} SET)
+
+if(NOT count_is_set)
+ set_property(GLOBAL PROPERTY ${prop_name} 1)
+else()
+ get_property(count GLOBAL PROPERTY ${prop_name})
+ math(EXPR count "${count} + 1")
+ set_property(GLOBAL PROPERTY ${prop_name} ${count})
+endif()
diff --git a/Tests/RunCMake/include_guard/Scripts/VarScript.cmake b/Tests/RunCMake/include_guard/Scripts/VarScript.cmake
new file mode 100644
index 0000000..3080377
--- /dev/null
+++ b/Tests/RunCMake/include_guard/Scripts/VarScript.cmake
@@ -0,0 +1,12 @@
+include_guard()
+
+set(prop_name VAR_SCRIPT_COUNT)
+get_property(count_is_set GLOBAL PROPERTY ${prop_name} SET)
+
+if(NOT count_is_set)
+ set_property(GLOBAL PROPERTY ${prop_name} 1)
+else()
+ get_property(count GLOBAL PROPERTY ${prop_name})
+ math(EXPR count "${count} + 1")
+ set_property(GLOBAL PROPERTY ${prop_name} ${count})
+endif()
diff --git a/Tests/RunCMake/include_guard/VariableScope.cmake b/Tests/RunCMake/include_guard/VariableScope.cmake
new file mode 100644
index 0000000..7f8477d
--- /dev/null
+++ b/Tests/RunCMake/include_guard/VariableScope.cmake
@@ -0,0 +1,24 @@
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Scripts")
+
+# Test include_guard with VARIABLE scope
+function(var_include_func)
+ # Include twice in the same scope
+ include(VarScript)
+ include(VarScript)
+ get_property(var_count GLOBAL PROPERTY VAR_SCRIPT_COUNT)
+ if(NOT var_count EQUAL 1)
+ message(FATAL_ERROR
+ "Wrong VAR_SCRIPT_COUNT value: ${var_count}, expected: 1")
+ endif()
+endfunction()
+
+var_include_func()
+
+# Check again that include_guard has been reset
+include(VarScript)
+
+get_property(var_count GLOBAL PROPERTY VAR_SCRIPT_COUNT)
+if(NOT var_count EQUAL 2)
+ message(FATAL_ERROR
+ "Wrong VAR_SCRIPT_COUNT value: ${var_count}, expected: 2")
+endif()
diff --git a/Tests/RunCMake/include_guard/global_script_dir/CMakeLists.txt b/Tests/RunCMake/include_guard/global_script_dir/CMakeLists.txt
new file mode 100644
index 0000000..ee7ea2e
--- /dev/null
+++ b/Tests/RunCMake/include_guard/global_script_dir/CMakeLists.txt
@@ -0,0 +1 @@
+include(GlobScript)
diff --git a/Tests/RunCMake/include_guard/sub_dir_script1/CMakeLists.txt b/Tests/RunCMake/include_guard/sub_dir_script1/CMakeLists.txt
new file mode 100644
index 0000000..d3626e5
--- /dev/null
+++ b/Tests/RunCMake/include_guard/sub_dir_script1/CMakeLists.txt
@@ -0,0 +1,9 @@
+function(dir_check)
+ include(DirScript)
+endfunction()
+
+dir_check()
+
+include(DirScript)
+
+add_subdirectory(sub_dir_script3)
diff --git a/Tests/RunCMake/include_guard/sub_dir_script1/sub_dir_script3/CMakeLists.txt b/Tests/RunCMake/include_guard/sub_dir_script1/sub_dir_script3/CMakeLists.txt
new file mode 100644
index 0000000..1c3b1b2
--- /dev/null
+++ b/Tests/RunCMake/include_guard/sub_dir_script1/sub_dir_script3/CMakeLists.txt
@@ -0,0 +1 @@
+include(DirScript)
diff --git a/Tests/RunCMake/include_guard/sub_dir_script2/CMakeLists.txt b/Tests/RunCMake/include_guard/sub_dir_script2/CMakeLists.txt
new file mode 100644
index 0000000..1c3b1b2
--- /dev/null
+++ b/Tests/RunCMake/include_guard/sub_dir_script2/CMakeLists.txt
@@ -0,0 +1 @@
+include(DirScript)
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=80f1221f5088bb7ea7864a819c36d03e96f21155
commit 80f1221f5088bb7ea7864a819c36d03e96f21155
Author: Pavel Solodovnikov <hellyeahdominate at gmail.com>
AuthorDate: Thu Jun 22 11:13:15 2017 +0300
Commit: Pavel Solodovnikov <hellyeahdominate at gmail.com>
CommitDate: Thu Jun 22 11:13:15 2017 +0300
include_guard: add doc pages and a release note
diff --git a/Help/command/include_guard.rst b/Help/command/include_guard.rst
new file mode 100644
index 0000000..62cce22
--- /dev/null
+++ b/Help/command/include_guard.rst
@@ -0,0 +1,46 @@
+include_guard
+-------------
+
+Provides an include guard for the file currently being processed by CMake.
+
+::
+
+ include_guard([DIRECTORY|GLOBAL])
+
+Sets up an include guard for the current CMake file (see the
+:variable:`CMAKE_CURRENT_LIST_FILE` variable documentation).
+
+CMake will end its processing of the current file at the location of the
+:command:`include_guard` command if the current file has already been
+processed for the applicable scope (see below). This provides functionality
+similar to the include guards commonly used in source headers or to the
+``#pragma once`` directive. If the current file has been processed previously
+for the applicable scope, the effect is as though :command:`return` had been
+called. Do not call this command from inside a function being defined within
+the current file.
+
+An optional argument specifying the scope of the guard may be provided.
+Possible values for the option are:
+
+``DIRECTORY``
+ The include guard applies within the current directory and below. The file
+ will only be included once within this directory scope, but may be included
+ again by other files outside of this directory (i.e. a parent directory or
+ another directory not pulled in by :command:`add_subdirectory` or
+ :command:`include` from the current file or its children).
+
+``GLOBAL``
+ The include guard applies globally to the whole build. The current file
+ will only be included once regardless of the scope.
+
+If no arguments given, ``include_guard`` has the same scope as a variable,
+meaning that the include guard effect is isolated by the most recent
+function scope or current directory if no inner function scopes exist.
+In this case the command behavior is the same as:
+
+.. code-block:: cmake
+
+ if(__CURRENT_FILE_VAR__)
+ return()
+ endif()
+ set(__CURRENT_FILE_VAR__ TRUE)
diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst
index 611c989..f8bfb32 100644
--- a/Help/manual/cmake-commands.7.rst
+++ b/Help/manual/cmake-commands.7.rst
@@ -44,6 +44,7 @@ These commands are always available.
/command/get_property
/command/if
/command/include
+ /command/include_guard
/command/list
/command/macro
/command/mark_as_advanced
diff --git a/Help/release/dev/include-guard.rst b/Help/release/dev/include-guard.rst
new file mode 100644
index 0000000..9b0c64c
--- /dev/null
+++ b/Help/release/dev/include-guard.rst
@@ -0,0 +1,8 @@
+include_guard
+-------------
+
+* The :command:`include_guard` command was introduced to allow guarding
+ CMake scripts from being included more than once. The command supports
+ ``DIRECTORY`` and ``GLOBAL`` options to adjust the corresponding include guard
+ scope. If no options given, include guard is similar to basic variable-based
+ check.
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=85b52a04bd225d04f54cabccc4cbd10f788c1bf0
commit 85b52a04bd225d04f54cabccc4cbd10f788c1bf0
Author: Pavel Solodovnikov <hellyeahdominate at gmail.com>
AuthorDate: Thu Jun 22 10:54:01 2017 +0300
Commit: Pavel Solodovnikov <hellyeahdominate at gmail.com>
CommitDate: Thu Jun 22 10:54:01 2017 +0300
include_guard: add vim syntax highlighting rules
diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim
index 4517603..d7542b5 100644
--- a/Auxiliary/vim/syntax/cmake.vim
+++ b/Auxiliary/vim/syntax/cmake.vim
@@ -203,6 +203,9 @@ syn keyword cmakeKWinclude_directories contained
syn keyword cmakeKWinclude_external_msproject contained
\ GUID MAP_IMPORTED_CONFIG_ PLATFORM TYPE WIX
+syn keyword cmakeKWinclude_guard contained
+ \ DIRECTORY GLOBAL
+
syn keyword cmakeKWinstall contained
\ ARCHIVE BUNDLE CODE COMPONENT CONFIGURATIONS CVS DESTDIR DESTINATION DIRECTORY DIRECTORY_PERMISSIONS DLL EXCLUDE_FROM_ALL EXPORT EXPORT_ANDROID_MK EXPORT_LINK_INTERFACE_LIBRARIES FILES FILES_MATCHING FILE_PERMISSIONS FRAMEWORK GROUP_EXECUTE GROUP_READ GROUP_WRITE IMPORTED_ INCLUDES INSTALL_PREFIX INTERFACE_INCLUDE_DIRECTORIES LIBRARY MACOSX_BUNDLE MESSAGE_NEVER NAMELINK_ONLY NAMELINK_SKIP NAMESPACE NDK OBJECTS OPTIONAL OWNER_EXECUTE OWNER_READ OWNER_WRITE PATTERN PERMISSIONS POST_INSTALL_SCRIPT PRE_INSTALL_SCRIPT PRIVATE_HEADER PROGRAMS PUBLIC_HEADER REGEX RENAME RESOURCE RUNTIME SCRIPT SETGID SETUID SOVERSION TARGETS TRUE USE_SOURCE_PERMISSIONS VERSION WORLD_EXECUTE WORLD_READ WORLD_WRITE
@@ -327,7 +330,7 @@ syn keyword cmakeGeneratorExpressions contained
syn case ignore
syn keyword cmakeCommand
- \ add_compile_options add_custom_command add_custom_target add_definitions add_dependencies add_executable add_library add_subdirectory add_test aux_source_directory break build_command cmake_host_system_information cmake_minimum_required cmake_parse_arguments cmake_policy configure_file continue create_test_sourcelist ctest_build ctest_configure ctest_coverage ctest_empty_binary_directory ctest_memcheck ctest_read_custom_files ctest_run_script ctest_sleep ctest_start ctest_submit ctest_test ctest_update ctest_upload define_property enable_language enable_testing endfunction endmacro execute_process export file find_file find_library find_package find_path find_program fltk_wrap_ui function get_cmake_property get_directory_property get_filename_component get_property get_source_file_property get_target_property get_test_property include include_directories include_external_msproject include_regular_expression install link_directories list load_cache load_command macro mark_as_advanced math message option project qt_wrap_cpp qt_wrap_ui remove_definitions return separate_arguments set set_directory_properties set_property set_source_files_properties set_target_properties set_tests_properties site_name source_group string target_compile_definitions target_compile_features target_compile_options target_include_directories target_link_libraries target_sources try_compile try_run unset variable_watch
+ \ add_compile_options add_custom_command add_custom_target add_definitions add_dependencies add_executable add_library add_subdirectory add_test aux_source_directory break build_command cmake_host_system_information cmake_minimum_required cmake_parse_arguments cmake_policy configure_file continue create_test_sourcelist ctest_build ctest_configure ctest_coverage ctest_empty_binary_directory ctest_memcheck ctest_read_custom_files ctest_run_script ctest_sleep ctest_start ctest_submit ctest_test ctest_update ctest_upload define_property enable_language enable_testing endfunction endmacro execute_process export file find_file find_library find_package find_path find_program fltk_wrap_ui function get_cmake_property get_directory_property get_filename_component get_property get_source_file_property get_target_property get_test_property include include_directories include_external_msproject include_guard include_regular_expression install link_directories list load_cache load_command macro mark_as_advanced math message option project qt_wrap_cpp qt_wrap_ui remove_definitions return separate_arguments set set_directory_properties set_property set_source_files_properties set_target_properties set_tests_properties site_name source_group string target_compile_definitions target_compile_features target_compile_options target_include_directories target_link_libraries target_sources try_compile try_run unset variable_watch
\ nextgroup=cmakeArguments
syn keyword cmakeCommandConditional
@@ -420,6 +423,7 @@ hi def link cmakeKWif ModeMsg
hi def link cmakeKWinclude ModeMsg
hi def link cmakeKWinclude_directories ModeMsg
hi def link cmakeKWinclude_external_msproject ModeMsg
+hi def link cmakeKWinclude_guard ModeMsg
hi def link cmakeKWinstall ModeMsg
hi def link cmakeKWinstall_files ModeMsg
hi def link cmakeKWinstall_programs ModeMsg
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d44bd1c25f3a1cba977eee5a6b2f5bd14c46c73d
commit d44bd1c25f3a1cba977eee5a6b2f5bd14c46c73d
Author: Pavel Solodovnikov <hellyeahdominate at gmail.com>
AuthorDate: Thu Jun 22 10:53:42 2017 +0300
Commit: Pavel Solodovnikov <hellyeahdominate at gmail.com>
CommitDate: Thu Jun 22 10:53:42 2017 +0300
include_guard: implement new command
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 1878b8a..660d632 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -469,6 +469,8 @@ set(SRCS
cmIncludeDirectoryCommand.h
cmIncludeExternalMSProjectCommand.cxx
cmIncludeExternalMSProjectCommand.h
+ cmIncludeGuardCommand.cxx
+ cmIncludeGuardCommand.h
cmIncludeRegularExpressionCommand.cxx
cmIncludeRegularExpressionCommand.h
cmInstallCommand.cxx
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index e1d8ef1..485dd50 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -42,6 +42,7 @@
#include "cmIfCommand.h"
#include "cmIncludeCommand.h"
#include "cmIncludeDirectoryCommand.h"
+#include "cmIncludeGuardCommand.h"
#include "cmIncludeRegularExpressionCommand.h"
#include "cmInstallCommand.h"
#include "cmInstallFilesCommand.h"
@@ -132,6 +133,7 @@ void GetScriptingCommands(cmState* state)
state->AddBuiltinCommand("get_property", new cmGetPropertyCommand);
state->AddBuiltinCommand("if", new cmIfCommand);
state->AddBuiltinCommand("include", new cmIncludeCommand);
+ state->AddBuiltinCommand("include_guard", new cmIncludeGuardCommand);
state->AddBuiltinCommand("list", new cmListCommand);
state->AddBuiltinCommand("macro", new cmMacroCommand);
state->AddBuiltinCommand("make_directory", new cmMakeDirectoryCommand);
diff --git a/Source/cmIncludeGuardCommand.cxx b/Source/cmIncludeGuardCommand.cxx
new file mode 100644
index 0000000..505b07c
--- /dev/null
+++ b/Source/cmIncludeGuardCommand.cxx
@@ -0,0 +1,108 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmIncludeGuardCommand.h"
+
+#include "cmExecutionStatus.h"
+#include "cmMakefile.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
+#include "cmSystemTools.h"
+#include "cmake.h"
+
+namespace {
+
+enum IncludeGuardScope
+{
+ VARIABLE,
+ DIRECTORY,
+ GLOBAL
+};
+
+std::string GetIncludeGuardVariableName(std::string const& filePath)
+{
+ std::string result = "__INCGUARD_";
+#ifdef CMAKE_BUILD_WITH_CMAKE
+ result += cmSystemTools::ComputeStringMD5(filePath);
+#else
+ result += cmSystemTools::MakeCidentifier(filePath);
+#endif
+ result += "__";
+ return result;
+}
+
+bool CheckIncludeGuardIsSet(cmMakefile* mf, std::string const& includeGuardVar)
+{
+ if (mf->GetProperty(includeGuardVar)) {
+ return true;
+ }
+ cmStateSnapshot dirSnapshot =
+ mf->GetStateSnapshot().GetBuildsystemDirectoryParent();
+ while (dirSnapshot.GetState()) {
+ cmStateDirectory stateDir = dirSnapshot.GetDirectory();
+ if (stateDir.GetProperty(includeGuardVar)) {
+ return true;
+ }
+ dirSnapshot = dirSnapshot.GetBuildsystemDirectoryParent();
+ }
+ return false;
+}
+
+} // anonymous namespace
+
+// cmIncludeGuardCommand
+bool cmIncludeGuardCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() > 1) {
+ this->SetError(
+ "given an invalid number of arguments. The command takes at "
+ "most 1 argument.");
+ return false;
+ }
+
+ IncludeGuardScope scope = VARIABLE;
+
+ if (!args.empty()) {
+ std::string const& arg = args[0];
+ if (arg == "DIRECTORY") {
+ scope = DIRECTORY;
+ } else if (arg == "GLOBAL") {
+ scope = GLOBAL;
+ } else {
+ this->SetError("given an invalid scope: " + arg);
+ return false;
+ }
+ }
+
+ std::string includeGuardVar = GetIncludeGuardVariableName(
+ this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE"));
+
+ cmMakefile* const mf = this->Makefile;
+
+ switch (scope) {
+ case VARIABLE:
+ if (mf->IsDefinitionSet(includeGuardVar)) {
+ status.SetReturnInvoked();
+ return true;
+ }
+ mf->AddDefinition(includeGuardVar, true);
+ break;
+ case DIRECTORY:
+ if (CheckIncludeGuardIsSet(mf, includeGuardVar)) {
+ status.SetReturnInvoked();
+ return true;
+ }
+ mf->SetProperty(includeGuardVar, "TRUE");
+ break;
+ case GLOBAL:
+ cmake* const cm = mf->GetCMakeInstance();
+ if (cm->GetProperty(includeGuardVar)) {
+ status.SetReturnInvoked();
+ return true;
+ }
+ cm->SetProperty(includeGuardVar, "TRUE");
+ break;
+ }
+
+ return true;
+}
diff --git a/Source/cmIncludeGuardCommand.h b/Source/cmIncludeGuardCommand.h
new file mode 100644
index 0000000..140c04f
--- /dev/null
+++ b/Source/cmIncludeGuardCommand.h
@@ -0,0 +1,37 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmIncludeGuardCommand_h
+#define cmIncludeGuardCommand_h
+
+#include "cmConfigure.h"
+
+#include <string>
+#include <vector>
+
+#include "cmCommand.h"
+
+class cmExecutionStatus;
+
+/** \class cmIncludeGuardCommand
+ * \brief cmIncludeGuardCommand identical to C++ #pragma_once command
+ * Can work in 3 modes: GLOBAL (works on global properties),
+ * DIRECTORY(use directory property), VARIABLE(unnamed overload without
+ * arguments) define an ordinary variable to be used as include guard checker
+ */
+class cmIncludeGuardCommand : public cmCommand
+{
+public:
+ /**
+ * This is a virtual constructor for the command.
+ */
+ cmCommand* Clone() CM_OVERRIDE { return new cmIncludeGuardCommand; }
+
+ /**
+ * This is called when the command is first encountered in
+ * the CMakeLists.txt file.
+ */
+ bool InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus& status) CM_OVERRIDE;
+};
+
+#endif
diff --git a/bootstrap b/bootstrap
index ba2a5f3..83e67c5 100755
--- a/bootstrap
+++ b/bootstrap
@@ -330,6 +330,7 @@ CMAKE_CXX_SOURCES="\
cmHexFileConverter \
cmIfCommand \
cmIncludeCommand \
+ cmIncludeGuardCommand \
cmIncludeDirectoryCommand \
cmIncludeRegularExpressionCommand \
cmInstallCommand \
-----------------------------------------------------------------------
Summary of changes:
Auxiliary/vim/syntax/cmake.vim | 6 +-
Help/command/include_guard.rst | 46 +++++++++
Help/manual/cmake-commands.7.rst | 1 +
Help/release/dev/include-guard.rst | 8 ++
Source/CMakeLists.txt | 2 +
Source/cmCommands.cxx | 2 +
Source/cmIncludeGuardCommand.cxx | 108 ++++++++++++++++++++
Source/cmIncludeGuardCommand.h | 37 +++++++
Source/cmNinjaNormalTargetGenerator.cxx | 16 ++-
Tests/RunCMake/CMakeLists.txt | 1 +
Tests/RunCMake/include_guard/CMakeLists.txt | 3 +
Tests/RunCMake/include_guard/DirectoryScope.cmake | 19 ++++
Tests/RunCMake/include_guard/GlobalScope.cmake | 11 ++
.../InvalidArgumentsNumber-result.txt} | 0
.../InvalidArgumentsNumber-stderr.txt | 5 +
.../include_guard/InvalidArgumentsNumber.cmake | 1 +
.../InvalidScope-result.txt} | 0
.../RunCMake/include_guard/InvalidScope-stderr.txt | 4 +
Tests/RunCMake/include_guard/InvalidScope.cmake | 1 +
Tests/RunCMake/include_guard/RunCMakeTest.cmake | 7 ++
.../RunCMake/include_guard/Scripts/DirScript.cmake | 12 +++
.../include_guard/Scripts/GlobScript.cmake | 12 +++
.../RunCMake/include_guard/Scripts/VarScript.cmake | 12 +++
Tests/RunCMake/include_guard/VariableScope.cmake | 24 +++++
.../include_guard/global_script_dir/CMakeLists.txt | 1 +
.../include_guard/sub_dir_script1/CMakeLists.txt | 9 ++
.../sub_dir_script1/sub_dir_script3/CMakeLists.txt | 1 +
.../include_guard/sub_dir_script2/CMakeLists.txt | 1 +
Utilities/cmcurl/CMakeLists.txt | 2 +
bootstrap | 1 +
30 files changed, 348 insertions(+), 5 deletions(-)
create mode 100644 Help/command/include_guard.rst
create mode 100644 Help/release/dev/include-guard.rst
create mode 100644 Source/cmIncludeGuardCommand.cxx
create mode 100644 Source/cmIncludeGuardCommand.h
create mode 100644 Tests/RunCMake/include_guard/CMakeLists.txt
create mode 100644 Tests/RunCMake/include_guard/DirectoryScope.cmake
create mode 100644 Tests/RunCMake/include_guard/GlobalScope.cmake
copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => include_guard/InvalidArgumentsNumber-result.txt} (100%)
create mode 100644 Tests/RunCMake/include_guard/InvalidArgumentsNumber-stderr.txt
create mode 100644 Tests/RunCMake/include_guard/InvalidArgumentsNumber.cmake
copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => include_guard/InvalidScope-result.txt} (100%)
create mode 100644 Tests/RunCMake/include_guard/InvalidScope-stderr.txt
create mode 100644 Tests/RunCMake/include_guard/InvalidScope.cmake
create mode 100644 Tests/RunCMake/include_guard/RunCMakeTest.cmake
create mode 100644 Tests/RunCMake/include_guard/Scripts/DirScript.cmake
create mode 100644 Tests/RunCMake/include_guard/Scripts/GlobScript.cmake
create mode 100644 Tests/RunCMake/include_guard/Scripts/VarScript.cmake
create mode 100644 Tests/RunCMake/include_guard/VariableScope.cmake
create mode 100644 Tests/RunCMake/include_guard/global_script_dir/CMakeLists.txt
create mode 100644 Tests/RunCMake/include_guard/sub_dir_script1/CMakeLists.txt
create mode 100644 Tests/RunCMake/include_guard/sub_dir_script1/sub_dir_script3/CMakeLists.txt
create mode 100644 Tests/RunCMake/include_guard/sub_dir_script2/CMakeLists.txt
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list