diff options
32 files changed, 360 insertions, 120 deletions
diff --git a/Help/command/file.rst b/Help/command/file.rst index 600464e..b0d4792 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -247,7 +247,9 @@ the ``<format>`` and ``UTC`` options. :: - file(GENERATE <options>...) + file(GENERATE OUTPUT output-file + <INPUT input-file|CONTENT content> + [CONDITION expression]) Generate an output file for each build configuration supported by the current :manual:`CMake Generator <cmake-generators(7)>`. Evaluate diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index 672c9b7..3b9b921 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -720,7 +720,9 @@ by the :command:`find_package` command when invoked for ``<package>``. The primary task of a find module is to determine whether a package exists on the system, set the ``<package>_FOUND`` variable to reflect this and provide any variables, macros and imported targets required to -use the package. +use the package. A find module is useful in cases where an upstream +library does not provide a +:ref:`config file package <Config File Packages>`. The traditional approach is to use variables for everything, including libraries and executables: see the `Standard Variable Names`_ section @@ -728,13 +730,9 @@ below. This is what most of the existing find modules provided by CMake do. The more modern approach is to behave as much like -``<package>Config.cmake`` files as possible, by providing imported -targets. As well as matching how ``*Config.cmake`` files work, the -libraries, include directories and compile definitions are all set just -by using the target in a :command:`target_link_libraries` call. The -disadvantage is that ``*Config.cmake`` files of projects that use -imported targets from find modules may require more work to make sure -those imported targets that are in the link interface are available. +:ref:`config file packages <Config File Packages>` files as possible, by +providing :ref:`imported target <Imported targets>`. This has the advantage +of propagating :ref:`Target Usage Requirements` to consumers. In either case (or even when providing both variables and imported targets), find modules should provide backwards compatibility with old @@ -878,7 +876,10 @@ To prevent users being overwhelmed with settings to configure, try to keep as many options as possible out of the cache, leaving at least one option which can be used to disable use of the module, or locate a not-found library (e.g. ``Xxx_ROOT_DIR``). For the same reason, mark -most cache options as advanced. +most cache options as advanced. For packages which provide both debug +and release binaries, it is common to create cache variables with a +``_LIBRARY_<CONFIG>`` suffix, such as ``Foo_LIBRARY_RELEASE`` and +``Foo_LIBRARY_DEBUG``. While these are the standard variable names, you should provide backwards compatibility for any old names that were actually in use. @@ -945,16 +946,6 @@ licence notice block # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -If the module is new to CMake, you may want to provide a warning for -projects that do not require a high enough CMake version. - -.. code-block:: cmake - - if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.0.0) - message(AUTHOR_WARNING - "Your project should require at least CMake 3.0.0 to use FindFoo.cmake") - endif() - Now the actual libraries and so on have to be found. The code here will obviously vary from module to module (dealing with that, after all, is the point of find modules), but there tends to be a common pattern for libraries. @@ -1061,6 +1052,47 @@ not any of its dependencies. Instead, those dependencies should also be targets, and CMake should be told that they are dependencies of this target. CMake will then combine all the necessary information automatically. +The type of the :prop_tgt:`IMPORTED` target created in the +:command:`add_library` command can always be specified as ``UNKNOWN`` +type. This simplifies the code in cases where static or shared variants may +be found, and CMake will determine the type by inspecting the files. + +If the library is available with multiple configurations, the +:prop_tgt:`IMPORTED_CONFIGURATIONS` target property should also be +populated: + +.. code-block:: cmake + + if(Foo_FOUND) + if (NOT TARGET Foo::Foo) + add_library(Foo::Foo UNKNOWN IMPORTED) + endif() + if (Foo_LIBRARY_RELEASE) + set_property(TARGET Foo::Foo APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE + ) + set_target_properties(Foo::Foo PROPERTIES + IMPORTED_LOCATION_RELEASE "${Foo_LIBRARY_RELEASE}" + ) + endif() + if (Foo_LIBRARY_DEBUG) + set_property(TARGET Foo::Foo APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG + ) + set_target_properties(Foo::Foo PROPERTIES + IMPORTED_LOCATION_DEBUG "${Foo_LIBRARY_DEBUG}" + ) + endif() + set_target_properties(Foo::Foo PROPERTIES + INTERFACE_COMPILE_OPTIONS "${PC_Foo_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Foo_INCLUDE_DIR}" + ) + endif() + +The ``RELEASE`` variant should be listed first in the property +so that that variant is chosen if the user uses a configuration which is +not an exact match for any listed ``IMPORTED_CONFIGURATIONS``. + We should also provide some information about the package, such as where to download it. diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 083ed7a..8337118 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -209,7 +209,7 @@ All Modules /module/FindWish /module/FindwxWidgets /module/FindwxWindows - /module/FindXerces + /module/FindXercesC /module/FindX11 /module/FindXMLRPC /module/FindZLIB diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst index 0d18fd7..fba1d61 100644 --- a/Help/manual/cmake-packages.7.rst +++ b/Help/manual/cmake-packages.7.rst @@ -76,6 +76,8 @@ By setting the :variable:`CMAKE_DISABLE_FIND_PACKAGE_<PackageName>` variable to ``TRUE``, the ``PackageName`` package will not be searched, and will always be ``NOTFOUND``. +.. _`Config File Packages`: + Config-file Packages -------------------- diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 9ed53fa..cca6d28 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -291,6 +291,7 @@ Properties on Source Files /prop_sf/OBJECT_OUTPUTS /prop_sf/SYMBOLIC /prop_sf/VS_DEPLOYMENT_CONTENT + /prop_sf/VS_DEPLOYMENT_LOCATION /prop_sf/VS_SHADER_ENTRYPOINT /prop_sf/VS_SHADER_MODEL /prop_sf/VS_SHADER_TYPE diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 99088e0..2de4103 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -47,6 +47,7 @@ Variables that Provide Information /variable/CMAKE_LINK_LIBRARY_SUFFIX /variable/CMAKE_MAJOR_VERSION /variable/CMAKE_MAKE_PROGRAM + /variable/CMAKE_MATCH_COUNT /variable/CMAKE_MINIMUM_REQUIRED_VERSION /variable/CMAKE_MINOR_VERSION /variable/CMAKE_PARENT_LIST_FILE diff --git a/Help/module/FindXerces.rst b/Help/module/FindXerces.rst deleted file mode 100644 index 166d8dd..0000000 --- a/Help/module/FindXerces.rst +++ /dev/null @@ -1 +0,0 @@ -.. cmake-module:: ../../Modules/FindXerces.cmake diff --git a/Help/module/FindXercesC.rst b/Help/module/FindXercesC.rst new file mode 100644 index 0000000..4818071 --- /dev/null +++ b/Help/module/FindXercesC.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/FindXercesC.cmake diff --git a/Help/prop_sf/VS_DEPLOYMENT_LOCATION.rst b/Help/prop_sf/VS_DEPLOYMENT_LOCATION.rst new file mode 100644 index 0000000..303db95 --- /dev/null +++ b/Help/prop_sf/VS_DEPLOYMENT_LOCATION.rst @@ -0,0 +1,8 @@ +VS_DEPLOYMENT_LOCATION +---------------------- + +Specifies the deployment location for a content source file with a Windows +Phone or Windows Store application when built with a Visual Studio generator. +This property is only applicable when using :prop_sf:`VS_DEPLOYMENT_CONTENT`. +The value represent the path relative to the app package and applies to all +configurations. diff --git a/Help/release/3.1.0.rst b/Help/release/3.1.0.rst index 1ffc5b5..a5b3e8e 100644 --- a/Help/release/3.1.0.rst +++ b/Help/release/3.1.0.rst @@ -165,6 +165,10 @@ Properties to tell the Visual Studio generators to mark content for deployment in Windows Phone and Windows Store projects. +* A :prop_sf:`VS_DEPLOYMENT_LOCATION` source file property was added + to tell the Visual Studio generators the relative location of content + marked for deployment in Windows Phone and Windows Store projects. + * The :prop_tgt:`VS_WINRT_COMPONENT` target property was created to tell Visual Studio generators to compile a shared library as a Windows Runtime (WinRT) component. @@ -241,6 +245,8 @@ Modules * The :module:`FindPkgConfig` module learned to use the ``PKG_CONFIG`` environment variable value as the ``pkg-config`` executable, if set. +* The :module:`FindXercesC` module was introduced. + * The :module:`FindZLIB` module now provides imported targets. * The :module:`GenerateExportHeader` module ``generate_export_header`` diff --git a/Help/release/dev/cached-regex-clear-fixed.rst b/Help/release/dev/cached-regex-clear-fixed.rst new file mode 100644 index 0000000..fbf08cc --- /dev/null +++ b/Help/release/dev/cached-regex-clear-fixed.rst @@ -0,0 +1,5 @@ +cached-regex-clear-fixed +------------------------ + +* Add :variable:`CMAKE_MATCH_COUNT` for the number of matches made in the last + regular expression. diff --git a/Help/variable/CMAKE_MATCH_COUNT.rst b/Help/variable/CMAKE_MATCH_COUNT.rst new file mode 100644 index 0000000..8b1c036 --- /dev/null +++ b/Help/variable/CMAKE_MATCH_COUNT.rst @@ -0,0 +1,8 @@ +CMAKE_MATCH_COUNT +----------------- + +The number of matches with the last regular expression. + +When a regular expression match is used, CMake fills in ``CMAKE_MATCH_<n>`` +variables with the match contents. The ``CMAKE_MATCH_COUNT`` variable holds +the number of match expressions when these are filled. diff --git a/Modules/FindUnixCommands.cmake b/Modules/FindUnixCommands.cmake index d4e5dcd..869ba38 100644 --- a/Modules/FindUnixCommands.cmake +++ b/Modules/FindUnixCommands.cmake @@ -2,12 +2,13 @@ # FindUnixCommands # ---------------- # -# Find unix commands from cygwin +# Find Unix commands, including the ones from Cygwin # -# This module looks for some usual Unix commands. +# This module looks for the Unix commands bash, cp, gzip, mv, rm, and tar +# and stores the result in the variables BASH, CP, GZIP, MV, RM, and TAR. #============================================================================= -# Copyright 2001-2009 Kitware, Inc. +# Copyright 2001-2014 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -95,3 +96,8 @@ find_program(TAR mark_as_advanced( TAR ) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(UnixCommands + REQUIRED_VARS BASH CP GZIP MV RM TAR +) diff --git a/Modules/FindXerces.cmake b/Modules/FindXercesC.cmake index 6c6007a..5a8ea9d 100644 --- a/Modules/FindXerces.cmake +++ b/Modules/FindXercesC.cmake @@ -1,21 +1,21 @@ #.rst: -# FindXerces -# ---------- +# FindXercesC +# ----------- # # Find the Apache Xerces-C++ validating XML parser headers and libraries. # # This module reports information about the Xerces installation in # several variables. General variables:: # -# Xerces_FOUND - true if the Xerces headers and libraries were found -# Xerces_VERSION - Xerces release version -# Xerces_INCLUDE_DIRS - the directory containing the Xerces headers -# Xerces_LIBRARIES - Xerces libraries to be linked +# XercesC_FOUND - true if the Xerces headers and libraries were found +# XercesC_VERSION - Xerces release version +# XercesC_INCLUDE_DIRS - the directory containing the Xerces headers +# XercesC_LIBRARIES - Xerces libraries to be linked # # The following cache variables may also be set:: # -# Xerces_INCLUDE_DIR - the directory containing the Xerces headers -# Xerces_LIBRARY - the Xerces library +# XercesC_INCLUDE_DIR - the directory containing the Xerces headers +# XercesC_LIBRARY - the Xerces library # Written by Roger Leigh <rleigh@codelibre.net> @@ -32,54 +32,54 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -function(_Xerces_GET_VERSION version_hdr) +function(_XercesC_GET_VERSION version_hdr) file(STRINGS ${version_hdr} _contents REGEX "^[ \t]*#define XERCES_VERSION_.*") if(_contents) - string(REGEX REPLACE ".*#define XERCES_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" Xerces_MAJOR "${_contents}") - string(REGEX REPLACE ".*#define XERCES_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" Xerces_MINOR "${_contents}") - string(REGEX REPLACE ".*#define XERCES_VERSION_REVISION[ \t]+([0-9]+).*" "\\1" Xerces_PATCH "${_contents}") + string(REGEX REPLACE ".*#define XERCES_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" XercesC_MAJOR "${_contents}") + string(REGEX REPLACE ".*#define XERCES_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" XercesC_MINOR "${_contents}") + string(REGEX REPLACE ".*#define XERCES_VERSION_REVISION[ \t]+([0-9]+).*" "\\1" XercesC_PATCH "${_contents}") - if(NOT Xerces_MAJOR MATCHES "^[0-9]+$") + if(NOT XercesC_MAJOR MATCHES "^[0-9]+$") message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_MAJOR!") endif() - if(NOT Xerces_MINOR MATCHES "^[0-9]+$") + if(NOT XercesC_MINOR MATCHES "^[0-9]+$") message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_MINOR!") endif() - if(NOT Xerces_PATCH MATCHES "^[0-9]+$") + if(NOT XercesC_PATCH MATCHES "^[0-9]+$") message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_REVISION!") endif() - set(Xerces_VERSION "${Xerces_MAJOR}.${Xerces_MINOR}.${Xerces_PATCH}" PARENT_SCOPE) + set(XercesC_VERSION "${XercesC_MAJOR}.${XercesC_MINOR}.${XercesC_PATCH}" PARENT_SCOPE) else() message(FATAL_ERROR "Include file ${version_hdr} does not exist or does not contain expected version information") endif() endfunction() # Find include directory -find_path(Xerces_INCLUDE_DIR +find_path(XercesC_INCLUDE_DIR NAMES "xercesc/util/PlatformUtils.hpp" DOC "Xerces-C++ include directory") -mark_as_advanced(Xerces_INCLUDE_DIR) +mark_as_advanced(XercesC_INCLUDE_DIR) -# Find all Xerces libraries -find_library(Xerces_LIBRARY "xerces-c" +# Find all XercesC libraries +find_library(XercesC_LIBRARY "xerces-c" DOC "Xerces-C++ libraries") -mark_as_advanced(Xerces_LIBRARY) +mark_as_advanced(XercesC_LIBRARY) -if(Xerces_INCLUDE_DIR) - _Xerces_GET_VERSION("${Xerces_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp") +if(XercesC_INCLUDE_DIR) + _XercesC_GET_VERSION("${XercesC_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp") endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Xerces - FOUND_VAR Xerces_FOUND - REQUIRED_VARS Xerces_LIBRARY - Xerces_INCLUDE_DIR - Xerces_VERSION - VERSION_VAR Xerces_VERSION - FAIL_MESSAGE "Failed to find Xerces") +FIND_PACKAGE_HANDLE_STANDARD_ARGS(XercesC + FOUND_VAR XercesC_FOUND + REQUIRED_VARS XercesC_LIBRARY + XercesC_INCLUDE_DIR + XercesC_VERSION + VERSION_VAR XercesC_VERSION + FAIL_MESSAGE "Failed to find XercesC") -if(Xerces_FOUND) - set(Xerces_INCLUDE_DIRS "${Xerces_INCLUDE_DIR}") - set(Xerces_LIBRARIES "${Xerces_LIBRARY}") +if(XercesC_FOUND) + set(XercesC_INCLUDE_DIRS "${XercesC_INCLUDE_DIR}") + set(XercesC_LIBRARIES "${XercesC_LIBRARY}") endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d1a0f20..9dd227c 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 1) -set(CMake_VERSION_PATCH 20141203) +set(CMake_VERSION_PATCH 20141208) #set(CMake_VERSION_RC 1) diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index cdc9f2a..bba4d41 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -328,9 +328,8 @@ bool cmAddLibraryCommand CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to STATIC. But at this point we know only the name of the target, but not yet its linker language. */ - if ((type != cmTarget::STATIC_LIBRARY) && - (type != cmTarget::OBJECT_LIBRARY) && - (type != cmTarget::INTERFACE_LIBRARY) && + if ((type == cmTarget::SHARED_LIBRARY || + type == cmTarget::MODULE_LIBRARY) && (this->Makefile->GetCMakeInstance()->GetPropertyAsBool( "TARGET_SUPPORTS_SHARED_LIBS") == false)) { diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 6065b8a..aba26de 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -11,7 +11,6 @@ ============================================================================*/ #include "cmConditionEvaluator.h" -#include "cmStringCommand.h" cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile): Makefile(makefile), @@ -556,7 +555,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs, { def = this->GetVariableOrString(*arg); const char* rex = argP2->c_str(); - cmStringCommand::ClearMatches(&this->Makefile); + this->Makefile.ClearMatches(); cmsys::RegularExpression regEntry; if ( !regEntry.compile(rex) ) { @@ -568,7 +567,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs, } if (regEntry.find(def)) { - cmStringCommand::StoreMatches(&this->Makefile, regEntry); + this->Makefile.StoreMatches(regEntry); *arg = cmExpandedCommandArgument("1", true); } else diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2506eaa..20dae5a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4851,6 +4851,64 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const return this->QtUiFilesWithOptions; } +static std::string const matchVariables[] = { + "CMAKE_MATCH_0", + "CMAKE_MATCH_1", + "CMAKE_MATCH_2", + "CMAKE_MATCH_3", + "CMAKE_MATCH_4", + "CMAKE_MATCH_5", + "CMAKE_MATCH_6", + "CMAKE_MATCH_7", + "CMAKE_MATCH_8", + "CMAKE_MATCH_9" +}; + +static std::string const nMatchesVariable = "CMAKE_MATCH_COUNT"; + +//---------------------------------------------------------------------------- +void cmMakefile::ClearMatches() +{ + const char* nMatchesStr = this->GetDefinition(nMatchesVariable); + if (!nMatchesStr) + { + return; + } + int nMatches = atoi(nMatchesStr); + for (int i=0; i<=nMatches; i++) + { + std::string const& var = matchVariables[i]; + std::string const& s = this->GetSafeDefinition(var); + if(!s.empty()) + { + this->AddDefinition(var, ""); + this->MarkVariableAsUsed(var); + } + } + this->AddDefinition(nMatchesVariable, "0"); + this->MarkVariableAsUsed(nMatchesVariable); +} + +//---------------------------------------------------------------------------- +void cmMakefile::StoreMatches(cmsys::RegularExpression& re) +{ + char highest = 0; + for (int i=0; i<10; i++) + { + std::string const& m = re.match(i); + if(!m.empty()) + { + std::string const& var = matchVariables[i]; + this->AddDefinition(var, m.c_str()); + this->MarkVariableAsUsed(var); + highest = static_cast<char>('0' + i); + } + } + char nMatches[] = {highest, '\0'}; + this->AddDefinition(nMatchesVariable, nMatches); + this->MarkVariableAsUsed(nMatchesVariable); +} + //---------------------------------------------------------------------------- cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 05b7a37..fcfec8d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -976,6 +976,9 @@ public: void PopLoopBlock(); bool IsLoopBlock() const; + void ClearMatches(); + void StoreMatches(cmsys::RegularExpression& re); + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const std::string& name, cmTarget& target); diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 9827c62..8341027 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -310,7 +310,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args) input += args[i]; } - this->ClearMatches(this->Makefile); + this->Makefile->ClearMatches(); // Compile the regular expression. cmsys::RegularExpression re; if(!re.compile(regex.c_str())) @@ -325,7 +325,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args) std::string output; if(re.find(input.c_str())) { - this->StoreMatches(this->Makefile, re); + this->Makefile->StoreMatches(re); std::string::size_type l = re.start(); std::string::size_type r = re.end(); if(r-l == 0) @@ -359,7 +359,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) input += args[i]; } - this->ClearMatches(this->Makefile); + this->Makefile->ClearMatches(); // Compile the regular expression. cmsys::RegularExpression re; if(!re.compile(regex.c_str())) @@ -376,7 +376,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) const char* p = input.c_str(); while(re.find(p)) { - this->StoreMatches(this->Makefile, re); + this->Makefile->StoreMatches(re); std::string::size_type l = re.start(); std::string::size_type r = re.end(); if(r-l == 0) @@ -463,7 +463,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) input += args[i]; } - this->ClearMatches(this->Makefile); + this->Makefile->ClearMatches(); // Compile the regular expression. cmsys::RegularExpression re; if(!re.compile(regex.c_str())) @@ -480,7 +480,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) std::string::size_type base = 0; while(re.find(input.c_str()+base)) { - this->StoreMatches(this->Makefile, re); + this->Makefile->StoreMatches(re); std::string::size_type l2 = re.start(); std::string::size_type r = re.end(); @@ -541,38 +541,6 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) } //---------------------------------------------------------------------------- -void cmStringCommand::ClearMatches(cmMakefile* mf) -{ - for (unsigned int i=0; i<10; i++) - { - char name[128]; - sprintf(name, "CMAKE_MATCH_%d", i); - const char* s = mf->GetDefinition(name); - if(s && *s != 0) - { - mf->AddDefinition(name, ""); - mf->MarkVariableAsUsed(name); - } - } -} - -//---------------------------------------------------------------------------- -void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re) -{ - for (unsigned int i=0; i<10; i++) - { - std::string m = re.match(i); - if(m.size() > 0) - { - char name[128]; - sprintf(name, "CMAKE_MATCH_%d", i); - mf->AddDefinition(name, re.match(i).c_str()); - mf->MarkVariableAsUsed(name); - } - } -} - -//---------------------------------------------------------------------------- bool cmStringCommand::HandleFindCommand(std::vector<std::string> const& args) { diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index a5fe893..9c75095 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -53,8 +53,6 @@ public: virtual std::string GetName() const { return "string";} cmTypeMacro(cmStringCommand, cmCommand); - static void ClearMatches(cmMakefile* mf); - static void StoreMatches(cmMakefile* mf, cmsys::RegularExpression& re); protected: bool HandleConfigureCommand(std::vector<std::string> const& args); bool HandleAsciiCommand(std::vector<std::string> const& args); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2304be8..68b6576 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1221,7 +1221,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) shaderEntryPoint = se; toolHasSettings = true; } - // Figure out which entry point to use if any + // Figure out which shader model to use if any if (const char* sm = sf->GetProperty("VS_SHADER_MODEL")) { shaderModel = sm; @@ -1261,6 +1261,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) } std::string deployContent; + std::string deployLocation; if(this->GlobalGenerator->TargetsWindowsPhone() || this->GlobalGenerator->TargetsWindowsStore()) { @@ -1269,6 +1270,12 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) { toolHasSettings = true; deployContent = content; + + const char* location = sf->GetProperty("VS_DEPLOYMENT_LOCATION"); + if(location && *location) + { + deployLocation = location; + } } } @@ -1283,6 +1290,14 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(deployContent); + // Deployment location cannot be set on a configuration basis + if(!deployLocation.empty()) + { + this->WriteString("<Link>", 3); + (*this->BuildFileStream) << deployLocation + << "\\%(FileName)%(Extension)"; + this->WriteString("</Link>\n", 0); + } for(size_t i = 0; i != configs->size(); ++i) { if(0 == strcmp(cge->Evaluate(this->Makefile, (*configs)[i]), "1")) diff --git a/Tests/RunCMake/string/RegexClear-stderr.txt b/Tests/RunCMake/string/RegexClear-stderr.txt new file mode 100644 index 0000000..22b0159 --- /dev/null +++ b/Tests/RunCMake/string/RegexClear-stderr.txt @@ -0,0 +1,54 @@ +^Matched string properly +results from: setting up initial state +CMAKE_MATCH_0: -->01<-- +CMAKE_MATCH_1: -->0<-- +CMAKE_MATCH_2: -->1<-- +CMAKE_MATCH_COUNT: -->2<-- +Matched string properly +results from: making a match inside of find_package +CMAKE_MATCH_0: -->01<-- +CMAKE_MATCH_1: -->0<-- +CMAKE_MATCH_2: -->1<-- +CMAKE_MATCH_COUNT: -->2<-- +Matched nothing properly +results from: making a failure inside of find_package +CMAKE_MATCH_0: --><-- +CMAKE_MATCH_1: --><-- +CMAKE_MATCH_2: --><-- +CMAKE_MATCH_COUNT: -->0<-- +Matched nothing properly +results from: checking after find_package +CMAKE_MATCH_0: --><-- +CMAKE_MATCH_1: --><-- +CMAKE_MATCH_2: --><-- +CMAKE_MATCH_COUNT: -->0<-- +Matched nothing properly +results from: clearing out results with a failing match +CMAKE_MATCH_0: --><-- +CMAKE_MATCH_1: --><-- +CMAKE_MATCH_2: --><-- +CMAKE_MATCH_COUNT: -->0<-- +Matched string properly +results from: making a successful match before add_subdirectory +CMAKE_MATCH_0: -->01<-- +CMAKE_MATCH_1: -->0<-- +CMAKE_MATCH_2: -->1<-- +CMAKE_MATCH_COUNT: -->2<-- +Matched string properly +results from: check for success in add_subdirectory +CMAKE_MATCH_0: -->01<-- +CMAKE_MATCH_1: -->0<-- +CMAKE_MATCH_2: -->1<-- +CMAKE_MATCH_COUNT: -->2<-- +Matched nothing properly +results from: failing inside of add_subdirectory +CMAKE_MATCH_0: --><-- +CMAKE_MATCH_1: --><-- +CMAKE_MATCH_2: --><-- +CMAKE_MATCH_COUNT: -->0<-- +Matched string properly +results from: ensuring the subdirectory did not interfere with the parent +CMAKE_MATCH_0: -->01<-- +CMAKE_MATCH_1: -->0<-- +CMAKE_MATCH_2: -->1<-- +CMAKE_MATCH_COUNT: -->2<--$ diff --git a/Tests/RunCMake/string/RegexClear.cmake b/Tests/RunCMake/string/RegexClear.cmake new file mode 100644 index 0000000..d5edaac --- /dev/null +++ b/Tests/RunCMake/string/RegexClear.cmake @@ -0,0 +1,54 @@ +cmake_minimum_required (VERSION 3.0) +project (RegexClear C) + +function (output_results msg) + message("results from: ${msg}") + message("CMAKE_MATCH_0: -->${CMAKE_MATCH_0}<--") + message("CMAKE_MATCH_1: -->${CMAKE_MATCH_1}<--") + message("CMAKE_MATCH_2: -->${CMAKE_MATCH_2}<--") + message("CMAKE_MATCH_COUNT: -->${CMAKE_MATCH_COUNT}<--") +endfunction () + +function (check_for_success msg) + if (CMAKE_MATCH_1 STREQUAL "0" AND + CMAKE_MATCH_2 STREQUAL "1") + message("Matched string properly") + else () + message("Failed to match properly") + endif () + output_results("${msg}") +endfunction () + +function (check_for_failure msg) + if (CMAKE_MATCH_1 STREQUAL "" AND + CMAKE_MATCH_2 STREQUAL "") + message("Matched nothing properly") + else () + message("Found a match where there should be none") + endif () + output_results("${msg}") +endfunction () + +macro (do_regex_success msg) + string(REGEX MATCH "(0)(1)" output "01") + check_for_success("${msg}") +endmacro () + +macro (do_regex_failure msg) + string(REGEX MATCH "(0)(1)" output "12") + check_for_failure("${msg}") +endmacro () + +do_regex_success("setting up initial state") + +list(INSERT CMAKE_MODULE_PATH 0 + "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +find_package(dummy) # Ensure cmMakefile::PushScope/PopScope work. + +check_for_failure("checking after find_package") +do_regex_failure("clearing out results with a failing match") +do_regex_success("making a successful match before add_subdirectory") + +add_subdirectory(subdir) + +check_for_success("ensuring the subdirectory did not interfere with the parent") # Ensure that the subdir didn't mess with this scope. diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake index e83db27..fc913c6 100644 --- a/Tests/RunCMake/string/RunCMakeTest.cmake +++ b/Tests/RunCMake/string/RunCMakeTest.cmake @@ -10,3 +10,5 @@ run_cmake(UuidBadNamespace) run_cmake(UuidMissingNameValue) run_cmake(UuidMissingTypeValue) run_cmake(UuidBadType) + +run_cmake(RegexClear) diff --git a/Tests/RunCMake/string/cmake/Finddummy.cmake b/Tests/RunCMake/string/cmake/Finddummy.cmake new file mode 100644 index 0000000..4cbc1fb --- /dev/null +++ b/Tests/RunCMake/string/cmake/Finddummy.cmake @@ -0,0 +1,4 @@ +check_for_success("making a match inside of find_package") +do_regex_failure("making a failure inside of find_package") + +set(dummy_FOUND 1) diff --git a/Tests/RunCMake/string/subdir/CMakeLists.txt b/Tests/RunCMake/string/subdir/CMakeLists.txt new file mode 100644 index 0000000..5573308 --- /dev/null +++ b/Tests/RunCMake/string/subdir/CMakeLists.txt @@ -0,0 +1,2 @@ +check_for_success("check for success in add_subdirectory") +do_regex_failure("failing inside of add_subdirectory") diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt index badb7da..7227fcc 100644 --- a/Tests/VSWinStorePhone/CMakeLists.txt +++ b/Tests/VSWinStorePhone/CMakeLists.txt @@ -86,6 +86,9 @@ if (WINDOWS_PHONE8) elseif (NOT "${PLATFORM}" STREQUAL "DESKTOP") set(CONTENT_FILES ${CONTENT_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${APP_MANIFEST_NAME} + ) + + set(ASSET_FILES ${ASSET_FILES} Direct3DApp1/Assets/Logo.png Direct3DApp1/Assets/SmallLogo.png Direct3DApp1/Assets/SplashScreen.png @@ -94,10 +97,12 @@ elseif (NOT "${PLATFORM}" STREQUAL "DESKTOP") endif() set(RESOURCE_FILES - ${CONTENT_FILES} ${DEBUG_CONTENT_FILES} ${RELEASE_CONTENT_FILES} + ${CONTENT_FILES} ${DEBUG_CONTENT_FILES} ${RELEASE_CONTENT_FILES} ${ASSET_FILES} Direct3DApp1/Direct3DApp1_TemporaryKey.pfx) set_property(SOURCE ${CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1) +set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1) +set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "Assets") set_property(SOURCE ${DEBUG_CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT $<CONFIG:Debug>) set_property(SOURCE ${RELEASE_CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>) diff --git a/Tests/VSWinStorePhone/cmake/Package_vc11.store.appxmanifest.in b/Tests/VSWinStorePhone/cmake/Package_vc11.store.appxmanifest.in index d3cb21f..68172fa 100644 --- a/Tests/VSWinStorePhone/cmake/Package_vc11.store.appxmanifest.in +++ b/Tests/VSWinStorePhone/cmake/Package_vc11.store.appxmanifest.in @@ -4,7 +4,7 @@ <Properties> <DisplayName>@SHORT_NAME@</DisplayName> <PublisherDisplayName>mgong</PublisherDisplayName> - <Logo>StoreLogo.png</Logo> + <Logo>Assets/StoreLogo.png</Logo> </Properties> <Prerequisites> <OSMinVersion>6.2.1</OSMinVersion> @@ -15,9 +15,9 @@ </Resources> <Applications> <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="@SHORT_NAME@.App"> - <VisualElements DisplayName="@SHORT_NAME@" Description="@SHORT_NAME@" BackgroundColor="#336699" ForegroundText="light" Logo="Logo.png" SmallLogo="SmallLogo.png"> + <VisualElements DisplayName="@SHORT_NAME@" Description="@SHORT_NAME@" BackgroundColor="#336699" ForegroundText="light" Logo="Assets/Logo.png" SmallLogo="Assets/SmallLogo.png"> <DefaultTile ShowName="allLogos" ShortName="@SHORT_NAME@" /> - <SplashScreen Image="SplashScreen.png" /> + <SplashScreen Image="Assets/SplashScreen.png" /> </VisualElements> </Application> </Applications> diff --git a/Tests/VSWinStorePhone/cmake/Package_vc12.store.appxmanifest.in b/Tests/VSWinStorePhone/cmake/Package_vc12.store.appxmanifest.in index 495f18e..08205f5 100644 --- a/Tests/VSWinStorePhone/cmake/Package_vc12.store.appxmanifest.in +++ b/Tests/VSWinStorePhone/cmake/Package_vc12.store.appxmanifest.in @@ -4,7 +4,7 @@ <Properties> <DisplayName>@SHORT_NAME@</DisplayName> <PublisherDisplayName>mgong</PublisherDisplayName> - <Logo>StoreLogo.png</Logo> + <Logo>Assets/StoreLogo.png</Logo> </Properties> <Prerequisites> <OSMinVersion>6.3</OSMinVersion> @@ -20,14 +20,14 @@ Description="@SHORT_NAME@" BackgroundColor="#336699" ForegroundText="light" - Square150x150Logo="Logo.png" - Square30x30Logo="SmallLogo.png"> + Square150x150Logo="Assets/Logo.png" + Square30x30Logo="Assets/SmallLogo.png"> <m2:DefaultTile ShortName="@SHORT_NAME@"> <m2:ShowNameOnTiles> <m2:ShowOn Tile="square150x150Logo" /> </m2:ShowNameOnTiles> </m2:DefaultTile> - <m2:SplashScreen Image="SplashScreen.png" /> + <m2:SplashScreen Image="Assets/SplashScreen.png" /> </m2:VisualElements> </Application> </Applications> diff --git a/Tests/VSWinStorePhone/cmake/Package_vc12.wp.appxmanifest.in b/Tests/VSWinStorePhone/cmake/Package_vc12.wp.appxmanifest.in index 2d4d389..d47d43c 100644 --- a/Tests/VSWinStorePhone/cmake/Package_vc12.wp.appxmanifest.in +++ b/Tests/VSWinStorePhone/cmake/Package_vc12.wp.appxmanifest.in @@ -6,7 +6,7 @@ <Properties> <DisplayName>@SHORT_NAME@</DisplayName> <PublisherDisplayName>mgong</PublisherDisplayName> - <Logo>StoreLogo.png</Logo> + <Logo>Assets/StoreLogo.png</Logo> </Properties> <Prerequisites> <OSMinVersion>6.3.1</OSMinVersion> @@ -22,14 +22,14 @@ Description="@SHORT_NAME@" BackgroundColor="#336699" ForegroundText="light" - Square150x150Logo="Logo.png" - Square30x30Logo="SmallLogo.png"> + Square150x150Logo="Assets/Logo.png" + Square30x30Logo="Assets/SmallLogo.png"> <m2:DefaultTile ShortName="@SHORT_NAME@"> <m2:ShowNameOnTiles> <m2:ShowOn Tile="square150x150Logo" /> </m2:ShowNameOnTiles> </m2:DefaultTile> - <m2:SplashScreen Image="SplashScreen.png" /> + <m2:SplashScreen Image="Assets/SplashScreen.png" /> </m2:VisualElements> </Application> </Applications> diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py index e20679a..5c0406d 100644 --- a/Utilities/Sphinx/cmake.py +++ b/Utilities/Sphinx/cmake.py @@ -201,7 +201,11 @@ class CMakeTransform(Transform): if make_index_entry: title = self.parse_title(env.docname) # Insert the object link target. - targetid = '%s:%s' % (objtype, title) + if objtype == 'command': + targetname = title.lower() + else: + targetname = title + targetid = '%s:%s' % (objtype, targetname) targetnode = nodes.target('', '', ids=[targetid]) self.document.note_explicit_target(targetnode) self.document.insert(0, targetnode) @@ -220,7 +224,11 @@ class CMakeObject(ObjectDescription): return sig def add_target_and_index(self, name, sig, signode): - targetid = '%s:%s' % (self.objtype, name) + if self.objtype == 'command': + targetname = name.lower() + else: + targetname = name + targetid = '%s:%s' % (self.objtype, targetname) if targetid not in self.state.document.ids: signode['names'].append(targetid) signode['ids'].append(targetid) |