diff options
122 files changed, 1824 insertions, 89 deletions
diff --git a/Help/command/break.rst b/Help/command/break.rst index 8f1067b..fc2cd3c 100644 --- a/Help/command/break.rst +++ b/Help/command/break.rst @@ -8,3 +8,5 @@ Break from an enclosing foreach or while loop. break() Breaks from an enclosing foreach loop or while loop + +See also the :command:`continue` command. diff --git a/Help/command/continue.rst b/Help/command/continue.rst new file mode 100644 index 0000000..1c7d673 --- /dev/null +++ b/Help/command/continue.rst @@ -0,0 +1,12 @@ +continue +-------- + +Continue to the top of enclosing foreach or while loop. + +:: + + continue() + +The ``continue`` command allows a cmake script to abort the rest of a block +in a :command:`foreach` or :command:`while` loop, and start at the top of +the next iteration. See also the :command:`break` command. diff --git a/Help/command/file.rst b/Help/command/file.rst index dbc4149..600464e 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -305,3 +305,33 @@ status messages (subject to the :variable:`CMAKE_INSTALL_MESSAGE` variable), and ``NO_SOURCE_PERMISSIONS`` is default. Installation scripts generated by the :command:`install` command use this signature (with some undocumented options for internal use). + +------------------------------------------------------------------------------ + +:: + + file(LOCK <path> [DIRECTORY] [RELEASE] + [GUARD <FUNCTION|FILE|PROCESS>] + [RESULT_VARIABLE <variable>] + [TIMEOUT <seconds>]) + +Lock a file specified by ``<path>`` if no ``DIRECTORY`` option present and file +``<path>/cmake.lock`` otherwise. File will be locked for scope defined by +``GUARD`` option (default value is ``PROCESS``). ``RELEASE`` option can be used +to unlock file explicitly. If option ``TIMEOUT`` is not specified CMake will +wait until lock succeed or until fatal error occurs. If ``TIMEOUT`` is set to +``0`` lock will be tried once and result will be reported immediately. If +``TIMEOUT`` is not ``0`` CMake will try to lock file for the period specified +by ``<seconds>`` value. Any errors will be interpreted as fatal if there is no +``RESULT_VARIABLE`` option. Otherwise result will be stored in ``<variable>`` +and will be ``0`` on success or error message on failure. + +Note that lock is advisory - there is no guarantee that other processes will +respect this lock, i.e. lock synchronize two or more CMake instances sharing +some modifiable resources. Similar logic applied to ``DIRECTORY`` option - +locking parent directory doesn't prevent other ``LOCK`` commands to lock any +child directory or file. + +Trying to lock file twice is not allowed. Any intermediate directories and +file itself will be created if they not exist. ``GUARD`` and ``TIMEOUT`` +options ignored on ``RELEASE`` operation. diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst index 9c1d3b9..4616dd1 100644 --- a/Help/manual/cmake-commands.7.rst +++ b/Help/manual/cmake-commands.7.rst @@ -31,6 +31,7 @@ These commands may be used freely in CMake projects. /command/cmake_minimum_required /command/cmake_policy /command/configure_file + /command/continue /command/create_test_sourcelist /command/define_property /command/elseif diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst index 9c511ca..15c101f 100644 --- a/Help/manual/cmake-language.7.rst +++ b/Help/manual/cmake-language.7.rst @@ -469,8 +469,10 @@ Loops The :command:`foreach`/:command:`endforeach` and :command:`while`/:command:`endwhile` commands delimit code -blocks to be executed in a loop. The :command:`break` command -may be used inside such blocks to terminate the loop early. +blocks to be executed in a loop. Inside such blocks the +:command:`break` command may be used to terminate the loop +early whereas the :command:`continue` command may be used +to start with the next iteration immediately. Command Definitions ------------------- diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index bf456f5..cca6d28 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -291,6 +291,9 @@ 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 /prop_sf/WRAP_EXCLUDE /prop_sf/XCODE_EXPLICIT_FILE_TYPE diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index afc8ba2..44ffb3b 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -241,3 +241,20 @@ Windows Store may look like this: set(CMAKE_SYSTEM_NAME WindowsStore) set(CMAKE_SYSTEM_VERSION 8.1) + +Cross Compiling using NVIDIA Nsight Tegra +----------------------------------------- + +A toolchain file to configure a Visual Studio generator to +build using NVIDIA Nsight Tegra targeting Android may look +like this: + +.. code-block:: cmake + + set(CMAKE_SYSTEM_NAME Android) + +The :variable:`CMAKE_GENERATOR_TOOLSET` may be set to select +the Nsight Tegra "Toolchain Version" value. + +See the :prop_tgt:`ANDROID_API` and :prop_tgt:`ANDROID_GUI` +target properties to configure targets within the project. diff --git a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst index bdeabdb..e24822c 100644 --- a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst @@ -145,7 +145,7 @@ The features known to this version of CMake are: .. _N2672: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm ``cxx_generic_lambdas`` - Generic lambdas, ss defined in N3649_. + Generic lambdas, as defined in N3649_. .. _N3649: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3649.html 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/prop_sf/VS_SHADER_ENTRYPOINT.rst b/Help/prop_sf/VS_SHADER_ENTRYPOINT.rst new file mode 100644 index 0000000..fe3471f --- /dev/null +++ b/Help/prop_sf/VS_SHADER_ENTRYPOINT.rst @@ -0,0 +1,5 @@ +VS_SHADER_ENTRYPOINT +-------------------- + +Specifies the name of the entry point for the shader of a ``.hlsl`` source +file. diff --git a/Help/prop_sf/VS_SHADER_MODEL.rst b/Help/prop_sf/VS_SHADER_MODEL.rst new file mode 100644 index 0000000..b1cf0df --- /dev/null +++ b/Help/prop_sf/VS_SHADER_MODEL.rst @@ -0,0 +1,5 @@ +VS_SHADER_MODEL +--------------- + +Specifies the shader model of a ``.hlsl`` source file. Some shader types can +only be used with recent shader models diff --git a/Help/prop_tgt/ANDROID_GUI.rst b/Help/prop_tgt/ANDROID_GUI.rst index 90d2428..abdba7a 100644 --- a/Help/prop_tgt/ANDROID_GUI.rst +++ b/Help/prop_tgt/ANDROID_GUI.rst @@ -7,3 +7,7 @@ When this property is set to true the executable when built for Android will be created as an application package. This property is initialized by the value of the :variable:`CMAKE_ANDROID_GUI` variable if it is set when a target is created. + +Add the ``AndroidManifest.xml`` source file explicitly to the +target :command:`add_executable` command invocation to specify the +root directory of the application package source. diff --git a/Help/release/3.1.0.rst b/Help/release/3.1.0.rst index d6921c4..96717c6 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. @@ -236,9 +240,6 @@ Modules * The :module:`FindOpenCL` module was introduced. -* The :module:`FindOpenGL` module now provides imported targets - ``OpenGL::GL`` and ``OpenGL::GLU`` when the libraries are found. - * The :module:`FindOpenMP` module learned to support Fortran. * The :module:`FindPkgConfig` module learned to use the ``PKG_CONFIG`` @@ -316,8 +317,10 @@ Other * The Visual Studio generators learned to treat ``.hlsl`` source files as High Level Shading Language sources (using ``FXCompile`` - in ``.vcxproj`` files). A :prop_sf:`VS_SHADER_TYPE` source file - property was added to specify the Shader Type. + in ``.vcxproj`` files). Source file properties + :prop_sf:`VS_SHADER_TYPE`, :prop_sf:`VS_SHADER_MODEL`, and + :prop_sf:`VS_SHADER_ENTRYPOINT` were added added to specify the + shader type, model, and entry point name. New Diagnostics =============== diff --git a/Help/release/dev/add-continue-command.rst b/Help/release/dev/add-continue-command.rst new file mode 100644 index 0000000..4995a8e --- /dev/null +++ b/Help/release/dev/add-continue-command.rst @@ -0,0 +1,6 @@ +add-continue-command +-------------------- + +* A new :command:`continue` command was added that can be called inside loop + contexts to end the current iteration and start the next one at the top of + the loop block. diff --git a/Help/release/dev/file-LOCK-command.rst b/Help/release/dev/file-LOCK-command.rst new file mode 100644 index 0000000..4b11e9e --- /dev/null +++ b/Help/release/dev/file-LOCK-command.rst @@ -0,0 +1,5 @@ +file-LOCK-command +----------------- + +* The :command:`file(LOCK)` subcommand was created to allow CMake + processes to synchronize through file and directory locks. diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index 6f2eeb3..e5b7601 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -14,19 +14,19 @@ # Overview # ^^^^^^^^ # -# CPack ``IFW`` generator helps you create online and offline +# CPack ``IFW`` generator helps you to create online and offline # binary cross-platform installers with a graphical user interface. # -# CPack IFW generator prepare project installation and generate configuration +# CPack IFW generator prepares project installation and generates configuration # and meta information for QtIFW_ tools. # # The QtIFW_ provides a set of tools and utilities to create # installers for the supported desktop Qt platforms: Linux, Microsoft Windows, # and Mac OS X. # -# To use CPack ``IFW`` generator you must also install QtIFW_. -# If you are not using the default path for the installation, please set -# the path to the variable ``QTIFWDIR``. +# You should also install QtIFW_ to use CPack ``IFW`` generator. +# If you don't use a default path for the installation, please set +# the used path in the variable ``QTIFWDIR``. # # Variables # ^^^^^^^^^ @@ -61,7 +61,7 @@ # # .. variable:: CPACK_IFW_PACKAGE_LOGO # -# Filename for a logo used as QWizard::LogoPixmap. +# Filename for a logo is used as QWizard::LogoPixmap. # # .. variable:: CPACK_IFW_TARGET_DIRECTORY # @@ -149,12 +149,12 @@ # This command should be called after cpack_add_component command. # # ``COMMON`` if set, then the component will be packaged and installed as part -# of a group to which he belongs. +# of a group to which it belongs. # # ``VERSION`` is version of component. # By default used :variable:`CPACK_PACKAGE_VERSION`. # -# ``SCRIPT`` is relative or absolute path to operations script +# ``SCRIPT`` is a relative or absolute path to operations script # for this component. # # ``NAME`` is used to create domain-like identification for this component. @@ -190,7 +190,7 @@ # ``NAME`` is used to create domain-like identification for this component group. # By default used origin component group name. # -# ``SCRIPT`` is relative or absolute path to operations script +# ``SCRIPT`` is a relative or absolute path to operations script # for this component group. # # ``PRIORITY`` is priority of the component group in the tree. @@ -255,7 +255,7 @@ # Online installer # ^^^^^^^^^^^^^^^^ # -# By defaul CPack IFW generator make offline installer. This means that all +# By default CPack IFW generator makes offline installer. This means that all # components will be packaged into a binary file. # # To make a component downloaded, you must set the ``DOWNLOADED`` option in @@ -267,7 +267,7 @@ # You also can use command :command:`cpack_ifw_add_repository` and # variable :variable:`CPACK_IFW_DOWNLOAD_ALL` for more specific configuration. # -# CPack IFW generator create "repository" dir in current binary dir. You +# CPack IFW generator creates "repository" dir in current binary dir. You # would copy content of this dir to specified ``site`` (``url``). # # See Also diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index 373c58f..a7eefa7 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -4,16 +4,6 @@ # # FindModule for OpenGL and GLU. # -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the :prop_tgt:`IMPORTED` targets: -# -# ``OpenGL::GL`` -# Defined if the system has OpenGL. -# ``OpenGL::GLU`` -# Defined if the system has GLU. -# # Result Variables # ^^^^^^^^^^^^^^^^ # @@ -178,36 +168,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS}) unset(_OpenGL_REQUIRED_VARS) -# OpenGL:: targets -if(OPENGL_FOUND) - if(NOT TARGET OpenGL::GL) - add_library(OpenGL::GL UNKNOWN IMPORTED) - set_target_properties(OpenGL::GL PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}") - if(OPENGL_gl_LIBRARY MATCHES "/([^/]+)\\.framework$") - set_target_properties(OpenGL::GL PROPERTIES - IMPORTED_LOCATION "${OPENGL_gl_LIBRARY}/${CMAKE_MATCH_1}") - else() - set_target_properties(OpenGL::GL PROPERTIES - IMPORTED_LOCATION "${OPENGL_gl_LIBRARY}") - endif() - endif() - - if(OPENGL_GLU_FOUND AND NOT TARGET OpenGL::GLU) - add_library(OpenGL::GLU UNKNOWN IMPORTED) - set_target_properties(OpenGL::GLU PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES OpenGL::GL) - if(OPENGL_glu_LIBRARY MATCHES "/([^/]+)\\.framework$") - set_target_properties(OpenGL::GLU PROPERTIES - IMPORTED_LOCATION "${OPENGL_glu_LIBRARY}/${CMAKE_MATCH_1}") - else() - set_target_properties(OpenGL::GLU PROPERTIES - IMPORTED_LOCATION "${OPENGL_glu_LIBRARY}") - endif() - endif() -endif() - mark_as_advanced( OPENGL_INCLUDE_DIR OPENGL_xmesa_INCLUDE_DIR diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 5e5c7b9..8784e18 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -148,8 +148,8 @@ if(PYTHON_EXECUTABLE) # this is older. set(PYTHON_VERSION_STRING "1.4") set(PYTHON_VERSION_MAJOR "1") - set(PYTHON_VERSION_MAJOR "4") - set(PYTHON_VERSION_MAJOR "0") + set(PYTHON_VERSION_MINOR "4") + set(PYTHON_VERSION_PATCH "0") endif() endif() unset(_PYTHON_VERSION_RESULT) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 7705683..a4c982f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -219,6 +219,12 @@ set(SRCS cmExtraKateGenerator.h cmExtraSublimeTextGenerator.cxx cmExtraSublimeTextGenerator.h + cmFileLock.cxx + cmFileLock.h + cmFileLockPool.cxx + cmFileLockPool.h + cmFileLockResult.cxx + cmFileLockResult.h cmFileTimeComparison.cxx cmFileTimeComparison.h cmGeneratedFileStream.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 8819c23..70d92d2 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 20141202) +set(CMake_VERSION_PATCH 20141204) #set(CMake_VERSION_RC 1) diff --git a/Source/cmBootstrapCommands1.cxx b/Source/cmBootstrapCommands1.cxx index 5502609..4274d85 100644 --- a/Source/cmBootstrapCommands1.cxx +++ b/Source/cmBootstrapCommands1.cxx @@ -28,6 +28,7 @@ #include "cmCMakePolicyCommand.cxx" #include "cmCommandArgumentsHelper.cxx" #include "cmConfigureFileCommand.cxx" +#include "cmContinueCommand.cxx" #include "cmCoreTryCompile.cxx" #include "cmCreateTestSourceList.cxx" #include "cmDefinePropertyCommand.cxx" @@ -70,6 +71,7 @@ void GetBootstrapCommands1(std::list<cmCommand*>& commands) commands.push_back(new cmCMakeMinimumRequired); commands.push_back(new cmCMakePolicyCommand); commands.push_back(new cmConfigureFileCommand); + commands.push_back(new cmContinueCommand); commands.push_back(new cmCreateTestSourceList); commands.push_back(new cmDefinePropertyCommand); commands.push_back(new cmElseCommand); diff --git a/Source/cmContinueCommand.cxx b/Source/cmContinueCommand.cxx new file mode 100644 index 0000000..4a03caa --- /dev/null +++ b/Source/cmContinueCommand.cxx @@ -0,0 +1,39 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2014 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include "cmContinueCommand.h" + +// cmContinueCommand +bool cmContinueCommand::InitialPass(std::vector<std::string> const &args, + cmExecutionStatus &status) +{ + if(!this->Makefile->IsLoopBlock()) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "A CONTINUE command was found outside of a " + "proper FOREACH or WHILE loop scope."); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + + status.SetContinueInvoked(true); + + if(!args.empty()) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "The CONTINUE command does not accept any " + "arguments."); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + + return true; +} diff --git a/Source/cmContinueCommand.h b/Source/cmContinueCommand.h new file mode 100644 index 0000000..093b14f --- /dev/null +++ b/Source/cmContinueCommand.h @@ -0,0 +1,55 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2014 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#ifndef cmContinueCommand_h +#define cmContinueCommand_h + +#include "cmCommand.h" + +/** \class cmContinueCommand + * \brief Continue from an enclosing foreach or while loop + * + * cmContinueCommand returns from an enclosing foreach or while loop + */ +class cmContinueCommand : public cmCommand +{ +public: + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + return new cmContinueCommand; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool InitialPass(std::vector<std::string> const& args, + cmExecutionStatus &status); + + /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() const { return true; } + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual std::string GetName() const { return "continue"; } + + cmTypeMacro(cmContinueCommand, cmCommand); +}; + + + +#endif diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h index 5c94a97..d4da5a4 100644 --- a/Source/cmExecutionStatus.h +++ b/Source/cmExecutionStatus.h @@ -36,10 +36,16 @@ public: virtual bool GetBreakInvoked() { return this->BreakInvoked; } + virtual void SetContinueInvoked(bool val) + { this->ContinueInvoked = val; } + virtual bool GetContinueInvoked() + { return this->ContinueInvoked; } + virtual void Clear() { this->ReturnInvoked = false; this->BreakInvoked = false; + this->ContinueInvoked = false; this->NestedError = false; } virtual void SetNestedError(bool val) { this->NestedError = val; } @@ -49,6 +55,7 @@ public: protected: bool ReturnInvoked; bool BreakInvoked; + bool ContinueInvoked; bool NestedError; }; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index aa4c95b..a6eb8c4 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -21,6 +21,7 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cm_curl.h" +#include "cmFileLockResult.h" #endif #undef GetCurrentDirectory @@ -202,6 +203,10 @@ bool cmFileCommand { return this->HandleGenerateCommand(args); } + else if ( subCommand == "LOCK" ) + { + return this->HandleLockCommand(args); + } std::string e = "does not recognize sub-command "+subCommand; this->SetError(e); @@ -3502,6 +3507,204 @@ bool cmFileCommand::HandleGenerateCommand( } //---------------------------------------------------------------------------- +bool cmFileCommand::HandleLockCommand( + std::vector<std::string> const& args) +{ +#if defined(CMAKE_BUILD_WITH_CMAKE) + // Default values + bool directory = false; + bool release = false; + enum Guard { + GUARD_FUNCTION, + GUARD_FILE, + GUARD_PROCESS + }; + Guard guard = GUARD_PROCESS; + std::string resultVariable; + unsigned timeout = static_cast<unsigned>(-1); + + // Parse arguments + if(args.size() < 2) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "sub-command LOCK requires at least two arguments."); + return false; + } + + std::string path = args[1]; + for (unsigned i = 2; i < args.size(); ++i) + { + if (args[i] == "DIRECTORY") + { + directory = true; + } + else if (args[i] == "RELEASE") + { + release = true; + } + else if (args[i] == "GUARD") + { + ++i; + const char* merr = "expected FUNCTION, FILE or PROCESS after GUARD"; + if (i >= args.size()) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, merr); + return false; + } + else + { + if (args[i] == "FUNCTION") + { + guard = GUARD_FUNCTION; + } + else if (args[i] == "FILE") + { + guard = GUARD_FILE; + } + else if (args[i] == "PROCESS") + { + guard = GUARD_PROCESS; + } + else + { + cmOStringStream e; + e << merr << ", but got:\n \"" << args[i] << "\"."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + } + else if (args[i] == "RESULT_VARIABLE") + { + ++i; + if (i >= args.size()) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "expected variable name after RESULT_VARIABLE"); + return false; + } + resultVariable = args[i]; + } + else if (args[i] == "TIMEOUT") + { + ++i; + if (i >= args.size()) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "expected timeout value after TIMEOUT"); + return false; + } + int scanned; + if(!cmSystemTools::StringToInt(args[i].c_str(), &scanned) || scanned < 0) + { + cmOStringStream e; + e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + timeout = static_cast<unsigned>(scanned); + } + else + { + cmOStringStream e; + e << "expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT\n"; + e << "but got: \"" << args[i] << "\"."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + + if (directory) + { + path += "/cmake.lock"; + } + + if (!cmsys::SystemTools::FileIsFullPath(path)) + { + path = this->Makefile->GetCurrentDirectory() + ("/" + path); + } + + // Unify path (remove '//', '/../', ...) + path = cmSystemTools::CollapseFullPath(path); + + // Create file and directories if needed + std::string parentDir = cmSystemTools::GetParentDirectory(path); + if (!cmSystemTools::MakeDirectory(parentDir)) + { + cmOStringStream e; + e << "directory\n \"" << parentDir << "\"\ncreation failed "; + e << "(check permissions)."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + FILE *file = cmsys::SystemTools::Fopen(path, "w"); + if (!file) + { + cmOStringStream e; + e << "file\n \"" << path << "\"\ncreation failed (check permissions)."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + fclose(file); + + // Actual lock/unlock + cmFileLockPool& lockPool = this->Makefile->GetLocalGenerator()-> + GetGlobalGenerator()->GetFileLockPool(); + + cmFileLockResult fileLockResult(cmFileLockResult::MakeOk()); + if (release) + { + fileLockResult = lockPool.Release(path); + } + else + { + switch (guard) + { + case GUARD_FUNCTION: + fileLockResult = lockPool.LockFunctionScope(path, timeout); + break; + case GUARD_FILE: + fileLockResult = lockPool.LockFileScope(path, timeout); + break; + case GUARD_PROCESS: + fileLockResult = lockPool.LockProcessScope(path, timeout); + break; + default: + cmSystemTools::SetFatalErrorOccured(); + return false; + } + } + + const std::string result = fileLockResult.GetOutputMessage(); + + if (resultVariable.empty() && !fileLockResult.IsOk()) + { + cmOStringStream e; + e << "error locking file\n \"" << path << "\"\n" << result << "."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + + if (!resultVariable.empty()) + { + this->Makefile->AddDefinition(resultVariable, result.c_str()); + } + + return true; +#else + static_cast<void>(args); + this->SetError("sub-command LOCK not implemented in bootstrap cmake"); + return false; +#endif +} + +//---------------------------------------------------------------------------- bool cmFileCommand::HandleTimestampCommand( std::vector<std::string> const& args) { diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index 8d66fdf..a4d341f 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -75,6 +75,7 @@ protected: bool HandleTimestampCommand(std::vector<std::string> const& args); bool HandleGenerateCommand(std::vector<std::string> const& args); + bool HandleLockCommand(std::vector<std::string> const& args); private: void AddEvaluationFile(const std::string &inputName, diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx new file mode 100644 index 0000000..5f75637 --- /dev/null +++ b/Source/cmFileLock.cxx @@ -0,0 +1,78 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Ruslan Baratov + + 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. +============================================================================*/ + +#include "cmFileLock.h" + +#include <assert.h> +#include "cmFileLockResult.h" + +// Common implementation + +cmFileLock::~cmFileLock() +{ + if (!this->Filename.empty()) + { + const cmFileLockResult result = this->Release(); + static_cast<void>(result); + assert(result.IsOk()); + } +} + +cmFileLockResult cmFileLock::Lock( + const std::string& filename, unsigned timeout) +{ + if (filename.empty()) + { + // Error is internal since all the directories and file must be created + // before actual lock called. + return cmFileLockResult::MakeInternal(); + } + + if (!this->Filename.empty()) + { + // Error is internal since double-lock must be checked in class + // cmFileLockPool by the cmFileLock::IsLocked method. + return cmFileLockResult::MakeInternal(); + } + + this->Filename = filename; + cmFileLockResult result = this->OpenFile(); + if (result.IsOk()) + { + if (timeout == static_cast<unsigned>(-1)) + { + result = this->LockWithoutTimeout(); + } + else + { + result = this->LockWithTimeout(timeout); + } + } + + if (!result.IsOk()) + { + this->Filename = ""; + } + + return result; +} + +bool cmFileLock::IsLocked(const std::string& filename) const +{ + return filename == this->Filename; +} + +#if defined(_WIN32) +# include "cmFileLockWin32.cxx" +#else +# include "cmFileLockUnix.cxx" +#endif diff --git a/Source/cmFileLock.h b/Source/cmFileLock.h new file mode 100644 index 0000000..4d922a0 --- /dev/null +++ b/Source/cmFileLock.h @@ -0,0 +1,74 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Ruslan Baratov + + 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. +============================================================================*/ + +#ifndef cmFileLock_h +#define cmFileLock_h + +#include "cmStandardIncludes.h" + +#if defined(_WIN32) +# include <windows.h> // HANDLE +#endif + +class cmFileLockResult; + +/** + * @brief Cross-platform file locking. + * @details Under the hood this class use 'fcntl' for Unix-like platforms and + * 'LockFileEx'/'UnlockFileEx' for Win32 platform. Locks are exclusive and + * advisory. + */ +class cmFileLock +{ + public: + cmFileLock(); + ~cmFileLock(); + + /** + * @brief Lock the file. + * @param timeoutSec Lock timeout. If -1 try until success or fatal error. + */ + cmFileLockResult Lock(const std::string& filename, unsigned timeoutSec); + + /** + * @brief Unlock the file. + */ + cmFileLockResult Release(); + + /** + * @brief Check file is locked by this class. + * @details This function helps to find double locks (deadlocks) and to do + * explicit unlocks. + */ + bool IsLocked(const std::string& filename) const; + + private: + cmFileLock(const cmFileLock&); + cmFileLock& operator=(const cmFileLock&); + + cmFileLockResult OpenFile(); + cmFileLockResult LockWithoutTimeout(); + cmFileLockResult LockWithTimeout(unsigned timeoutSec); + +#if defined(_WIN32) + typedef HANDLE FileId; + BOOL LockFile(DWORD flags); +#else + typedef int FileId; + int LockFile(int cmd, int type); +#endif + + FileId File; + std::string Filename; +}; + +#endif // cmFileLock_h diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx new file mode 100644 index 0000000..e84e71a --- /dev/null +++ b/Source/cmFileLockPool.cxx @@ -0,0 +1,198 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Ruslan Baratov + + 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. +============================================================================*/ + +#include "cmFileLockPool.h" + +#include <assert.h> + +#include "cmFileLock.h" +#include "cmFileLockResult.h" + +cmFileLockPool::cmFileLockPool() +{ +} + +cmFileLockPool::~cmFileLockPool() +{ + for (It i = this->FunctionScopes.begin(); + i != this->FunctionScopes.end(); ++i) + { + delete *i; + } + + for (It i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i) + { + delete *i; + } +} + +void cmFileLockPool::PushFunctionScope() +{ + this->FunctionScopes.push_back(new ScopePool()); +} + +void cmFileLockPool::PopFunctionScope() +{ + assert(!this->FunctionScopes.empty()); + delete this->FunctionScopes.back(); + this->FunctionScopes.pop_back(); +} + +void cmFileLockPool::PushFileScope() +{ + this->FileScopes.push_back(new ScopePool()); +} + +void cmFileLockPool::PopFileScope() +{ + assert(!this->FileScopes.empty()); + delete this->FileScopes.back(); + this->FileScopes.pop_back(); +} + +cmFileLockResult cmFileLockPool::LockFunctionScope( + const std::string& filename, unsigned timeoutSec) +{ + if (this->IsAlreadyLocked(filename)) + { + return cmFileLockResult::MakeAlreadyLocked(); + } + if (this->FunctionScopes.empty()) + { + return cmFileLockResult::MakeNoFunction(); + } + return this->FunctionScopes.back()->Lock(filename, timeoutSec); +} + +cmFileLockResult cmFileLockPool::LockFileScope( + const std::string& filename, unsigned timeoutSec) +{ + if (this->IsAlreadyLocked(filename)) + { + return cmFileLockResult::MakeAlreadyLocked(); + } + assert(!this->FileScopes.empty()); + return this->FileScopes.back()->Lock(filename, timeoutSec); +} + +cmFileLockResult cmFileLockPool::LockProcessScope( + const std::string& filename, unsigned timeoutSec) +{ + if (this->IsAlreadyLocked(filename)) + { + return cmFileLockResult::MakeAlreadyLocked(); + } + return this->ProcessScope.Lock(filename, timeoutSec); +} + +cmFileLockResult cmFileLockPool::Release(const std::string& filename) +{ + for (It i = this->FunctionScopes.begin(); + i != this->FunctionScopes.end(); ++i) + { + const cmFileLockResult result = (*i)->Release(filename); + if (!result.IsOk()) + { + return result; + } + } + + for (It i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i) + { + const cmFileLockResult result = (*i)->Release(filename); + if (!result.IsOk()) + { + return result; + } + } + + return this->ProcessScope.Release(filename); +} + +bool cmFileLockPool::IsAlreadyLocked(const std::string& filename) const +{ + for (CIt i = this->FunctionScopes.begin(); + i != this->FunctionScopes.end(); ++i) + { + const bool result = (*i)->IsAlreadyLocked(filename); + if (result) + { + return true; + } + } + + for (CIt i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i) + { + const bool result = (*i)->IsAlreadyLocked(filename); + if (result) + { + return true; + } + } + + return this->ProcessScope.IsAlreadyLocked(filename); +} + +cmFileLockPool::ScopePool::ScopePool() +{ +} + +cmFileLockPool::ScopePool::~ScopePool() +{ + for (It i = this->Locks.begin(); i != this->Locks.end(); ++i) + { + delete *i; + } +} + +cmFileLockResult cmFileLockPool::ScopePool::Lock( + const std::string& filename, unsigned timeoutSec) +{ + cmFileLock *lock = new cmFileLock(); + const cmFileLockResult result = lock->Lock(filename, timeoutSec); + if (result.IsOk()) + { + this->Locks.push_back(lock); + return cmFileLockResult::MakeOk(); + } + else + { + delete lock; + return result; + } +} + +cmFileLockResult cmFileLockPool::ScopePool::Release( + const std::string& filename) +{ + for (It i = this->Locks.begin(); i != this->Locks.end(); ++i) + { + if ((*i)->IsLocked(filename)) + { + return (*i)->Release(); + } + } + return cmFileLockResult::MakeOk(); +} + +bool cmFileLockPool::ScopePool::IsAlreadyLocked( + const std::string& filename) const +{ + for (CIt i = this->Locks.begin(); i != this->Locks.end(); ++i) + { + if ((*i)->IsLocked(filename)) + { + return true; + } + } + return false; +} diff --git a/Source/cmFileLockPool.h b/Source/cmFileLockPool.h new file mode 100644 index 0000000..a63540c --- /dev/null +++ b/Source/cmFileLockPool.h @@ -0,0 +1,100 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Ruslan Baratov + + 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. +============================================================================*/ +#ifndef cmFileLockPool_h +#define cmFileLockPool_h + +#include "cmStandardIncludes.h" + +class cmFileLockResult; +class cmFileLock; + +class cmFileLockPool +{ + public: + cmFileLockPool(); + ~cmFileLockPool(); + + //@{ + /** + * @brief Function scope control. + */ + void PushFunctionScope(); + void PopFunctionScope(); + //@} + + //@{ + /** + * @brief File scope control. + */ + void PushFileScope(); + void PopFileScope(); + //@} + + //@{ + /** + * @brief Lock the file in given scope. + * @param timeoutSec Lock timeout. If -1 try until success or fatal error. + */ + cmFileLockResult LockFunctionScope( + const std::string& filename, unsigned timeoutSec + ); + cmFileLockResult LockFileScope( + const std::string& filename, unsigned timeoutSec + ); + cmFileLockResult LockProcessScope( + const std::string& filename, unsigned timeoutSec + ); + //@} + + /** + * @brief Unlock the file explicitly. + */ + cmFileLockResult Release(const std::string& filename); + + private: + cmFileLockPool(const cmFileLockPool&); + cmFileLockPool& operator=(const cmFileLockPool&); + + bool IsAlreadyLocked(const std::string& filename) const; + + class ScopePool + { + public: + ScopePool(); + ~ScopePool(); + + cmFileLockResult Lock(const std::string& filename, unsigned timeoutSec); + cmFileLockResult Release(const std::string& filename); + bool IsAlreadyLocked(const std::string& filename) const; + + private: + ScopePool(const ScopePool&); + ScopePool& operator=(const ScopePool&); + + typedef std::list<cmFileLock*> List; + typedef List::iterator It; + typedef List::const_iterator CIt; + + List Locks; + }; + + typedef std::list<ScopePool*> List; + + typedef List::iterator It; + typedef List::const_iterator CIt; + + List FunctionScopes; + List FileScopes; + ScopePool ProcessScope; +}; + +#endif // cmFileLockPool_h diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx new file mode 100644 index 0000000..045e7ee --- /dev/null +++ b/Source/cmFileLockResult.cxx @@ -0,0 +1,111 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Ruslan Baratov + + 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. +============================================================================*/ + +#include "cmFileLockResult.h" + +#include <errno.h> + +cmFileLockResult cmFileLockResult::MakeOk() +{ + return cmFileLockResult(OK, 0); +} + +cmFileLockResult cmFileLockResult::MakeSystem() +{ +#if defined(_WIN32) + const Error lastError = GetLastError(); +#else + const Error lastError = errno; +#endif + return cmFileLockResult(SYSTEM, lastError); +} + +cmFileLockResult cmFileLockResult::MakeTimeout() +{ + return cmFileLockResult(TIMEOUT, 0); +} + +cmFileLockResult cmFileLockResult::MakeAlreadyLocked() +{ + return cmFileLockResult(ALREADY_LOCKED, 0); +} + +cmFileLockResult cmFileLockResult::MakeInternal() +{ + return cmFileLockResult(INTERNAL, 0); +} + +cmFileLockResult cmFileLockResult::MakeNoFunction() +{ + return cmFileLockResult(NO_FUNCTION, 0); +} + +bool cmFileLockResult::IsOk() const +{ + return this->Type == OK; +} + +std::string cmFileLockResult::GetOutputMessage() const +{ + switch (this->Type) + { + case OK: + return "0"; + case SYSTEM: +#if defined(_WIN32) + { + char* errorText = NULL; + + // http://stackoverflow.com/a/455533/2288008 + DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_IGNORE_INSERTS; + ::FormatMessageA( + flags, + NULL, + this->ErrorValue, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)&errorText, + 0, + NULL + ); + + if (errorText != NULL) + { + const std::string message = errorText; + ::LocalFree(errorText); + return message; + } + else + { + return "Internal error (FormatMessageA failed)"; + } + } +#else + return strerror(this->ErrorValue); +#endif + case TIMEOUT: + return "Timeout reached"; + case ALREADY_LOCKED: + return "File already locked"; + case NO_FUNCTION: + return "'GUARD FUNCTION' not used in function definition"; + case INTERNAL: + default: + return "Internal error"; + } +} + +cmFileLockResult::cmFileLockResult(ErrorType typeValue, Error errorValue): + Type(typeValue), ErrorValue(errorValue) +{ +} diff --git a/Source/cmFileLockResult.h b/Source/cmFileLockResult.h new file mode 100644 index 0000000..531fb49 --- /dev/null +++ b/Source/cmFileLockResult.h @@ -0,0 +1,85 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Ruslan Baratov + + 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. +============================================================================*/ + +#ifndef cmFileLockResult_h +#define cmFileLockResult_h + +#include "cmStandardIncludes.h" + +#if defined(_WIN32) +# include <windows.h> // DWORD +#endif + +/** + * @brief Result of the locking/unlocking file. + * @note See @c cmFileLock + */ +class cmFileLockResult +{ + public: +#if defined(_WIN32) + typedef DWORD Error; +#else + typedef int Error; +#endif + + /** + * @brief Successful lock/unlock. + */ + static cmFileLockResult MakeOk(); + + /** + * @brief Lock/Unlock failed. Read error/GetLastError. + */ + static cmFileLockResult MakeSystem(); + + /** + * @brief Lock/Unlock failed. Timeout reached. + */ + static cmFileLockResult MakeTimeout(); + + /** + * @brief File already locked. + */ + static cmFileLockResult MakeAlreadyLocked(); + + /** + * @brief Internal error. + */ + static cmFileLockResult MakeInternal(); + + /** + * @brief Try to lock with function guard outside of the function + */ + static cmFileLockResult MakeNoFunction(); + + bool IsOk() const; + std::string GetOutputMessage() const; + + private: + enum ErrorType + { + OK, + SYSTEM, + TIMEOUT, + ALREADY_LOCKED, + INTERNAL, + NO_FUNCTION + }; + + cmFileLockResult(ErrorType type, Error errorValue); + + ErrorType Type; + Error ErrorValue; +}; + +#endif // cmFileLockResult_h diff --git a/Source/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx new file mode 100644 index 0000000..038011e --- /dev/null +++ b/Source/cmFileLockUnix.cxx @@ -0,0 +1,102 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Ruslan Baratov + + 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. +============================================================================*/ + +#include "cmFileLock.h" + +#include <errno.h> // errno +#include <stdio.h> // SEEK_SET +#include <fcntl.h> +#include "cmSystemTools.h" + +cmFileLock::cmFileLock(): File(-1) +{ +} + +cmFileLockResult cmFileLock::Release() +{ + if (this->Filename.empty()) + { + return cmFileLockResult::MakeOk(); + } + const int lockResult = this->LockFile(F_SETLK, F_UNLCK); + + this->Filename = ""; + + if (lockResult == 0) + { + return cmFileLockResult::MakeOk(); + } + else + { + return cmFileLockResult::MakeSystem(); + } +} + +cmFileLockResult cmFileLock::OpenFile() +{ + this->File = ::open(this->Filename.c_str(), O_RDWR); + if (this->File == -1) + { + return cmFileLockResult::MakeSystem(); + } + else + { + return cmFileLockResult::MakeOk(); + } +} + +cmFileLockResult cmFileLock::LockWithoutTimeout() +{ + if (this->LockFile(F_SETLKW, F_WRLCK) == -1) + { + return cmFileLockResult::MakeSystem(); + } + else + { + return cmFileLockResult::MakeOk(); + } +} + +cmFileLockResult cmFileLock::LockWithTimeout(unsigned seconds) +{ + while (true) + { + if (this->LockFile(F_SETLK, F_WRLCK) == -1) + { + if (errno != EACCES && errno != EAGAIN) + { + return cmFileLockResult::MakeSystem(); + } + } + else + { + return cmFileLockResult::MakeOk(); + } + if (seconds == 0) + { + return cmFileLockResult::MakeTimeout(); + } + --seconds; + cmSystemTools::Delay(1000); + } +} + +int cmFileLock::LockFile(int cmd, int type) +{ + struct ::flock lock; + lock.l_start = 0; + lock.l_len = 0; // lock all bytes + lock.l_pid = 0; // unused (for F_GETLK only) + lock.l_type = static_cast<short>(type); // exclusive lock + lock.l_whence = SEEK_SET; + return ::fcntl(this->File, cmd, &lock); +} diff --git a/Source/cmFileLockWin32.cxx b/Source/cmFileLockWin32.cxx new file mode 100644 index 0000000..17231ea --- /dev/null +++ b/Source/cmFileLockWin32.cxx @@ -0,0 +1,126 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Ruslan Baratov + + 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. +============================================================================*/ + +#include "cmFileLock.h" + +#include <windows.h> // CreateFileW +#include "cmSystemTools.h" + +cmFileLock::cmFileLock(): File(INVALID_HANDLE_VALUE) +{ +} + +cmFileLockResult cmFileLock::Release() +{ + if (this->Filename.empty()) + { + return cmFileLockResult::MakeOk(); + } + const unsigned long len = static_cast<unsigned long>(-1); + static OVERLAPPED overlapped; + const DWORD reserved = 0; + const BOOL unlockResult = UnlockFileEx( + File, + reserved, + len, + len, + &overlapped + ); + + this->Filename = ""; + + if (unlockResult) + { + return cmFileLockResult::MakeOk(); + } + else + { + return cmFileLockResult::MakeSystem(); + } +} + +cmFileLockResult cmFileLock::OpenFile() +{ + const DWORD access = GENERIC_READ | GENERIC_WRITE; + const DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; + const PSECURITY_ATTRIBUTES security = NULL; + const DWORD attr = 0; + const HANDLE templ = NULL; + this->File = CreateFileW( + cmSystemTools::ConvertToWindowsExtendedPath(this->Filename).c_str(), + access, + shareMode, + security, + OPEN_EXISTING, + attr, + templ + ); + if (this->File == INVALID_HANDLE_VALUE) + { + return cmFileLockResult::MakeSystem(); + } + else + { + return cmFileLockResult::MakeOk(); + } +} + +cmFileLockResult cmFileLock::LockWithoutTimeout() +{ + if (!this->LockFile(LOCKFILE_EXCLUSIVE_LOCK)) + { + return cmFileLockResult::MakeSystem(); + } + else + { + return cmFileLockResult::MakeOk(); + } +} + +cmFileLockResult cmFileLock::LockWithTimeout(unsigned seconds) +{ + const DWORD flags = LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY; + while (true) + { + const BOOL result = this->LockFile(flags); + if (result) + { + return cmFileLockResult::MakeOk(); + } + const DWORD error = GetLastError(); + if (error != ERROR_LOCK_VIOLATION) + { + return cmFileLockResult::MakeSystem(); + } + if (seconds == 0) + { + return cmFileLockResult::MakeTimeout(); + } + --seconds; + cmSystemTools::Delay(1000); + } +} + +BOOL cmFileLock::LockFile(DWORD flags) +{ + const DWORD reserved = 0; + const unsigned long len = static_cast<unsigned long>(-1); + static OVERLAPPED overlapped; + return LockFileEx( + this->File, + flags, + reserved, + len, + len, + &overlapped + ); +} diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index dec5157..03d6590 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -69,6 +69,10 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, mf.AddDefinition(this->Args[0],oldDef.c_str()); return true; } + if (status.GetContinueInvoked()) + { + break; + } if(cmSystemTools::GetFatalErrorOccured() ) { return true; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 926efe7..6b75298 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -23,6 +23,7 @@ #include "cmGeneratorExpression.h" #if defined(CMAKE_BUILD_WITH_CMAKE) +# include "cmFileLockPool.h" # include <cmsys/hash_map.hxx> #endif @@ -348,6 +349,10 @@ public: std::set<cmTarget const*> const& GetFilenameTargetDepends(cmSourceFile* sf) const; +#if defined(CMAKE_BUILD_WITH_CMAKE) + cmFileLockPool& GetFileLockPool() { return FileLockPool; } +#endif + protected: virtual void Generate(); @@ -499,6 +504,11 @@ private: mutable std::map<cmSourceFile*, std::set<cmTarget const*> > FilenameTargetDepends; + +#if defined(CMAKE_BUILD_WITH_CMAKE) + // Pool of file locks + cmFileLockPool FileLockPool; +#endif }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b9f64e2..d222288 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -557,6 +557,7 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects() } this->XCodeObjects.clear(); this->XCodeObjectIDs.clear(); + this->XCodeObjectMap.clear(); this->GroupMap.clear(); this->GroupNameMap.clear(); this->TargetGroup.clear(); @@ -2458,6 +2459,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) target->AddAttribute("name", this->CreateString(cmtarget.GetName())); target->AddAttribute("productName",this->CreateString(cmtarget.GetName())); target->SetTarget(&cmtarget); + this->XCodeObjectMap[&cmtarget] = target; // Add source files without build rules for editing convenience. if(cmtarget.GetType() == cmTarget::UTILITY) @@ -2661,6 +2663,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, target->AddAttribute("productType", this->CreateString(productType)); } target->SetTarget(&cmtarget); + this->XCodeObjectMap[&cmtarget] = target; target->SetId(this->GetOrCreateId( cmtarget.GetName(), target->GetId()).c_str()); return target; @@ -2673,16 +2676,14 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t) { return 0; } - for(std::vector<cmXCodeObject*>::iterator i = this->XCodeObjects.begin(); - i != this->XCodeObjects.end(); ++i) + + std::map<cmTarget const*, cmXCodeObject*>::const_iterator const i = + this->XCodeObjectMap.find(t); + if (i == this->XCodeObjectMap.end()) { - cmXCodeObject* o = *i; - if(o->GetTarget() == t) - { - return o; - } + return 0; } - return 0; + return i->second; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 9d7b784..d2bc9d1 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -241,6 +241,7 @@ private: std::map<std::string, cmXCodeObject* > GroupNameMap; std::map<std::string, cmXCodeObject* > TargetGroup; std::map<std::string, cmXCodeObject* > FileRefs; + std::map<cmTarget const*, cmXCodeObject* > XCodeObjectMap; std::vector<std::string> Architectures; std::string GeneratorToolset; }; diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index f728c15..b8e30b7 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -151,6 +151,11 @@ IsFunctionBlocked(const cmListFileFunction& lff, inStatus.SetBreakInvoked(true); return true; } + if (status.GetContinueInvoked()) + { + inStatus.SetContinueInvoked(true); + return true; + } } } return true; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3fb1e1e..2de6c93 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -79,9 +79,15 @@ public: this->GG = lg->GetGlobalGenerator(); this->LG = this->GG->GetCurrentLocalGenerator(); this->GG->SetCurrentLocalGenerator(lg); +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GG->GetFileLockPool().PushFileScope(); +#endif } ~cmLocalGeneratorCurrent() { +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GG->GetFileLockPool().PopFileScope(); +#endif this->GG->SetCurrentLocalGenerator(this->LG); } }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 53fd56f..2506eaa 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4522,10 +4522,20 @@ void cmMakefile::PushScope() this->Internal->VarUsageStack.push(usage); this->PushLoopBlockBarrier(); + +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PushFunctionScope(); +#endif } void cmMakefile::PopScope() { +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PopFunctionScope(); +#endif + this->PopLoopBlockBarrier(); cmDefinitions* current = &this->Internal->VarStack.top(); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index baac7b8..9852dd6 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2923,3 +2923,11 @@ std::vector<std::string> cmSystemTools::tokenize(const std::string& str, } return tokens; } + +//---------------------------------------------------------------------------- +bool cmSystemTools::StringToInt(const char* str, int* value) +{ + char *endp; + *value = static_cast<int>(strtol(str, &endp, 10)); + return (*endp == '\0') && (endp != str); +} diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 4455dd1..763389b 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -458,6 +458,9 @@ public: static std::vector<std::string> tokenize(const std::string& str, const std::string& sep); + /** Convert string to int. Expected that the whole string is an integer */ + static bool StringToInt(const char* str, int* value); + #ifdef _WIN32 struct WindowsFileRetry { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f591fc8..68b6576 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1203,6 +1203,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) bool toolHasSettings = false; std::string tool = "None"; std::string shaderType; + std::string shaderEntryPoint; + std::string shaderModel; std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); if(ext == "hlsl") { @@ -1213,6 +1215,18 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) shaderType = st; toolHasSettings = true; } + // Figure out which entry point to use if any + if (const char* se = sf->GetProperty("VS_SHADER_ENTRYPOINT")) + { + shaderEntryPoint = se; + toolHasSettings = true; + } + // Figure out which shader model to use if any + if (const char* sm = sf->GetProperty("VS_SHADER_MODEL")) + { + shaderModel = sm; + toolHasSettings = true; + } } else if(ext == "jpg" || ext == "png") @@ -1247,6 +1261,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) } std::string deployContent; + std::string deployLocation; if(this->GlobalGenerator->TargetsWindowsPhone() || this->GlobalGenerator->TargetsWindowsStore()) { @@ -1255,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; + } } } @@ -1269,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")) @@ -1295,7 +1324,18 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) (*this->BuildFileStream) << cmVS10EscapeXML(shaderType) << "</ShaderType>\n"; } - + if(!shaderEntryPoint.empty()) + { + this->WriteString("<EntryPointName>", 3); + (*this->BuildFileStream) << cmVS10EscapeXML(shaderEntryPoint) + << "</EntryPointName>\n"; + } + if(!shaderModel.empty()) + { + this->WriteString("<ShaderModel>", 3); + (*this->BuildFileStream) << cmVS10EscapeXML(shaderModel) + << "</ShaderModel>\n"; + } this->WriteString("</", 2); (*this->BuildFileStream) << tool << ">\n"; } @@ -2268,7 +2308,14 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) linkOptions.AddFlag("SubSystem", "WindowsCE"); if (this->Target->GetType() == cmTarget::EXECUTABLE) { - linkOptions.AddFlag("EntryPointSymbol", "WinMainCRTStartup"); + if (this->ClOptions[config]->UsingUnicode()) + { + linkOptions.AddFlag("EntryPointSymbol", "wWinMainCRTStartup"); + } + else + { + linkOptions.AddFlag("EntryPointSymbol", "WinMainCRTStartup"); + } } } else @@ -2283,7 +2330,14 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) linkOptions.AddFlag("SubSystem", "WindowsCE"); if (this->Target->GetType() == cmTarget::EXECUTABLE) { - linkOptions.AddFlag("EntryPointSymbol", "mainACRTStartup"); + if (this->ClOptions[config]->UsingUnicode()) + { + linkOptions.AddFlag("EntryPointSymbol", "mainWCRTStartup"); + } + else + { + linkOptions.AddFlag("EntryPointSymbol", "mainACRTStartup"); + } } } else diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index d36095e..47edb03 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -83,6 +83,10 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, { return true; } + if (status.GetContinueInvoked()) + { + break; + } if(cmSystemTools::GetFatalErrorOccured() ) { return true; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index c9d9568..fda9359 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -291,6 +291,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(ConfigSources ConfigSources) endif() ADD_TEST_MACRO(SourcesProperty SourcesProperty) + ADD_TEST_MACRO(SourceFileProperty SourceFileProperty) if(CMAKE_CXX_COMPILER_ID STREQUAL GNU AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) set(runCxxDialectTest 1) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 9832a95..54fe2d9 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -102,6 +102,7 @@ add_RunCMake_test(add_dependencies) add_RunCMake_test(build_command) add_RunCMake_test(export) add_RunCMake_test(cmake_minimum_required) +add_RunCMake_test(continue) add_RunCMake_test(file) add_RunCMake_test(find_package) add_RunCMake_test(get_filename_component) diff --git a/Tests/RunCMake/continue/CMakeLists.txt b/Tests/RunCMake/continue/CMakeLists.txt new file mode 100644 index 0000000..ef2163c --- /dev/null +++ b/Tests/RunCMake/continue/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/continue/ContinueForEachInLists.cmake b/Tests/RunCMake/continue/ContinueForEachInLists.cmake new file mode 100644 index 0000000..fbd7359 --- /dev/null +++ b/Tests/RunCMake/continue/ContinueForEachInLists.cmake @@ -0,0 +1,10 @@ +list(APPEND foo 1 2 3 4 5) + +message(STATUS "start") +foreach(iter IN LISTS foo) + if("${iter}" EQUAL 1 OR "${iter}" EQUAL 3 OR "${iter}" EQUAL 5) + continue() + endif() + message(STATUS "${iter}") +endforeach() +message(STATUS "end") diff --git a/Tests/RunCMake/continue/ContinueForeach-stdout.txt b/Tests/RunCMake/continue/ContinueForeach-stdout.txt new file mode 100644 index 0000000..955b859 --- /dev/null +++ b/Tests/RunCMake/continue/ContinueForeach-stdout.txt @@ -0,0 +1,4 @@ +-- start +-- 2 +-- 4 +-- end diff --git a/Tests/RunCMake/continue/ContinueForeach.cmake b/Tests/RunCMake/continue/ContinueForeach.cmake new file mode 100644 index 0000000..9b3e17f --- /dev/null +++ b/Tests/RunCMake/continue/ContinueForeach.cmake @@ -0,0 +1,8 @@ +message(STATUS "start") +foreach(iter RANGE 1 5) + if("${iter}" EQUAL 1 OR "${iter}" EQUAL 3 OR "${iter}" EQUAL 5) + continue() + endif() + message(STATUS "${iter}") +endforeach() +message(STATUS "end") diff --git a/Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt b/Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt new file mode 100644 index 0000000..adb02bc --- /dev/null +++ b/Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt @@ -0,0 +1,6 @@ +-- start +-- 7 2 +-- 7 4 +-- 9 2 +-- 9 4 +-- end diff --git a/Tests/RunCMake/continue/ContinueNestedForeach.cmake b/Tests/RunCMake/continue/ContinueNestedForeach.cmake new file mode 100644 index 0000000..de7c51b --- /dev/null +++ b/Tests/RunCMake/continue/ContinueNestedForeach.cmake @@ -0,0 +1,13 @@ +message(STATUS "start") +foreach(outer RANGE 7 9) + if("${outer}" EQUAL 8) + continue() + endif() + foreach(inner RANGE 1 5) + if("${inner}" EQUAL 1 OR "${inner}" EQUAL 3 OR "${inner}" EQUAL 5) + continue() + endif() + message(STATUS "${outer} ${inner}") + endforeach() +endforeach() +message(STATUS "end") diff --git a/Tests/RunCMake/continue/ContinueWhile-stdout.txt b/Tests/RunCMake/continue/ContinueWhile-stdout.txt new file mode 100644 index 0000000..f99b2a1 --- /dev/null +++ b/Tests/RunCMake/continue/ContinueWhile-stdout.txt @@ -0,0 +1,6 @@ +-- start +-- a +-- aa +-- aaaa +-- aaaaa +-- end diff --git a/Tests/RunCMake/continue/ContinueWhile.cmake b/Tests/RunCMake/continue/ContinueWhile.cmake new file mode 100644 index 0000000..c1fa87a --- /dev/null +++ b/Tests/RunCMake/continue/ContinueWhile.cmake @@ -0,0 +1,10 @@ +message(STATUS "start") +unset(iter) +while(NOT "${iter}" STREQUAL "aaaaa") + set(iter "${iter}a") + if("${iter}" STREQUAL "aaa") + continue() + endif() + message(STATUS "${iter}") +endwhile() +message(STATUS "end") diff --git a/Tests/RunCMake/continue/NoArgumentsToContinue-result.txt b/Tests/RunCMake/continue/NoArgumentsToContinue-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/continue/NoArgumentsToContinue-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt b/Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt new file mode 100644 index 0000000..66be4629 --- /dev/null +++ b/Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at NoArgumentsToContinue.cmake:2 \(continue\): + The CONTINUE command does not accept any arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/continue/NoArgumentsToContinue.cmake b/Tests/RunCMake/continue/NoArgumentsToContinue.cmake new file mode 100644 index 0000000..609804d --- /dev/null +++ b/Tests/RunCMake/continue/NoArgumentsToContinue.cmake @@ -0,0 +1,3 @@ +foreach(i RANGE 1 2) + continue(1) +endforeach() diff --git a/Tests/RunCMake/continue/NoEnclosingBlock-result.txt b/Tests/RunCMake/continue/NoEnclosingBlock-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlock-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt b/Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt new file mode 100644 index 0000000..24caf57 --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at NoEnclosingBlock.cmake:1 \(continue\): + A CONTINUE command was found outside of a proper FOREACH or WHILE loop + scope. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/continue/NoEnclosingBlock.cmake b/Tests/RunCMake/continue/NoEnclosingBlock.cmake new file mode 100644 index 0000000..9661e0d --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlock.cmake @@ -0,0 +1 @@ +continue() diff --git a/Tests/RunCMake/continue/NoEnclosingBlockInFunction-result.txt b/Tests/RunCMake/continue/NoEnclosingBlockInFunction-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlockInFunction-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt b/Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt new file mode 100644 index 0000000..af4f3b6 --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at NoEnclosingBlockInFunction.cmake:2 \(continue\): + A CONTINUE command was found outside of a proper FOREACH or WHILE loop + scope. +Call Stack \(most recent call first\): + NoEnclosingBlockInFunction.cmake:6 \(foo\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/continue/NoEnclosingBlockInFunction.cmake b/Tests/RunCMake/continue/NoEnclosingBlockInFunction.cmake new file mode 100644 index 0000000..eb2a098 --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlockInFunction.cmake @@ -0,0 +1,8 @@ +function(foo) + continue() +endfunction(foo) + +foreach(i RANGE 1 2) + foo() + message(STATUS "Hello World") +endforeach() diff --git a/Tests/RunCMake/continue/RunCMakeTest.cmake b/Tests/RunCMake/continue/RunCMakeTest.cmake new file mode 100644 index 0000000..37caf9c --- /dev/null +++ b/Tests/RunCMake/continue/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCMake) + +run_cmake(ContinueForeach) +run_cmake(ContinueForEachInLists) +run_cmake(ContinueNestedForeach) +run_cmake(ContinueWhile) +run_cmake(NoArgumentsToContinue) +run_cmake(NoEnclosingBlock) +run_cmake(NoEnclosingBlockInFunction) diff --git a/Tests/RunCMake/file/LOCK-error-file-create-fail-result.txt b/Tests/RunCMake/file/LOCK-error-file-create-fail-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-file-create-fail-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-file-create-fail-stderr.txt b/Tests/RunCMake/file/LOCK-error-file-create-fail-stderr.txt new file mode 100644 index 0000000..72b7fe0 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-file-create-fail-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at LOCK-error-file-create-fail\.cmake:[0-9]+ \(file\): + file + + ".*" + + creation failed \(check permissions\)\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-file-create-fail.cmake b/Tests/RunCMake/file/LOCK-error-file-create-fail.cmake new file mode 100644 index 0000000..4868cfe --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-file-create-fail.cmake @@ -0,0 +1,3 @@ +set(tmp "${CMAKE_CURRENT_BINARY_DIR}/temp-directory") +file(MAKE_DIRECTORY "${tmp}") +file(LOCK "${tmp}") diff --git a/Tests/RunCMake/file/LOCK-error-guard-incorrect-result.txt b/Tests/RunCMake/file/LOCK-error-guard-incorrect-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-guard-incorrect-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-guard-incorrect-stderr.txt b/Tests/RunCMake/file/LOCK-error-guard-incorrect-stderr.txt new file mode 100644 index 0000000..85136b4 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-guard-incorrect-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at LOCK-error-guard-incorrect\.cmake:[0-9]+ \(file\): + expected FUNCTION, FILE or PROCESS after GUARD, but got: + + "FUNCTIO"\. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-guard-incorrect.cmake b/Tests/RunCMake/file/LOCK-error-guard-incorrect.cmake new file mode 100644 index 0000000..51daa7c --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-guard-incorrect.cmake @@ -0,0 +1 @@ +file(LOCK "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock" GUARD FUNCTIO) diff --git a/Tests/RunCMake/file/LOCK-error-incorrect-timeout-result.txt b/Tests/RunCMake/file/LOCK-error-incorrect-timeout-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-incorrect-timeout-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-incorrect-timeout-stderr.txt b/Tests/RunCMake/file/LOCK-error-incorrect-timeout-stderr.txt new file mode 100644 index 0000000..c6ae1e0 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-incorrect-timeout-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-incorrect-timeout\.cmake:[0-9]+ \(file\): + TIMEOUT value "qwerty" is not an unsigned integer\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail-result.txt b/Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail-stderr.txt b/Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail-stderr.txt new file mode 100644 index 0000000..6ea2507 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-incorrect-timeout-trail\.cmake:[0-9]+ \(file\): + TIMEOUT value "123xyz" is not an unsigned integer\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail.cmake b/Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail.cmake new file mode 100644 index 0000000..c4f1b75 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail.cmake @@ -0,0 +1 @@ +file(LOCK "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock" TIMEOUT 123xyz) diff --git a/Tests/RunCMake/file/LOCK-error-incorrect-timeout.cmake b/Tests/RunCMake/file/LOCK-error-incorrect-timeout.cmake new file mode 100644 index 0000000..d882467 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-incorrect-timeout.cmake @@ -0,0 +1 @@ +file(LOCK "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock" TIMEOUT qwerty) diff --git a/Tests/RunCMake/file/LOCK-error-lock-fail-result.txt b/Tests/RunCMake/file/LOCK-error-lock-fail-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-lock-fail-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-lock-fail-stderr.txt b/Tests/RunCMake/file/LOCK-error-lock-fail-stderr.txt new file mode 100644 index 0000000..a7b0447 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-lock-fail-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at LOCK-error-lock-fail.cmake:[0-9]+ \(file\): + directory + + ".*" + + creation failed \(check permissions\)\. diff --git a/Tests/RunCMake/file/LOCK-error-lock-fail.cmake b/Tests/RunCMake/file/LOCK-error-lock-fail.cmake new file mode 100644 index 0000000..aa7f663 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-lock-fail.cmake @@ -0,0 +1,6 @@ +set(lfile "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock") +FILE(WRITE "${lfile}" "") + +# Try to lock file '${lfile}/cmake.lock'. Since `lfile` is not a directory +# expected that operation will fail. +file(LOCK "${lfile}" DIRECTORY) diff --git a/Tests/RunCMake/file/LOCK-error-negative-timeout-result.txt b/Tests/RunCMake/file/LOCK-error-negative-timeout-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-negative-timeout-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-negative-timeout-stderr.txt b/Tests/RunCMake/file/LOCK-error-negative-timeout-stderr.txt new file mode 100644 index 0000000..0d159c1 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-negative-timeout-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-negative-timeout\.cmake:[0-9]+ \(file\): + TIMEOUT value "-2" is not an unsigned integer\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-negative-timeout.cmake b/Tests/RunCMake/file/LOCK-error-negative-timeout.cmake new file mode 100644 index 0000000..6a0f190 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-negative-timeout.cmake @@ -0,0 +1 @@ +file(LOCK "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock" TIMEOUT -2) diff --git a/Tests/RunCMake/file/LOCK-error-no-function-result.txt b/Tests/RunCMake/file/LOCK-error-no-function-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-function-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-no-function-stderr.txt b/Tests/RunCMake/file/LOCK-error-no-function-stderr.txt new file mode 100644 index 0000000..51ed12d --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-function-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at LOCK-error-no-function\.cmake:[0-9]+ \(file\): + error locking file + + ".*" + + 'GUARD FUNCTION' not used in function definition\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-no-function.cmake b/Tests/RunCMake/file/LOCK-error-no-function.cmake new file mode 100644 index 0000000..1b8b06a --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-function.cmake @@ -0,0 +1 @@ +file(LOCK "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock" GUARD FUNCTION) diff --git a/Tests/RunCMake/file/LOCK-error-no-guard-result.txt b/Tests/RunCMake/file/LOCK-error-no-guard-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-guard-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-no-guard-stderr.txt b/Tests/RunCMake/file/LOCK-error-no-guard-stderr.txt new file mode 100644 index 0000000..41177ce --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-guard-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-no-guard\.cmake:[0-9]+ \(file\): + expected FUNCTION, FILE or PROCESS after GUARD +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-no-guard.cmake b/Tests/RunCMake/file/LOCK-error-no-guard.cmake new file mode 100644 index 0000000..48ffc5e --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-guard.cmake @@ -0,0 +1 @@ +file(LOCK "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock" GUARD) diff --git a/Tests/RunCMake/file/LOCK-error-no-path-result.txt b/Tests/RunCMake/file/LOCK-error-no-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-no-path-stderr.txt b/Tests/RunCMake/file/LOCK-error-no-path-stderr.txt new file mode 100644 index 0000000..2247aa6 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-path-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-no-path.cmake:[0-9]+ \(file\): + file must be called with at least two arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-no-path.cmake b/Tests/RunCMake/file/LOCK-error-no-path.cmake new file mode 100644 index 0000000..12d79b7 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-path.cmake @@ -0,0 +1 @@ +file(LOCK) diff --git a/Tests/RunCMake/file/LOCK-error-no-result-variable-result.txt b/Tests/RunCMake/file/LOCK-error-no-result-variable-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-result-variable-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-no-result-variable-stderr.txt b/Tests/RunCMake/file/LOCK-error-no-result-variable-stderr.txt new file mode 100644 index 0000000..b38e23c --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-result-variable-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-no-result-variable\.cmake:[0-9]+ \(file\): + expected variable name after RESULT_VARIABLE +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-no-result-variable.cmake b/Tests/RunCMake/file/LOCK-error-no-result-variable.cmake new file mode 100644 index 0000000..e6ac18d --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-result-variable.cmake @@ -0,0 +1 @@ +file(LOCK "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock" RESULT_VARIABLE) diff --git a/Tests/RunCMake/file/LOCK-error-no-timeout-result.txt b/Tests/RunCMake/file/LOCK-error-no-timeout-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-timeout-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-no-timeout-stderr.txt b/Tests/RunCMake/file/LOCK-error-no-timeout-stderr.txt new file mode 100644 index 0000000..f34d46f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-timeout-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-no-timeout\.cmake:[0-9]+ \(file\): + expected timeout value after TIMEOUT +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-no-timeout.cmake b/Tests/RunCMake/file/LOCK-error-no-timeout.cmake new file mode 100644 index 0000000..1618192 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-timeout.cmake @@ -0,0 +1 @@ +file(LOCK "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock" TIMEOUT) diff --git a/Tests/RunCMake/file/LOCK-error-timeout-result.txt b/Tests/RunCMake/file/LOCK-error-timeout-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-timeout-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-timeout-stderr.txt b/Tests/RunCMake/file/LOCK-error-timeout-stderr.txt new file mode 100644 index 0000000..4ad1f04 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-timeout-stderr.txt @@ -0,0 +1,12 @@ +Output:[ ]* +Error: CMake Error at .*.timeout-script\.cmake:[0-9]+ \(file\): + error locking file + + ".*" + + Timeout reached\. ++ +CMake Error at LOCK-error-timeout\.cmake:[0-9]+ \(message\): + Result: 1 +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-timeout-stdout.txt b/Tests/RunCMake/file/LOCK-error-timeout-stdout.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-timeout-stdout.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/file/LOCK-error-timeout.cmake b/Tests/RunCMake/file/LOCK-error-timeout.cmake new file mode 100644 index 0000000..b6b9476 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-timeout.cmake @@ -0,0 +1,17 @@ +set(script "${CMAKE_CURRENT_LIST_DIR}/timeout-script.cmake") +set(file_to_lock "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock") + +file(LOCK "${file_to_lock}") +execute_process( + COMMAND "${CMAKE_COMMAND}" "-Dfile_to_lock=${file_to_lock}" -P "${script}" + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE error +) + +message("Output: ${output}") +message("Error: ${error}") + +if(NOT result EQUAL 0) + message(FATAL_ERROR "Result: ${result}") +endif() diff --git a/Tests/RunCMake/file/LOCK-error-unknown-option-result.txt b/Tests/RunCMake/file/LOCK-error-unknown-option-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-unknown-option-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/LOCK-error-unknown-option-stderr.txt b/Tests/RunCMake/file/LOCK-error-unknown-option-stderr.txt new file mode 100644 index 0000000..ad596af --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-unknown-option-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at LOCK-error-unknown-option\.cmake:[0-9]+ \(file\): + expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT + + but got: "UNKNOWN"\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]* \(include\) diff --git a/Tests/RunCMake/file/LOCK-error-unknown-option.cmake b/Tests/RunCMake/file/LOCK-error-unknown-option.cmake new file mode 100644 index 0000000..88ef002 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-unknown-option.cmake @@ -0,0 +1 @@ +file(LOCK "${CMAKE_CURRENT_BINARY_DIR}/temp-file" UNKNOWN) diff --git a/Tests/RunCMake/file/LOCK-stdout.txt b/Tests/RunCMake/file/LOCK-stdout.txt new file mode 100644 index 0000000..416126a --- /dev/null +++ b/Tests/RunCMake/file/LOCK-stdout.txt @@ -0,0 +1,11 @@ +-- Simple lock +-- Directory lock +-- Release +-- Lock function scope +-- Lock file scope +-- Lock in subdirectory +-- Lock process scope +-- Error double lock +-- Ok +-- Timeout 0 +-- Timeout not 0 diff --git a/Tests/RunCMake/file/LOCK.cmake b/Tests/RunCMake/file/LOCK.cmake new file mode 100644 index 0000000..8eff084 --- /dev/null +++ b/Tests/RunCMake/file/LOCK.cmake @@ -0,0 +1,40 @@ +set(lfile "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock") +set(ldir "${CMAKE_CURRENT_BINARY_DIR}/dir-to-lock") + +message(STATUS "Simple lock") +file(LOCK ${lfile}) + +message(STATUS "Directory lock") +file(LOCK ${ldir} DIRECTORY) + +message(STATUS "Release") +file(LOCK ${lfile} RELEASE) + +function(foo) + file(LOCK "${lfile}" GUARD FUNCTION) +endfunction() + +message(STATUS "Lock function scope") +foo() + +message(STATUS "Lock file scope") +add_subdirectory(subdir_test_unlock) + +message(STATUS "Lock process scope") +file(LOCK "${lfile}" GUARD PROCESS) + +message(STATUS "Error double lock") +file(LOCK "${lfile}" RESULT_VARIABLE lock_result) +if(lock_result STREQUAL "File already locked") + message(STATUS "Ok") +else() + message(STATUS FATAL_ERROR "Expected error message") +endif() + +message(STATUS "Timeout 0") +file(LOCK "${lfile}" RELEASE) +file(LOCK "${lfile}" TIMEOUT 0) + +message(STATUS "Timeout not 0") +file(LOCK "${lfile}" RELEASE) +file(LOCK "${lfile}" TIMEOUT 3) diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index bf14263..14819e7 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -3,3 +3,17 @@ include(RunCMake) run_cmake(INSTALL-DIRECTORY) run_cmake(INSTALL-MESSAGE-bad) run_cmake(FileOpenFailRead) +run_cmake(LOCK) +run_cmake(LOCK-error-file-create-fail) +run_cmake(LOCK-error-guard-incorrect) +run_cmake(LOCK-error-incorrect-timeout) +run_cmake(LOCK-error-incorrect-timeout-trail) +run_cmake(LOCK-error-lock-fail) +run_cmake(LOCK-error-negative-timeout) +run_cmake(LOCK-error-no-function) +run_cmake(LOCK-error-no-guard) +run_cmake(LOCK-error-no-path) +run_cmake(LOCK-error-no-result-variable) +run_cmake(LOCK-error-no-timeout) +run_cmake(LOCK-error-timeout) +run_cmake(LOCK-error-unknown-option) diff --git a/Tests/RunCMake/file/subdir_test_unlock/CMakeLists.txt b/Tests/RunCMake/file/subdir_test_unlock/CMakeLists.txt new file mode 100644 index 0000000..c167cd7 --- /dev/null +++ b/Tests/RunCMake/file/subdir_test_unlock/CMakeLists.txt @@ -0,0 +1,2 @@ +message(STATUS "Lock in subdirectory") +file(LOCK "${lfile}" GUARD FILE) diff --git a/Tests/RunCMake/file/timeout-script.cmake b/Tests/RunCMake/file/timeout-script.cmake new file mode 100644 index 0000000..e07dbf0 --- /dev/null +++ b/Tests/RunCMake/file/timeout-script.cmake @@ -0,0 +1,5 @@ +if(NOT file_to_lock) + message(FATAL_ERROR "file_to_lock is empty") +endif() + +file(LOCK "${file_to_lock}" TIMEOUT 1) diff --git a/Tests/SourceFileProperty/CMakeLists.txt b/Tests/SourceFileProperty/CMakeLists.txt new file mode 100644 index 0000000..1b6506d --- /dev/null +++ b/Tests/SourceFileProperty/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.0) +project(SourceFileProperty C) + +set(sources) + +if (EXISTS icasetest.c) + # If a file exists by this name, use it. + set_source_files_properties(icasetest.c + PROPERTIES + COMPILE_FLAGS -DNEEDED_TO_WORK) +else () + # Work on case-sensitive file systems as well. + set_source_files_properties(main.c + PROPERTIES + COMPILE_FLAGS -DNO_NEED_TO_CALL) +endif () +list(APPEND sources ICaseTest.c) + +add_executable(SourceFileProperty main.c ${sources}) diff --git a/Tests/SourceFileProperty/ICaseTest.c b/Tests/SourceFileProperty/ICaseTest.c new file mode 100644 index 0000000..454c721 --- /dev/null +++ b/Tests/SourceFileProperty/ICaseTest.c @@ -0,0 +1,7 @@ + +#ifdef NEEDED_TO_WORK +int icasetest() +{ + return 0; +} +#endif diff --git a/Tests/SourceFileProperty/main.c b/Tests/SourceFileProperty/main.c new file mode 100644 index 0000000..b853408 --- /dev/null +++ b/Tests/SourceFileProperty/main.c @@ -0,0 +1,13 @@ + +#ifndef NO_NEED_TO_CALL +extern int icasetest(); +#endif + +int main(int argc, char** argv) +{ +#ifdef NO_NEED_TO_CALL + return 0; +#else + return icasetest(); +#endif +} diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt index 0041c75..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,16 +97,24 @@ 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>>) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel) +set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainPS) +set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3) + set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_TYPE Vertex) +set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainVS) +set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3) + source_group("Source Files" FILES ${SOURCE_FILES}) source_group("Header Files" FILES ${HEADER_FILES}) diff --git a/Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.hlsl b/Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.hlsl index d61e2c8..6796da1 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.hlsl +++ b/Tests/VSWinStorePhone/Direct3DApp1/SimplePixelShader.hlsl @@ -4,7 +4,7 @@ struct PixelShaderInput float3 color : COLOR0; }; -float4 main(PixelShaderInput input) : SV_TARGET +float4 mainPS(PixelShaderInput input) : SV_TARGET { return float4(input.color,1.0f); } diff --git a/Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.hlsl b/Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.hlsl index 65d60e5..0963060 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.hlsl +++ b/Tests/VSWinStorePhone/Direct3DApp1/SimpleVertexShader.hlsl @@ -17,7 +17,7 @@ struct VertexShaderOutput float3 color : COLOR0; }; -VertexShaderOutput main(VertexShaderInput input) +VertexShaderOutput mainVS(VertexShaderInput input) { VertexShaderOutput output; float4 pos = float4(input.pos, 1.0f); 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/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake index a3f7032..19f4cb1 100644 --- a/Utilities/Release/create-cmake-release.cmake +++ b/Utilities/Release/create-cmake-release.cmake @@ -10,6 +10,7 @@ set(RELEASE_SCRIPTS_BATCH_1 dashmacmini2_release.cmake # Mac Darwin universal ppc;i386 dashmacmini5_release.cmake # Mac Darwin64 universal x86_64;i386 magrathea_release.cmake # Linux + linux64_release.cmake # Linux x86_64 ibm_aix_release.cmake # AIX ) diff --git a/Utilities/Release/linux64_release.cmake b/Utilities/Release/linux64_release.cmake new file mode 100644 index 0000000..513f42f --- /dev/null +++ b/Utilities/Release/linux64_release.cmake @@ -0,0 +1,23 @@ +set(PROCESSORS 4) +set(HOST linux64) +set(MAKE_PROGRAM "make") +set(CC /opt/gcc-4.9.2/bin/gcc) +set(CXX /opt/gcc-4.9.2/bin/g++) +set(CFLAGS "") +set(CXXFLAGS "") +set(INITIAL_CACHE " +CMAKE_BUILD_TYPE:STRING=Release +CURSES_LIBRARY:FILEPATH=/home/kitware/ncurses-5.9/lib/libncurses.a +CURSES_INCLUDE_PATH:PATH=/home/kitware/ncurses-5.9/include +FORM_LIBRARY:FILEPATH=/home/kitware/ncurses-5.9/lib/libform.a +CMAKE_USE_OPENSSL:BOOL=ON +OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1j/lib/libcrypto.a +OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.1j/include +OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1j/lib/libssl.a +CPACK_SYSTEM_NAME:STRING=Linux-x86_64 +BUILD_QtDialog:BOOL:=TRUE +CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE +QT_QMAKE_EXECUTABLE:FILEPATH=/home/kitware/qt-4.8.6/bin/qmake +") +get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) +include(${path}/release_cmake.cmake) 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) |