From d3ck0r at gmail.com Sat Nov 1 19:03:41 2014 From: d3ck0r at gmail.com (J Decker) Date: Sat, 1 Nov 2014 16:03:41 -0700 Subject: [cmake-developers] Watcom updates in 3.1 break linking usable code Message-ID: wlink uses the option 'system nt_dll' if it builds a DLL; if this is not specified, the resulting file generates exceptions. This was moved from ... / ---- modules/platform/windows-wcl386.cmake ------ set(CMAKE_CXX_CREATE_SHARED_LIBRARY "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name option implib= file {} ${CMAKE_END_TEMP_FILE}") /------ used to be ----- / set(CMAKE_CXX_CREATE_SHARED_MODULE "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '' option implib= option caseexact file {} ${CMAKE_END_TEMP_FILE}") ---------------- ... to a variable CMAKE_SHARED_LINKER_FLAGS_INIT but I don't see the latter flag ever being used. So the generator does not output 'system nt_dll' when building shared library targets. -------------- next part -------------- An HTML attachment was scrubbed... URL: From d3ck0r at gmail.com Sat Nov 1 19:26:20 2014 From: d3ck0r at gmail.com (J Decker) Date: Sat, 1 Nov 2014 16:26:20 -0700 Subject: [cmake-developers] Watcom updates in 3.1 break linking usable code In-Reply-To: References: Message-ID: *regarding prior issue; might be because I had not cleaned properly when changing versions of cmake; because with fix and reinstall, I ended up duplicating the system nt_dll option * Should add version ... also in windows-wcl386.cmake if(NOT _CMAKE_WATCOM_VERSION) set(_CMAKE_WATCOM_VERSION 1) if(CMAKE_C_COMPILER_VERSION) set(_compiler_version ${CMAKE_C_COMPILER_VERSION}) set(_compiler_id ${CMAKE_C_COMPILER_ID}) else() set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION}) set(_compiler_id ${CMAKE_CXX_COMPILER_ID}) endif() set(WATCOM16) set(WATCOM17) set(WATCOM18) set(WATCOM19) set(WATCOM20) if("${_compiler_id}" STREQUAL "OpenWatcom") if("${_compiler_version}" VERSION_LESS 1.7) set(WATCOM16 1) endif() if("${_compiler_version}" VERSION_EQUAL 1.7) set(WATCOM17 1) endif() if("${_compiler_version}" VERSION_EQUAL 1.8) set(WATCOM18 1) endif() if("${_compiler_version}" VERSION_EQUAL 1.9) set(WATCOM19 1) endif() if("${_compiler_version}" VERSION_EQUAL 2.0) set(WATCOM20 1) endif() endif() endif() On Sat, Nov 1, 2014 at 4:03 PM, J Decker wrote: > wlink uses the option 'system nt_dll' if it builds a DLL; if this is not > specified, the resulting file generates exceptions. > > This was moved from ... > > / ---- modules/platform/windows-wcl386.cmake ------ > set(CMAKE_CXX_CREATE_SHARED_LIBRARY > "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name > option implib= file {} > ${CMAKE_END_TEMP_FILE}") > > /------ used to be ----- / > set(CMAKE_CXX_CREATE_SHARED_MODULE > "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name > '' option implib= option > caseexact file {} ${CMAKE_END_TEMP_FILE}") > ---------------- > > ... to a variable > > CMAKE_SHARED_LINKER_FLAGS_INIT > > but I don't see the latter flag ever being used. > > So the generator does not output 'system nt_dll' when building shared > library targets. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From d3ck0r at gmail.com Sun Nov 2 16:59:27 2014 From: d3ck0r at gmail.com (J Decker) Date: Sun, 2 Nov 2014 13:59:27 -0800 Subject: [cmake-developers] Revert watcom symfile option Message-ID: Recently watcom link options were changed to generate .sym files instead of building the debug information into targets. The rules used to create the .sym name for some files are kind of bad, and there is no way to set the symbol file name of a target; so it is better to revert that change. It's easy to run 'wstrip *' if the symbols need to be stripped, but it's very difficult to get the right names for the .sym files to install with debug/rel_with_deb_info targets.... tried to add generator expressions to the flags to build a better symfile name; but they don't get resolved correctly this diff is based against current git sources modifies share/modules/platform/windows-wcl386.cmake -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- Modules/Platform/Windows-wcl386.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index ac410de..88f9bf7 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -18,8 +18,8 @@ set(CMAKE_CREATE_CONSOLE_EXE "system nt" ) set(CMAKE_SHARED_LINKER_FLAGS_INIT "system nt_dll") set(CMAKE_MODULE_LINKER_FLAGS_INIT "system nt_dll") foreach(type SHARED MODULE EXE) - set(CMAKE_${type}_LINKER_FLAGS_DEBUG_INIT "debug all opt map, symfile") - set(CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all opt map, symfile") + set(CMAKE_${type}_LINKER_FLAGS_DEBUG_INIT "debug all opt map") + set(CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all opt map") endforeach() set(CMAKE_C_COMPILE_OPTIONS_DLL "-bd") # Note: This variable is a ';' separated list From brad.king at kitware.com Mon Nov 3 08:55:21 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 03 Nov 2014 08:55:21 -0500 Subject: [cmake-developers] Revert watcom symfile option In-Reply-To: References: Message-ID: <54578949.7040403@kitware.com> On 11/02/2014 04:59 PM, J Decker wrote: > there is no way to set the symbol file name of a target; > so it is better to revert that change. I've applied the patch here: Watcom: Drop symfile linker option http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6b63942e and merged it to 'next' for testing. I plan to merge this for the next 3.1 release candidate if it is clean. The change in default behavior for linker symbols from 3.0 was not intended. For those that really want the separate symbols file they can set the CMAKE_*_LINKER_FLAGS_DEBUG cache entries themselves. We do not need it in the default link flags. Thanks, -Brad From brad.king at kitware.com Mon Nov 3 08:57:51 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 03 Nov 2014 08:57:51 -0500 Subject: [cmake-developers] Watcom updates in 3.1 break linking usable code In-Reply-To: References: Message-ID: <545789DF.3070604@kitware.com> On 11/01/2014 07:26 PM, J Decker wrote: > Should add version ... also in windows-wcl386.cmake > > set(WATCOM20) > ... > if("${_compiler_version}" VERSION_EQUAL 2.0) > set(WATCOM20 1) > endif() The old WATCOM1* names are kept for compatibility, but new code should use CMAKE_CXX_COMPILER_ID and CMAKE_CXX_COMPILER_VERSION which are set automatically. The old variables were never documented anyway. -Brad From daniele.domenichelli at gmail.com Mon Nov 3 09:07:04 2014 From: daniele.domenichelli at gmail.com (Daniele E. Domenichelli) Date: Mon, 03 Nov 2014 15:07:04 +0100 Subject: [cmake-developers] Review Request: Topic ExternalProject-independent-step-targets In-Reply-To: <528B3896.5090608@gmail.com> References: <528B3896.5090608@gmail.com> Message-ID: <54578C08.4030600@gmail.com> Hello, Sorry for resuming an old thread, you can read the original thread here: http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/8680/ This topic was reviewed and merged into next, but there were some issues in the unit tests with Ninja and with parallel builds. I finally found the time to update and properly fix it. In order to fix the issues with ninja, I added the ExternalProject_Add_StepDependencies function as discussed here: http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/8680/focus=8926 In order not to modify all the ExternalProject_Add calls in the main ExternalProject test, I reverted the changes to this test, and instead I modified the ExternalProjectUpdate one to use "EP_INDEPENDENT_STEP_TARGETS update" for this folder. This means that I had to change the ExternalProject_Add call to use ExternalProject_Add_StepDependencies instead of DEPENDS, but it is just one call and the DEPENDS argument is widely tested in the main ExternalProject test, so in my opinion it shouldn't be an issue, and allows to test both. Finally I also added some RunCMake tests for the new command and options. These are the commits included in the topic. ExternalProject: Add independent step targets http://www.cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=b69c4233 ExternalProject: Add ExternalProject_Add_StepDependencies function http://www.cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=068fb542 ExternalProject: Add unit tests http://www.cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=0edd9fc6 Can you please review the topic again? Cheers, Daniele From brad.king at kitware.com Mon Nov 3 09:27:49 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 03 Nov 2014 09:27:49 -0500 Subject: [cmake-developers] Please review patch for 'continue' keyword In-Reply-To: <5453EA4B.5090804@googlemail.com> References: <5453EA4B.5090804@googlemail.com> Message-ID: <545790E5.5090300@kitware.com> On 10/31/2014 04:00 PM, Gregor Jasny wrote: > http://www.cmake.org/Bug/view.php?id=14013 > > I re-applied the patch to master, fixed some bit-rot and formatted it > via git format-patch (also attached). Could you please take a look? It > would be great if the 'continue' keyword support would be part of CMake > 3.2. Thanks for working on this. The patch looks like a good start. In order to be integrated a bit more work is needed: - Tests covering the command are needed. They can be added as a new Tests/RunCMake/continue test. - It needs to be an error to call continue() outside of a suitable context. Thanks, -Brad From brad.king at kitware.com Mon Nov 3 10:02:53 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 03 Nov 2014 10:02:53 -0500 Subject: [cmake-developers] Review Request: Topic ExternalProject-independent-step-targets In-Reply-To: <54578C08.4030600@gmail.com> References: <528B3896.5090608@gmail.com> <54578C08.4030600@gmail.com> Message-ID: <5457991D.2020909@kitware.com> On 11/03/2014 09:07 AM, Daniele E. Domenichelli wrote: > Can you please review the topic again? Thanks for updating the topic. The revised topic looks ready for testing in 'next' to me. My only nitpick is that the work was spread out over so long that the author dates are a little confusing. Please reset them and then merge to 'next'. Thanks, -Brad From daniele.domenichelli at gmail.com Mon Nov 3 10:19:05 2014 From: daniele.domenichelli at gmail.com (Daniele E. Domenichelli) Date: Mon, 03 Nov 2014 16:19:05 +0100 Subject: [cmake-developers] Review Request: Topic ExternalProject-independent-step-targets In-Reply-To: <5457991D.2020909@kitware.com> References: <528B3896.5090608@gmail.com> <54578C08.4030600@gmail.com> <5457991D.2020909@kitware.com> Message-ID: <54579CE9.6020701@gmail.com> On 03/11/14 16:02, Brad King wrote: > My only nitpick is that the work was spread out over so long > that the author dates are a little confusing. Please reset > them and then merge to 'next'. Done. Thanks! Daniele From norman-k-williams at uiowa.edu Mon Nov 3 15:29:39 2014 From: norman-k-williams at uiowa.edu (Williams, Norman K) Date: Mon, 3 Nov 2014 20:29:39 +0000 Subject: [cmake-developers] CMake.app Qt5 vs Qt4 on 10.10 In-Reply-To: References: Message-ID: I?m trying to build CMake with the Qt Dialog on Ubuntu and it?s really not working. do I have to do something like add -DQT5Widgets_DIR:PATH=/opt/Qt/5.3/gcc_64/lib/cmake/Qt5Widgets to my CMake build line? On 10/21/14, 11:16 AM, "Adam Strzelecki" wrote: >Following discussion regarding fix-OSX-bundle-rpaths-and-Qt5 topic I just >wanted to share with you how CMake looks with Qt4 vs Qt5 on Yosemite: > > https://www.dropbox.com/s/knnybhed8fahste/CMake3.1rc1-Qt4.8.6-Yosemite.pn >g > https://www.dropbox.com/s/tm95rntexn4z6j6/CMake3.1rc1-Qt5.4-Yosemite.png > >As you can see Qt4 has some problems with button test layout. Anyway >nothing serious that prevents it from running. Please note I am using Qt >4.8.6 there not 4.8.0 as it is used for official builds (as far I >understood correctly from what Robert told me on IRC). > >FYI CMake bundle is 62MB with Qt4 vs 66MB with Qt5 (64-bit Intel only). > >--Adam >-- > >Powered by www.kitware.com > >Please keep messages on-topic and check the CMake FAQ at: >http://www.cmake.org/Wiki/CMake_FAQ > >Kitware offers various services to support the CMake community. For more >information on each offering, please visit: > >CMake Support: http://cmake.org/cmake/help/support.html >CMake Consulting: http://cmake.org/cmake/help/consulting.html >CMake Training Courses: http://cmake.org/cmake/help/training.html > >Visit other Kitware open-source projects at >http://www.kitware.com/opensource/opensource.html > >Follow this link to subscribe/unsubscribe: >http://public.kitware.com/mailman/listinfo/cmake-developers ________________________________ Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you. ________________________________ From brad.king at kitware.com Mon Nov 3 15:32:32 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 03 Nov 2014 15:32:32 -0500 Subject: [cmake-developers] CMake.app Qt5 vs Qt4 on 10.10 In-Reply-To: References: Message-ID: <5457E660.1060106@kitware.com> On 11/03/2014 03:29 PM, Williams, Norman K wrote: > I'm trying to build CMake with the Qt Dialog on Ubuntu and it's really not > working. > > do I have to do something like add > -DQT5Widgets_DIR:PATH=/opt/Qt/5.3/gcc_64/lib/cmake/Qt5Widgets to my CMake > build line? In order to tell CMake where to find Qt 5, add its installation prefix (/opt/Qt/5.3/gcc_64) to the CMAKE_PREFIX_PATH, either in your environment or on the command line: -DCMAKE_PREFIX_PATH=/opt/Qt/5.3/gcc_64 If you're using the 'bootstrap' script you can add it after a '--' option: ./bootstrap --prefix=... -- -DCMAKE_PREFIX_PATH=/opt/Qt/5.3/gcc_64 -Brad From peter at pcc.me.uk Mon Nov 3 19:22:56 2014 From: peter at pcc.me.uk (Peter Collingbourne) Date: Mon, 3 Nov 2014 16:22:56 -0800 Subject: [cmake-developers] [wip/patch] Expose Ninja console pool feature for custom commands/targets Message-ID: <20141104002256.GA29444@pcc.me.uk> Hi all, This patch exposes the Ninja console pool feature via the add_custom_command and add_custom_target commands. Specifically, it introduces a USE_CONSOLE flag which can be used to communicate to the generator that the command would prefer to use the console. It has no effect on generators other than the Ninja generator. The patch also causes the feature to be used with the built-in cache editor. Docs/tests to come. Any comments on the proposed approach are appreciated. Thanks, -- Peter -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-console-pools.patch Type: text/x-diff Size: 22971 bytes Desc: not available URL: From mantis at public.kitware.com Tue Nov 4 00:31:20 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 4 Nov 2014 00:31:20 -0500 Subject: [cmake-developers] [CMake 0015232]: "A quick introduction to CMake syntax" page is not available Message-ID: The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15232 ====================================================================== Reported By: ovz Assigned To: ====================================================================== Project: CMake Issue ID: 15232 Category: Documentation Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-04 00:31 EST Last Modified: 2014-11-04 00:31 EST ====================================================================== Summary: "A quick introduction to CMake syntax" page is not available Description: http://www.cmake.org/HTML/syntax.html returns 404. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-04 00:31 ovz New Issue ====================================================================== From ben.boeckel at kitware.com Tue Nov 4 00:53:07 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Tue, 4 Nov 2014 00:53:07 -0500 Subject: [cmake-developers] [wip/patch] Expose Ninja console pool feature for custom commands/targets In-Reply-To: <20141104002256.GA29444@pcc.me.uk> References: <20141104002256.GA29444@pcc.me.uk> Message-ID: <20141104055307.GA14967@erythro.kitwarein.com> On Mon, Nov 03, 2014 at 16:22:56 -0800, Peter Collingbourne wrote: > This patch exposes the Ninja console pool feature via the add_custom_command > and add_custom_target commands. Specifically, it introduces a USE_CONSOLE > flag which can be used to communicate to the generator that the command > would prefer to use the console. It has no effect on generators other than > the Ninja generator. > > The patch also causes the feature to be used with the built-in cache editor. +1 to the feature. I think there are some bugs open on the tracker for this we should ping when appropriate. > Docs/tests to come. Any comments on the proposed approach are appreciated. See inline below. > - doing_verbatim > + doing_nothing A separate commit to rename this would be nice. > + else if(copy == "USE_CONSOLE") > + { > + doing = doing_nothing; > + console = true; > + } Is there any reason this could not be implemented with a JOB_POOL target property? This would allow custom commands to be placed into a pool with JOB_POOLS other than the console pool. > cmTarget CreateGlobalTarget(const std::string& name, const char* message, > const cmCustomCommandLines* commandLines, > - std::vector depends, const char* workingDir); > + std::vector depends, const char* workingDir, > + bool console); A separate commit to add this parameter would be nice so that the "make current things console'd" is separate from "allow the user to make targets console'd". This parameter might not even be necessary with a generic JOB_POOL target property. Thanks, --Ben From peter at pcc.me.uk Tue Nov 4 05:46:02 2014 From: peter at pcc.me.uk (Peter Collingbourne) Date: Tue, 4 Nov 2014 02:46:02 -0800 Subject: [cmake-developers] [wip/patch] Expose Ninja console pool feature for custom commands/targets In-Reply-To: <20141104055307.GA14967@erythro.kitwarein.com> References: <20141104002256.GA29444@pcc.me.uk> <20141104055307.GA14967@erythro.kitwarein.com> Message-ID: <20141104104602.GA14934@pcc.me.uk> On Tue, Nov 04, 2014 at 12:53:07AM -0500, Ben Boeckel wrote: > On Mon, Nov 03, 2014 at 16:22:56 -0800, Peter Collingbourne wrote: > > This patch exposes the Ninja console pool feature via the add_custom_command > > and add_custom_target commands. Specifically, it introduces a USE_CONSOLE > > flag which can be used to communicate to the generator that the command > > would prefer to use the console. It has no effect on generators other than > > the Ninja generator. > > > > The patch also causes the feature to be used with the built-in cache editor. > > +1 to the feature. I think there are some bugs open on the tracker for > this we should ping when appropriate. There's http://public.kitware.com/Bug/view.php?id=14915 which I will ping when I get a chance. > > Docs/tests to come. Any comments on the proposed approach are appreciated. > > See inline below. > > > - doing_verbatim > > + doing_nothing > > A separate commit to rename this would be nice. Will do. > > + else if(copy == "USE_CONSOLE") > > + { > > + doing = doing_nothing; > > + console = true; > > + } > > Is there any reason this could not be implemented with a JOB_POOL target > property? This would allow custom commands to be placed into a pool with > JOB_POOLS other than the console pool. I think that any feature which allows custom commands to be placed in arbitrary pools should be exposed separately from this feature, the reason being that a build system may choose to implement the features orthogonally. Having the features be separate is also useful for supporting older versions of Ninja (1.1 to 1.4) that support the pool feature but not console pools. > > cmTarget CreateGlobalTarget(const std::string& name, const char* message, > > const cmCustomCommandLines* commandLines, > > - std::vector depends, const char* workingDir); > > + std::vector depends, const char* workingDir, > > + bool console); > > A separate commit to add this parameter would be nice so that the "make > current things console'd" is separate from "allow the user to make > targets console'd". This parameter might not even be necessary with a > generic JOB_POOL target property. Will do. Thanks, -- Peter From mantis at public.kitware.com Tue Nov 4 10:11:58 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 4 Nov 2014 10:11:58 -0500 Subject: [cmake-developers] [CMake 0015233]: is there a way to force the use of bash for command execution? Message-ID: The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15233 ====================================================================== Reported By: Bill Torpey Assigned To: ====================================================================== Project: CMake Issue ID: 15233 Category: CMake Reproducibility: always Severity: feature Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-04 10:11 EST Last Modified: 2014-11-04 10:11 EST ====================================================================== Summary: is there a way to force the use of bash for command execution? Description: Under Linux, cmake runs external commands (e.g., specified in add_custom_command) using sh. While sh resolves to bash, when invoked as sh bash does not support many features. In particular, we need to: - Specify LD_LIBRARY_PATH for a custom command (since it is being built as part of the build process, with a non-standard compiler) - Specify ASAN_OPTIONS (since the custom commmand is being built w/clang+asan) to force it to return a zero return code. The natural way to do this is to prefix the custom command: LD_LIBRARY_PATH=... ASAN_OPTIONS=... command While this is perfectly legal bash, sh fails with "No such file or directory" It's possible to wrap the command in a shell script and execute that, but it would be much cleaner to specify the command directly in the CMakeLists.txt file. FWIW, we don't care about portability -- our application is strictly Linux x86_64 -- we just use CMake as a superior alternative to autotools. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-04 10:11 Bill Torpey New Issue ====================================================================== From chuck.atkins at kitware.com Tue Nov 4 11:27:24 2014 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Tue, 4 Nov 2014 11:27:24 -0500 Subject: [cmake-developers] GCC HPPA linker errors Message-ID: stage/fix-gcc-hppa Add -mlong-calls for gcc on HPPA. Merged to next for testing. - Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From gjasny at googlemail.com Tue Nov 4 15:10:18 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 4 Nov 2014 21:10:18 +0100 Subject: [cmake-developers] [PATCH v2 0/2] Support for continue command In-Reply-To: <545790E5.5090300@kitware.com> References: <545790E5.5090300@kitware.com> Message-ID: <1415131820-1721-1-git-send-email-gjasny@googlemail.com> Hello, I added some tests for the continue command but ran into a problem when matching stdout output: 302: Expected stdout to match: 302: 302: expect-out> a 302: expect-out> aa 302: expect-out> aaaa 302: expect-out> aaaaa 302: 302: Actual stdout: 302: 302: actual-out> Not searching for unused variables given on the command line. 302: actual-out> -- a 302: actual-out> -- aa 302: actual-out> -- aaaa 302: actual-out> -- aaaaa 302: actual-out> -- Configuring done 302: actual-out> -- Generating done 302: actual-out> -- Build files have been written to: /Users/jasny/src/cmake/Tests/RunCMake/continue/ContinueWhile-build How do I strip off the trailing "Configuring done" and following lines? No other -stdout.txt file I checked contains these. About the continue() outside of a block error: I added a test but I have no idea how to enforce the desired behavior. Note: cmake does not error out on break() outside of loops, too. I guess the original author used the break() code as boilerplate for continue() therefore they show the same bug. Thanks, Gregor Gregor Jasny (2): Add continue keyword (#14013) Add tests for continue command Help/command/continue.rst | 7 +++ Source/cmBootstrapCommands1.cxx | 2 + Source/cmContinueCommand.cxx | 21 +++++++++ Source/cmContinueCommand.h | 55 ++++++++++++++++++++++ Source/cmExecutionStatus.h | 7 +++ Source/cmForEachCommand.cxx | 4 ++ Source/cmIfCommand.cxx | 5 ++ Source/cmWhileCommand.cxx | 4 ++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/continue/CMakeLists.txt | 3 ++ Tests/RunCMake/continue/ContinueForeach-stdout.txt | 2 + Tests/RunCMake/continue/ContinueForeach.cmake | 6 +++ .../continue/ContinueNestedForeach-stdout.txt | 4 ++ .../RunCMake/continue/ContinueNestedForeach.cmake | 11 +++++ Tests/RunCMake/continue/ContinueWhile-stdout.txt | 4 ++ Tests/RunCMake/continue/ContinueWhile.cmake | 8 ++++ .../RunCMake/continue/NoEnclosingBlock-result.txt | 1 + .../RunCMake/continue/NoEnclosingBlock-stderr.txt | 1 + Tests/RunCMake/continue/NoEnclosingBlock.cmake | 1 + Tests/RunCMake/continue/RunCMakeTest.cmake | 6 +++ 20 files changed, 153 insertions(+) create mode 100644 Help/command/continue.rst create mode 100644 Source/cmContinueCommand.cxx create mode 100644 Source/cmContinueCommand.h create mode 100644 Tests/RunCMake/continue/CMakeLists.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueWhile-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueWhile.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock.cmake create mode 100644 Tests/RunCMake/continue/RunCMakeTest.cmake -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Tue Nov 4 15:10:19 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 4 Nov 2014 21:10:19 +0100 Subject: [cmake-developers] [PATCH v2 1/2] Add continue keyword (#14013) In-Reply-To: <1415131820-1721-1-git-send-email-gjasny@googlemail.com> References: <1415131820-1721-1-git-send-email-gjasny@googlemail.com> Message-ID: <1415131820-1721-2-git-send-email-gjasny@googlemail.com> Original patch by Doug Barbieri. Signed-off-by: Gregor Jasny --- Help/command/continue.rst | 7 ++++++ Source/cmBootstrapCommands1.cxx | 2 ++ Source/cmContinueCommand.cxx | 21 ++++++++++++++++ Source/cmContinueCommand.h | 55 +++++++++++++++++++++++++++++++++++++++++ Source/cmExecutionStatus.h | 7 ++++++ Source/cmForEachCommand.cxx | 4 +++ Source/cmIfCommand.cxx | 5 ++++ Source/cmWhileCommand.cxx | 4 +++ 8 files changed, 105 insertions(+) create mode 100644 Help/command/continue.rst create mode 100644 Source/cmContinueCommand.cxx create mode 100644 Source/cmContinueCommand.h diff --git a/Help/command/continue.rst b/Help/command/continue.rst new file mode 100644 index 0000000..d377542 --- /dev/null +++ b/Help/command/continue.rst @@ -0,0 +1,7 @@ +continue +-------- + +Continue to the top of enclosing foreach or while loop. + +Continue allows the cmake script to abort the rest of a block in a foreach +or while loop, and start at the top of the next iteration. See also break(). diff --git a/Source/cmBootstrapCommands1.cxx b/Source/cmBootstrapCommands1.cxx index 9093579..d129aef 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" @@ -68,6 +69,7 @@ void GetBootstrapCommands1(std::list& 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..ecb894b --- /dev/null +++ b/Source/cmContinueCommand.cxx @@ -0,0 +1,21 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 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 const&, + cmExecutionStatus &status) +{ + status.SetContinueInvoked(true); + return true; +} + diff --git a/Source/cmContinueCommand.h b/Source/cmContinueCommand.h new file mode 100644 index 0000000..2107637 --- /dev/null +++ b/Source/cmContinueCommand.h @@ -0,0 +1,55 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 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 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/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index e3f66c1..dfb9ae7 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -67,6 +67,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/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/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 851c4cb..d648a0c 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -81,6 +81,10 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, { return true; } + if (status.GetContinueInvoked()) + { + break; + } if(cmSystemTools::GetFatalErrorOccured() ) { return true; -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Tue Nov 4 15:10:20 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 4 Nov 2014 21:10:20 +0100 Subject: [cmake-developers] [PATCH v2 2/2] Add tests for continue command In-Reply-To: <1415131820-1721-1-git-send-email-gjasny@googlemail.com> References: <1415131820-1721-1-git-send-email-gjasny@googlemail.com> Message-ID: <1415131820-1721-3-git-send-email-gjasny@googlemail.com> Signed-off-by: Gregor Jasny --- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/continue/CMakeLists.txt | 3 +++ Tests/RunCMake/continue/ContinueForeach-stdout.txt | 2 ++ Tests/RunCMake/continue/ContinueForeach.cmake | 6 ++++++ Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt | 4 ++++ Tests/RunCMake/continue/ContinueNestedForeach.cmake | 11 +++++++++++ Tests/RunCMake/continue/ContinueWhile-stdout.txt | 4 ++++ Tests/RunCMake/continue/ContinueWhile.cmake | 8 ++++++++ Tests/RunCMake/continue/NoEnclosingBlock-result.txt | 1 + Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt | 1 + Tests/RunCMake/continue/NoEnclosingBlock.cmake | 1 + Tests/RunCMake/continue/RunCMakeTest.cmake | 6 ++++++ 12 files changed, 48 insertions(+) create mode 100644 Tests/RunCMake/continue/CMakeLists.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueWhile-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueWhile.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock.cmake create mode 100644 Tests/RunCMake/continue/RunCMakeTest.cmake diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index a99b46f..0099d4b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -99,6 +99,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/ContinueForeach-stdout.txt b/Tests/RunCMake/continue/ContinueForeach-stdout.txt new file mode 100644 index 0000000..da7f847 --- /dev/null +++ b/Tests/RunCMake/continue/ContinueForeach-stdout.txt @@ -0,0 +1,2 @@ +2 +4 diff --git a/Tests/RunCMake/continue/ContinueForeach.cmake b/Tests/RunCMake/continue/ContinueForeach.cmake new file mode 100644 index 0000000..25c3e81 --- /dev/null +++ b/Tests/RunCMake/continue/ContinueForeach.cmake @@ -0,0 +1,6 @@ +foreach (iter RANGE 1 5) + if ("${iter}" EQUAL 1 OR "${iter}" EQUAL 3 OR "${iter}" EQUAL 5) + continue () + endif () + message (STATUS "${iter}") +endforeach () diff --git a/Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt b/Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt new file mode 100644 index 0000000..34e37b7 --- /dev/null +++ b/Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt @@ -0,0 +1,4 @@ +7 2 +7 4 +9 2 +9 4 diff --git a/Tests/RunCMake/continue/ContinueNestedForeach.cmake b/Tests/RunCMake/continue/ContinueNestedForeach.cmake new file mode 100644 index 0000000..50966eb --- /dev/null +++ b/Tests/RunCMake/continue/ContinueNestedForeach.cmake @@ -0,0 +1,11 @@ +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 () diff --git a/Tests/RunCMake/continue/ContinueWhile-stdout.txt b/Tests/RunCMake/continue/ContinueWhile-stdout.txt new file mode 100644 index 0000000..26095d6 --- /dev/null +++ b/Tests/RunCMake/continue/ContinueWhile-stdout.txt @@ -0,0 +1,4 @@ +a +aa +aaaa +aaaaa \ No newline at end of file diff --git a/Tests/RunCMake/continue/ContinueWhile.cmake b/Tests/RunCMake/continue/ContinueWhile.cmake new file mode 100644 index 0000000..c4c9b31 --- /dev/null +++ b/Tests/RunCMake/continue/ContinueWhile.cmake @@ -0,0 +1,8 @@ +unset (iter) +while(NOT "${iter}" STREQUAL "aaaaa") + set (iter "${iter}a") + if ("${iter}" STREQUAL "aaa") + continue () + endif () + message (STATUS "${iter}") +endwhile() 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..e2a9aa4 --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt @@ -0,0 +1 @@ +Some helpful error message diff --git a/Tests/RunCMake/continue/NoEnclosingBlock.cmake b/Tests/RunCMake/continue/NoEnclosingBlock.cmake new file mode 100644 index 0000000..c038863 --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlock.cmake @@ -0,0 +1 @@ +continue() \ No newline at end of file diff --git a/Tests/RunCMake/continue/RunCMakeTest.cmake b/Tests/RunCMake/continue/RunCMakeTest.cmake new file mode 100644 index 0000000..de1255e --- /dev/null +++ b/Tests/RunCMake/continue/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) + +run_cmake(ContinueForeach) +run_cmake(ContinueNestedForeach) +run_cmake(ContinueWhile) +run_cmake(NoEnclosingBlock) -- 1.9.3 (Apple Git-50) From brad.king at kitware.com Tue Nov 4 15:21:04 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 04 Nov 2014 15:21:04 -0500 Subject: [cmake-developers] [PATCH v2 0/2] Support for continue command In-Reply-To: <1415131820-1721-1-git-send-email-gjasny@googlemail.com> References: <545790E5.5090300@kitware.com> <1415131820-1721-1-git-send-email-gjasny@googlemail.com> Message-ID: <54593530.8040005@kitware.com> On 11/04/2014 03:10 PM, Gregor Jasny wrote: > 302: Expected stdout to match: > 302: > 302: expect-out> a > 302: expect-out> aa > 302: expect-out> aaaa > 302: expect-out> aaaaa The message(STATUS) output lines start with "-- " so you need to add that to your expected output in order to match correctly. > How do I strip off the trailing "Configuring done" and following lines? You don't need to do that because the expectation does not have to match the entire output unless you add your own '^' at the beginning and '$' at the end. > About the continue() outside of a block error: I added a test but I > have no idea how to enforce the desired behavior. It's been a while since I looked at the relevant parts of the code but here is one approach that may work: Find all call sites to cmMakefile::ExecuteCommand. Teach them to check the resulting status argument for GetContinueInvoked. If it is true for any call sites other than the loop implementations then it is an error. > Note: cmake does not error out on break() outside of loops, too. I > guess the original author used the break() code as boilerplate for > continue() therefore they show the same bug. The break() command was added a long time ago when we were much less mature and also less rigorous about testing. That bug should be fixed in break() with a policy, but that is outside the scope of your work to add the new continue() command. If you want to try it as another topic after adding continue() I can provide guidance. Thanks, -Brad From tim.gallagher at gatech.edu Tue Nov 4 15:19:45 2014 From: tim.gallagher at gatech.edu (Tim Gallagher) Date: Tue, 4 Nov 2014 15:19:45 -0500 (EST) Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <675889837.24959969.1415129490675.JavaMail.root@mail.gatech.edu> Message-ID: <934174551.25006490.1415132385566.JavaMail.root@mail.gatech.edu> Hi all, I was trying to generate the assembly listing for some Fortran code and while searching for how to do it in CMake, I came across an email thread from a few years ago from somebody asking how to do it in C/C++ by running `make .s`. I vaguely remembered knowing this at one point so I tried it with my Fortran source and those targets didn't exist. I was about to get on the mailing list to ask if anybody else came across this problem, but first I clicked through the email thread and there was a message that I sent out basically saying "Hey, this doesn't work for Fortran -- is there any way that could be fixed?" I guess I send too many emails and forgot about that. At any rate, I looked through the CMake source code and it didn't seem that hard to make it work correctly for Fortran also. I made the changes on my local branch and it works great for the Intel and GNU compiler suites on Linux (those are the only ones I have access to). I modified the other compiler modules on the assumption that the options were the same for C, C++ and Fortran source files (which is true for Intel and GNU). I have a couple questions: 1) There are only 2 lines that needed changing in the C++ source to enable the functionality. In both places it is adding "Fortran" to the check for "C" and "C++" when assigning the `lang_is_c_or_cxx` variable. That variable name should change, but is `lang_is_c_or_cxx_or_fortran` really a good name? Seems a bit long, but it's not used often and that makes it very clear what it is storing. 2) How would/could I go about testing the changes to the other compilers/platforms that I do not have personal access to? I'd like to verify the options work, and that I didn't miss any compilers/platforms. Let me know if this is something that anybody else is interested in and I can send out a patch or something to get it tested. If there is interest in including the update, I can send a patch if that's easier than setting me up for push access -- the changes are really minor. Thanks, Tim From gjasny at googlemail.com Tue Nov 4 15:37:22 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 04 Nov 2014 21:37:22 +0100 Subject: [cmake-developers] CMake (C++) coding style Message-ID: <54593902.9030001@googlemail.com> Hello, could you please point me to some documentation regarding C++ coding style? Or do you have a checkpatch script? Google was not very helpful. Thanks, Gregor From brad.king at kitware.com Tue Nov 4 15:45:39 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 04 Nov 2014 15:45:39 -0500 Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <934174551.25006490.1415132385566.JavaMail.root@mail.gatech.edu> References: <934174551.25006490.1415132385566.JavaMail.root@mail.gatech.edu> Message-ID: <54593AF3.1050504@kitware.com> On 11/04/2014 03:19 PM, Tim Gallagher wrote: > I looked through the CMake source code and it didn't seem that > hard to make it work correctly for Fortran also. I made the > changes on my local branch and it works great for the Intel > and GNU compiler suites on Linux (those are the only ones I > have access to). I modified the other compiler modules on the > assumption that the options were the same for C, C++ and Fortran > source files (which is true for Intel and GNU). Great, thanks for looking into this. > adding "Fortran" to the check for "C" and "C++" when assigning > the `lang_is_c_or_cxx` variable. That variable name should change Perhaps "lang_has_preprocessor"? You could also add bool const lang_has_assembly = lang_has_preprocessor; and update each use of the variable to use the proper name. In the future the answer may not be the same. Watch out for other uses of lang_is_c_or_cxx, like for CMAKE_EXPORT_COMPILE_COMMANDS. Check if each use case makes sense for Fortran. > 2) How would/could I go about testing the changes to the other > compilers/platforms that I do not have personal access to? You could look at adding coverage of these make targets to the test suite under the proper conditions. That will likely be a harder change than your main fix though. Thanks, -Brad From brad.king at kitware.com Tue Nov 4 15:48:48 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 04 Nov 2014 15:48:48 -0500 Subject: [cmake-developers] CMake (C++) coding style In-Reply-To: <54593902.9030001@googlemail.com> References: <54593902.9030001@googlemail.com> Message-ID: <54593BB0.1050302@kitware.com> On 11/04/2014 03:37 PM, Gregor Jasny wrote: > could you please point me to some documentation regarding C++ coding > style? Or do you have a checkpatch script? It's never been formalized to that level. Basically: - Don't exceed 79 columns. - Align {} with the code inside them. - CamelCase class member names. - Explicit "this" for member access: this->Member Otherwise, try to match the style near the code you're changing. Someday this should be added to the cmake-developer(7) manual: http://www.cmake.org/cmake/help/v3.1/manual/cmake-developer.7.html Right now it only has a style guide for the documentation formatting. -Brad From eike at sf-mail.de Tue Nov 4 15:50:46 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Tue, 04 Nov 2014 21:50:46 +0100 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: References: Message-ID: <2538149.Y82WuCOlBM@caliban.sf-tec.de> Am Dienstag, 4. November 2014, 11:27:24 schrieb Chuck Atkins: > stage/fix-gcc-hppa > > Add -mlong-calls for gcc on HPPA. Merged to next for testing. Sorry, saw this mail only after I mailed you privately because I looked into the commit log first. For general consumption, here are the relevant parts again: Please make sure you also add these to bootstrap. And please see the very end of CompileFlags.cmake where we already added workarounds for HPPA, those are also in bootstrap. Until now we have not seen the problem on HP-UX, so this has been restricted to Linux until now. Greetings, Eike -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From tim.gallagher at gatech.edu Tue Nov 4 16:08:49 2014 From: tim.gallagher at gatech.edu (Tim Gallagher) Date: Tue, 4 Nov 2014 16:08:49 -0500 (EST) Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <54593AF3.1050504@kitware.com> Message-ID: <247062241.25054171.1415135329013.JavaMail.root@mail.gatech.edu> Hi Brad, Thanks for the info. What does the CMAKE_EXPORT_COMPILE_COMMANDS do? Or maybe more precisely, what output should I expect when it is set to ON instead of OFF? I tried it with my changes and nothing breaks, but I also don't see any difference in outputs with it set to ON so maybe I am missing something. I'll also dig into the testing to see what it would take to add the coverage. Thanks again, Tim ----- Original Message ----- From: "Brad King" To: "tim gallagher" , cmake-developers at cmake.org Sent: Tuesday, November 4, 2014 3:45:39 PM Subject: Re: [cmake-developers] Assembly/preprocessed targets for Fortran On 11/04/2014 03:19 PM, Tim Gallagher wrote: > I looked through the CMake source code and it didn't seem that > hard to make it work correctly for Fortran also. I made the > changes on my local branch and it works great for the Intel > and GNU compiler suites on Linux (those are the only ones I > have access to). I modified the other compiler modules on the > assumption that the options were the same for C, C++ and Fortran > source files (which is true for Intel and GNU). Great, thanks for looking into this. > adding "Fortran" to the check for "C" and "C++" when assigning > the `lang_is_c_or_cxx` variable. That variable name should change Perhaps "lang_has_preprocessor"? You could also add bool const lang_has_assembly = lang_has_preprocessor; and update each use of the variable to use the proper name. In the future the answer may not be the same. Watch out for other uses of lang_is_c_or_cxx, like for CMAKE_EXPORT_COMPILE_COMMANDS. Check if each use case makes sense for Fortran. > 2) How would/could I go about testing the changes to the other > compilers/platforms that I do not have personal access to? You could look at adding coverage of these make targets to the test suite under the proper conditions. That will likely be a harder change than your main fix though. Thanks, -Brad From tim.gallagher at gatech.edu Tue Nov 4 16:12:01 2014 From: tim.gallagher at gatech.edu (Tim Gallagher) Date: Tue, 4 Nov 2014 16:12:01 -0500 (EST) Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <247062241.25054171.1415135329013.JavaMail.root@mail.gatech.edu> Message-ID: <900274826.25055487.1415135521782.JavaMail.root@mail.gatech.edu> Scratch that, I found it. Wasn't looking in the right places! The export command works for Fortran, so that's not an issue. I'll take a look at the testing and see if I can get that going. I'll send along a patch when I get it worked out. Thanks, Tim ----- Original Message ----- From: "Tim Gallagher" To: "Brad King" Cc: cmake-developers at cmake.org Sent: Tuesday, November 4, 2014 4:08:49 PM Subject: Re: [cmake-developers] Assembly/preprocessed targets for Fortran Hi Brad, Thanks for the info. What does the CMAKE_EXPORT_COMPILE_COMMANDS do? Or maybe more precisely, what output should I expect when it is set to ON instead of OFF? I tried it with my changes and nothing breaks, but I also don't see any difference in outputs with it set to ON so maybe I am missing something. I'll also dig into the testing to see what it would take to add the coverage. Thanks again, Tim ----- Original Message ----- From: "Brad King" To: "tim gallagher" , cmake-developers at cmake.org Sent: Tuesday, November 4, 2014 3:45:39 PM Subject: Re: [cmake-developers] Assembly/preprocessed targets for Fortran On 11/04/2014 03:19 PM, Tim Gallagher wrote: > I looked through the CMake source code and it didn't seem that > hard to make it work correctly for Fortran also. I made the > changes on my local branch and it works great for the Intel > and GNU compiler suites on Linux (those are the only ones I > have access to). I modified the other compiler modules on the > assumption that the options were the same for C, C++ and Fortran > source files (which is true for Intel and GNU). Great, thanks for looking into this. > adding "Fortran" to the check for "C" and "C++" when assigning > the `lang_is_c_or_cxx` variable. That variable name should change Perhaps "lang_has_preprocessor"? You could also add bool const lang_has_assembly = lang_has_preprocessor; and update each use of the variable to use the proper name. In the future the answer may not be the same. Watch out for other uses of lang_is_c_or_cxx, like for CMAKE_EXPORT_COMPILE_COMMANDS. Check if each use case makes sense for Fortran. > 2) How would/could I go about testing the changes to the other > compilers/platforms that I do not have personal access to? You could look at adding coverage of these make targets to the test suite under the proper conditions. That will likely be a harder change than your main fix though. Thanks, -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers From chuck.atkins at kitware.com Tue Nov 4 16:17:08 2014 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Tue, 4 Nov 2014 16:17:08 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: <2538149.Y82WuCOlBM@caliban.sf-tec.de> References: <2538149.Y82WuCOlBM@caliban.sf-tec.de> Message-ID: > > Please make sure you also add these to bootstrap.sh. Will do. > And please see the very end of > CompileFlags.cmake where we already added workarounds for HPPA. Until now > we > have not seen the problem on HP-UX, so this has been restricted to Linux > until > now. > I considered putting it in there but from what I can tell, the issue is specific to GCC code generation for PA-RISC, regardless of OS, and is unrelated to Linux. Would you be able to verify whether or not this is needed on PA-RISC HP-UX with GCC v4+? I only have access to an ia64 HP-UX environment. - Chuck - Chuck On Tue, Nov 4, 2014 at 3:50 PM, Rolf Eike Beer wrote: > Am Dienstag, 4. November 2014, 11:27:24 schrieb Chuck Atkins: > > stage/fix-gcc-hppa > > > > Add -mlong-calls for gcc on HPPA. Merged to next for testing. > > Sorry, > > saw this mail only after I mailed you privately because I looked into the > commit log first. For general consumption, here are the relevant parts > again: > > Please make sure you also add these to bootstrap. And please see the very > end > of CompileFlags.cmake where we already added workarounds for HPPA, those > are > also in bootstrap. Until now we have not seen the problem on HP-UX, so this > has been restricted to Linux until now. > > Greetings, > > Eike -------------- next part -------------- An HTML attachment was scrubbed... URL: From eike at sf-mail.de Tue Nov 4 16:21:26 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Tue, 04 Nov 2014 22:21:26 +0100 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: References: <2538149.Y82WuCOlBM@caliban.sf-tec.de> Message-ID: <9073452.koTdryVNNO@caliban.sf-tec.de> Am Dienstag, 4. November 2014, 16:17:08 schrieb Chuck Atkins: > > Please make sure you also add these to bootstrap.sh. > > Will do. > > > And please see the very end of > > CompileFlags.cmake where we already added workarounds for HPPA. Until now > > we have not seen the problem on HP-UX, so this has been restricted to > > Linux until now. > > I considered putting it in there but from what I can tell, the issue is > specific to GCC code generation for PA-RISC, regardless of OS, and is > unrelated to Linux. Would you be able to verify whether or not this is > needed on PA-RISC HP-UX with GCC v4+? I only have access to an ia64 HP-UX > environment. We once had one HPPA-HP-UX system that reported to the dashboard, but using aCC. The machine died and I have not heard of a replacement yet. I guess it is just a matter of taste if this will be narrowed to Linux or not. In any case please try if you can just drop the existing workarounds. The best would probably to just replace their set() with yours and see if it works. If it does you can remove the if(Linux) and only match for the processor. Greetings, Eike -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From chuck.atkins at kitware.com Tue Nov 4 16:27:33 2014 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Tue, 4 Nov 2014 16:27:33 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: <9073452.koTdryVNNO@caliban.sf-tec.de> References: <2538149.Y82WuCOlBM@caliban.sf-tec.de> <9073452.koTdryVNNO@caliban.sf-tec.de> Message-ID: > > just a matter of taste if this will be narrowed to Linux or not. In any > case > please try if you can just drop the existing workarounds. The best would > probably to just replace their set() with yours and see if it works. If it > does you can remove the if(Linux) and only match for the processor. > I didn't realize the -Wl,--unique=.text._* was trying to address the same problem! I'll try this as a replacement tonight and we'll see if it cleans it up. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ewmailing at gmail.com Tue Nov 4 18:21:00 2014 From: ewmailing at gmail.com (Eric Wing) Date: Tue, 4 Nov 2014 15:21:00 -0800 Subject: [cmake-developers] [CMake] [ANNOUNCE] CMake 3.1.0-rc1 now ready for testing! In-Reply-To: References: <5453AA07.1000104@kitware.com> Message-ID: On 10/31/14, Gilles Khouzam wrote: > We actually have a couple if extra changes that are not fully ready to be > pushed upstream yet. > > ~Gilles > Sent from my Windows Phone Since I have your attention, using CMakeMS, I hit what looks like a bug in the generation for the Windows Phone simulator. I have not tested 3.1.0-rc1, but since it is the from the same code base, I'm assuming it is affected too. I get a linking failure for only the WinPhone simulator (Win32) binary. This is the error the linker is spitting out: vccorlib.lib(compiler.obj) : error LNK2038: mismatch detected for 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker': value '1' doesn't match '0' in MSVCRT.lib(appinit.obj) vccorlib.lib(compiler.obj) : error LNK2005: ___crtWinrtInitType already defined in MSVCRT.lib(appinit.obj) D:\\Release\FlappyBlurrr.exe : fatal error LNK1169: one or more multiply defined symbols found This only happens for me with the Win32 simulator binary. I do not have this problem with the ARM device binary, nor do I have this problem with the Windows Store x64 binary. (I do not bother with Win32 Windows Store.) Somebody helped me and told me to add these switches directly to my Visual Studio project: - for Debug builds, add: /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib - for Release builds, add: /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib This seemed to make my linking problems go away. I'm thinking that CMake should automatically be setting these for me for the Windows Phone simulator. Thanks, Eric -- Beginning iPhone Games Development http://playcontrol.net/iphonegamebook/ From tim.gallagher at gatech.edu Tue Nov 4 18:37:21 2014 From: tim.gallagher at gatech.edu (Tim Gallagher) Date: Tue, 4 Nov 2014 18:37:21 -0500 (EST) Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <900274826.25055487.1415135521782.JavaMail.root@mail.gatech.edu> Message-ID: <449492706.25156358.1415144241173.JavaMail.root@mail.gatech.edu> Hi Brad, I have attached the patch to enable the targets for Fortran. It includes updates to 2 tests to make sure that it works as expected. Both of the tests pass for me with Intel and GNU but that's all I have access to. Let me know if I messed anything up or if you have any suggestions on things I should have done better/differently so I know to do it correctly next time I have a patch. Thanks, Tim ----- Original Message ----- From: "Tim Gallagher" To: "tim gallagher" Cc: cmake-developers at cmake.org, "Brad King" Sent: Tuesday, November 4, 2014 4:12:01 PM Subject: Re: [cmake-developers] Assembly/preprocessed targets for Fortran Scratch that, I found it. Wasn't looking in the right places! The export command works for Fortran, so that's not an issue. I'll take a look at the testing and see if I can get that going. I'll send along a patch when I get it worked out. Thanks, Tim ----- Original Message ----- From: "Tim Gallagher" To: "Brad King" Cc: cmake-developers at cmake.org Sent: Tuesday, November 4, 2014 4:08:49 PM Subject: Re: [cmake-developers] Assembly/preprocessed targets for Fortran Hi Brad, Thanks for the info. What does the CMAKE_EXPORT_COMPILE_COMMANDS do? Or maybe more precisely, what output should I expect when it is set to ON instead of OFF? I tried it with my changes and nothing breaks, but I also don't see any difference in outputs with it set to ON so maybe I am missing something. I'll also dig into the testing to see what it would take to add the coverage. Thanks again, Tim ----- Original Message ----- From: "Brad King" To: "tim gallagher" , cmake-developers at cmake.org Sent: Tuesday, November 4, 2014 3:45:39 PM Subject: Re: [cmake-developers] Assembly/preprocessed targets for Fortran On 11/04/2014 03:19 PM, Tim Gallagher wrote: > I looked through the CMake source code and it didn't seem that > hard to make it work correctly for Fortran also. I made the > changes on my local branch and it works great for the Intel > and GNU compiler suites on Linux (those are the only ones I > have access to). I modified the other compiler modules on the > assumption that the options were the same for C, C++ and Fortran > source files (which is true for Intel and GNU). Great, thanks for looking into this. > adding "Fortran" to the check for "C" and "C++" when assigning > the `lang_is_c_or_cxx` variable. That variable name should change Perhaps "lang_has_preprocessor"? You could also add bool const lang_has_assembly = lang_has_preprocessor; and update each use of the variable to use the proper name. In the future the answer may not be the same. Watch out for other uses of lang_is_c_or_cxx, like for CMAKE_EXPORT_COMPILE_COMMANDS. Check if each use case makes sense for Fortran. > 2) How would/could I go about testing the changes to the other > compilers/platforms that I do not have personal access to? You could look at adding coverage of these make targets to the test suite under the proper conditions. That will likely be a harder change than your main fix though. Thanks, -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers -------------- next part -------------- A non-text attachment was scrubbed... Name: FortranAssemblyPreprocessor.patch Type: text/x-patch Size: 15482 bytes Desc: not available URL: From ewmailing at gmail.com Tue Nov 4 18:38:47 2014 From: ewmailing at gmail.com (Eric Wing) Date: Tue, 4 Nov 2014 15:38:47 -0800 Subject: [cmake-developers] [CMake] Forwarding parameters to cmake through cmake-gui In-Reply-To: References: <8D0A84A143D83B9-798-58886@webmail-m164.sysops.aol.com> <201311052036.08983.neundorf@kde.org> <8D0A88F2490D7CF-798-61E36@webmail-m164.sysops.aol.com> <543D585D-2052-489B-BA05-755C21694077@aol.com> <527AA7B2.2090103@kitware.com> Message-ID: Bump. With CMake 3.1 on the horizon, I was wondering if there was any progress on this. This would be really useful to me. I am basically invoking command line cmake.exe so I can pass all the right options, including my own CMake Initial Cache file. I ship an entire self-contained "SDK" of sorts which has all the prebuilt library dependencies in a place relative to a .bat or .sh script used to invoke cmake.exe, which makes project generation for all of my platforms essentially a turn-key operation. However, my projects have a couple of configurable options (e.g. I don't need to link in OpenAL), And it would be nice if I could present the CMake gui first so they can uncheck the options before generation. (I copy some things into the build directory on generation which means they get stuff they may not want if they can't uncheck the option first.) I think basically the behavior I want is essentially the same as ccmake, except have a proper GUI (a lot of Windows and newer users don't grok the curses thing). Thanks, Eric From ewmailing at gmail.com Tue Nov 4 19:46:50 2014 From: ewmailing at gmail.com (Eric Wing) Date: Tue, 4 Nov 2014 16:46:50 -0800 Subject: [cmake-developers] [CMake] [ANNOUNCE] CMake 3.1.0-rc1 now ready for testing! In-Reply-To: <33dd5601ba2845b7a1c1adf951522022@BY2PR0301MB0709.namprd03.prod.outlook.com> References: <5453AA07.1000104@kitware.com> <33dd5601ba2845b7a1c1adf951522022@BY2PR0301MB0709.namprd03.prod.outlook.com> Message-ID: On 11/4/14, Gilles Khouzam wrote: > Hi Eric, > > Can you send me a little more details or an example that exhibits the > problem? I'd be happy to take a look. > Sure. I'll respond offlist for this. Thanks, Eric From Gilles.Khouzam at microsoft.com Tue Nov 4 19:24:46 2014 From: Gilles.Khouzam at microsoft.com (Gilles Khouzam) Date: Wed, 5 Nov 2014 00:24:46 +0000 Subject: [cmake-developers] [CMake] [ANNOUNCE] CMake 3.1.0-rc1 now ready for testing! In-Reply-To: References: <5453AA07.1000104@kitware.com> Message-ID: <33dd5601ba2845b7a1c1adf951522022@BY2PR0301MB0709.namprd03.prod.outlook.com> Hi Eric, Can you send me a little more details or an example that exhibits the problem? I'd be happy to take a look. -----Original Message----- From: Eric Wing [mailto:ewmailing at gmail.com] Sent: Tuesday, November 4, 2014 15:21 To: Gilles Khouzam Cc: Brad King; Robert Maynard; CMake Developers; CMake MailingList Subject: Re: [CMake] [cmake-developers] [ANNOUNCE] CMake 3.1.0-rc1 now ready for testing! On 10/31/14, Gilles Khouzam wrote: > We actually have a couple if extra changes that are not fully ready to > be pushed upstream yet. > > ~Gilles > Sent from my Windows Phone Since I have your attention, using CMakeMS, I hit what looks like a bug in the generation for the Windows Phone simulator. I have not tested 3.1.0-rc1, but since it is the from the same code base, I'm assuming it is affected too. I get a linking failure for only the WinPhone simulator (Win32) binary. This is the error the linker is spitting out: vccorlib.lib(compiler.obj) : error LNK2038: mismatch detected for 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker': value '1' doesn't match '0' in MSVCRT.lib(appinit.obj) vccorlib.lib(compiler.obj) : error LNK2005: ___crtWinrtInitType already defined in MSVCRT.lib(appinit.obj) D:\\Release\FlappyBlurrr.exe : fatal error LNK1169: one or more multiply defined symbols found This only happens for me with the Win32 simulator binary. I do not have this problem with the ARM device binary, nor do I have this problem with the Windows Store x64 binary. (I do not bother with Win32 Windows Store.) Somebody helped me and told me to add these switches directly to my Visual Studio project: - for Debug builds, add: /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib - for Release builds, add: /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib This seemed to make my linking problems go away. I'm thinking that CMake should automatically be setting these for me for the Windows Phone simulator. Thanks, Eric -- Beginning iPhone Games Development http://playcontrol.net/iphonegamebook/ From mantis at public.kitware.com Tue Nov 4 23:15:24 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 4 Nov 2014 23:15:24 -0500 Subject: [cmake-developers] [CMake 0015234]: [Feature Request] Allow interface library have public header source Message-ID: The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15234 ====================================================================== Reported By: LAN Xingcan Assigned To: ====================================================================== Project: CMake Issue ID: 15234 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-04 23:15 EST Last Modified: 2014-11-04 23:15 EST ====================================================================== Summary: [Feature Request] Allow interface library have public header source Description: By allowing this. The public header installation needn't to be manually specified by INSTALL(FILES ...). And this make it more friendly for IDE to cooperating with CMake. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-04 23:15 LAN Xingcan New Issue ====================================================================== From daniele.domenichelli at gmail.com Wed Nov 5 03:58:24 2014 From: daniele.domenichelli at gmail.com (Daniele E. Domenichelli) Date: Wed, 05 Nov 2014 09:58:24 +0100 Subject: [cmake-developers] [Review request] Topic ExternalProject_SCM_DISCONNECTED Message-ID: <5459E6B0.4030505@gmail.com> Hello all, Please review the topic ExternalProject_SCM_DISCONNECTED. This patch adds a SCM_DISCONNECTED option to ExternalProject_Add. If SCM_DISCONNECTED is set, the update step is not executed automatically when building the main target. The update step can still be added as a step target and called manually. This is useful if you want to allow to build the project when you are disconnected from the network (you might still need the network for the download step). This is disabled by default. The directory property EP_SCM_DISCONNECTED can be used to change the default value for all the external projects in the current directory and its subdirectories. These are the commits in the topic: * ExternalProject: Always add a command to a step http://cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=b3983d18d * ExternalProject: Add SCM_DISCONNECTED option http://cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=7a7b29311 * ExternalProject: Add unit tests for SCM_DISCONNECTED http://cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=48b78695e Cheers, Daniele From tim at klingt.org Wed Nov 5 07:01:41 2014 From: tim at klingt.org (Tim Blechmann) Date: Wed, 05 Nov 2014 13:01:41 +0100 Subject: [cmake-developers] install(DIRECTORY) genex support Message-ID: hi all, i wonder, is there any reason for not supporting generator expressions for install(DIRECTORY)? i need this functionality to be able to install dSYM folders which are generated by xcode. if not, could someone review/merge this patch [1]? it is probably too late for 3.1, right? thanks a lot, tim [1] https://github.com/Kitware/CMake/pull/124 From brad.king at kitware.com Wed Nov 5 10:30:30 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 05 Nov 2014 10:30:30 -0500 Subject: [cmake-developers] [CMake] Forwarding parameters to cmake through cmake-gui In-Reply-To: References: <8D0A84A143D83B9-798-58886@webmail-m164.sysops.aol.com> <201311052036.08983.neundorf@kde.org> <8D0A88F2490D7CF-798-61E36@webmail-m164.sysops.aol.com> <543D585D-2052-489B-BA05-755C21694077@aol.com> <527AA7B2.2090103@kitware.com> Message-ID: <545A4296.5090900@kitware.com> On 11/04/2014 06:38 PM, Eric Wing wrote: > This would be really useful to me. No one plans to work on it AFAIK. You'd have to dig in yourself. Sorry, -Brad From chuck.atkins at kitware.com Wed Nov 5 10:38:14 2014 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Wed, 5 Nov 2014 10:38:14 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: References: <2538149.Y82WuCOlBM@caliban.sf-tec.de> <9073452.koTdryVNNO@caliban.sf-tec.de> Message-ID: So, it seems nothing changed. Looking at the log though, it looks like the flags aren't even getting used. Can you check the output of uname with it's various options? I suspect the result might not be exactly "parisc". - Chuck On Tue, Nov 4, 2014 at 4:27 PM, Chuck Atkins wrote: > just a matter of taste if this will be narrowed to Linux or not. In any >> case >> please try if you can just drop the existing workarounds. The best would >> probably to just replace their set() with yours and see if it works. If it >> does you can remove the if(Linux) and only match for the processor. >> > > I didn't realize the -Wl,--unique=.text._* was trying to address the same > problem! I'll try this as a replacement tonight and we'll see if it cleans > it up. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad.king at kitware.com Wed Nov 5 11:19:20 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 05 Nov 2014 11:19:20 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: References: <2538149.Y82WuCOlBM@caliban.sf-tec.de> <9073452.koTdryVNNO@caliban.sf-tec.de> Message-ID: <545A4E08.4090902@kitware.com> On 11/05/2014 10:38 AM, Chuck Atkins wrote: > So, it seems nothing changed. Looking at the log though, it > looks like the flags aren't even getting used. The value of cmake_machine_parisc is not set on HP-UX by the bootstrap script so it can only ever work on Linux right now. These changes broke the bootstrap script on non-Linux systems. I've extended the topic to fix that: bootstrap: Initialize cmake_machine_parisc on non-Linux systems http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=25bae877 Previously the variable was only ever used on Linux. You'll have to update the topic further to actually set the value of cmake_machine_parisc on HP-UX. -Brad From brad.king at kitware.com Wed Nov 5 11:26:26 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 05 Nov 2014 11:26:26 -0500 Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <449492706.25156358.1415144241173.JavaMail.root@mail.gatech.edu> References: <449492706.25156358.1415144241173.JavaMail.root@mail.gatech.edu> Message-ID: <545A4FB2.3050606@kitware.com> On 11/04/2014 06:37 PM, Tim Gallagher wrote: > I have attached the patch to enable the targets for Fortran. Thanks. Please update it to avoid using hard TABs for indentation. Also in the CompileCommandOutput test hunk: > -project (CompileCommandOutput CXX) > +project (CompileCommandOutput) > +enable_language(CXX) > +enable_language(Fortran) there are a couple problems: - By removing any explicit languages from the project() call it will enable C and CXX by default. Use NONE to suppress that. - We cannot assume that Fortran will be available. The other Fortran tests are all guarded by availability of a Fortran compiler. The test for CMAKE_EXPORT_COMPILE_COMMANDS was already missing for C, so let's just skip Fortran for the test too. They can be fixed together as a separate change later. Thanks, -Brad From brad.king at kitware.com Wed Nov 5 11:34:02 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 05 Nov 2014 11:34:02 -0500 Subject: [cmake-developers] install(DIRECTORY) genex support In-Reply-To: References: Message-ID: <545A517A.4030100@kitware.com> On 11/05/2014 07:01 AM, Tim Blechmann wrote: > i wonder, is there any reason for not supporting generator expressions > for install(DIRECTORY)? It just hasn't been implemented. Support for generator expressions was added to install(FILES) here: install: Support generator expressions in FILES and PROGRAMS mode http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6e89c8a5 and included in 3.0. Thanks for working on it. > it is probably too late for 3.1, right? Yes. We don't make non-doc/non-regression fixes after the feature freeze for the release, which is long past. > [1] https://github.com/Kitware/CMake/pull/124 Good start. Please extend documentation and tests for this feature similar to how it was done for install(FILES) in the above-linked commit. Then please read CONTRIBUTING.rst and send the patch to this list for further review. Thanks, -Brad From brad.king at kitware.com Wed Nov 5 11:39:44 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 05 Nov 2014 11:39:44 -0500 Subject: [cmake-developers] [Review request] Topic ExternalProject_SCM_DISCONNECTED In-Reply-To: <5459E6B0.4030505@gmail.com> References: <5459E6B0.4030505@gmail.com> Message-ID: <545A52D0.2030407@kitware.com> On 11/05/2014 03:58 AM, Daniele E. Domenichelli wrote: > If SCM_DISCONNECTED is set, the update step is not executed > automatically when building the main target. The update step can still > be added as a step target and called manually. Good feature. Would the name "UPDATE_INDEPENDENT" or "UPDATE_DISCONNECTED" make more sense? Otherwise, the topic looks ready for testing to me. Thanks, -Brad From tim at klingt.org Wed Nov 5 11:41:34 2014 From: tim at klingt.org (Tim Blechmann) Date: Wed, 05 Nov 2014 17:41:34 +0100 Subject: [cmake-developers] install(DIRECTORY) genex support In-Reply-To: <545A517A.4030100@kitware.com> References: <545A517A.4030100@kitware.com> Message-ID: hi brad, >> [1] https://github.com/Kitware/CMake/pull/124 > > Good start. Please extend documentation and tests for this feature > similar to how it was done for install(FILES) in the above-linked > commit. > > Then please read CONTRIBUTING.rst and send the patch to this list > for further review. thanks for the link regarding files/programs ... will update the patch in the next few days ... cheers, tim From eike at sf-mail.de Wed Nov 5 11:55:48 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Wed, 05 Nov 2014 17:55:48 +0100 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: References: Message-ID: <2139841.0mn74AEJGy@caliban.sf-tec.de> Am Mittwoch, 5. November 2014, 10:38:14 schrieben Sie: > So, it seems nothing changed. Looking at the log though, it looks like the > flags aren't even getting used. Can you check the output of uname with > it's various options? I suspect the result might not be exactly "parisc". voyager ~ # uname -a Linux voyager 3.16.1 #1 Tue Sep 2 17:27:07 CEST 2014 parisc PA8600 (PCX-W+) 9000/785/C3600 GNU/Linux voyager ~ # uname -m parisc -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From tim.gallagher at gatech.edu Wed Nov 5 12:14:50 2014 From: tim.gallagher at gatech.edu (Tim Gallagher) Date: Wed, 5 Nov 2014 12:14:50 -0500 (EST) Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <545A4FB2.3050606@kitware.com> Message-ID: <2132484579.25526211.1415207690914.JavaMail.root@mail.gatech.edu> Sorry about the TABs, I guess emacs defaults to it and I never noticed. I have attached an updated patch where the tabs are removed and the test for CMAKE_EXPORT_COMPILE_COMMANDS is also removed. Tim ----- Original Message ----- From: "Brad King" To: "tim gallagher" , cmake-developers at cmake.org Sent: Wednesday, November 5, 2014 11:26:26 AM Subject: Re: [cmake-developers] Assembly/preprocessed targets for Fortran On 11/04/2014 06:37 PM, Tim Gallagher wrote: > I have attached the patch to enable the targets for Fortran. Thanks. Please update it to avoid using hard TABs for indentation. Also in the CompileCommandOutput test hunk: > -project (CompileCommandOutput CXX) > +project (CompileCommandOutput) > +enable_language(CXX) > +enable_language(Fortran) there are a couple problems: - By removing any explicit languages from the project() call it will enable C and CXX by default. Use NONE to suppress that. - We cannot assume that Fortran will be available. The other Fortran tests are all guarded by availability of a Fortran compiler. The test for CMAKE_EXPORT_COMPILE_COMMANDS was already missing for C, so let's just skip Fortran for the test too. They can be fixed together as a separate change later. Thanks, -Brad -------------- next part -------------- A non-text attachment was scrubbed... Name: FortranAssemblyPreprocessor.patch Type: text/x-patch Size: 13938 bytes Desc: not available URL: From brad.king at kitware.com Wed Nov 5 12:55:04 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 05 Nov 2014 12:55:04 -0500 Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <2132484579.25526211.1415207690914.JavaMail.root@mail.gatech.edu> References: <2132484579.25526211.1415207690914.JavaMail.root@mail.gatech.edu> Message-ID: <545A6478.3040509@kitware.com> On 11/05/2014 12:14 PM, Tim Gallagher wrote: > I have attached an updated patch Thanks! Please split this into two patches. The first one should do the refactoring of the variable name and corresponding logic with no functionality changes. The second one can add the Fortran feature. Also please keep C++ source lines to 79 columns or below. The FortranOnly test fails for me with: f95: error: gfortran does not support -E without -cpp because it doesn't enable preprocessing for lower-case extensions. You'll need to add another .F test source with an upper-case extension to activate preprocessing without special flags. Thanks, -Brad From Geoffrey.Viola at asirobots.com Wed Nov 5 13:11:01 2014 From: Geoffrey.Viola at asirobots.com (Geoffrey Viola) Date: Wed, 5 Nov 2014 18:11:01 +0000 Subject: [cmake-developers] Initial Attempt at Green Hill MULTI IDE Generator Support In-Reply-To: <544E4C9F.3050408@kitware.com> References: <0543633b28c7431f93808182fc1e26e1@CO1PR07MB208.namprd07.prod.outlook.com> <543D2BBC.1010306@kitware.com> <0b5b33c4d1f0472782e260f9e5bce980@CO1PR07MB208.namprd07.prod.outlook.com> <544E4C9F.3050408@kitware.com> Message-ID: <64abd7ba273245b686146aa67acb7e8a@DM2PR0701MB1020.namprd07.prod.outlook.com> I rebased and squashed the previous commits and made some new changes. The GHS generator should now build a kernel and a monolith, which is necessary to autogenerate all the files necessary to compile. The generator determines that the executable target is a kernel based on a compiler flag and determines that it is a monolith if a file with an "int" ending is there. Also, there are a few changes to find boost libraries with this generator. Some of the code is C++11. I'm not sure if that is an issue. Also, it skips the step where it determines the compiler by using the force compiler macro. I don't see any other cmake module using this functionality. Geoffrey Viola SOFTWARE ENGINEER T +1.435.755.2980 ext 1077 M +1.215.896.6521 asirobots.com -----Original Message----- From: Brad King [mailto:brad.king at kitware.com] Sent: Monday, October 27, 2014 7:46 AM To: Geoffrey Viola Cc: cmake-developers at cmake.org Subject: Re: [cmake-developers] Initial Attempt at Green Hill MULTI IDE Generator Support On 10/14/2014 12:48 PM, Geoffrey Viola wrote: > Green Hills MULTI is an IDE for embedded real-time systems. > http://www.ghs.com/products/MULTI_IDE.html. > http://www.ghs.com/products/rtos/integrity.html. Thanks for the explanation. > I took a look at CMAKE_OSX_SYSROOT. It is similar to GHS_OS_DIR. > There may be a simpler way to represent these customizations, but I > don't know if there are any guarantees on standard folder structures > or names. [snip] > It seems there needs to be some development to use the find boost > module, because "CMAKE_FIND_LIBRARY_PREFIXES" is not set. Both of these should be addressed by creating the corresponding Modules/Platform/*.cmake files associated with the target platform. -Brad This message contains confidential information and is intended only for the recipient. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately if you have received this e-mail by mistake and delete this e-mail from your system. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Added-basic-and-partial-support-for-a-Green-Hill-MUL.patch Type: application/octet-stream Size: 50381 bytes Desc: 0001-Added-basic-and-partial-support-for-a-Green-Hill-MUL.patch URL: From tim.gallagher at gatech.edu Wed Nov 5 13:53:33 2014 From: tim.gallagher at gatech.edu (Tim Gallagher) Date: Wed, 5 Nov 2014 13:53:33 -0500 (EST) Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <545A6478.3040509@kitware.com> Message-ID: <958020373.25581068.1415213613735.JavaMail.root@mail.gatech.edu> Here's to hoping 3rd time's the charm... Also, what version of gfortran do you have that requires both -E and -cpp to do the preprocessing? I don't need that on my version, I'm using 4.7.1. There may need to be more sophisticated logic in the Compiler module to add -cpp to the command line for versions that require it. Tim ----- Original Message ----- From: "Brad King" To: "Tim Gallagher" Cc: cmake-developers at cmake.org Sent: Wednesday, November 5, 2014 12:55:04 PM Subject: Re: [cmake-developers] Assembly/preprocessed targets for Fortran On 11/05/2014 12:14 PM, Tim Gallagher wrote: > I have attached an updated patch Thanks! Please split this into two patches. The first one should do the refactoring of the variable name and corresponding logic with no functionality changes. The second one can add the Fortran feature. Also please keep C++ source lines to 79 columns or below. The FortranOnly test fails for me with: f95: error: gfortran does not support -E without -cpp because it doesn't enable preprocessing for lower-case extensions. You'll need to add another .F test source with an upper-case extension to activate preprocessing without special flags. Thanks, -Brad -------------- next part -------------- A non-text attachment was scrubbed... Name: TargetLogicRefactor.patch Type: text/x-patch Size: 4903 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: FortranAssemblyPreprocessor.patch Type: text/x-patch Size: 10762 bytes Desc: not available URL: From brad.king at kitware.com Wed Nov 5 14:19:06 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 05 Nov 2014 14:19:06 -0500 Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <958020373.25581068.1415213613735.JavaMail.root@mail.gatech.edu> References: <958020373.25581068.1415213613735.JavaMail.root@mail.gatech.edu> Message-ID: <545A782A.5040805@kitware.com> On 11/05/2014 01:53 PM, Tim Gallagher wrote: > Here's to hoping 3rd time's the charm... Thanks. Applied with minor tweaks: Makefile: Refactor checks for lang-specific targets and export compile cmds http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=06f8b429 Makefile: Add assembly and preprocessed targets for Fortran http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a811f014 and merged to 'next' for testing. > Also, what version of gfortran do you have that requires both -E > and -cpp to do the preprocessing? It is gfortran 4.9.1. Many other compilers have this too. Uppercase source extensions get preprocessed by default, lowercase extensions require -cpp. That is why Modules/CMakeFortranCompilerId.F.in uses an uppercase extension. -Brad From tim.gallagher at gatech.edu Wed Nov 5 14:32:29 2014 From: tim.gallagher at gatech.edu (Tim Gallagher) Date: Wed, 5 Nov 2014 14:32:29 -0500 (EST) Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <545A782A.5040805@kitware.com> Message-ID: <669456082.25602660.1415215949773.JavaMail.root@mail.gatech.edu> Great, thank you. Next time I won't have to go back and forth several times (I hope)! Tim ----- Original Message ----- From: "Brad King" To: "Tim Gallagher" Cc: cmake-developers at cmake.org Sent: Wednesday, November 5, 2014 2:19:06 PM Subject: Re: [cmake-developers] Assembly/preprocessed targets for Fortran On 11/05/2014 01:53 PM, Tim Gallagher wrote: > Here's to hoping 3rd time's the charm... Thanks. Applied with minor tweaks: Makefile: Refactor checks for lang-specific targets and export compile cmds http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=06f8b429 Makefile: Add assembly and preprocessed targets for Fortran http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a811f014 and merged to 'next' for testing. > Also, what version of gfortran do you have that requires both -E > and -cpp to do the preprocessing? It is gfortran 4.9.1. Many other compilers have this too. Uppercase source extensions get preprocessed by default, lowercase extensions require -cpp. That is why Modules/CMakeFortranCompilerId.F.in uses an uppercase extension. -Brad From brad.king at kitware.com Wed Nov 5 14:34:46 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 05 Nov 2014 14:34:46 -0500 Subject: [cmake-developers] Assembly/preprocessed targets for Fortran In-Reply-To: <669456082.25602660.1415215949773.JavaMail.root@mail.gatech.edu> References: <669456082.25602660.1415215949773.JavaMail.root@mail.gatech.edu> Message-ID: <545A7BD6.9020500@kitware.com> On 11/05/2014 02:32 PM, Tim Gallagher wrote: > Next time I won't have to go back and forth several times It's no problem. That's part of the code review process and is to be expected. Thanks for your patience with it. -Brad From brad.king at kitware.com Wed Nov 5 14:36:36 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 05 Nov 2014 14:36:36 -0500 Subject: [cmake-developers] Initial Attempt at Green Hill MULTI IDE Generator Support In-Reply-To: <64abd7ba273245b686146aa67acb7e8a@DM2PR0701MB1020.namprd07.prod.outlook.com> References: <0543633b28c7431f93808182fc1e26e1@CO1PR07MB208.namprd07.prod.outlook.com> <543D2BBC.1010306@kitware.com> <0b5b33c4d1f0472782e260f9e5bce980@CO1PR07MB208.namprd07.prod.outlook.com> <544E4C9F.3050408@kitware.com> <64abd7ba273245b686146aa67acb7e8a@DM2PR0701MB1020.namprd07.prod.outlook.com> Message-ID: <545A7C44.6040305@kitware.com> On 11/05/2014 01:11 PM, Geoffrey Viola wrote: > I rebased and squashed the previous commits and made some new changes. Thanks. Here are more comments. The hunk in Modules/CMakeSystemSpecificInformation.cmake is now just removing a blank line so it should not be needed. > +message("GHS-DetermineCompiler.cmake") This looks like a leftover debugging message. > there are a few changes to find boost libraries with this generator. [snip] > -if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) > +if ("Windows" STREQUAL ${CMAKE_HOST_SYSTEM_NAME} AND > + Boost_USE_STATIC_LIBS AND NOT CYGWIN) Why does the host affect the library prefix for binaries meant for the target platform? > Some of the code is C++11. I'm not sure if that is an issue. It is. We build on compilers that barely support C++98. > Also, it skips the step where it determines the compiler by using the > force compiler macro. I don't see any other cmake module using this > functionality. [snip] > +set(CMAKE_SYSTEM_NAME "GHS-MULTI") > +set(CMAKE_SYSTEM_PROCESSOR "ARM") ... > +include(CMakeForceCompiler) > +CMAKE_FORCE_CXX_COMPILER("cxarm" "GhsMultiArmCXX") Those APIs are meant for use in a CMAKE_TOOLCHAIN_FILE. The cmGlobalGhsMultiGenerator::EnableLanguage method should be able to take care of those. This is the first time we've had a generator that locks to a specific target platform (and implicitly cross-compiles). Is CMAKE_SYSTEM_VERSION always hard-coded on a given system or should the user be able to choose it in some way? Thanks, -Brad From peter at pcc.me.uk Wed Nov 5 16:12:13 2014 From: peter at pcc.me.uk (Peter Collingbourne) Date: Wed, 5 Nov 2014 13:12:13 -0800 Subject: [cmake-developers] [wip/patch] Expose Ninja console pool feature for custom commands/targets In-Reply-To: <20141104002256.GA29444@pcc.me.uk> References: <20141104002256.GA29444@pcc.me.uk> Message-ID: <20141105211213.GA9592@pcc.me.uk> On Mon, Nov 03, 2014 at 04:22:56PM -0800, Peter Collingbourne wrote: > Hi all, > > This patch exposes the Ninja console pool feature via the add_custom_command > and add_custom_target commands. Specifically, it introduces a USE_CONSOLE > flag which can be used to communicate to the generator that the command > would prefer to use the console. It has no effect on generators other than > the Ninja generator. I've added documentation and tests and addressed Ben's comments, and published the staging branch 'console-pool'. PTAL. Thanks, -- Peter From ben.boeckel at kitware.com Wed Nov 5 16:49:52 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Wed, 5 Nov 2014 16:49:52 -0500 Subject: [cmake-developers] [wip/patch] Expose Ninja console pool feature for custom commands/targets In-Reply-To: <20141105211213.GA9592@pcc.me.uk> References: <20141104002256.GA29444@pcc.me.uk> <20141105211213.GA9592@pcc.me.uk> Message-ID: <20141105214952.GA16571@erythro> On Wed, Nov 05, 2014 at 13:12:13 -0800, Peter Collingbourne wrote: > I've added documentation and tests and addressed Ben's comments, and published > the staging branch 'console-pool'. PTAL. Thanks for splitting the commits. For the testing of it, since only Ninja supports it, maybe it would be possible to run a program which exits testing for isatty(STDIN_FILENO) or isatty(STDOUT_FILENO). Looking at it again, it strikes me that maybe USES_CONSOLE would be better since it's more declarative (telling CMake about the command) than imperative (telling the command it may use the console). USES_CONSOLE may also be better and generators such as VS might know to error with "I don't offer a terminal to use" or tools such as Eclipse to hide these targets from their lists (though how CMake communicates the requirement is an open question). ...Which makes me think that MAY_USE_CONSOLE would be useful, but I don't think CMake should be saddled with the job of telling the command whether a terminal exists or not (and documented as such). "TERMINAL" rather than "CONSOLE" may also be more accurate (I feel "console" is being used because that happens to be the Ninja builtin pool name). Thoughts? --Ben From peter at pcc.me.uk Wed Nov 5 18:03:02 2014 From: peter at pcc.me.uk (Peter Collingbourne) Date: Wed, 5 Nov 2014 15:03:02 -0800 Subject: [cmake-developers] [wip/patch] Expose Ninja console pool feature for custom commands/targets In-Reply-To: <20141105214952.GA16571@erythro> References: <20141104002256.GA29444@pcc.me.uk> <20141105211213.GA9592@pcc.me.uk> <20141105214952.GA16571@erythro> Message-ID: <20141105230302.GB10722@pcc.me.uk> On Wed, Nov 05, 2014 at 04:49:52PM -0500, Ben Boeckel wrote: > On Wed, Nov 05, 2014 at 13:12:13 -0800, Peter Collingbourne wrote: > > I've added documentation and tests and addressed Ben's comments, and published > > the staging branch 'console-pool'. PTAL. > > Thanks for splitting the commits. > > For the testing of it, since only Ninja supports it, maybe it would be > possible to run a program which exits testing for isatty(STDIN_FILENO) > or isatty(STDOUT_FILENO). I considered that, and indeed this is how I tested the console pool feature in Ninja's test suite [1]. (That test disables itself if the test suite itself does not have access to the console.) The problem is that CTest does not give Ninja direct access to the console, so a test like the one Ninja uses wouldn't work, or at least it wouldn't provide coverage if the test suite is invoked in the normal way. I don't know enough about CTest to know if there is some way to get it to pass through console access. > Looking at it again, it strikes me that maybe USES_CONSOLE would be > better since it's more declarative (telling CMake about the command) > than imperative (telling the command it may use the console). > USES_CONSOLE may also be better and generators such as VS might know to > error with "I don't offer a terminal to use" or tools such as Eclipse to > hide these targets from their lists (though how CMake communicates the > requirement is an open question). ...Which makes me think that > MAY_USE_CONSOLE would be useful, but I don't think CMake should be > saddled with the job of telling the command whether a terminal exists or > not (and documented as such). "TERMINAL" rather than "CONSOLE" may also > be more accurate (I feel "console" is being used because that happens to > be the Ninja builtin pool name). > > Thoughts? I would rather keep things simple and have this flag always be opportunistic. Remember that the build tool could be invoked with or without a terminal, so I would expect commands to normally do something sensible if it turns out not to be available. We might want to have a mechanism to control whether targets appear in IDEs, but that seems like it should be a separate feature. I'm happy to change the name to USES_CONSOLE (or USES_TERMINAL, I don't really mind which). Thanks, -- Peter [1] https://github.com/martine/ninja/blob/master/src/subprocess_test.cc#L102 From ben.boeckel at kitware.com Wed Nov 5 18:35:25 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Wed, 5 Nov 2014 18:35:25 -0500 Subject: [cmake-developers] [wip/patch] Expose Ninja console pool feature for custom commands/targets In-Reply-To: <20141105230302.GB10722@pcc.me.uk> References: <20141104002256.GA29444@pcc.me.uk> <20141105211213.GA9592@pcc.me.uk> <20141105214952.GA16571@erythro> <20141105230302.GB10722@pcc.me.uk> Message-ID: <20141105233525.GA7567@erythro> On Wed, Nov 05, 2014 at 15:03:02 -0800, Peter Collingbourne wrote: > On Wed, Nov 05, 2014 at 04:49:52PM -0500, Ben Boeckel wrote: > > For the testing of it, since only Ninja supports it, maybe it would be > > possible to run a program which exits testing for isatty(STDIN_FILENO) > > or isatty(STDOUT_FILENO). > > I considered that, and indeed this is how I tested the console pool feature > in Ninja's test suite [1]. (That test disables itself if the test suite > itself does not have access to the console.) > > The problem is that CTest does not give Ninja direct access to the console, > so a test like the one Ninja uses wouldn't work, or at least it wouldn't > provide coverage if the test suite is invoked in the normal way. I don't know > enough about CTest to know if there is some way to get it to pass through > console access. Hrm. Forgot about that :( . The best I can think of is to have certain dashboards run it separately, but that means we still need some way to get it to the dashboard and for it *not* to run on the other dashboards as a always-fail (maybe WILL_FAIL TRUE to make sure it actually *detects* it?). Anyways, I wouldn't worry about it too much due to the many issues. > I would rather keep things simple and have this flag always be > opportunistic. Remember that the build tool could be invoked with or without > a terminal, so I would expect commands to normally do something sensible > if it turns out not to be available. We might want to have a mechanism to > control whether targets appear in IDEs, but that seems like it should be a > separate feature. Good point. It was more to get the ideas out in the air than a formal request for change. --Ben From daniele.domenichelli at gmail.com Wed Nov 5 18:57:54 2014 From: daniele.domenichelli at gmail.com (Daniele E. Domenichelli) Date: Thu, 06 Nov 2014 00:57:54 +0100 Subject: [cmake-developers] [Review request] Topic ExternalProject_SCM_DISCONNECTED In-Reply-To: <545A52D0.2030407@kitware.com> References: <5459E6B0.4030505@gmail.com> <545A52D0.2030407@kitware.com> Message-ID: <545AB982.1090705@gmail.com> On 05/11/14 17:39, Brad King wrote: > Would the name "UPDATE_INDEPENDENT" or "UPDATE_DISCONNECTED" > make more sense? Otherwise, the topic looks ready for testing > to me. "UPDATE_INDEPENDENT" might be confused with something related to "INDEPENDENT_STEP_TARGETS", so I'd rather choose between SCM_DISCONNECTED or UPDATE_DISCONNECTED... Both work for me. Let me know if I should rename it or if I should merge it to next. Cheers, Daniele From DLRdave at aol.com Thu Nov 6 07:27:23 2014 From: DLRdave at aol.com (David Cole) Date: Thu, 6 Nov 2014 07:27:23 -0500 Subject: [cmake-developers] [Review request] Topic ExternalProject_SCM_DISCONNECTED In-Reply-To: <545AB982.1090705@gmail.com> References: <5459E6B0.4030505@gmail.com> <545A52D0.2030407@kitware.com> <545AB982.1090705@gmail.com> Message-ID: I would prefer a name that begins with UPDATE_ if it only affects the update step. D On Wed, Nov 5, 2014 at 6:57 PM, Daniele E. Domenichelli < daniele.domenichelli at gmail.com> wrote: > On 05/11/14 17:39, Brad King wrote: > > Would the name "UPDATE_INDEPENDENT" or "UPDATE_DISCONNECTED" > > make more sense? Otherwise, the topic looks ready for testing > > to me. > > "UPDATE_INDEPENDENT" might be confused with something related to > "INDEPENDENT_STEP_TARGETS", so I'd rather choose between > SCM_DISCONNECTED or UPDATE_DISCONNECTED... Both work for me. > > Let me know if I should rename it or if I should merge it to next. > > Cheers, > Daniele > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake-developers > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad.king at kitware.com Thu Nov 6 08:25:09 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 06 Nov 2014 08:25:09 -0500 Subject: [cmake-developers] [Review request] Topic ExternalProject_SCM_DISCONNECTED In-Reply-To: References: <5459E6B0.4030505@gmail.com> <545A52D0.2030407@kitware.com> <545AB982.1090705@gmail.com> Message-ID: <545B76B5.30905@kitware.com> On 11/06/2014 07:27 AM, David Cole wrote: > I would prefer a name that begins with UPDATE_ if it only affects the update step. > > On Wed, Nov 5, 2014 at 6:57 PM, Daniele E. Domenichelli wrote: >> SCM_DISCONNECTED or UPDATE_DISCONNECTED... Both work for me. >> >> Let me know if I should rename it or if I should merge it to next. Let's go with UPDATE_DISCONNECTED. Thanks, -Brad From daniele.domenichelli at gmail.com Thu Nov 6 09:13:56 2014 From: daniele.domenichelli at gmail.com (Daniele E. Domenichelli) Date: Thu, 06 Nov 2014 15:13:56 +0100 Subject: [cmake-developers] [Review request] Topic ExternalProject_SCM_DISCONNECTED In-Reply-To: <545B76B5.30905@kitware.com> References: <5459E6B0.4030505@gmail.com> <545A52D0.2030407@kitware.com> <545AB982.1090705@gmail.com> <545B76B5.30905@kitware.com> Message-ID: <545B8224.5060201@gmail.com> On 06/11/14 14:25, Brad King wrote: > Let's go with UPDATE_DISCONNECTED. I renamed the option and the topic name and merged it to next for testing. Thanks, Daniele From chuck.atkins at kitware.com Thu Nov 6 10:37:25 2014 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Thu, 6 Nov 2014 10:37:25 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: <2139841.0mn74AEJGy@caliban.sf-tec.de> References: <2139841.0mn74AEJGy@caliban.sf-tec.de> Message-ID: Hi Eike, So, it seems that voyager has no issue, only pioneer, which I'm just taking as coincidence from differences in various binary sizes. However, from looking at the error log, the link line for cmake shows: /usr/bin/c++ -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W -Wshadow -Wpointer-arith -Wformat-security -Wundef -g CMakeFiles/cmake.dir/cmakemain.cxx.o CMakeFiles/cmake.dir/cmcmd.cxx.o -o ../bin/cmake -rdynamic libCMakeLib.a kwsys/libcmsys.a ../Utilities/cmexpat/libcmexpat.a ../Utilities/cmlibarchive/libarchive/libcmlibarchive.a ../Utilities/cmliblzma/libcmliblzma.a ../Utilities/cmbzip2/libcmbzip2.a ../Utilities/cmcompress/libcmcompress.a ../Utilities/cmcurl/libcmcurl.a ../Utilities/cmzlib/libcmzlib.a -ldl which doesn't show the addition of the -mlong-calls flag. This is a bit perplexing as it would seem to imply that some how the if conditions are not being satisfied. On pioneer, does cmake --system-information show the expected value for CMAKE_SYSTEM_PROCESSOR, CMAKE_C_COMPILER_ID, and CMAKE_CXX_COMPILER_ID, i.e. "parisc", "GNU", and "GNU" ? - Chuck On Wed, Nov 5, 2014 at 11:55 AM, Rolf Eike Beer wrote: > Am Mittwoch, 5. November 2014, 10:38:14 schrieben Sie: > > So, it seems nothing changed. Looking at the log though, it looks like > the > > flags aren't even getting used. Can you check the output of uname with > > it's various options? I suspect the result might not be exactly > "parisc". > > voyager ~ # uname -a > Linux voyager 3.16.1 #1 Tue Sep 2 17:27:07 CEST 2014 parisc PA8600 > (PCX-W+) 9000/785/C3600 GNU/Linux > voyager ~ # uname -m > parisc > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake-developers > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eike at sf-mail.de Thu Nov 6 10:54:15 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Thu, 06 Nov 2014 16:54:15 +0100 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: References: <2139841.0mn74AEJGy@caliban.sf-tec.de> Message-ID: <1435997.x5AfdUPNEC@caliban.sf-tec.de> Am Donnerstag, 6. November 2014, 10:37:25 schrieb Chuck Atkins: > Hi Eike, > > So, it seems that voyager has no issue, only pioneer, which I'm just taking > as coincidence from differences in various binary sizes. However, from > looking at the error log, the link line for cmake shows: > > /usr/bin/c++ -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W > -Wshadow -Wpointer-arith -Wformat-security -Wundef -g > CMakeFiles/cmake.dir/cmakemain.cxx.o CMakeFiles/cmake.dir/cmcmd.cxx.o -o > ../bin/cmake -rdynamic libCMakeLib.a kwsys/libcmsys.a > ../Utilities/cmexpat/libcmexpat.a > ../Utilities/cmlibarchive/libarchive/libcmlibarchive.a > ../Utilities/cmliblzma/libcmliblzma.a ../Utilities/cmbzip2/libcmbzip2.a > ../Utilities/cmcompress/libcmcompress.a ../Utilities/cmcurl/libcmcurl.a > ../Utilities/cmzlib/libcmzlib.a -ldl > > which doesn't show the addition of the -mlong-calls flag. This is a bit > perplexing as it would seem to imply that some how the if conditions are > not being satisfied. On pioneer, does cmake --system-information show the > expected value for CMAKE_SYSTEM_PROCESSOR, CMAKE_C_COMPILER_ID, and > CMAKE_CXX_COMPILER_ID, i.e. "parisc", "GNU", and "GNU" ? It says parisc64. I obviously never properly checked that when playing with my workaround code. Eike -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From chuck.atkins at kitware.com Thu Nov 6 10:58:36 2014 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Thu, 6 Nov 2014 10:58:36 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: <1435997.x5AfdUPNEC@caliban.sf-tec.de> References: <2139841.0mn74AEJGy@caliban.sf-tec.de> <1435997.x5AfdUPNEC@caliban.sf-tec.de> Message-ID: Aha! I'll change it to MATCHES instead of STREQUALS and that should do it since technically the issue is with both 32 and 64 bit architectures, it just might not have shown up yet on both. Perhaps the build name for the dashboard should be HPPA64 then instead HPPA32? - Chuck On Thu, Nov 6, 2014 at 10:54 AM, Rolf Eike Beer wrote: > Am Donnerstag, 6. November 2014, 10:37:25 schrieb Chuck Atkins: > > Hi Eike, > > > > So, it seems that voyager has no issue, only pioneer, which I'm just > taking > > as coincidence from differences in various binary sizes. However, from > > looking at the error log, the link line for cmake shows: > > > > /usr/bin/c++ -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W > > -Wshadow -Wpointer-arith -Wformat-security -Wundef -g > > CMakeFiles/cmake.dir/cmakemain.cxx.o CMakeFiles/cmake.dir/cmcmd.cxx.o -o > > ../bin/cmake -rdynamic libCMakeLib.a kwsys/libcmsys.a > > ../Utilities/cmexpat/libcmexpat.a > > ../Utilities/cmlibarchive/libarchive/libcmlibarchive.a > > ../Utilities/cmliblzma/libcmliblzma.a ../Utilities/cmbzip2/libcmbzip2.a > > ../Utilities/cmcompress/libcmcompress.a ../Utilities/cmcurl/libcmcurl.a > > ../Utilities/cmzlib/libcmzlib.a -ldl > > > > which doesn't show the addition of the -mlong-calls flag. This is a bit > > perplexing as it would seem to imply that some how the if conditions are > > not being satisfied. On pioneer, does cmake --system-information show > the > > expected value for CMAKE_SYSTEM_PROCESSOR, CMAKE_C_COMPILER_ID, and > > CMAKE_CXX_COMPILER_ID, i.e. "parisc", "GNU", and "GNU" ? > > It says parisc64. I obviously never properly checked that when playing > with my > workaround code. > > Eike -------------- next part -------------- An HTML attachment was scrubbed... URL: From eike at sf-mail.de Thu Nov 6 11:01:26 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Thu, 06 Nov 2014 17:01:26 +0100 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: References: <1435997.x5AfdUPNEC@caliban.sf-tec.de> Message-ID: <3340014.Yk7gHCtCBA@caliban.sf-tec.de> Am Donnerstag, 6. November 2014, 10:58:36 schrieben Sie: > Aha! I'll change it to MATCHES instead of STREQUALS and that should do it > since technically the issue is with both 32 and 64 bit architectures, it > just might not have shown up yet on both. Perhaps the build name for the > dashboard should be HPPA64 then instead HPPA32? I hate MATCHES ;) at least make it MATCHES "^parisc". The build name is HPPA32 because it is a 32 bit userspace, Linux/HPPA does not have a 64 bit one (yet?). Eike -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From chuck.atkins at kitware.com Thu Nov 6 11:22:34 2014 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Thu, 6 Nov 2014 11:22:34 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: <3340014.Yk7gHCtCBA@caliban.sf-tec.de> References: <1435997.x5AfdUPNEC@caliban.sf-tec.de> <3340014.Yk7gHCtCBA@caliban.sf-tec.de> Message-ID: > > I hate MATCHES ;) at least make it MATCHES "^parisc". > A reasonable compromise. The branch has been updated, merged, squashed, and remerged to next. We'll see what happens tonight. - Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad.king at kitware.com Thu Nov 6 11:27:16 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 06 Nov 2014 11:27:16 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: References: <1435997.x5AfdUPNEC@caliban.sf-tec.de> <3340014.Yk7gHCtCBA@caliban.sf-tec.de> Message-ID: <545BA164.6080401@kitware.com> On 11/06/2014 11:22 AM, Chuck Atkins wrote: > The branch has been updated, merged, squashed, and remerged to next Thanks. This hunk: > # Determine whether this is Linux > if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then > cmake_system_linux=true > # find out if it is a HP PA-RISC machine > if uname -m | grep parisc >/dev/null 2>&1; then > cmake_machine_parisc=true > else > cmake_machine_parisc=false > fi > else > cmake_system_linux=false > cmake_machine_parisc=false > fi Now sets an unused 'cmake_system_linux' variable and will never set 'cmake_machine_parisc' on non-Linux systems. Isn't the goal for this to work on HP-UX too? -Brad From mantis at public.kitware.com Thu Nov 6 11:57:43 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Thu, 6 Nov 2014 11:57:43 -0500 Subject: [cmake-developers] [CMake 0015235]: CMAKE_LD_FLAGS from toolchain is ignored by compiler's check Message-ID: <891aa0bdd71b92b65b5ae2a7ccb696c3@www.cmake.org> The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15235 ====================================================================== Reported By: Andrew Aladjev Assigned To: ====================================================================== Project: CMake Issue ID: 15235 Category: CMake Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-06 11:57 EST Last Modified: 2014-11-06 11:57 EST ====================================================================== Summary: CMAKE_LD_FLAGS from toolchain is ignored by compiler's check Description: I want to use gcc's thread sanitizer. I have toolchain.cmake set (CMAKE_SYSTEM_NAME "Linux") set (CMAKE_C_COMPILER "gcc-4.8.3") set (CMAKE_C_FLAGS "-fPIE -Werror -Wno-maybe-uninitialized -fsanitize=thread -fno-omit-frame-pointer" CACHE STRING "gcc-4.8.3 thread cflags") set (CMAKE_LD_FLAGS "-pie") Steps to Reproduce: cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake .. /usr/bin/gcc-4.8.3 -fPIE -Werror -Wno-maybe-uninitialized -fsanitize=thread -fno-omit-frame-pointer CMakeFiles/cmTryCompileExec3265698553.dir/testCCompiler.c.o -o cmTryCompileExec3265698553 -rdynamic gcc-4.8.3: error: -fsanitize=thread linking must be done with -pie or -shared CMAKE_C_FLAGS works, but CMAKE_LD_FLAGS is ignored. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-06 11:57 Andrew Aladjev New Issue ====================================================================== From chuck.atkins at kitware.com Thu Nov 6 12:00:12 2014 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Thu, 6 Nov 2014 12:00:12 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: <545BA164.6080401@kitware.com> References: <1435997.x5AfdUPNEC@caliban.sf-tec.de> <3340014.Yk7gHCtCBA@caliban.sf-tec.de> <545BA164.6080401@kitware.com> Message-ID: Rats! I keep forgetting about the bootstrap. I added an HP-UX block and adjusted the logic to be a bit more consistent with the other "determine system" blocks by moving the parisc determination out on it's own. How's this? # Determine whether this is HP-UX if echo "${cmake_system}" | grep HP-UX >/dev/null 2>&1; then cmake_system_hpux=true else cmake_system_hpux=false fi # Determine whether this is Linux if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then cmake_system_linux=true else cmake_system_linux=false fi # Determine whether this is a PA-RISC machine if ${cmake_system_linux}; then if uname -m | grep parisc >/dev/null 2>&1; then cmake_machine_parisc=true else cmake_machine_parisc=false fi elif ${cmake_system_hpux}; then if uname -m | grep ia64 >/dev/null 2>&1; then cmake_machine_parisc=false else cmake_machine_parisc=true fi fi - Chuck On Thu, Nov 6, 2014 at 11:27 AM, Brad King wrote: > On 11/06/2014 11:22 AM, Chuck Atkins wrote: > > The branch has been updated, merged, squashed, and remerged to next > > Thanks. This hunk: > > > # Determine whether this is Linux > > if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then > > cmake_system_linux=true > > # find out if it is a HP PA-RISC machine > > if uname -m | grep parisc >/dev/null 2>&1; then > > cmake_machine_parisc=true > > else > > cmake_machine_parisc=false > > fi > > else > > cmake_system_linux=false > > cmake_machine_parisc=false > > fi > > Now sets an unused 'cmake_system_linux' variable and will never > set 'cmake_machine_parisc' on non-Linux systems. Isn't the goal > for this to work on HP-UX too? > > -Brad > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad.king at kitware.com Thu Nov 6 12:44:12 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 06 Nov 2014 12:44:12 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: References: <1435997.x5AfdUPNEC@caliban.sf-tec.de> <3340014.Yk7gHCtCBA@caliban.sf-tec.de> <545BA164.6080401@kitware.com> Message-ID: <545BB36C.4090400@kitware.com> On 11/06/2014 12:00 PM, Chuck Atkins wrote: > I added an HP-UX block and adjusted the logic to be a bit more > consistent with the other "determine system" blocks Looks good to me, assuming the test for parisc on hpux is correct. -Brad From gjasny at googlemail.com Thu Nov 6 15:20:14 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Thu, 06 Nov 2014 21:20:14 +0100 Subject: [cmake-developers] [PATCH v2 0/2] Support for continue command In-Reply-To: <54593530.8040005@kitware.com> References: <545790E5.5090300@kitware.com> <1415131820-1721-1-git-send-email-gjasny@googlemail.com> <54593530.8040005@kitware.com> Message-ID: <545BD7FE.6090501@googlemail.com> On 04/11/14 21:21, Brad King wrote: > On 11/04/2014 03:10 PM, Gregor Jasny wrote: >> About the continue() outside of a block error: I added a test but I >> have no idea how to enforce the desired behavior. > > It's been a while since I looked at the relevant parts of the code > but here is one approach that may work: > > Find all call sites to cmMakefile::ExecuteCommand. Teach them to > check the resulting status argument for GetContinueInvoked. If it > is true for any call sites other than the loop implementations then > it is an error. I wonder if this will really work. Imaging the following: foreach(...) if(...) continue() endif() endforeach() As you can see in the patch the if command detects the continue invocation and aborts looping over the collected commands. It also bounces the continue to the outer inStatus execution status. IMHO what's needed is a in loop counter that counts how deep we are in a loop construct. It gets incremented within every foreach or while loop. Decremented with each endforeach or endwhile. Additionally new function, macro or includes will push the counter on a stack and reset it. I'd consider the following invalid: function(foo) continue() endfunction() foreach(...) foo() endforeach() Do you have and idea how to achieve this? I thought about storing the state in the cmExecutionStatus which gets pushed to the cmMakefile::CallStack. But the call stack is surprisingly empty at the continue() when I execute the following: if (1) if (1) continue () endif (1) endif (1) Another approach would be to hook into ExecuteCommand, but this misses all the endFoos. Thanks for your help, Gregor From brad.king at kitware.com Thu Nov 6 15:43:04 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 06 Nov 2014 15:43:04 -0500 Subject: [cmake-developers] [PATCH v2 0/2] Support for continue command In-Reply-To: <545BD7FE.6090501@googlemail.com> References: <545790E5.5090300@kitware.com> <1415131820-1721-1-git-send-email-gjasny@googlemail.com> <54593530.8040005@kitware.com> <545BD7FE.6090501@googlemail.com> Message-ID: <545BDD58.9000207@kitware.com> On 11/06/2014 03:20 PM, Gregor Jasny wrote: > As you can see in the patch the if command detects the continue > invocation and aborts looping over the collected commands. Right. > IMHO what's needed is a in loop counter that counts how deep we are in a > loop construct. It gets incremented within every foreach or while loop. > Decremented with each endforeach or endwhile. Take a look at uses of LexicalPushPop, ScopePushPop, and PolicyPushPop. Something similar may work for maintaining a loop nesting count. Thanks, -Brad From clinton at elemtech.com Thu Nov 6 17:23:27 2014 From: clinton at elemtech.com (Clinton Stimpson) Date: Thu, 06 Nov 2014 15:23:27 -0700 Subject: [cmake-developers] CMake 3.1 regression with incremental builds ? Message-ID: <4188908.TBkUtKrK5X@stryke> Using the netcdf project ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.3.2.tar.gz I see a problem with incremental builds doing a relink of libraries. Within my project, this leads to unnecessarily relinking of many executables every time I run cmake. For example: tar zxf netcdf-4.3.2.tar.gz cd netcdf-4.3.2 mkdir build cd build cmake ../ git init . git add . git commit -m"init" cmake ../ git diff These files have modifications in them which will lead to relinking. liblib/CMakeFiles/netcdf.dir/build.make liblib/CMakeFiles/netcdf.dir/link.txt I see object files listed in a random order. Perhaps there is a std::set used somewhere in CMake or something. I do not see this behavior with CMake 3.0.2. Clint From eike at sf-mail.de Thu Nov 6 17:27:30 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Thu, 06 Nov 2014 23:27:30 +0100 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: <545BB36C.4090400@kitware.com> References: <545BB36C.4090400@kitware.com> Message-ID: <6348761.UsCQIEF8Gn@caliban.sf-tec.de> Am Donnerstag, 6. November 2014, 12:44:12 schrieb Brad King: > On 11/06/2014 12:00 PM, Chuck Atkins wrote: > > I added an HP-UX block and adjusted the logic to be a bit more > > consistent with the other "determine system" blocks > > Looks good to me, assuming the test for parisc on hpux is correct. Chuck, you could try looking back into June/July to see what the HP-UX machine reported (hpux11.detec). On the other hand the check now only matches machines that are not Itanium, which is in theory 2 architectures, but I don't think that anyone can get CMake to work on an HP-UX m68k machine ;) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From DLRdave at aol.com Thu Nov 6 19:24:21 2014 From: DLRdave at aol.com (David Cole) Date: Thu, 6 Nov 2014 19:24:21 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: <6348761.UsCQIEF8Gn@caliban.sf-tec.de> References: <545BB36C.4090400@kitware.com> <6348761.UsCQIEF8Gn@caliban.sf-tec.de> Message-ID: These are the earliest CDash results available for CMake: http://open.cdash.org/index.php?project=CMake&date=2014-07-09 (they're discarded after 120 days...) On Thu, Nov 6, 2014 at 5:27 PM, Rolf Eike Beer wrote: > Am Donnerstag, 6. November 2014, 12:44:12 schrieb Brad King: > > On 11/06/2014 12:00 PM, Chuck Atkins wrote: > > > I added an HP-UX block and adjusted the logic to be a bit more > > > consistent with the other "determine system" blocks > > > > Looks good to me, assuming the test for parisc on hpux is correct. > > Chuck, you could try looking back into June/July to see what the HP-UX > machine > reported (hpux11.detec). On the other hand the check now only matches > machines > that are not Itanium, which is in theory 2 architectures, but I don't think > that anyone can get CMake to work on an HP-UX m68k machine ;) > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake-developers > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clinton at elemtech.com Thu Nov 6 23:09:35 2014 From: clinton at elemtech.com (clinton at elemtech.com) Date: Thu, 6 Nov 2014 21:09:35 -0700 (MST) Subject: [cmake-developers] CMake 3.1 regression with incremental builds ? In-Reply-To: <4188908.TBkUtKrK5X@stryke> References: <4188908.TBkUtKrK5X@stryke> Message-ID: <1402919500.1644277.1415333375867.JavaMail.zimbra@elemtech.com> I've put in a fix for this. 580b668d genex: Preserve order while evaluating TARGET_OBJECTS Can we put this in RC 2? Clint ----- Original Message ----- > > Using the netcdf project > ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.3.2.tar.gz > > I see a problem with incremental builds doing a relink of libraries. Within > my project, this leads to unnecessarily relinking of many executables every > time I run cmake. > > For example: > > tar zxf netcdf-4.3.2.tar.gz > cd netcdf-4.3.2 > mkdir build > cd build > cmake ../ > git init . > git add . > git commit -m"init" > cmake ../ > git diff > > > These files have modifications in them which will lead to relinking. > liblib/CMakeFiles/netcdf.dir/build.make > liblib/CMakeFiles/netcdf.dir/link.txt > > I see object files listed in a random order. Perhaps there is a std::set > used > somewhere in CMake or something. > > I do not see this behavior with CMake 3.0.2. > > Clint > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake-developers > From chuck.atkins at kitware.com Fri Nov 7 07:19:32 2014 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Fri, 7 Nov 2014 07:19:32 -0500 Subject: [cmake-developers] GCC HPPA linker errors In-Reply-To: References: <545BB36C.4090400@kitware.com> <6348761.UsCQIEF8Gn@caliban.sf-tec.de> Message-ID: While the dashboard may be red today from the curl update, it looks like this branch has cleared the linker issue and now pioneer and voyager are happily green together. On Nov 6, 2014 7:24 PM, "David Cole via cmake-developers" < cmake-developers at cmake.org> wrote: These are the earliest CDash results available for CMake: http://open.cdash.org/index.php?project=CMake&date=2014-07-09 (they're discarded after 120 days...) On Thu, Nov 6, 2014 at 5:27 PM, Rolf Eike Beer wrote: > Am Donnerstag, 6. November 2014, 12:44:12 schrieb Brad King: > > On 11/06/2014 12:00 PM, Chuck Atkins wrote: > > > I added an HP-UX block and adjusted the logic to be a bit more > > > consistent with the other "determine system" blocks > > > > Looks good to me, assuming the test for parisc on hpux is correct. > > Chuck, you could try looking back into June/July to see what the HP-UX > machine > reported (hpux11.detec). On the other hand the check now only matches > machines > that are not Itanium, which is in theory 2 architectures, but I don't think > that anyone can get CMake to work on an HP-UX m68k machine ;) > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake-developers > -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers -------------- next part -------------- An HTML attachment was scrubbed... URL: From DLRdave at aol.com Fri Nov 7 07:24:45 2014 From: DLRdave at aol.com (David Cole) Date: Fri, 7 Nov 2014 07:24:45 -0500 Subject: [cmake-developers] CMake 3.1 regression with incremental builds ? In-Reply-To: <1402919500.1644277.1415333375867.JavaMail.zimbra@elemtech.com> References: <4188908.TBkUtKrK5X@stryke> <1402919500.1644277.1415333375867.JavaMail.zimbra@elemtech.com> Message-ID: I just looked at the diff, not the surrounding code, so forgive the question if it's obvious when inspecting the code...... but here's a question about your change before we push it into RC 2: Is "objectSources" guaranteed to contain the same set of objects as "mapping"? If so, I wonder why the code calls: cmSourceFile* sf = context->Makefile->GetOrCreateSource(objFile, true); instead of simply using "map_it->first"? i.e. -- isn't the GetOrCreateSourceFile call superfluous if you have a pointer to the source file object in the iterator...? Or is it a "const" thing? Curious, David C. On Thu, Nov 6, 2014 at 11:09 PM, wrote: > > I've put in a fix for this. > 580b668d genex: Preserve order while evaluating TARGET_OBJECTS > > Can we put this in RC 2? > > Clint > > ----- Original Message ----- > > > > Using the netcdf project > > ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.3.2.tar.gz > > > > I see a problem with incremental builds doing a relink of libraries. Within > > my project, this leads to unnecessarily relinking of many executables every > > time I run cmake. > > > > For example: > > > > tar zxf netcdf-4.3.2.tar.gz > > cd netcdf-4.3.2 > > mkdir build > > cd build > > cmake ../ > > git init . > > git add . > > git commit -m"init" > > cmake ../ > > git diff > > > > > > These files have modifications in them which will lead to relinking. > > liblib/CMakeFiles/netcdf.dir/build.make > > liblib/CMakeFiles/netcdf.dir/link.txt > > > > I see object files listed in a random order. Perhaps there is a std::set > > used > > somewhere in CMake or something. > > > > I do not see this behavior with CMake 3.0.2. > > > > Clint > > -- > > > > Powered by www.kitware.com > > > > Please keep messages on-topic and check the CMake FAQ at: > > http://www.cmake.org/Wiki/CMake_FAQ > > > > Kitware offers various services to support the CMake community. For more > > information on each offering, please visit: > > > > CMake Support: http://cmake.org/cmake/help/support.html > > CMake Consulting: http://cmake.org/cmake/help/consulting.html > > CMake Training Courses: http://cmake.org/cmake/help/training.html > > > > Visit other Kitware open-source projects at > > http://www.kitware.com/opensource/opensource.html > > > > Follow this link to subscribe/unsubscribe: > > http://public.kitware.com/mailman/listinfo/cmake-developers > > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake-developers From brad.king at kitware.com Fri Nov 7 09:51:39 2014 From: brad.king at kitware.com (Brad King) Date: Fri, 07 Nov 2014 09:51:39 -0500 Subject: [cmake-developers] CMake 3.1 regression with incremental builds ? In-Reply-To: References: <4188908.TBkUtKrK5X@stryke> <1402919500.1644277.1415333375867.JavaMail.zimbra@elemtech.com> Message-ID: <545CDC7B.6030505@kitware.com> On Thu, Nov 6, 2014 at 11:09 PM, Clinton Stimpson wrote: > I've put in a fix for this. > 580b668d genex: Preserve order while evaluating TARGET_OBJECTS Thanks. I bisected it down to cmTarget: Allow any generator expression in SOURCES property. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e5da9e51 where the problem was exposed by using the generator expression to construct the list of sources. However, the problematic code was actually introduced at Genex: Evaluate TARGET_OBJECTS as a normal expression. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bf98cc25 Both of these were after 3.0 and before 3.1. > Can we put this in RC 2? Yes. I added some comments, revised the commit message, and merged to 'next' for testing: genex: Preserve order while evaluating TARGET_OBJECTS http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=caa4b7b8 On 11/07/2014 07:24 AM, David Cole via cmake-developers wrote: > Is "objectSources" guaranteed to contain the same set of objects as "mapping"? Yes. Just above this context, mapping[] is populated by iterating over objectSources. Then ComputeObjectFilenames is called to fill in the values of the map for each key. It does not change the set of keys. > isn't the GetOrCreateSourceFile call superfluous if you have a > pointer to the source file object in the iterator...? IIUC that is to create a cmSourceFile entry for the object file corresponding to the source file. They are different entries. -Brad From brad.king at kitware.com Fri Nov 7 09:58:08 2014 From: brad.king at kitware.com (Brad King) Date: Fri, 07 Nov 2014 09:58:08 -0500 Subject: [cmake-developers] pause on new topics, please Message-ID: <545CDE00.1010408@kitware.com> Hi Folks, Please refrain from adding new topics to 'next' until the current dashboard trouble has been resolved. Of course any dashboard fixes to current topics are still welcome, or new topics specifically fixing a 3.1 regression. I need to resolve the issues with the curl update and also get Clinton's 3.1 regression fix through. I will send another message when 'next' is open again. Thanks, -Brad From mantis at public.kitware.com Fri Nov 7 10:25:35 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Fri, 7 Nov 2014 10:25:35 -0500 Subject: [cmake-developers] [CMake 0015236]: CPACK_COMPONENT_GROUP can de-select required children Message-ID: The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15236 ====================================================================== Reported By: Richard Ulrich Assigned To: ====================================================================== Project: CMake Issue ID: 15236 Category: CPack Reproducibility: always Severity: feature Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-07 10:25 EST Last Modified: 2014-11-07 10:25 EST ====================================================================== Summary: CPACK_COMPONENT_GROUP can de-select required children Description: I have some required features inside a group. Now in the WiX installer, I cannot deselect the features separately, but I can de-select the group as a whole. I didn't find a way to make the group required. No idea how this bahaves with the other generators.. Steps to Reproduce: SET(CPACK_GENERATOR WIX) # documenting the components SET(CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "Runtimes") SET(CPACK_COMPONENT_RUNTIME_DESCRIPTION "!(loc.FeatDescRuntimes)") SET(CPACK_COMPONENT_BASE_DISPLAY_NAME "Base") SET(CPACK_COMPONENT_BASE_DESCRIPTION "!(loc.FeatDescBase)") SET(CPACK_COMPONENT_SHARED_DISPLAY_NAME "Shared") SET(CPACK_COMPONENT_SHARED_DESCRIPTION "!(loc.FeatDescShared)") SET(CPACK_COMPONENT_PYTHON_DISPLAY_NAME "Python") SET(CPACK_COMPONENT_PYTHON_DESCRIPTION "!(loc.FeatDescPython)") SET(CPACK_COMPONENT_CONVERTER_DISPLAY_NAME "Converter") SET(CPACK_COMPONENT_CONVERTER_DESCRIPTION "!(loc.FeatDescConverter)") SET(CPACK_COMPONENT_VIEWER_DISPLAY_NAME "Viewer") SET(CPACK_COMPONENT_VIEWER_DESCRIPTION "!(loc.FeatDescViewer)") SET(CPACK_COMPONENT_PL2D_DISPLAY_NAME "PointLine2D") SET(CPACK_COMPONENT_PL2D_DESCRIPTION "!(loc.FeatDescPointLine2D)") SET(CPACK_COMPONENT_PL3D_DISPLAY_NAME "PointLine3D") SET(CPACK_COMPONENT_PL3D_DESCRIPTION "!(loc.FeatDescPointLine3D)") # grouping SET(CPACK_COMPONENT_GROUP_REQUIREMENTS_DESCRIPTION "!(loc.FeatDescRequirements)") SET(CPACK_COMPONENT_RUNTIME_GROUP "Requirements") SET(CPACK_COMPONENT_BASE_GROUP "Requirements") SET(CPACK_COMPONENT_SHARED_GROUP "Requirements") SET(CPACK_COMPONENT_PYTHON_GROUP "Requirements") # requirements SET(CPACK_COMPONENT_RUNTIME_REQUIRED TRUE) SET(CPACK_COMPONENT_BASE_REQUIRED TRUE) SET(CPACK_COMPONENT_SHARED_REQUIRED TRUE) SET(CPACK_COMPONENT_PYTHON_REQUIRED FALSE) SET(CPACK_COMPONENT_CONVERTER_REQUIRED FALSE) SET(CPACK_COMPONENT_VIEWER_REQUIRED FALSE) SET(CPACK_COMPONENT_PL2D_REQUIRED FALSE) SET(CPACK_COMPONENT_PL3D_REQUIRED FALSE) translates to features.wxs : Additional Information: Wix does support hidden features, this would also solve the problem. http://wixtoolset.org/documentation/manual/v3/xsd/wix/feature.html -> Display:hidden So for my case, two different solutions could solve it: * SET(CPACK_COMPONENT_GROUP_REQUIREMENTS_REQUIRED TRUE) * SET(CPACK_COMPONENT_RUNTIME_HIDDEN TRUE) ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-07 10:25 Richard Ulrich New Issue ====================================================================== From ben.boeckel at kitware.com Fri Nov 7 11:43:47 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Fri, 7 Nov 2014 11:43:47 -0500 Subject: [cmake-developers] CMake 3.1 regression with incremental builds ? In-Reply-To: <545CDC7B.6030505@kitware.com> References: <4188908.TBkUtKrK5X@stryke> <1402919500.1644277.1415333375867.JavaMail.zimbra@elemtech.com> <545CDC7B.6030505@kitware.com> Message-ID: <20141107164347.GA9528@erythro> On Fri, Nov 07, 2014 at 09:51:39 -0500, Brad King wrote: > On Thu, Nov 6, 2014 at 11:09 PM, Clinton Stimpson wrote: > > isn't the GetOrCreateSourceFile call superfluous if you have a > > pointer to the source file object in the iterator...? > > IIUC that is to create a cmSourceFile entry for the object file > corresponding to the source file. They are different entries. Do we know the source file doesn't exist at this point? If so, CreateSourceFile would be better. --Ben From brad.king at kitware.com Fri Nov 7 11:52:45 2014 From: brad.king at kitware.com (Brad King) Date: Fri, 07 Nov 2014 11:52:45 -0500 Subject: [cmake-developers] CMake 3.1 regression with incremental builds ? In-Reply-To: <20141107164347.GA9528@erythro> References: <4188908.TBkUtKrK5X@stryke> <1402919500.1644277.1415333375867.JavaMail.zimbra@elemtech.com> <545CDC7B.6030505@kitware.com> <20141107164347.GA9528@erythro> Message-ID: <545CF8DD.2090603@kitware.com> On 11/07/2014 11:43 AM, Ben Boeckel wrote: >> IIUC that is to create a cmSourceFile entry for the object file >> corresponding to the source file. They are different entries. > > Do we know the source file doesn't exist at this point? If so, > CreateSourceFile would be better. My take: Normally it shouldn't because there should be exactly one object file per source file per target in a unique location. Steve? OTOH, it is possible that application code tries to set a property on an object file ahead of time. Thanks, -Brad From ben.boeckel at kitware.com Fri Nov 7 12:19:23 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Fri, 7 Nov 2014 12:19:23 -0500 Subject: [cmake-developers] CMake 3.1 regression with incremental builds ? In-Reply-To: <545CF8DD.2090603@kitware.com> References: <4188908.TBkUtKrK5X@stryke> <1402919500.1644277.1415333375867.JavaMail.zimbra@elemtech.com> <545CDC7B.6030505@kitware.com> <20141107164347.GA9528@erythro> <545CF8DD.2090603@kitware.com> Message-ID: <20141107171923.GA14037@erythro> On Fri, Nov 07, 2014 at 11:52:45 -0500, Brad King wrote: > OTOH, it is possible that application code tries to set a > property on an object file ahead of time. AFAIK, CMake doesn't expose where it stores these files and has always treated it as an internal detail. Is this something we promise compatibility on? --Ben From brad.king at kitware.com Fri Nov 7 12:44:54 2014 From: brad.king at kitware.com (Brad King) Date: Fri, 07 Nov 2014 12:44:54 -0500 Subject: [cmake-developers] CMake 3.1 regression with incremental builds ? In-Reply-To: <20141107171923.GA14037@erythro> References: <4188908.TBkUtKrK5X@stryke> <1402919500.1644277.1415333375867.JavaMail.zimbra@elemtech.com> <545CDC7B.6030505@kitware.com> <20141107164347.GA9528@erythro> <545CF8DD.2090603@kitware.com> <20141107171923.GA14037@erythro> Message-ID: <545D0516.3080208@kitware.com> On 11/07/2014 12:19 PM, Ben Boeckel wrote: > On Fri, Nov 07, 2014 at 11:52:45 -0500, Brad King wrote: >> OTOH, it is possible that application code tries to set a >> property on an object file ahead of time. > > AFAIK, CMake doesn't expose where it stores these files and has always > treated it as an internal detail. Is this something we promise > compatibility on? No. We just need to be sure we don't crash if they do try to set one and happen to guess the location. -Brad From mantis at public.kitware.com Fri Nov 7 15:20:59 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Fri, 7 Nov 2014 15:20:59 -0500 Subject: [cmake-developers] [CMake 0015237]: No CMAKE_C_COMPILER could be found (3.1.0-rc1 regression) Message-ID: The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15237 ====================================================================== Reported By: Ruslan Baratov Assigned To: ====================================================================== Project: CMake Issue ID: 15237 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-07 15:20 EST Last Modified: 2014-11-07 15:20 EST ====================================================================== Summary: No CMAKE_C_COMPILER could be found (3.1.0-rc1 regression) Description: Error while configuring project with Xcode 5.0.2 and CMake 3.1.0-rc1: -- The C compiler identification is AppleClang 5.0.0.5000279 -- The CXX compiler identification is AppleClang 5.0.0.5000279 CMake Error at CMakeLists.txt:2 (project): No CMAKE_C_COMPILER could be found. Steps to Reproduce: Create toolchain.cmake file: set(CMAKE_OSX_SYSROOT "iphoneos" CACHE STRING "" FORCE) set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") set(MACOSX_BUNDLE_GUI_IDENTIFIER com.example) set(CMAKE_MACOSX_BUNDLE YES) set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer") Create CMakeLists.txt: cmake_minimum_required(VERSION 3.0) project(Foo) Run build: cmake -H. -B_builds -GXcode -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake Additional Information: Works fine with CMake 3.0.2 ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-07 15:20 Ruslan Baratov New Issue ====================================================================== From domen.vrankar at gmail.com Sat Nov 8 16:17:53 2014 From: domen.vrankar at gmail.com (Domen Vrankar) Date: Sat, 8 Nov 2014 22:17:53 +0100 Subject: [cmake-developers] [CPack] [CPackRPM]patch for bug 15209 - handling of symbolic links Message-ID: Hi, Patch add support for symlink handling in RPM packages. Symlinks to directories and files are correctly recognized as such so directory symlinks are no longer prefixed with %dir. In case of relocatable RPM packages the patch also tries to make symlink as relocatable as possible by making a relative path symlink if needed. Please review the patch and post the feedback. If the patch is OK add it to repository. Thanks, Domen -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-CPackRPM-handling-of-symbolic-links.patch Type: text/x-diff Size: 12666 bytes Desc: not available URL: From mantis at public.kitware.com Sun Nov 9 04:42:11 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Sun, 9 Nov 2014 04:42:11 -0500 Subject: [cmake-developers] [CMake 0015238]: Add timestamp in seconds starts at the Unix Epoch on January 1st, 1970 at UTC. Message-ID: <7c65be2e3208c002731a9f1e35f6be54@public.kitware.com> The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15238 ====================================================================== Reported By: Dudi Assigned To: ====================================================================== Project: CMake Issue ID: 15238 Category: CMake Reproducibility: N/A Severity: feature Priority: low Status: new ====================================================================== Date Submitted: 2014-11-09 04:42 EST Last Modified: 2014-11-09 04:42 EST ====================================================================== Summary: Add timestamp in seconds starts at the Unix Epoch on January 1st, 1970 at UTC. Description: It would be great to add this small feature, it is often used (by me) for easy remember the compilation time (while making a build). I propose: string(TIMESTAMP "%e" [] [UTC]) It will return: 1415525945 ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-09 04:42 Dudi New Issue ====================================================================== From steveire at gmail.com Sun Nov 9 07:59:02 2014 From: steveire at gmail.com (Stephen Kelly) Date: Sun, 09 Nov 2014 13:59:02 +0100 Subject: [cmake-developers] CMake 3.1 regression with incremental builds ? In-Reply-To: <545CF8DD.2090603@kitware.com> References: <4188908.TBkUtKrK5X@stryke> <1402919500.1644277.1415333375867.JavaMail.zimbra@elemtech.com> <545CDC7B.6030505@kitware.com> <20141107164347.GA9528@erythro> <545CF8DD.2090603@kitware.com> Message-ID: <545F6516.7080800@gmail.com> On 11/07/2014 05:52 PM, Brad King wrote: > On 11/07/2014 11:43 AM, Ben Boeckel wrote: >>> IIUC that is to create a cmSourceFile entry for the object file >>> corresponding to the source file. They are different entries. >> Do we know the source file doesn't exist at this point? If so, >> CreateSourceFile would be better. > My take: Normally it shouldn't because there should be exactly one > object file per source file per target in a unique location. > > Steve? The above reasoning makes sense to me, but I guess someone would have to experiment with it. > OTOH, it is possible that application code tries to set a > property on an object file ahead of time. Indeed. Thanks, Steve. From daniele.domenichelli at gmail.com Sun Nov 9 12:05:22 2014 From: daniele.domenichelli at gmail.com (Daniele E. Domenichelli) Date: Sun, 09 Nov 2014 18:05:22 +0100 Subject: [cmake-developers] [Review Request][3.1-rc1 regression] topic fix_link-line-dedup_regression Message-ID: <545F9ED2.3010902@gmail.com> Hello, Please review topic fix_link-line-dedup_regression: Fix regression in link order introduced by the link-line-dedup topic Some compilers will fail linking if an executable is linking to a library that is not used and a static library that uses the shared one. This patch reverse the direction of the for loop that removes the duplicate shared libraries, in order to ensure that the last occurrence of the library is left instead of the first one. Also adds one unit test to show the issue. Cheers, Daniele From rleigh at codelibre.net Sun Nov 9 18:55:00 2014 From: rleigh at codelibre.net (Roger Leigh) Date: Sun, 9 Nov 2014 23:55:00 +0000 Subject: [cmake-developers] [PATCH] FindIntl: Module to find Gettext libintl headers and library Message-ID: <20141109235459.GJ20816@codelibre.net> Hi, I have attached an initial patch for adding support for Sun/Uniforum/GNU gettext libintl. This is likely better in cmake than upstream because there are: 1) multiple upstreams (Sun, GNU) 2) it may or may not be in the glibc C library depending upon the platform and build options used It could be argued that this belongs in the FindGettext module, which is currently restricted to the Gettext tools rather than the library and headers, and I'd certainly be fine with that. However, given the unusual nature of the library, I think the "_FOUND" variable should probably be separate given that it's perfectly OK to use libintl without the gettext tools (and vice versa), and they might not all be found. I've added cross references between the two in notes to make the relationship clearer. Regards, Roger -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools `- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800 -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-FindIntl-New-module-to-find-Gettext-libintl.patch Type: text/x-diff Size: 4019 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From brad.king at kitware.com Mon Nov 10 09:18:24 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Nov 2014 09:18:24 -0500 Subject: [cmake-developers] [Review Request][3.1-rc1 regression] topic fix_link-line-dedup_regression In-Reply-To: <545F9ED2.3010902@gmail.com> References: <545F9ED2.3010902@gmail.com> Message-ID: <5460C930.1080903@kitware.com> On 11/09/2014 12:05 PM, Daniele E. Domenichelli wrote: > Fix regression in link order introduced by the link-line-dedup topic Thanks. I revised the implementation slightly to avoid prepending to a vector on every iteration. I've merged to 'next' for testing: Fix link line order when shared libraries are de-duplicated http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c3589e1 Test linking to a shared lib needed only through a static lib http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a4716b6b The change and its explanation make sense. Please verify that it still fixes your original case after my modification. However, the test does not fail for me even without the fix. I think for 3.1.0-rc2 I will take this fix but not the test yet. Please extend the topic to revise the test: - See if it can be integrated into the Tests/Dependency test, perhaps as a new Case5 directory. - Convert the test implementation to use only C so that the test can be switched to "project (Dependency C)" as it should have been already. Thanks, -Brad From brad.king at kitware.com Mon Nov 10 10:49:18 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Nov 2014 10:49:18 -0500 Subject: [cmake-developers] [Review Request][3.1-rc1 regression] topic fix_link-line-dedup_regression In-Reply-To: <5460DDCA.2010100@gmail.com> References: <545F9ED2.3010902@gmail.com> <5460C930.1080903@kitware.com> <5460DDCA.2010100@gmail.com> Message-ID: <5460DE7E.4020000@kitware.com> On 11/10/2014 10:46 AM, Daniele E. Domenichelli wrote: >> - See if it can be integrated into the Tests/Dependency test, >> perhaps as a new Case5 directory. > > Done, see: > > Convert the test to use C only and move it into Tests/Dependency/Case5 > http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c875db31 Thanks. Please rename the 'foo' and 'bar' libs to 'case5Foo' and 'case5Bar' to avoid conflict with other cases in the future. > It should probably be squashed to a4716b6b... I will squash it all before merging to master or release. Thanks, -Brad From daniele.domenichelli at gmail.com Mon Nov 10 10:46:18 2014 From: daniele.domenichelli at gmail.com (Daniele E. Domenichelli) Date: Mon, 10 Nov 2014 16:46:18 +0100 Subject: [cmake-developers] [Review Request][3.1-rc1 regression] topic fix_link-line-dedup_regression In-Reply-To: <5460C930.1080903@kitware.com> References: <545F9ED2.3010902@gmail.com> <5460C930.1080903@kitware.com> Message-ID: <5460DDCA.2010100@gmail.com> On 10/11/14 15:18, Brad King wrote: > However, the test does not fail for me even without the fix. I > think for 3.1.0-rc2 I will take this fix but not the test yet. > Please extend the topic to revise the test: The test fails for me on a ubuntu precise chroot using gcc 4.6.3 (I wasn't able to reproduce it elsewhere). With the patch applied it succeeds. This is the output: --------------------------------------------------------------------- # ctest -VV -R LinkMixed UpdateCTestConfiguration from :/root/cmake/build/DartConfiguration.tcl Parse Config file:/root/cmake/build/DartConfiguration.tcl Add coverage exclude regular expressions. Add coverage exclude: XCode Add coverage exclude: Kdevelop Add coverage exclude: /Source/(cm|kw)sys/ Add coverage exclude: /CMakeFiles/CMakeTmp/ Add coverage exclude: [A-Za-z]./[Qq]t/qt-.+-opensource-src SetCTestConfiguration:CMakeCommand:/usr/local/bin/cmake UpdateCTestConfiguration from :/root/cmake/build/DartConfiguration.tcl Parse Config file:/root/cmake/build/DartConfiguration.tcl Test project /root/cmake/build Constructing a list of tests Guessing configuration NoConfig Done constructing a list of tests Checking test dependency graph... Checking test dependency graph end test 160 Start 160: LinkMixed 160: Test command: /root/cmake/build/bin/ctest "--build-and-test" "/root/cmake/Tests/LinkMixed" "/root/cmake/build/Tests/LinkMixed" "--build-generator" "Unix Makefiles" "--build-project" "LinkMixed" "--build-options" "-DCMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make" "--test-command" "exec" 160: Test timeout computed to be: 1500 160: Internal cmake changing into directory: /root/cmake/build/Tests/LinkMixed 160: ======== CMake output ====== 160: The C compiler identification is GNU 4.6.3 160: The CXX compiler identification is GNU 4.6.3 160: Check for working C compiler: /usr/bin/cc 160: Configuring 160: Check for working C compiler: /usr/bin/cc -- works 160: Detecting C compiler ABI info 160: Configuring 160: Detecting C compiler ABI info - done 160: Detecting C compile features 160: Detecting C compile features - done 160: Check for working CXX compiler: /usr/bin/c++ 160: Configuring 160: Check for working CXX compiler: /usr/bin/c++ -- works 160: Detecting CXX compiler ABI info 160: Configuring 160: Detecting CXX compiler ABI info - done 160: Detecting CXX compile features 160: Detecting CXX compile features - done 160: Configuring 160: Configuring done 160: Generating 160: Generating done 160: Build files have been written to: /root/cmake/build/Tests/LinkMixed 160: ======== End CMake output ====== 160: Change Dir: /root/cmake/build/Tests/LinkMixed 160: 160: Run Clean Command:"/usr/bin/make" "clean" 160: 160: Run Build Command:"/usr/bin/make" 160: Scanning dependencies of target lib1 160: [ 33%] Building CXX object CMakeFiles/lib1.dir/lib1.cpp.o 160: Linking CXX shared library liblib1.so 160: [ 33%] Built target lib1 160: Scanning dependencies of target lib2 160: [ 66%] Building CXX object CMakeFiles/lib2.dir/lib2.cpp.o 160: Linking CXX static library liblib2.a 160: [ 66%] Built target lib2 160: Scanning dependencies of target exec 160: [100%] Building CXX object CMakeFiles/exec.dir/main.cpp.o 160: Linking CXX executable exec 160: liblib2.a(lib2.cpp.o): In function `lib2::L2::bar()': 160: lib2.cpp:(.text+0xd): undefined reference to `lib1::L1::foo()' 160: collect2: ld returned 1 exit status 160: make[2]: *** [exec] Error 1 160: make[1]: *** [CMakeFiles/exec.dir/all] Error 2 160: make: *** [all] Error 2 1/1 Test #160: LinkMixed ........................***Failed 0.90 sec 0% tests passed, 1 tests failed out of 1 Total Test time (real) = 0.91 sec The following tests FAILED: 160 - LinkMixed (Failed) Errors while running CTest --------------------------------------------------------------------- > - See if it can be integrated into the Tests/Dependency test, > perhaps as a new Case5 directory. > > - Convert the test implementation to use only C so that the > test can be switched to "project (Dependency C)" as it should > have been already. Done, see: Convert the test to use C only and move it into Tests/Dependency/Case5 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c875db31 It should probably be squashed to a4716b6b... Cheers, Daniele From brad.king at kitware.com Mon Nov 10 11:36:14 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Nov 2014 11:36:14 -0500 Subject: [cmake-developers] pause on new topics, please In-Reply-To: <545CDE00.1010408@kitware.com> References: <545CDE00.1010408@kitware.com> Message-ID: <5460E97E.2000100@kitware.com> On 11/07/2014 09:58 AM, Brad King wrote: > I need to resolve the issues with the curl update and also > get Clinton's 3.1 regression fix through. This is done, but a couple more regression-fix topics now need to go through in preparation for 3.1.0-rc2, so please continue to hold off on new topics in 'next'. Thanks for your patience. -Brad From brad.king at kitware.com Mon Nov 10 11:44:37 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 10 Nov 2014 11:44:37 -0500 Subject: [cmake-developers] [CPack] [CPackRPM]patch for bug 15209 - handling of symbolic links In-Reply-To: References: Message-ID: <5460EB75.1010207@kitware.com> On 11/08/2014 04:17 PM, Domen Vrankar wrote: > Patch add support for symlink handling in RPM packages. > Symlinks to directories and files are correctly recognized as such so > directory symlinks are no longer prefixed with %dir. > In case of relocatable RPM packages the patch also tries to make > symlink as relocatable as possible by making a relative path symlink > if needed. Thanks. Please also look at extending the test suite with a case for this. There are several CPack RPM tests already. Also, since the rpm packaging tools are posix-specific anyway, perhaps it will be easier to maintain this transformation as a standard shell script. I don't feel strongly about this, but we have the option to do it that way. The script could be launched with execute_process. Thanks, -Brad From daniele.domenichelli at gmail.com Mon Nov 10 11:24:26 2014 From: daniele.domenichelli at gmail.com (Daniele E. Domenichelli) Date: Mon, 10 Nov 2014 17:24:26 +0100 Subject: [cmake-developers] [Review Request][3.1-rc1 regression] topic fix_link-line-dedup_regression In-Reply-To: <5460DE7E.4020000@kitware.com> References: <545F9ED2.3010902@gmail.com> <5460C930.1080903@kitware.com> <5460DDCA.2010100@gmail.com> <5460DE7E.4020000@kitware.com> Message-ID: <5460E6BA.7010201@gmail.com> On 10/11/14 16:49, Brad King wrote: > Thanks. Please rename the 'foo' and 'bar' libs to 'case5Foo' and > 'case5Bar' to avoid conflict with other cases in the future. Done: Rename the 'foo' and 'bar' libs to 'case5Foo' and 'case5Bar' http://www.cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=4fc05fd7 Cheers, Daniele From ruslan_baratov at yahoo.com Mon Nov 10 16:44:29 2014 From: ruslan_baratov at yahoo.com (Ruslan Baratov) Date: Tue, 11 Nov 2014 00:44:29 +0300 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <5453912F.6000305@kitware.com> References: <5431B11C.3010209@yahoo.com> <54329100.8020502@kitware.com> <54338CF1.3070304@yahoo.com> <5433DBC1.5080800@kitware.com> <5435257B.80201@yahoo.com> <543531CC.7090103@kitware.com> <5437C6CA.3030201@yahoo.com> <543BE40C.4000404@kitware.com> <544FFC83.4090107@yahoo.com> <5450F03F.2040500@kitware.com> <54538976.5050007@yahoo.com> <5453912F.6000305@kitware.com> Message-ID: <546131BD.4010402@yahoo.com> Done On 31-Oct-14 16:39, Brad King wrote: > On 10/31/2014 09:07 AM, Ruslan Baratov wrote: >> Does anybody ready to implement it or you want me to send the patches? > Please work on the patches. You can use "git format-patch" to format > them and post here either inline or as attachments. > > Thanks, > -Brad > -------------- next part -------------- >From b235db704545bee59952c491c14a7eb4a5bdcde6 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 7 Nov 2014 17:22:48 +0400 Subject: [PATCH 1/4] Add class cmFileLockResult --- Source/cmFileLockResult.cxx | 102 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockResult.h | 77 +++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 Source/cmFileLockResult.cxx create mode 100644 Source/cmFileLockResult.h diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx new file mode 100644 index 0000000..d6cb16e --- /dev/null +++ b/Source/cmFileLockResult.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 "cmFileLockResult.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); +} + +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 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..4d8f794 --- /dev/null +++ b/Source/cmFileLockResult.h @@ -0,0 +1,77 @@ +/*============================================================================ + 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 + +#if defined(_WIN32) +# include // 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(); + + bool IsOk() const; + std::string GetOutputMessage() const; + + private: + enum ErrorType + { + OK, + SYSTEM, + TIMEOUT, + ALREADY_LOCKED, + INTERNAL + }; + + cmFileLockResult(ErrorType type, Error errorValue); + + ErrorType Type; + Error ErrorValue; +}; + +#endif // cmFileLockResult_h -- 2.1.1 -------------- next part -------------- >From 8f9691b3bedf97bab1ac405ac44c24a05285ebc1 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 7 Nov 2014 17:33:30 +0400 Subject: [PATCH 2/4] Add class cmFileLock --- Source/cmFileLock.cxx | 76 +++++++++++++++++++++++++++ Source/cmFileLock.h | 72 ++++++++++++++++++++++++++ Source/cmFileLockUnix.cxx | 102 ++++++++++++++++++++++++++++++++++++ Source/cmFileLockWin32.cxx | 125 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 375 insertions(+) create mode 100755 Source/cmFileLock.cxx create mode 100644 Source/cmFileLock.h create mode 100755 Source/cmFileLockUnix.cxx create mode 100755 Source/cmFileLockWin32.cxx diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx new file mode 100755 index 0000000..a9116ff --- /dev/null +++ b/Source/cmFileLock.cxx @@ -0,0 +1,76 @@ +/*============================================================================ + 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 "cmFileLockResult.h" + +// Common implementation + +cmFileLock::~cmFileLock() +{ + if (!this->Filename.empty()) + { + const cmFileLockResult result = this->Release(); + 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(-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..3852f9a --- /dev/null +++ b/Source/cmFileLock.h @@ -0,0 +1,72 @@ +/*============================================================================ + 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 + +#if defined(_WIN32) +# include // HANDLE +#endif + +class cmFileLockResult; + +/** + * @brief Cross-platform file locking. + * @detail 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. + * @detail 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/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx new file mode 100755 index 0000000..5d10b3e --- /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 +#include // SEEK_SET +#include +#include // sleep + +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 != EAGAIN) + { + return cmFileLockResult::MakeSystem(); + } + } + else + { + return cmFileLockResult::MakeOk(); + } + if (seconds == 0) + { + return cmFileLockResult::MakeTimeout(); + } + --seconds; + ::sleep(1); + } +} + +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 = 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 100755 index 0000000..0beb272 --- /dev/null +++ b/Source/cmFileLockWin32.cxx @@ -0,0 +1,125 @@ +/*============================================================================ + 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 // CreateFile + +cmFileLock::cmFileLock(): File(INVALID_HANDLE_VALUE) +{ +} + +cmFileLockResult cmFileLock::Release() +{ + if (this->Filename.empty()) + { + return cmFileLockResult::MakeOk(); + } + const unsigned long len = static_cast(-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 = CreateFile( + cmsys::Encoding::ToWide(this->Filename.c_str()).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; + ::Sleep(1000); + } +} + +BOOL cmFileLock::LockFile(DWORD flags) +{ + const DWORD reserved = 0; + const unsigned long len = static_cast(-1); + static OVERLAPPED overlapped; + return LockFileEx( + this->File, + flags, + reserved, + len, + len, + &overlapped + ); +} -- 2.1.1 -------------- next part -------------- >From 32ee0f33c7de9fea4f5ff8d1efe854be2b6426c0 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 7 Nov 2014 17:37:02 +0400 Subject: [PATCH 3/4] Add class cmFileLockPool --- Source/cmFileLockPool.cxx | 190 ++++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockPool.h | 98 ++++++++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100755 Source/cmFileLockPool.cxx create mode 100644 Source/cmFileLockPool.h diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx new file mode 100755 index 0000000..42d26f1 --- /dev/null +++ b/Source/cmFileLockPool.cxx @@ -0,0 +1,190 @@ +/*============================================================================ + 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" + +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(); + } + assert(!this->FunctionScopes.empty()); + 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..86145ae --- /dev/null +++ b/Source/cmFileLockPool.h @@ -0,0 +1,98 @@ +/*============================================================================ + 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 + +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 List; + typedef List::iterator It; + typedef List::const_iterator CIt; + + List Locks; + }; + + typedef std::list List; + + typedef List::iterator It; + typedef List::const_iterator CIt; + + List FunctionScopes; + List FileScopes; + ScopePool ProcessScope; +}; + +#endif // cmFileLockPool_h -- 2.1.1 -------------- next part -------------- >From c1f3df2ef4903e29c85f5b95015473e437ece55f Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 7 Nov 2014 17:49:14 +0400 Subject: [PATCH 4/4] Add command 'file(LOCK ...)' --- Source/cmBootstrapCommands1.cxx | 3 + Source/cmFileCommand.cxx | 191 ++++++++++++++++++++++++++++++++++++++++ Source/cmFileCommand.h | 1 + Source/cmGlobalGenerator.h | 6 ++ Source/cmLocalGenerator.cxx | 2 + Source/cmMakefile.cxx | 4 + 6 files changed, 207 insertions(+) diff --git a/Source/cmBootstrapCommands1.cxx b/Source/cmBootstrapCommands1.cxx index 9093579..3742fac 100644 --- a/Source/cmBootstrapCommands1.cxx +++ b/Source/cmBootstrapCommands1.cxx @@ -45,6 +45,9 @@ #include "cmFindBase.cxx" #include "cmFindCommon.cxx" #include "cmFileCommand.cxx" +#include "cmFileLock.cxx" +#include "cmFileLockPool.cxx" +#include "cmFileLockResult.cxx" #include "cmFindFileCommand.cxx" #include "cmFindLibraryCommand.cxx" #include "cmFindPackageCommand.cxx" diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 7ebd750..4c61c2e 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -16,6 +16,7 @@ #include "cmInstallType.h" #include "cmFileTimeComparison.h" #include "cmCryptoHash.h" +#include "cmFileLockResult.h" #include "cmTimestamp.h" @@ -172,6 +173,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); @@ -3464,6 +3469,192 @@ bool cmFileCommand::HandleGenerateCommand( } //---------------------------------------------------------------------------- +bool cmFileCommand::HandleLockCommand( + std::vector const& args) +{ + // 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(-1); + + // Parse arguments + if(args.size() < 2) + { + this->SetError("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->SetError(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: \"" << args[i] << "\"."; + this->SetError(e.str()); + return false; + } + } + } + else if (args[i] == "RESULT_VARIABLE") + { + ++i; + if (i >= args.size()) + { + this->SetError(": expected variable name after RESULT_VARIABLE"); + return false; + } + resultVariable = args[i]; + } + else if (args[i] == "TIMEOUT") + { + ++i; + if (i >= args.size()) + { + this->SetError(": expected timeout value after TIMEOUT"); + return false; + } + int scanned; + if(sscanf(args[i].c_str(), "%d", &scanned) != 1 || scanned < 0) + { + cmOStringStream e; + e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer."; + this->SetError(e.str()); + return false; + } + timeout = static_cast(scanned); + } + else + { + cmOStringStream e; + e << ": expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT"; + e << ", but got: \"" << args[i] << "\"."; + this->SetError(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 \"" << parentDir << "\" creation failed "; + e << "(check permissions)."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + cmsys::ofstream file(path.c_str()); + if (!file.good()) + { + cmOStringStream e; + e << ": file \"" << path << "\" creation failed (check permissions)."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + file.close(); + + // 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 \"" << path << "\" (" << result << ")."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + + if (!resultVariable.empty()) + { + this->Makefile->AddDefinition(resultVariable, result.c_str()); + } + + return true; +} + +//---------------------------------------------------------------------------- bool cmFileCommand::HandleTimestampCommand( std::vector 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 const& args); bool HandleGenerateCommand(std::vector const& args); + bool HandleLockCommand(std::vector const& args); private: void AddEvaluationFile(const std::string &inputName, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ddd7e91..00ba9a0 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -21,6 +21,7 @@ #include "cmExportSetMap.h" // For cmExportSetMap #include "cmGeneratorTarget.h" #include "cmGeneratorExpression.h" +#include "cmFileLockPool.h" #if defined(CMAKE_BUILD_WITH_CMAKE) # include @@ -341,6 +342,8 @@ public: bool GenerateCPackPropertiesFile(); + cmFileLockPool& GetFileLockPool() { return FileLockPool; } + protected: virtual void Generate(); @@ -488,6 +491,9 @@ private: // track targets to issue CMP0042 warning for. std::set CMP0042WarnTargets; + + // Pool of file locks + cmFileLockPool FileLockPool; }; #endif diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 69b56c6..27cb8d0 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -79,9 +79,11 @@ public: this->GG = lg->GetGlobalGenerator(); this->LG = this->GG->GetCurrentLocalGenerator(); this->GG->SetCurrentLocalGenerator(lg); + this->GG->GetFileLockPool().PushFileScope(); } ~cmLocalGeneratorCurrent() { + this->GG->GetFileLockPool().PopFileScope(); this->GG->SetCurrentLocalGenerator(this->LG); } }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8a8aadc..a94c752 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4426,6 +4426,8 @@ void cmMakefile::PushScope() this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PushFunctionScope(); } void cmMakefile::PopScope() @@ -4463,6 +4465,8 @@ void cmMakefile::PopScope() { this->Internal->VarUsageStack.top().insert(*it); } + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PopFunctionScope(); } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) -- 2.1.1 From ruslan_baratov at yahoo.com Mon Nov 10 16:49:15 2014 From: ruslan_baratov at yahoo.com (Ruslan Baratov) Date: Tue, 11 Nov 2014 00:49:15 +0300 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <5453912F.6000305@kitware.com> References: <5431B11C.3010209@yahoo.com> <54329100.8020502@kitware.com> <54338CF1.3070304@yahoo.com> <5433DBC1.5080800@kitware.com> <5435257B.80201@yahoo.com> <543531CC.7090103@kitware.com> <5437C6CA.3030201@yahoo.com> <543BE40C.4000404@kitware.com> <544FFC83.4090107@yahoo.com> <5450F03F.2040500@kitware.com> <54538976.5050007@yahoo.com> <5453912F.6000305@kitware.com> Message-ID: <546132DB.7020209@yahoo.com> Done On 31-Oct-14 16:39, Brad King wrote: > On 10/31/2014 09:07 AM, Ruslan Baratov wrote: >> Does anybody ready to implement it or you want me to send the patches? > Please work on the patches. You can use "git format-patch" to format > them and post here either inline or as attachments. > > Thanks, > -Brad > -------------- next part -------------- >From b235db704545bee59952c491c14a7eb4a5bdcde6 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 7 Nov 2014 17:22:48 +0400 Subject: [PATCH 1/4] Add class cmFileLockResult --- Source/cmFileLockResult.cxx | 102 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockResult.h | 77 +++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 Source/cmFileLockResult.cxx create mode 100644 Source/cmFileLockResult.h diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx new file mode 100644 index 0000000..d6cb16e --- /dev/null +++ b/Source/cmFileLockResult.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 "cmFileLockResult.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); +} + +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 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..4d8f794 --- /dev/null +++ b/Source/cmFileLockResult.h @@ -0,0 +1,77 @@ +/*============================================================================ + 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 + +#if defined(_WIN32) +# include // 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(); + + bool IsOk() const; + std::string GetOutputMessage() const; + + private: + enum ErrorType + { + OK, + SYSTEM, + TIMEOUT, + ALREADY_LOCKED, + INTERNAL + }; + + cmFileLockResult(ErrorType type, Error errorValue); + + ErrorType Type; + Error ErrorValue; +}; + +#endif // cmFileLockResult_h -- 2.1.1 -------------- next part -------------- >From 8f9691b3bedf97bab1ac405ac44c24a05285ebc1 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 7 Nov 2014 17:33:30 +0400 Subject: [PATCH 2/4] Add class cmFileLock --- Source/cmFileLock.cxx | 76 +++++++++++++++++++++++++++ Source/cmFileLock.h | 72 ++++++++++++++++++++++++++ Source/cmFileLockUnix.cxx | 102 ++++++++++++++++++++++++++++++++++++ Source/cmFileLockWin32.cxx | 125 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 375 insertions(+) create mode 100755 Source/cmFileLock.cxx create mode 100644 Source/cmFileLock.h create mode 100755 Source/cmFileLockUnix.cxx create mode 100755 Source/cmFileLockWin32.cxx diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx new file mode 100755 index 0000000..a9116ff --- /dev/null +++ b/Source/cmFileLock.cxx @@ -0,0 +1,76 @@ +/*============================================================================ + 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 "cmFileLockResult.h" + +// Common implementation + +cmFileLock::~cmFileLock() +{ + if (!this->Filename.empty()) + { + const cmFileLockResult result = this->Release(); + 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(-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..3852f9a --- /dev/null +++ b/Source/cmFileLock.h @@ -0,0 +1,72 @@ +/*============================================================================ + 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 + +#if defined(_WIN32) +# include // HANDLE +#endif + +class cmFileLockResult; + +/** + * @brief Cross-platform file locking. + * @detail 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. + * @detail 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/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx new file mode 100755 index 0000000..5d10b3e --- /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 +#include // SEEK_SET +#include +#include // sleep + +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 != EAGAIN) + { + return cmFileLockResult::MakeSystem(); + } + } + else + { + return cmFileLockResult::MakeOk(); + } + if (seconds == 0) + { + return cmFileLockResult::MakeTimeout(); + } + --seconds; + ::sleep(1); + } +} + +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 = 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 100755 index 0000000..0beb272 --- /dev/null +++ b/Source/cmFileLockWin32.cxx @@ -0,0 +1,125 @@ +/*============================================================================ + 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 // CreateFile + +cmFileLock::cmFileLock(): File(INVALID_HANDLE_VALUE) +{ +} + +cmFileLockResult cmFileLock::Release() +{ + if (this->Filename.empty()) + { + return cmFileLockResult::MakeOk(); + } + const unsigned long len = static_cast(-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 = CreateFile( + cmsys::Encoding::ToWide(this->Filename.c_str()).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; + ::Sleep(1000); + } +} + +BOOL cmFileLock::LockFile(DWORD flags) +{ + const DWORD reserved = 0; + const unsigned long len = static_cast(-1); + static OVERLAPPED overlapped; + return LockFileEx( + this->File, + flags, + reserved, + len, + len, + &overlapped + ); +} -- 2.1.1 -------------- next part -------------- >From 32ee0f33c7de9fea4f5ff8d1efe854be2b6426c0 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 7 Nov 2014 17:37:02 +0400 Subject: [PATCH 3/4] Add class cmFileLockPool --- Source/cmFileLockPool.cxx | 190 ++++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockPool.h | 98 ++++++++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100755 Source/cmFileLockPool.cxx create mode 100644 Source/cmFileLockPool.h diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx new file mode 100755 index 0000000..42d26f1 --- /dev/null +++ b/Source/cmFileLockPool.cxx @@ -0,0 +1,190 @@ +/*============================================================================ + 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" + +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(); + } + assert(!this->FunctionScopes.empty()); + 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..86145ae --- /dev/null +++ b/Source/cmFileLockPool.h @@ -0,0 +1,98 @@ +/*============================================================================ + 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 + +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 List; + typedef List::iterator It; + typedef List::const_iterator CIt; + + List Locks; + }; + + typedef std::list List; + + typedef List::iterator It; + typedef List::const_iterator CIt; + + List FunctionScopes; + List FileScopes; + ScopePool ProcessScope; +}; + +#endif // cmFileLockPool_h -- 2.1.1 -------------- next part -------------- >From c1f3df2ef4903e29c85f5b95015473e437ece55f Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 7 Nov 2014 17:49:14 +0400 Subject: [PATCH 4/4] Add command 'file(LOCK ...)' --- Source/cmBootstrapCommands1.cxx | 3 + Source/cmFileCommand.cxx | 191 ++++++++++++++++++++++++++++++++++++++++ Source/cmFileCommand.h | 1 + Source/cmGlobalGenerator.h | 6 ++ Source/cmLocalGenerator.cxx | 2 + Source/cmMakefile.cxx | 4 + 6 files changed, 207 insertions(+) diff --git a/Source/cmBootstrapCommands1.cxx b/Source/cmBootstrapCommands1.cxx index 9093579..3742fac 100644 --- a/Source/cmBootstrapCommands1.cxx +++ b/Source/cmBootstrapCommands1.cxx @@ -45,6 +45,9 @@ #include "cmFindBase.cxx" #include "cmFindCommon.cxx" #include "cmFileCommand.cxx" +#include "cmFileLock.cxx" +#include "cmFileLockPool.cxx" +#include "cmFileLockResult.cxx" #include "cmFindFileCommand.cxx" #include "cmFindLibraryCommand.cxx" #include "cmFindPackageCommand.cxx" diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 7ebd750..4c61c2e 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -16,6 +16,7 @@ #include "cmInstallType.h" #include "cmFileTimeComparison.h" #include "cmCryptoHash.h" +#include "cmFileLockResult.h" #include "cmTimestamp.h" @@ -172,6 +173,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); @@ -3464,6 +3469,192 @@ bool cmFileCommand::HandleGenerateCommand( } //---------------------------------------------------------------------------- +bool cmFileCommand::HandleLockCommand( + std::vector const& args) +{ + // 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(-1); + + // Parse arguments + if(args.size() < 2) + { + this->SetError("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->SetError(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: \"" << args[i] << "\"."; + this->SetError(e.str()); + return false; + } + } + } + else if (args[i] == "RESULT_VARIABLE") + { + ++i; + if (i >= args.size()) + { + this->SetError(": expected variable name after RESULT_VARIABLE"); + return false; + } + resultVariable = args[i]; + } + else if (args[i] == "TIMEOUT") + { + ++i; + if (i >= args.size()) + { + this->SetError(": expected timeout value after TIMEOUT"); + return false; + } + int scanned; + if(sscanf(args[i].c_str(), "%d", &scanned) != 1 || scanned < 0) + { + cmOStringStream e; + e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer."; + this->SetError(e.str()); + return false; + } + timeout = static_cast(scanned); + } + else + { + cmOStringStream e; + e << ": expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT"; + e << ", but got: \"" << args[i] << "\"."; + this->SetError(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 \"" << parentDir << "\" creation failed "; + e << "(check permissions)."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + cmsys::ofstream file(path.c_str()); + if (!file.good()) + { + cmOStringStream e; + e << ": file \"" << path << "\" creation failed (check permissions)."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + file.close(); + + // 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 \"" << path << "\" (" << result << ")."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + + if (!resultVariable.empty()) + { + this->Makefile->AddDefinition(resultVariable, result.c_str()); + } + + return true; +} + +//---------------------------------------------------------------------------- bool cmFileCommand::HandleTimestampCommand( std::vector 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 const& args); bool HandleGenerateCommand(std::vector const& args); + bool HandleLockCommand(std::vector const& args); private: void AddEvaluationFile(const std::string &inputName, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ddd7e91..00ba9a0 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -21,6 +21,7 @@ #include "cmExportSetMap.h" // For cmExportSetMap #include "cmGeneratorTarget.h" #include "cmGeneratorExpression.h" +#include "cmFileLockPool.h" #if defined(CMAKE_BUILD_WITH_CMAKE) # include @@ -341,6 +342,8 @@ public: bool GenerateCPackPropertiesFile(); + cmFileLockPool& GetFileLockPool() { return FileLockPool; } + protected: virtual void Generate(); @@ -488,6 +491,9 @@ private: // track targets to issue CMP0042 warning for. std::set CMP0042WarnTargets; + + // Pool of file locks + cmFileLockPool FileLockPool; }; #endif diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 69b56c6..27cb8d0 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -79,9 +79,11 @@ public: this->GG = lg->GetGlobalGenerator(); this->LG = this->GG->GetCurrentLocalGenerator(); this->GG->SetCurrentLocalGenerator(lg); + this->GG->GetFileLockPool().PushFileScope(); } ~cmLocalGeneratorCurrent() { + this->GG->GetFileLockPool().PopFileScope(); this->GG->SetCurrentLocalGenerator(this->LG); } }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8a8aadc..a94c752 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4426,6 +4426,8 @@ void cmMakefile::PushScope() this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PushFunctionScope(); } void cmMakefile::PopScope() @@ -4463,6 +4465,8 @@ void cmMakefile::PopScope() { this->Internal->VarUsageStack.top().insert(*it); } + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PopFunctionScope(); } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) -- 2.1.1 From domen.vrankar at gmail.com Mon Nov 10 17:32:38 2014 From: domen.vrankar at gmail.com (Domen Vrankar) Date: Mon, 10 Nov 2014 23:32:38 +0100 Subject: [cmake-developers] [CPack] [CPackRPM]patch for bug 15209 - handling of symbolic links In-Reply-To: <5460EB75.1010207@kitware.com> References: <5460EB75.1010207@kitware.com> Message-ID: 2014-11-10 17:44 GMT+01:00 Brad King : > On 11/08/2014 04:17 PM, Domen Vrankar wrote: >> Patch add support for symlink handling in RPM packages. >> Symlinks to directories and files are correctly recognized as such so >> directory symlinks are no longer prefixed with %dir. >> In case of relocatable RPM packages the patch also tries to make >> symlink as relocatable as possible by making a relative path symlink >> if needed. > > Thanks. Please also look at extending the test suite with a > case for this. There are several CPack RPM tests already. I'll add the tests to the patch. > Also, since the rpm packaging tools are posix-specific anyway, > perhaps it will be easier to maintain this transformation as a > standard shell script. I don't feel strongly about this, but > we have the option to do it that way. The script could be > launched with execute_process. I've just noticed that I can remove a large part of the patch (attached) and replace it with a single file command. I'll try to shorten the patch even further and than if it will still be too long and complex I'll consider replacing it with a shell script. Domen -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-CPackRPM-handling-of-symbolic-links.patch Type: text/x-diff Size: 10739 bytes Desc: not available URL: From mantis at public.kitware.com Tue Nov 11 06:53:45 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 11 Nov 2014 06:53:45 -0500 Subject: [cmake-developers] [CMake 0015239]: Escape %3B in preprocessor definitions Message-ID: <7105a44724ee7aa859e981700305d407@public.kitware.com> The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15239 ====================================================================== Reported By: DavidSto Assigned To: ====================================================================== Project: CMake Issue ID: 15239 Category: CMake Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-11 06:53 EST Last Modified: 2014-11-11 06:53 EST ====================================================================== Summary: Escape %3B in preprocessor definitions Description: Bug fix: http://www.cmake.org/pipermail/cmake-commits/2013-April/014836.html (Escape ; as %3B in preprocessor definitions - replace ; with %3B) breaks the preprocessor definitions in Visual Studio 2012 (VS11) It generates one line instead line breaks. For example: "NDEBUG%3BwxDEBUG_LEVEL=0%3BFULLVERSION" instead of NDEBUG wxDEBUG_LEVEL=0 FULLVERSION (with line breaks) Steps to Reproduce: set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} "wxDEBUG_LEVEL=0;FULLVERSION") set(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} "wxDEBUG_LEVEL=0;FULLVERSION") ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-11 06:53 DavidSto New Issue ====================================================================== From mantis at public.kitware.com Tue Nov 11 10:04:23 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 11 Nov 2014 10:04:23 -0500 Subject: [cmake-developers] [CMake 0015240]: When compiling CUDA *.cu code, NVCC uses CXX_FLAGS when it should be using C_FLAGS Message-ID: <8fd1057b8b716d3691f28d2c02f461b3@public.kitware.com> The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15240 ====================================================================== Reported By: jeremyherbert Assigned To: ====================================================================== Project: CMake Issue ID: 15240 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-11 10:04 EST Last Modified: 2014-11-11 10:04 EST ====================================================================== Summary: When compiling CUDA *.cu code, NVCC uses CXX_FLAGS when it should be using C_FLAGS Description: When compiling cu files with cmake, it applies CXX_FLAGS to C compilation. See the attached main.cu and CMakeLists.txt for an example. This can lead to unnecessary warnings and errors as seen below: $ make -- Configuring done -- Generating done -- Build files have been written to: /home/jeremy/optix/jaguar/tmp/build [ 50%] Building NVCC (Device) object CMakeFiles/a_test.dir/a_test_generated_main.cu.o cc1: warning: command line option ?-std=c++11? is valid for C++/ObjC++ but not for C [enabled by default] cc1: warning: command line option ?-std=c++11? is valid for C++/ObjC++ but not for C [enabled by default] [100%] Building NVCC intermediate link file CMakeFiles/a_test.dir/a_test_intermediate_link.o Linking CXX executable a_test [100%] Built target a_test $ if you use the -v option of nvcc, you can see that cmake is indeed applying the wrong arguments to "gcc -x c": ... #$ "/usr/bin"/gcc-4.8 -D__CUDA_ARCH__=200 -E -x c -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDACC__ -D__NVCC__ -D__CUDACC_RDC__ -D__CUDANVVM__ -std=c++11 -g -fPIC -g -fexceptions -fPIC -D__CUDA_PREC_DIV -D__CUDA_PREC_SQRT -I"/usr/local/cuda-6.5/include" -I"/usr/local/cuda-6.5/targets/x86_64-linux/include" -I"/usr/local/cuda-6.5/include" "-I/usr/local/cuda-6.5/bin/../targets/x86_64-linux/include" -m64 -g -gdwarf-2 -o "/tmp/tmpxft_00003aee_00000000-7_main.cpp2.i" "/tmp/tmpxft_00003aee_00000000-3_main.cudafe1.gpu" cc1: warning: command line option ?-std=c++11? is valid for C++/ObjC++ but not for C [enabled by default] ... Steps to Reproduce: cmake the attached files. Additional Information: see http://stackoverflow.com/questions/26867352/cant-get-rid-of-warning-command-line-option-std-c11-using-nvcc-cuda-cma/26867522#26867522 ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-11 10:04 jeremyherbert New Issue 2014-11-11 10:04 jeremyherbert File Added: example.zip ====================================================================== From mantis at public.kitware.com Tue Nov 11 12:51:05 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 11 Nov 2014 12:51:05 -0500 Subject: [cmake-developers] [CMake 0015241]: Replace TEST_AFTER_INSTALL / TEST_BEFORE_INSTALL with TEST_COMMAND_AFTER_INSTALL / TEST_COMMAND_BEFORE_INSTALL Message-ID: <6c9bcd49f980de81668495b46e0b045c@www.cmake.org> The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15241 ====================================================================== Reported By: Ilya Assigned To: ====================================================================== Project: CMake Issue ID: 15241 Category: CMake Reproducibility: always Severity: feature Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-11 12:51 EST Last Modified: 2014-11-11 12:51 EST ====================================================================== Summary: Replace TEST_AFTER_INSTALL / TEST_BEFORE_INSTALL with TEST_COMMAND_AFTER_INSTALL / TEST_COMMAND_BEFORE_INSTALL Description: It's not clear why one have to choose at all whether he wants to run test before or after install. There are circumstances when it makes sense to have both. While it's possible to use ExternalProject_Add_Step in such case, I believe TEST_COMMAND_AFTER_INSTALL / TEST_COMMAND_BEFORE_INSTALL is far more straightforward solution. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-11 12:51 Ilya New Issue ====================================================================== From mantis at public.kitware.com Tue Nov 11 13:00:54 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 11 Nov 2014 13:00:54 -0500 Subject: [cmake-developers] [CMake 0015242]: Teach the "cmake -E echo" command to write to a file. Message-ID: <2bbb01812b6702f5c3c8a85dd74522f0@www.cmake.org> The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15242 ====================================================================== Reported By: Ilya Assigned To: ====================================================================== Project: CMake Issue ID: 15242 Category: CMake Reproducibility: always Severity: feature Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-11 13:00 EST Last Modified: 2014-11-11 13:00 EST ====================================================================== Summary: Teach the "cmake -E echo" command to write to a file. Description: There are commands to create files, copy files and print strings to stdout. And cmake already supports the file(WRITE) command. Having a cross-platform solution to write to files or at least to create files with content would be awesome. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-11 13:00 Ilya New Issue ====================================================================== From brad.king at kitware.com Tue Nov 11 13:03:41 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Nov 2014 13:03:41 -0500 Subject: [cmake-developers] pause on new topics, please In-Reply-To: <5460E97E.2000100@kitware.com> References: <545CDE00.1010408@kitware.com> <5460E97E.2000100@kitware.com> Message-ID: <54624F7D.2000009@kitware.com> On 11/10/2014 11:36 AM, Brad King wrote: > This is done, but a couple more regression-fix topics now need to > go through in preparation for 3.1.0-rc2, so please continue to > hold off on new topics in 'next'. This is all done so 'next' is now open for new topics! Thanks, -Brad From brad.king at kitware.com Tue Nov 11 13:04:08 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Nov 2014 13:04:08 -0500 Subject: [cmake-developers] [PATCH] FindIntl: Module to find Gettext libintl headers and library In-Reply-To: <20141109235459.GJ20816@codelibre.net> References: <20141109235459.GJ20816@codelibre.net> Message-ID: <54624F98.8000002@kitware.com> On 11/09/2014 06:55 PM, Roger Leigh wrote: > I have attached an initial patch for adding support for Sun/Uniforum/GNU > gettext libintl. Applied with minor tweaks and merged to 'next' for testing: FindIntl: New module to find Gettext libintl http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c5e797db Thanks, -Brad From brad.king at kitware.com Tue Nov 11 13:28:18 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 11 Nov 2014 13:28:18 -0500 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <546132DB.7020209@yahoo.com> References: <5431B11C.3010209@yahoo.com> <54329100.8020502@kitware.com> <54338CF1.3070304@yahoo.com> <5433DBC1.5080800@kitware.com> <5435257B.80201@yahoo.com> <543531CC.7090103@kitware.com> <5437C6CA.3030201@yahoo.com> <543BE40C.4000404@kitware.com> <544FFC83.4090107@yahoo.com> <5450F03F.2040500@kitware.com> <54538976.5050007@yahoo.com> <5453912F.6000305@kitware.com> <546132DB.7020209@yahoo.com> Message-ID: <54625542.8050808@kitware.com> On 11/10/2014 04:49 PM, Ruslan Baratov wrote: > On 31-Oct-14 16:39, Brad King wrote: >> Please work on the patches. You can use "git format-patch" to format >> them and post here either inline or as attachments. >> > Done Thanks for working on it. Good start. Here are some comments so far: * All headers and sources need to include cmStandardIncludes.h first, directly or indirectly through other headers. It can affect the way certain standard library headers are preprocessed on some platforms, and needs to be consistent across all translation units. * Please add the .cxx files to 'bootstrap' and Source/CMakeLists.txt rather than including them in cmBootstrapCommands*.cxx. * The windows header should be included in lower case . * The cerrno and cstdio headers need to be just errno.h and stdio.h to work on some of the older compilers. * Please add documentation to Help/command/file.rst and anywhere else that is appropriate. * Please add test cases for all APIs and error cases, probably in Tests/RunCMake/file using the RunCMake infrastructure. Thanks, -Brad From mantis at public.kitware.com Tue Nov 11 14:24:18 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 11 Nov 2014 14:24:18 -0500 Subject: [cmake-developers] [CMake 0015243]: /EHs-c- or /EHs- /EHc- as COMPILE_FLAGS target property does not remove /EHsc from the global CMAKE_CXX_FLAGS Message-ID: The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15243 ====================================================================== Reported By: Rodrigo Hernandez Assigned To: ====================================================================== Project: CMake Issue ID: 15243 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-11 14:24 EST Last Modified: 2014-11-11 14:24 EST ====================================================================== Summary: /EHs-c- or /EHs- /EHc- as COMPILE_FLAGS target property does not remove /EHsc from the global CMAKE_CXX_FLAGS Description: Sometimes when adding external projects replacing /EHsc with /EHs-c- to disable exceptions on CMAKE_CXX_FLAGS is not an option because it may break the external project, but when adding /EHs-c- or /EHs- /EHc- to the COMPILE_FLAGS property of the local project, the /EHsc flag remains, causing compiler command line warnings: cl : Command line warning D9025: overriding '/EHs' with '/EHs-' cl : Command line warning D9025: overriding '/EHc' with '/EHc-' This does not seem to happen when /GR- is set, in that case the global flag from CMAKE_CXX_FLAGS seems to vanish. Steps to Reproduce: add_executable( test test.cpp ) set_target_properties(test PROPERTIES COMPILE_FLAGS "/EHs-c- /D_HAS_EXCEPTIONS=0 /GR-") Additional Information: The provided file contains a minimal project on which the issue is reproduced. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-11 14:24 Rodrigo HernandezNew Issue 2014-11-11 14:24 Rodrigo HernandezFile Added: NoExceptions.zip ====================================================================== From domen.vrankar at gmail.com Tue Nov 11 18:16:16 2014 From: domen.vrankar at gmail.com (Domen Vrankar) Date: Wed, 12 Nov 2014 00:16:16 +0100 Subject: [cmake-developers] string SUBSTRING TRUNCATE mode Message-ID: Hi, I wrote a patch that adds functionality to string SUBSTRING command: string(SUBSTRING [TRUNCATE]) When TRUNCATE is set this is valid: cmake_minimum_required (VERSION 3.0) project(string_test) set(test_str "abcd") string(SUBSTRING ${test_str} 2 6 substr TRUNCATE) message(${test_str}) message(${substr}) If length is set to a higher value than the length of the original string the substring is still created but its end is the end of original string. If this functionality would be welcome I'll write the tests and documentation. TRUNCATE could also be renamed to SHORTEN or something more appropriate since we aren't truncating the string but are just lowering the length parameter. Suggestions are welcome. Thanks, Domen -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-String-substring-truncate.patch Type: text/x-diff Size: 2559 bytes Desc: not available URL: From mantis at public.kitware.com Tue Nov 11 19:21:18 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 11 Nov 2014 19:21:18 -0500 Subject: [cmake-developers] [CMake 0015244]: Add "cmake -E patch" command line option and "file(PATCH)" command Message-ID: <5b58d58dc801db4bdb8375f2b1d915f1@www.cmake.org> The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15244 ====================================================================== Reported By: Daniele E. Domenichelli Assigned To: ====================================================================== Project: CMake Issue ID: 15244 Category: CMake Reproducibility: N/A Severity: feature Priority: low Status: new ====================================================================== Date Submitted: 2014-11-11 19:21 EST Last Modified: 2014-11-11 19:21 EST ====================================================================== Summary: Add "cmake -E patch" command line option and "file(PATCH)" command Description: The ExternalProject module accepts a "PATCH_COMMAND" argument to apply a patch to a project. In another scenario, one would like be to able to apply a patch to a downloaded file. Unfortunately neither of these goal can be achieved easily in a portable way. - The "patch" command is usually not available on windows. - "git apply", "hg import", etc work on every platform, but only work for git, mercurial repositories, etc. and don't work for downloaded archives and files. It would be nice to have a command line option like "cmake -E patch" to apply a patch, that accepts the most commonly used options of the "patch" command (at least -p, -l, -R, and -i). This would ensure that the "PATCH_COMMAND" will work on every platform. The "file" command could have a new PATCH argument that accepts(at least) an input file, the working directory, a STRIP argument (-p1), an IGNORE_WHITESPACE, and a REVERSE option. The signature could be something like this: file(PATCH filename working_dir [STRIP levels] [IGNORE_WHITESPACE] [REVERSE]) This could be used to patch a file after downloading it with "file(DOWNLOAD)" ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-11 19:21 Daniele E. DomenichelliNew Issue ====================================================================== From mantis at public.kitware.com Tue Nov 11 20:54:47 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 11 Nov 2014 20:54:47 -0500 Subject: [cmake-developers] [CMake 0015245]: Add support for LTO Message-ID: The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15245 ====================================================================== Reported By: Ilya Assigned To: ====================================================================== Project: CMake Issue ID: 15245 Category: CMake Reproducibility: always Severity: feature Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-11 20:54 EST Last Modified: 2014-11-11 20:54 EST ====================================================================== Summary: Add support for LTO Description: When compiling both with LTO and debugging symbols enabled (at least in clang) one must supply the -object_path_lto option: -object_path_lto filename When performing Link Time Optimization (LTO) and a temporary mach-o object file is needed, if this option is used, the temporary file will be stored at the specified path and remain after the link is complete. Without the option, the linker picks a path and deletes the object file before the linker tool completes, thus tools such as the debugger or dsymutil will not be able to access the DWARF debug info in the temporary object file. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-11 20:54 Ilya New Issue ====================================================================== From mantis at public.kitware.com Tue Nov 11 20:57:33 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 11 Nov 2014 20:57:33 -0500 Subject: [cmake-developers] [CMake 0015246]: Better support for autotools directory paths Message-ID: <19a055c7f5c029518b36e948a3b959c8@public.kitware.com> The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15246 ====================================================================== Reported By: Jessica Hamilton Assigned To: ====================================================================== Project: CMake Issue ID: 15246 Category: CMake Reproducibility: always Severity: feature Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-11 20:57 EST Last Modified: 2014-11-11 20:57 EST ====================================================================== Summary: Better support for autotools directory paths Description: CMake basically only supports the --prefix option found in configure/autotools based scripts, which leads to users of CMake to hardcode a bunch of paths that are configurable under traditional configure/autotools based projects. This is a big problem for porting projects using CMake to Haiku, as the paths are different to what is required on Haiku. For example, pretty much every CMake based project hardcodes @CMAKE_INSTALL_PREFIX@/include all over the place. This location does not exist on Haiku, nor is it searched for. For autotools based projects, it is a simple matter of specifying --includedir=/boot/system/develop/headers, just as we do for the other locations. Can CMake please introduce the needed variables to be able to define these locations, so that projects can be updated to use them as they should. Having to patch/workaround EVERY CMake based project is a nightmare, when the build system should take care of this automatically. Additional Information: Introduce variables along the lines of CMAKE_INSTALL_PREFIX: - CMAKE_INSTALL_BINDIR - CMAKE_INSTALL_LIBDIR - CMAKE_INSTALL_INCLUDEDIR ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-11 20:57 Jessica HamiltonNew Issue ====================================================================== From syohex at gmail.com Wed Nov 12 02:17:07 2014 From: syohex at gmail.com (Syohei YOSHIDA) Date: Wed, 12 Nov 2014 16:17:07 +0900 Subject: [cmake-developers] syntax of '_' should be treated as symbol Message-ID: <1415776627-28137-1-git-send-email-syohex@gmail.com> Word commands, such as foward-word(M-f), backward-kill-word(M-backspace), don't work well like other major-modes if syntax of '_' is treated as "word". --- Auxiliary/cmake-mode.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el index c8b9f8b..f1470f3 100644 --- a/Auxiliary/cmake-mode.el +++ b/Auxiliary/cmake-mode.el @@ -202,7 +202,7 @@ the indentation. Otherwise it retains the same position on the line" ;; Keyword highlighting regex-to-face map. ;; (defconst cmake-font-lock-keywords - (list '("^[ \t]*\\(\\w+\\)[ \t]*(" 1 font-lock-function-name-face)) + (list '("^[ \t]*\\([[:word:]_]+\\)[ \t]*(" 1 font-lock-function-name-face)) "Highlighting expressions for CMAKE mode." ) @@ -241,7 +241,6 @@ the indentation. Otherwise it retains the same position on the line" ; Create the syntax table (setq cmake-mode-syntax-table (make-syntax-table)) (set-syntax-table cmake-mode-syntax-table) - (modify-syntax-entry ?_ "w" cmake-mode-syntax-table) (modify-syntax-entry ?\( "()" cmake-mode-syntax-table) (modify-syntax-entry ?\) ")(" cmake-mode-syntax-table) (modify-syntax-entry ?# "<" cmake-mode-syntax-table) -- 2.1.0 From syohex at gmail.com Wed Nov 12 02:27:10 2014 From: syohex at gmail.com (Syohei Yoshida) Date: Wed, 12 Nov 2014 16:27:10 +0900 Subject: [cmake-developers] syntax of '_' should be treated as symbol In-Reply-To: <1415776627-28137-1-git-send-email-syohex@gmail.com> References: <1415776627-28137-1-git-send-email-syohex@gmail.com> Message-ID: I created git animations about this patch. Please see them. Original version does not stop at underscore by word commands such as forward-word. On the other hands, fixed version stops at underscore. This behavior is same as other major-modes. [Original] https://gist.github.com/syohex/a8a3899b3cd861584e2d#file-cmake-before-gif [Apply this patch] https://gist.github.com/syohex/a8a3899b3cd861584e2d#file-cmake-after-gif 2014-11-12 16:17 GMT+09:00 Syohei YOSHIDA : > Word commands, such as foward-word(M-f), backward-kill-word(M-backspace), > don't work well like other major-modes if syntax of '_' is treated as "word". > --- > Auxiliary/cmake-mode.el | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el > index c8b9f8b..f1470f3 100644 > --- a/Auxiliary/cmake-mode.el > +++ b/Auxiliary/cmake-mode.el > @@ -202,7 +202,7 @@ the indentation. Otherwise it retains the same position on the line" > ;; Keyword highlighting regex-to-face map. > ;; > (defconst cmake-font-lock-keywords > - (list '("^[ \t]*\\(\\w+\\)[ \t]*(" 1 font-lock-function-name-face)) > + (list '("^[ \t]*\\([[:word:]_]+\\)[ \t]*(" 1 font-lock-function-name-face)) > "Highlighting expressions for CMAKE mode." > ) > > @@ -241,7 +241,6 @@ the indentation. Otherwise it retains the same position on the line" > ; Create the syntax table > (setq cmake-mode-syntax-table (make-syntax-table)) > (set-syntax-table cmake-mode-syntax-table) > - (modify-syntax-entry ?_ "w" cmake-mode-syntax-table) > (modify-syntax-entry ?\( "()" cmake-mode-syntax-table) > (modify-syntax-entry ?\) ")(" cmake-mode-syntax-table) > (modify-syntax-entry ?# "<" cmake-mode-syntax-table) > -- > 2.1.0 > -- Syohei YOSHIDA(syohex at gmail.com) From guillaume.papin at parrot.com Wed Nov 12 04:25:02 2014 From: guillaume.papin at parrot.com (Guillaume Papin) Date: Wed, 12 Nov 2014 09:25:02 +0000 Subject: [cmake-developers] syntax of '_' should be treated as symbol In-Reply-To: References: <1415776627-28137-1-git-send-email-syohex@gmail.com>, Message-ID: <4037EE152A73A9448DAD73C415D4D8C0876342@MBX79.aswsp.lan> I tested your patch and that is indeed how I expect cmake-mode to work. The current behavior has always been surprising compared to other Emacs modes. I hope this get added to CMake, Guillaume ________________________________________ From: cmake-developers [cmake-developers-bounces at cmake.org] on behalf of Syohei Yoshida [syohex at gmail.com] Sent: 12 November 2014 08:27 To: cmake-developers at cmake.org Subject: Re: [cmake-developers] syntax of '_' should be treated as symbol I created git animations about this patch. Please see them. Original version does not stop at underscore by word commands such as forward-word. On the other hands, fixed version stops at underscore. This behavior is same as other major-modes. [Original] https://gist.github.com/syohex/a8a3899b3cd861584e2d#file-cmake-before-gif [Apply this patch] https://gist.github.com/syohex/a8a3899b3cd861584e2d#file-cmake-after-gif 2014-11-12 16:17 GMT+09:00 Syohei YOSHIDA : > Word commands, such as foward-word(M-f), backward-kill-word(M-backspace), > don't work well like other major-modes if syntax of '_' is treated as "word". > --- > Auxiliary/cmake-mode.el | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el > index c8b9f8b..f1470f3 100644 > --- a/Auxiliary/cmake-mode.el > +++ b/Auxiliary/cmake-mode.el > @@ -202,7 +202,7 @@ the indentation. Otherwise it retains the same position on the line" > ;; Keyword highlighting regex-to-face map. > ;; > (defconst cmake-font-lock-keywords > - (list '("^[ \t]*\\(\\w+\\)[ \t]*(" 1 font-lock-function-name-face)) > + (list '("^[ \t]*\\([[:word:]_]+\\)[ \t]*(" 1 font-lock-function-name-face)) > "Highlighting expressions for CMAKE mode." > ) > > @@ -241,7 +241,6 @@ the indentation. Otherwise it retains the same position on the line" > ; Create the syntax table > (setq cmake-mode-syntax-table (make-syntax-table)) > (set-syntax-table cmake-mode-syntax-table) > - (modify-syntax-entry ?_ "w" cmake-mode-syntax-table) > (modify-syntax-entry ?\( "()" cmake-mode-syntax-table) > (modify-syntax-entry ?\) ")(" cmake-mode-syntax-table) > (modify-syntax-entry ?# "<" cmake-mode-syntax-table) > -- > 2.1.0 > -- Syohei YOSHIDA(syohex at gmail.com) -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers From listworks at gmail.com Wed Nov 12 04:30:55 2014 From: listworks at gmail.com (Marco) Date: Wed, 12 Nov 2014 10:30:55 +0100 Subject: [cmake-developers] New Generator for Keil uVision Message-ID: Hello In our development environment, we have to support multiple platforms like Make-based, Visual Studio, Eclipse CDT and Keil uVision. CMake seems perfect to support this. But obviously there is no generator for uVision. Here comes the fun part: I am going to implement a generator for it :-) Looking at the code of cmake, I identified cmGlobalGenerator and cmLocalGenerator as a base "hock" to start off. But actually I am looking for higer-level starting-point. Could you help me to identify one based on the information for uVision: uVision: - uVision does not use makefiles. - Multiproject Workspace: Kind of like a VisualStudio-solution. It is a xml-file basically just naming the projects contained in to workspace. Here's how it looks like: 1.0
### uVision Project, (C) Keil Software
WorkSpace .\Project1\Project1.uvproj .\Project2\Project2.uvproj 1
- Then there is a project-file, also xml. One sub-section of it names the files contained within the project. This part looks like this: SOURCE_FILES Main.cpp 8 .\src\Main.cpp startup_stm32f10x_md_vl.s 2 .\src\startup_stm32f10x_md_vl.s - Then there is an option-file. In there, there is also some reference to the source-files. But I guess once I am able to create the project-file entries, generating the option-files is trivial. If anyone could guide me to a good starting point, that would be awesome! Thanks a lot in advance! -- Cheers! Marco -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad.king at kitware.com Wed Nov 12 08:45:35 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Nov 2014 08:45:35 -0500 Subject: [cmake-developers] syntax of '_' should be treated as symbol In-Reply-To: <4037EE152A73A9448DAD73C415D4D8C0876342@MBX79.aswsp.lan> References: <1415776627-28137-1-git-send-email-syohex@gmail.com>, <4037EE152A73A9448DAD73C415D4D8C0876342@MBX79.aswsp.lan> Message-ID: <5463647F.30200@kitware.com> On 11/12/2014 04:25 AM, Guillaume Papin wrote: > On 11/12/2014 02:17 AM, Syohei YOSHIDA wrote: >> Word commands, such as foward-word(M-f), backward-kill-word(M-backspace), >> don't work well like other major-modes if syntax of '_' is treated as "word". > I tested your patch and that is indeed how I expect cmake-mode to work. Applied, thanks! cmake-mode.el: syntax of '_' should be treated as symbol http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=30f14aeb -Brad From brad.king at kitware.com Wed Nov 12 08:56:07 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Nov 2014 08:56:07 -0500 Subject: [cmake-developers] string SUBSTRING TRUNCATE mode In-Reply-To: References: Message-ID: <546366F7.6090902@kitware.com> On 11/11/2014 06:16 PM, Domen Vrankar wrote: > string(SUBSTRING [TRUNCATE]) [snip] > string(SUBSTRING ${test_str} 2 6 substr TRUNCATE) > > If length is set to a higher value than the length of the original > string the substring is still created but its end is the end of > original string. The functionality makes sense. Python 'abcd'[2:6] does this automatically. I agree the name TRUNCATE is hard to follow because I had to read the example to understand the command. SHORTEN may have the same problem. Other brainstorming ideas: (CLIP|INTERSECT|TOLERANT)(_RANGE)? Another option is to just start tolerating out-of-range indexes. Since it is currently an error there would be no compatibility problem (except that someone may write code using a newer CMake that then breaks on an older version). > If this functionality would be welcome I'll write the tests and > documentation. Yes. After the naming bikeshed is painted then tests can go in Tests/RunCMake/string/* Thanks, -Brad From robert.maynard at kitware.com Wed Nov 12 09:54:54 2014 From: robert.maynard at kitware.com (Robert Maynard) Date: Wed, 12 Nov 2014 09:54:54 -0500 Subject: [cmake-developers] string SUBSTRING TRUNCATE mode In-Reply-To: <546366F7.6090902@kitware.com> References: <546366F7.6090902@kitware.com> Message-ID: I vote for the implicit behavior of SUBSTRING for it to tolerate out-of-range indexes. On Wed, Nov 12, 2014 at 8:56 AM, Brad King wrote: > On 11/11/2014 06:16 PM, Domen Vrankar wrote: >> string(SUBSTRING [TRUNCATE]) > [snip] >> string(SUBSTRING ${test_str} 2 6 substr TRUNCATE) >> >> If length is set to a higher value than the length of the original >> string the substring is still created but its end is the end of >> original string. > > The functionality makes sense. Python 'abcd'[2:6] does this > automatically. I agree the name TRUNCATE is hard to follow > because I had to read the example to understand the command. > SHORTEN may have the same problem. Other brainstorming ideas: > > (CLIP|INTERSECT|TOLERANT)(_RANGE)? > > Another option is to just start tolerating out-of-range indexes. > Since it is currently an error there would be no compatibility > problem (except that someone may write code using a newer CMake > that then breaks on an older version). > >> If this functionality would be welcome I'll write the tests and >> documentation. > > Yes. After the naming bikeshed is painted then tests can go in > Tests/RunCMake/string/* > > Thanks, > -Brad > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake-developers From domen.vrankar at gmail.com Wed Nov 12 10:23:58 2014 From: domen.vrankar at gmail.com (Domen Vrankar) Date: Wed, 12 Nov 2014 16:23:58 +0100 Subject: [cmake-developers] string SUBSTRING TRUNCATE mode In-Reply-To: References: <546366F7.6090902@kitware.com> Message-ID: 2014-11-12 15:54 GMT+01:00 Robert Maynard : > I vote for the implicit behavior of SUBSTRING for it to tolerate > out-of-range indexes. I would also prefer implicit behavior but in that case should it still be treated as error if CMake minimum required version is set to less than 3.1 since it would break on older versions of CMake? I know that CMake policies exist but I am not familiar with them... Could they be used for this? From brad.king at kitware.com Wed Nov 12 11:37:51 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Nov 2014 11:37:51 -0500 Subject: [cmake-developers] string SUBSTRING TRUNCATE mode In-Reply-To: References: <546366F7.6090902@kitware.com> Message-ID: <54638CDF.4090802@kitware.com> On 11/12/2014 10:23 AM, Domen Vrankar wrote: > I would also prefer implicit behavior but in that case should it still > be treated as error if CMake minimum required version is set to less > than 3.1 since it would break on older versions of CMake? > I know that CMake policies exist but I am not familiar with them... > Could they be used for this? Policies are for making backward-incompatible behavior changes for the better. In this case old code cannot break, so we should not need a policy. You could check the value of the CMAKE_MINIMUM_REQUIRED_VERSION variable to decide whether to make it an error. Extend the error message to mention that it could be fixed by requiring a new enough version of CMake. OTOH, there have been many times in the past where we've converted an error case to a non-error case without such a check. Projects should test themselves with the oldest CMake they support anyway. I have no strong feeling on this requirement. -Brad From brad.king at kitware.com Wed Nov 12 11:43:39 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 12 Nov 2014 11:43:39 -0500 Subject: [cmake-developers] New Generator for Keil uVision In-Reply-To: References: Message-ID: <54638E3B.8020908@kitware.com> On 11/12/2014 04:30 AM, Marco wrote: > But obviously there is no generator for uVision. Here comes the > fun part: I am going to implement a generator for it :-) Great! > I am looking for higer-level starting-point. [snip] > - Multiproject Workspace: Kind of like a VisualStudio-solution. The example layout you gave looks just like the VS IDE project file layout, assuming that there is one .uvproj file for each exe/lib/custom target. You should model the generator based off the VS >= 10 generator works: cmGlobalVisualStudio10Generator One for the whole tree, generates the .sln file cmLocalVisualStudio10Generator One per directory (CMakeLists.txt) cmVisualStudio10TargetGenerator One per logical target (exe, lib, etc.), generates .vcxproj file -Brad From mantis at public.kitware.com Wed Nov 12 17:14:10 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Wed, 12 Nov 2014 17:14:10 -0500 Subject: [cmake-developers] [CMake 0015247]: install([[SCRIPT ] [CODE ]] [...]) missing documentation for COMPONENT argument Message-ID: <22dbb20b09a5e4ff144386f369beeff7@public.kitware.com> The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15247 ====================================================================== Reported By: Walter Gray Assigned To: ====================================================================== Project: CMake Issue ID: 15247 Category: Documentation Reproducibility: always Severity: tweak Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-12 17:14 EST Last Modified: 2014-11-12 17:14 EST ====================================================================== Summary: install([[SCRIPT ] [CODE ]] [...]) missing documentation for COMPONENT argument Description: The install command with the SCRIPT/CODE signature accepts a COMPONENT argument, which is not documented. A check should be made to see if there are other arguments this signature accepts as well, and they should be added to the signature. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-12 17:14 Walter Gray New Issue ====================================================================== From mantis at public.kitware.com Wed Nov 12 17:23:27 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Wed, 12 Nov 2014 17:23:27 -0500 Subject: [cmake-developers] [CMake 0015248]: When cross compiling, "make install" invokes target "cmake" instead of host version Message-ID: <4871d9c22643393b4401c17870ee4f32@public.kitware.com> The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15248 ====================================================================== Reported By: Davide Viti Assigned To: ====================================================================== Project: CMake Issue ID: 15248 Category: CMakeSetup Reproducibility: always Severity: minor Priority: low Status: new ====================================================================== Date Submitted: 2014-11-12 17:23 EST Last Modified: 2014-11-12 17:23 EST ====================================================================== Summary: When cross compiling, "make install" invokes target "cmake" instead of host version Description: Crosscompilation goes smooth up to "make install" step where it fails: bin/cmake: 1: bin/cmake: Syntax error: word unexpected (expecting ")") it is trying to invoke cross compiled cmake instead of the version available for the host machine. The problem can be workarounded replacing "make install" with "cmake -P cmake_install.cmake" Steps to Reproduce: I've run into the problem while crosscompiling cmake in buildroot (http://buildroot.uclibc.org/) for arm. The build process invokes bootstrap: LDFLAGS="$(TARGET_LDFLAGS)" \ CFLAGS="$(TARGET_CFLAGS)" \ ./bootstrap --prefix=$(TARGET_DIR)/usr \ --parallel=$(PARALLEL_JOBS) -- \ -DCMAKE_C_FLAGS="$(TARGET_CFLAGS)" \ -DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS)" \ -DCMAKE_EXE_LINKER_FLAGS="$(TARGET_LDFLAGS)" \ -DCMAKE_C_COMPILER="$(TARGET_CC)" \ -DCMAKE_CXX_COMPILER="$(TARGET_CXX)" \ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="NEVER" \ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="ONLY" \ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="ONLY" \ -DBUILD_CursesDialog=OFF then "make" and finally "make install" ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-12 17:23 Davide Viti New Issue ====================================================================== From domen.vrankar at gmail.com Wed Nov 12 18:08:58 2014 From: domen.vrankar at gmail.com (Domen Vrankar) Date: Thu, 13 Nov 2014 00:08:58 +0100 Subject: [cmake-developers] string SUBSTRING TRUNCATE mode In-Reply-To: <54638CDF.4090802@kitware.com> References: <546366F7.6090902@kitware.com> <54638CDF.4090802@kitware.com> Message-ID: > You could check the value of the CMAKE_MINIMUM_REQUIRED_VERSION > variable to decide whether to make it an error. Extend the error > message to mention that it could be fixed by requiring a new > enough version of CMake. OTOH, there have been many times in the > past where we've converted an error case to a non-error case > without such a check. Projects should test themselves with the > oldest CMake they support anyway. I have no strong feeling on > this requirement. I have decided against the checking for back compatibility as it would only make writing of modules that come with CMake harder. Attached is the final patch. I have changed the already existing tests and added a note regarding the change in documentation. If this patch will not make it into CMake 3.1 the note in documentation should be changed before applying the patch. Please review the patch and if there are no changes required add it to the repository. Thanks, Domen -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-string-SUBSTRING-length-exceeding-end-index.patch Type: text/x-diff Size: 4159 bytes Desc: not available URL: From mantis at public.kitware.com Thu Nov 13 02:02:03 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Thu, 13 Nov 2014 02:02:03 -0500 Subject: [cmake-developers] [CMake 0015249]: Default WORKING_DIRECTORY of EXECUTE_PROCESS Message-ID: The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15249 ====================================================================== Reported By: Micha Renner Assigned To: ====================================================================== Project: CMake Issue ID: 15249 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-13 02:02 EST Last Modified: 2014-11-13 02:02 EST ====================================================================== Summary: Default WORKING_DIRECTORY of EXECUTE_PROCESS Description: 3.1.rc1. Windows version - only It seems that the default WORKING_DIRECTORY of EXECUTE_PROCESS is not any longer CMAKE_BINARY_DIR. EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory conftest.a) results in Error making directory " conftest.a". Maybe EXECUTE_PROCESS runs in a write-protected directory. EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory conftest.a # WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) works. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-13 02:02 Micha Renner New Issue ====================================================================== From listworks at gmail.com Thu Nov 13 07:41:11 2014 From: listworks at gmail.com (Marco) Date: Thu, 13 Nov 2014 13:41:11 +0100 Subject: [cmake-developers] New Generator for Keil uVision In-Reply-To: <54638E3B.8020908@kitware.com> References: <54638E3B.8020908@kitware.com> Message-ID: On Wed, Nov 12, 2014 at 5:43 PM, Brad King wrote: > On 11/12/2014 04:30 AM, Marco wrote: > > [snip] > >> > - Multiproject Workspace: Kind of like a VisualStudio-solution. >> >> The example layout you gave looks just like the VS IDE project >> file layout, assuming that there is one .uvproj file for each >> exe/lib/custom target. You should model the generator based off >> the VS >= 10 generator works: >> >> cmGlobalVisualStudio10Generator >> One for the whole tree, generates the .sln file >> >> cmLocalVisualStudio10Generator >> One per directory (CMakeLists.txt) >> >> cmVisualStudio10TargetGenerator >> One per logical target (exe, lib, etc.), generates .vcxproj file >> > Thanks for your tips! I was a bit afraid that VisualStudio would be recommended as starting-point. There is lots of inherited code there which is rather hard to understand as a cmake-newbie-developer... I had a look at XCode-generators and the look quit tidy. How about this as starting-point? -- Marco -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad.king at kitware.com Thu Nov 13 08:32:02 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Nov 2014 08:32:02 -0500 Subject: [cmake-developers] New Generator for Keil uVision In-Reply-To: References: <54638E3B.8020908@kitware.com> Message-ID: <5464B2D2.3070908@kitware.com> On 11/13/2014 07:41 AM, Marco wrote: > Thanks for your tips! I was a bit afraid that VisualStudio > would be recommended as starting-point. There is lots of > inherited code there which is rather hard to understand as > a cmake-newbie-developer... It's the global/local/target generator breakdown that should be followed for a new generator. The VS generators have all kinds of inheritance to support multiple versions. Yours shouldn't need that level of complexity. > I had a look at XCode-generators and the look quit tidy. It uses fragile logic like a "CurrentLocalGenerator" that is not a good example of how to organize the generation steps. One day it may be refactored. -Brad From ruslan_baratov at yahoo.com Thu Nov 13 09:01:05 2014 From: ruslan_baratov at yahoo.com (Ruslan Baratov) Date: Thu, 13 Nov 2014 17:01:05 +0300 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <54625542.8050808@kitware.com> References: <5431B11C.3010209@yahoo.com> <54329100.8020502@kitware.com> <54338CF1.3070304@yahoo.com> <5433DBC1.5080800@kitware.com> <5435257B.80201@yahoo.com> <543531CC.7090103@kitware.com> <5437C6CA.3030201@yahoo.com> <543BE40C.4000404@kitware.com> <544FFC83.4090107@yahoo.com> <5450F03F.2040500@kitware.com> <54538976.5050007@yahoo.com> <5453912F.6000305@kitware.com> <546132DB.7020209@yahoo.com> <54625542.8050808@kitware.com> Message-ID: <5464B9A1.9050903@yahoo.com> On 11-Nov-14 21:28, Brad King wrote: > * All headers and sources need to include cmStandardIncludes.h first, > directly or indirectly through other headers. It can affect the > way certain standard library headers are preprocessed on some > platforms, and needs to be consistent across all translation units. > > * Please add the .cxx files to 'bootstrap' and Source/CMakeLists.txt > rather than including them in cmBootstrapCommands*.cxx. > > * The windows header should be included in lower case . > > * The cerrno and cstdio headers need to be just errno.h and stdio.h > to work on some of the older compilers. > > * Please add documentation to Help/command/file.rst and anywhere else > that is appropriate. Done > * Please add test cases for all APIs and error cases, probably in > Tests/RunCMake/file using the RunCMake infrastructure. I added test LOCK.cmake but not quite understand how to execute it. Is it possible to run tests only from 'Tests/RunCMake/file' directory? By the way I got the following error (Visual Studio 2013) if I include 'cmFileLockResult.h' before 'cm_curl.h' in file 'cmFileCommand.cxx': C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ws2ipdef.h(202): error C2079: '_SOCKADDR_INET::Ipv4' uses undefined struct 'sockaddr_in' C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ws2ipdef.h(715): error C2011: 'ip_mreq' : 'struct' type redefinition C:\Program Files (x86)\Windows Kits\8.1\Include\um\winsock.h(355) : see declaration of 'ip_mreq' C:\Program Files (x86)\Windows Kits\8.1\Include\um\ws2tcpip.h(696): error C3861: 'WSASetLastError': identifier not found C:\Program Files (x86)\Windows Kits\8.1\Include\um\ws2tcpip.h(703): error C3861: 'WSASetLastError': identifier not found C:\Program Files (x86)\Windows Kits\8.1\Include\um\ws2tcpip.h(742): error C3861: 'WSASetLastError': identifier not found C:\Program Files (x86)\Windows Kits\8.1\Include\um\ws2tcpip.h(749): error C3861: 'WSASetLastError': identifier not found C:\Program Files (x86)\Windows Kits\8.1\Include\um\ws2tcpip.h(793): error C3861: 'WSASetLastError': identifier not found C:\Program Files (x86)\Windows Kits\8.1\Include\um\ws2tcpip.h(800): error C3861: 'WSASetLastError': identifier not found C:\Program Files (x86)\Windows Kits\8.1\Include\um\ws2tcpip.h(841): error C3861: 'WSASetLastError': identifier not found C:\Program Files (x86)\Windows Kits\8.1\Include\um\ws2tcpip.h(848): error C3861: 'WSASetLastError': identifier not found ...\cmake\Utilities\cmcurl/include/curl/curl.h(337): error C2079: 'curl_sockaddr::addr' uses undefined struct 'sockaddr' Compiles fine if 'cmFileLockResult.h' placed after 'cm_curl.h'. Ruslo -------------- next part -------------- >From 55514802c135595e658f1897c123c0daf291ae81 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Thu, 13 Nov 2014 17:35:36 +0400 Subject: [PATCH 1/5] Add class cmFileLockResult --- Source/cmFileLockResult.cxx | 111 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockResult.h | 85 +++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 Source/cmFileLockResult.cxx create mode 100644 Source/cmFileLockResult.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 + +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 // 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 -- 2.1.1 -------------- next part -------------- >From 29727385af600c6aef0771c2bc835e4939cf7e02 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Thu, 13 Nov 2014 17:36:02 +0400 Subject: [PATCH 2/5] Add class cmFileLock --- Source/cmFileLock.cxx | 77 +++++++++++++++++++++++++++ Source/cmFileLock.h | 74 ++++++++++++++++++++++++++ Source/cmFileLockUnix.cxx | 102 ++++++++++++++++++++++++++++++++++++ Source/cmFileLockWin32.cxx | 126 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 379 insertions(+) create mode 100755 Source/cmFileLock.cxx create mode 100644 Source/cmFileLock.h create mode 100755 Source/cmFileLockUnix.cxx create mode 100755 Source/cmFileLockWin32.cxx diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx new file mode 100755 index 0000000..f69c36a --- /dev/null +++ b/Source/cmFileLock.cxx @@ -0,0 +1,77 @@ +/*============================================================================ + 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 +#include "cmFileLockResult.h" + +// Common implementation + +cmFileLock::~cmFileLock() +{ + if (!this->Filename.empty()) + { + const cmFileLockResult result = this->Release(); + 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(-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..7c2803b --- /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 // HANDLE +#endif + +class cmFileLockResult; + +/** + * @brief Cross-platform file locking. + * @detail 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. + * @detail 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/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx new file mode 100755 index 0000000..519df3e --- /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 +#include // SEEK_SET +#include +#include // sleep + +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 != EAGAIN) + { + return cmFileLockResult::MakeSystem(); + } + } + else + { + return cmFileLockResult::MakeOk(); + } + if (seconds == 0) + { + return cmFileLockResult::MakeTimeout(); + } + --seconds; + ::sleep(1); + } +} + +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 = 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 100755 index 0000000..d5b069d --- /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 // CreateFile +#include + +cmFileLock::cmFileLock(): File(INVALID_HANDLE_VALUE) +{ +} + +cmFileLockResult cmFileLock::Release() +{ + if (this->Filename.empty()) + { + return cmFileLockResult::MakeOk(); + } + const unsigned long len = static_cast(-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 = CreateFile( + cmsys::Encoding::ToWide(this->Filename.c_str()).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; + ::Sleep(1000); + } +} + +BOOL cmFileLock::LockFile(DWORD flags) +{ + const DWORD reserved = 0; + const unsigned long len = static_cast(-1); + static OVERLAPPED overlapped; + return LockFileEx( + this->File, + flags, + reserved, + len, + len, + &overlapped + ); +} -- 2.1.1 -------------- next part -------------- >From be8c24118e06d66fe59950792af194d10e0c3f25 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Thu, 13 Nov 2014 17:36:25 +0400 Subject: [PATCH 3/5] Add class cmFileLockPool --- Source/cmFileLockPool.cxx | 198 ++++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockPool.h | 100 +++++++++++++++++++++++ 2 files changed, 298 insertions(+) create mode 100755 Source/cmFileLockPool.cxx create mode 100644 Source/cmFileLockPool.h diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx new file mode 100755 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 + +#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 List; + typedef List::iterator It; + typedef List::const_iterator CIt; + + List Locks; + }; + + typedef std::list List; + + typedef List::iterator It; + typedef List::const_iterator CIt; + + List FunctionScopes; + List FileScopes; + ScopePool ProcessScope; +}; + +#endif // cmFileLockPool_h -- 2.1.1 -------------- next part -------------- >From fc43d35350334613e9afbea1581cc90b1547fa5a Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Thu, 13 Nov 2014 17:39:13 +0400 Subject: [PATCH 4/5] New command 'file(LOCK ...)' --- Source/CMakeLists.txt | 6 ++ Source/cmFileCommand.cxx | 192 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileCommand.h | 1 + Source/cmGlobalGenerator.h | 6 ++ Source/cmLocalGenerator.cxx | 2 + Source/cmMakefile.cxx | 4 + bootstrap | 3 + 7 files changed, 214 insertions(+) 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/cmFileCommand.cxx b/Source/cmFileCommand.cxx index b0ddff4..3b1f44e 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -23,6 +23,8 @@ #include "cm_curl.h" #endif +#include "cmFileLockResult.h" + #undef GetCurrentDirectory #include #include @@ -202,6 +204,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 +3508,192 @@ bool cmFileCommand::HandleGenerateCommand( } //---------------------------------------------------------------------------- +bool cmFileCommand::HandleLockCommand( + std::vector const& args) +{ + // 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(-1); + + // Parse arguments + if(args.size() < 2) + { + this->SetError("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->SetError(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: \"" << args[i] << "\"."; + this->SetError(e.str()); + return false; + } + } + } + else if (args[i] == "RESULT_VARIABLE") + { + ++i; + if (i >= args.size()) + { + this->SetError(": expected variable name after RESULT_VARIABLE"); + return false; + } + resultVariable = args[i]; + } + else if (args[i] == "TIMEOUT") + { + ++i; + if (i >= args.size()) + { + this->SetError(": expected timeout value after TIMEOUT"); + return false; + } + int scanned; + if(sscanf(args[i].c_str(), "%d", &scanned) != 1 || scanned < 0) + { + cmOStringStream e; + e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer."; + this->SetError(e.str()); + return false; + } + timeout = static_cast(scanned); + } + else + { + cmOStringStream e; + e << ": expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT"; + e << ", but got: \"" << args[i] << "\"."; + this->SetError(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 \"" << parentDir << "\" creation failed "; + e << "(check permissions)."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + cmsys::ofstream file(path.c_str()); + if (!file.good()) + { + cmOStringStream e; + e << ": file \"" << path << "\" creation failed (check permissions)."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + file.close(); + + // 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 \"" << path << "\" (" << result << ")."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + + if (!resultVariable.empty()) + { + this->Makefile->AddDefinition(resultVariable, result.c_str()); + } + + return true; +} + +//---------------------------------------------------------------------------- bool cmFileCommand::HandleTimestampCommand( std::vector 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 const& args); bool HandleGenerateCommand(std::vector const& args); + bool HandleLockCommand(std::vector const& args); private: void AddEvaluationFile(const std::string &inputName, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ddd7e91..00ba9a0 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -21,6 +21,7 @@ #include "cmExportSetMap.h" // For cmExportSetMap #include "cmGeneratorTarget.h" #include "cmGeneratorExpression.h" +#include "cmFileLockPool.h" #if defined(CMAKE_BUILD_WITH_CMAKE) # include @@ -341,6 +342,8 @@ public: bool GenerateCPackPropertiesFile(); + cmFileLockPool& GetFileLockPool() { return FileLockPool; } + protected: virtual void Generate(); @@ -488,6 +491,9 @@ private: // track targets to issue CMP0042 warning for. std::set CMP0042WarnTargets; + + // Pool of file locks + cmFileLockPool FileLockPool; }; #endif diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 69b56c6..27cb8d0 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -79,9 +79,11 @@ public: this->GG = lg->GetGlobalGenerator(); this->LG = this->GG->GetCurrentLocalGenerator(); this->GG->SetCurrentLocalGenerator(lg); + this->GG->GetFileLockPool().PushFileScope(); } ~cmLocalGeneratorCurrent() { + this->GG->GetFileLockPool().PopFileScope(); this->GG->SetCurrentLocalGenerator(this->LG); } }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8a8aadc..a94c752 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4426,6 +4426,8 @@ void cmMakefile::PushScope() this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PushFunctionScope(); } void cmMakefile::PopScope() @@ -4463,6 +4465,8 @@ void cmMakefile::PopScope() { this->Internal->VarUsageStack.top().insert(*it); } + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PopFunctionScope(); } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) diff --git a/bootstrap b/bootstrap index 94bed0e..19189d3 100755 --- a/bootstrap +++ b/bootstrap @@ -286,6 +286,9 @@ CMAKE_CXX_SOURCES="\ cmSystemTools \ cmTestGenerator \ cmVersion \ + cmFileLock \ + cmFileLockPool \ + cmFileLockResult \ cmFileTimeComparison \ cmGlobalUnixMakefileGenerator3 \ cmLocalUnixMakefileGenerator3 \ -- 2.1.1 -------------- next part -------------- >From 81b304fe8b87422733e9f91612b188583e7ea3db Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Thu, 13 Nov 2014 17:40:26 +0400 Subject: [PATCH 5/5] Update documentation of command file (LOCK option) --- Help/command/file.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 [DIRECTORY] [RELEASE] + [GUARD ] + [RESULT_VARIABLE ] + [TIMEOUT ]) + +Lock a file specified by ```` if no ``DIRECTORY`` option present and file +``/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 ```` value. Any errors will be interpreted as fatal if there is no +``RESULT_VARIABLE`` option. Otherwise result will be stored in ```` +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. -- 2.1.1 From brad.king at kitware.com Thu Nov 13 11:03:41 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Nov 2014 11:03:41 -0500 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <5464B9A1.9050903@yahoo.com> References: <5431B11C.3010209@yahoo.com> <54329100.8020502@kitware.com> <54338CF1.3070304@yahoo.com> <5433DBC1.5080800@kitware.com> <5435257B.80201@yahoo.com> <543531CC.7090103@kitware.com> <5437C6CA.3030201@yahoo.com> <543BE40C.4000404@kitware.com> <544FFC83.4090107@yahoo.com> <5450F03F.2040500@kitware.com> <54538976.5050007@yahoo.com> <5453912F.6000305@kitware.com> <546132DB.7020209@yahoo.com> <54625542.8050808@kitware.com> <5464B9A1.9050903@yahoo.com> Message-ID: <5464D65D.6030902@kitware.com> On 11/13/2014 09:01 AM, Ruslan Baratov wrote: >> * Please add documentation to Help/command/file.rst and anywhere else >> that is appropriate. > Done Thanks. I will try out the patch when I get a chance to provide further feedback. > Is it possible to run tests only from 'Tests/RunCMake/file' directory? ctest -R RunCMake.file -V > By the way I got the following error (Visual Studio 2013) if I include > 'cmFileLockResult.h' before 'cm_curl.h' in file 'cmFileCommand.cxx': > Compiles fine if 'cmFileLockResult.h' placed after 'cm_curl.h'. Okay. One comment from a quick scroll through the patches: - Use ConvertToWindowsExtendedPath for passing file paths to windows APIs. That will allow use of longer path names. Thanks, -Brad From brad.king at kitware.com Thu Nov 13 11:19:26 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Nov 2014 11:19:26 -0500 Subject: [cmake-developers] string SUBSTRING TRUNCATE mode In-Reply-To: References: <546366F7.6090902@kitware.com> <54638CDF.4090802@kitware.com> Message-ID: <5464DA0E.9010808@kitware.com> On 11/12/2014 06:08 PM, Domen Vrankar wrote: > Attached is the final patch. Applied with minor tweaks, thanks: string: Tolerate SUBSTRING length exceeding end index http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=474bbb9d -Brad From mantis at public.kitware.com Thu Nov 13 12:38:53 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Thu, 13 Nov 2014 12:38:53 -0500 Subject: [cmake-developers] [CMake 0015250]: cmake --find-package ignores multi-arch dir Message-ID: The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15250 ====================================================================== Reported By: Felix Geyer Assigned To: ====================================================================== Project: CMake Issue ID: 15250 Category: Modules Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-13 12:38 EST Last Modified: 2014-11-13 12:38 EST ====================================================================== Summary: cmake --find-package ignores multi-arch dir Description: cmake --find-package ignores multi-arch dirs when looking for the library. In Modules/CMakeFindPackageMode.cmake it sets CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE which I believe is a typo. It should be CMAKE_${LANGUAGE}_LIBRARY_ARCHITECTURE. It also doesn't set the CMAKE_LIBRARY_ARCHITECTURE variable. Steps to Reproduce: Steps to reproduce in Debian unstable: # apt-get install cmake libgdcm2-dev # cmake --find-package -DNAME=GDCM -DLANGUAGE=CXX -DCOMPILER_ID=GNU -DMODE=COMPILE GDCM not found. CMake Error: Problem processing arguments. Aborting. with the attached patch: # cmake --find-package -DNAME=GDCM -DLANGUAGE=CXX -DCOMPILER_ID=GNU -DMODE=COMPILE -I/usr/include/gdcm-2.4 The gdcm cmake files are located in /usr/lib/x86_64-linux-gnu/gdcm-2.4/ ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-13 12:38 Felix Geyer New Issue 2014-11-13 12:38 Felix Geyer File Added: cmake_findpackage_multiarch.patch ====================================================================== From eike at sf-mail.de Thu Nov 13 12:48:02 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Thu, 13 Nov 2014 18:48:02 +0100 Subject: [cmake-developers] string SUBSTRING TRUNCATE mode In-Reply-To: <5464DA0E.9010808@kitware.com> References: <5464DA0E.9010808@kitware.com> Message-ID: <1476946.clnm8XJARf@caliban.sf-tec.de> Am Donnerstag, 13. November 2014, 11:19:26 schrieb Brad King: > On 11/12/2014 06:08 PM, Domen Vrankar wrote: > > Attached is the final patch. > > Applied with minor tweaks, thanks: > > string: Tolerate SUBSTRING length exceeding end index > http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=474bbb9d This should be a good addition, no? diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 56d9b66..66717ef 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -683,9 +683,7 @@ foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLIC # Transform NAME --> Name e.g. PROVIDES --> Provides # The Upper-case first letter and lowercase tail is the # appropriate value required in the final RPM spec file. - string(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH) - math(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - 1") - string(SUBSTRING ${_RPM_SPEC_HEADER} 1 ${_PACKAGE_HEADER_STRLENGTH} _PACKAGE_HEADER_TAIL) + string(SUBSTRING ${_RPM_SPEC_HEADER} 1 -1 _PACKAGE_HEADER_TAIL) string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From robert.maynard at kitware.com Thu Nov 13 12:54:26 2014 From: robert.maynard at kitware.com (Robert Maynard) Date: Thu, 13 Nov 2014 12:54:26 -0500 Subject: [cmake-developers] CMake 3.1.0-rc2 is now ready! Message-ID: I am proud to announce the CMake 3.1 second release candidate. Sources and binaries are available at: http://www.cmake.org/files/v3.1/?C=M;O=D Documentation is available at: http://www.cmake.org/cmake/help/v3.1 Release notes appear below and are also published at http://www.cmake.org/cmake/help/v3.1/release/3.1.0.html Some of the more significant features of CMake 3.1 are: * Windows Phone and Windows Store support has been added to Visual Studio 11 (2012) and above Generators. * NVIDIA Nsight Tegra support has been added to Visual Studio 10 (2010) and above Generators. * New "target_compile_features" command allows populating target based compile features. CMake uses this information to ensure that the compiler in use is capable of building the target, and to add any necessary compile flags such as -std=gnu++11 to support language features. More information on this is found at: - http://www.cmake.org/cmake/help/v3.1/manual/cmake-compile-features.7.html * The syntax for *Variable References* and *Escape Sequences* was simplified in order to allow a much faster implementation. See policy "CMP0053". * The "if" command no longer automatically dereferences variables named in quoted or bracket arguments. See policy "CMP0054". * The target property "SOURCES" now generally supports "Generator Expressions". The generator expressions may be used in the "add_library" and "add_executable" commands. * It is now possible to write and append to the target property "SOURCES". The variable "CMAKE_DEBUG_TARGET_PROPERTIES" can be used to trace the origin of sources. * CPack gained "7Z" and "TXZ" generators supporting lzma-compressed archives. * The ExternalProject module has learned to support lzma-compressed source tarballs with ".7z", ".tar.xz", and ".txz" extensions. * The ExternalProject module ExternalProject_Add command learned a new BUILD_ALWAYS option to cause the external project build step to run every time the host project is built. * The ctest_coverage command learned to support Intel coverage files with the "codecov" tool. * The ctest_memcheck command learned to support sanitizer modes, including "AddressSanitizer", "MemorySanitizer", "ThreadSanitizer", and "UndefinedBehaviorSanitizer". Deprecated and Removed Features: * In CMake 3.0 the "target_link_libraries" command accidentally began allowing unquoted arguments to use Generator Expressions containing a semicolon separated list within them. For example: set(libs B C) target_link_libraries(A PUBLIC $) This is equivalent to writing: target_link_libraries(A PUBLIC $) and was never intended to work. It did not work in CMake 2.8.12. Such generator expressions should be in quoted arguments: set(libs B C) target_link_libraries(A PUBLIC "$") CMake 3.1 again requires the quotes for this to work correctly. CMake 3.1.0 Release Notes ************************* Changes made since CMake 3.0.0 include the following. Documentation Changes ===================== * A new "cmake-compile-features(7)" manual was added. New Features ============ Generators ---------- * A "Visual Studio 14" generator was added. Windows Phone and Windows Store ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Generators for Visual Studio 11 (2012) and above learned to generate projects for Windows Phone and Windows Store. One may set the "CMAKE_SYSTEM_NAME" variable to "WindowsPhone" or "WindowsStore" on the "cmake(1)" command-line or in a "CMAKE_TOOLCHAIN_FILE" to activate these platforms. Also set "CMAKE_SYSTEM_VERSION" to "8.0" or "8.1" to specify the version of Windows to be targeted. NVIDIA Nsight Tegra ~~~~~~~~~~~~~~~~~~~ * Generators for Visual Studio 10 (2010) and above learned to generate projects for NVIDIA Nsight Tegra Visual Studio Edition. One may set the "CMAKE_SYSTEM_NAME" variable to "Android" on the "cmake(1)" command-line or in a "CMAKE_TOOLCHAIN_FILE" to activate this platform. Syntax ------ * The "cmake-language(7)" syntax for *Variable References* and *Escape Sequences* was simplified in order to allow a much faster implementation. See policy "CMP0053". * The "if()" command no longer automatically dereferences variables named in quoted or bracket arguments. See policy "CMP0054". Commands -------- * The "add_custom_command()" command learned to interpret "cmake- generator-expressions(7)" in arguments to "DEPENDS". * The "export(PACKAGE)" command learned to check the "CMAKE_EXPORT_NO_PACKAGE_REGISTRY" variable to skip exporting the package. * The "file(STRINGS)" command gained a new "ENCODING" option to enable extraction of "UTF-8" strings. * The "find_package()" command learned to check the "CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY" and "CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY" variables to skip searching the package registries. * The "install()" command learned a "MESSAGE_NEVER" option to avoid output during installation. * The "string()" command learned a new "GENEX_STRIP" subcommand which removes "generator expression". * The "string()" command learned a new "UUID" subcommand to generate a univerally unique identifier. * New "target_compile_features()" command allows populating the "COMPILE_FEATURES" target property, just like any other build variable. * The "target_sources()" command was added to add to the "SOURCES" target property. Variables --------- * The Visual Studio generators for versions 8 (2005) and above learned to read the target platform name from a new "CMAKE_GENERATOR_PLATFORM" variable when it is not specified as part of the generator name. The platform name may be specified on the "cmake(1)" command line with the "-A" option, e.g. "-G "Visual Studio 12 2013" -A x64". * The "CMAKE_GENERATOR_TOOLSET" variable may now be initialized in a toolchain file specified by the "CMAKE_TOOLCHAIN_FILE" variable. This is useful when cross-compiling with the Xcode or Visual Studio generators. * The "CMAKE_INSTALL_MESSAGE" variable was introduced to optionally reduce output installation. Properties ---------- * New "CXX_STANDARD" and "CXX_EXTENSIONS" target properties may specify values which CMake uses to compute required compile options such as "-std=c++11" or "-std=gnu++11". The "CMAKE_CXX_STANDARD" and "CMAKE_CXX_EXTENSIONS" variables may be set to initialize the target properties. * New "C_STANDARD" and "C_EXTENSIONS" target properties may specify values which CMake uses to compute required compile options such as "-std=c11" or "-std=gnu11". The "CMAKE_C_STANDARD" and "CMAKE_C_EXTENSIONS" variables may be set to initialize the target properties. * New "COMPILE_FEATURES" target property may contain a list of features required to compile a target. CMake uses this information to ensure that the compiler in use is capable of building the target, and to add any necessary compile flags to support language features. * New "COMPILE_PDB_NAME" and "COMPILE_PDB_OUTPUT_DIRECTORY" target properties were introduced to specify the MSVC compiler program database file location ("cl /Fd"). This complements the existing "PDB_NAME" and "PDB_OUTPUT_DIRECTORY" target properties that specify the linker program database file location ("link /pdb"). * The "INTERFACE_LINK_LIBRARIES" target property now supports a "$" "generator expression". * A new "INTERFACE_SOURCES" target property was introduced. This is consumed by dependent targets, which compile and link the listed sources. * The "SOURCES" target property now contains "generator expression" such as "TARGET_OBJECTS" when read at configure time, if policy "CMP0051" is "NEW". * The "SOURCES" target property now generally supports "generator expression". The generator expressions may be used in the "add_library()" and "add_executable()" commands. * It is now possible to write and append to the "SOURCES" target property. The "CMAKE_DEBUG_TARGET_PROPERTIES" variable may be used to trace the origin of sources. * A "VS_DEPLOYMENT_CONTENT" source file property was added to tell the Visual Studio generators to mark content for deployment in Windows Phone and Windows Store projects. * The "VS_WINRT_COMPONENT" target property was created to tell Visual Studio generators to compile a shared library as a Windows Runtime (WinRT) component. * The "Xcode" generator learned to check source file properties "XCODE_EXPLICIT_FILE_TYPE" and "XCODE_LAST_KNOWN_FILE_TYPE" for a custom Xcode file reference type. Modules ------- * The "BundleUtilities" module learned to resolve and replace "@rpath" placeholders on OS X to correctly bundle applications using them. * The "CMakePackageConfigHelpers" module "configure_package_config_file()" command learned a new "INSTALL_PREFIX" option to generate package configuration files meant for a prefix other than "CMAKE_INSTALL_PREFIX". * The "CheckFortranSourceCompiles" module was added to provide a "CHECK_Fortran_SOURCE_COMPILES" macro. * The "ExternalData" module learned to tolerate a "DATA{}" reference to a missing source file with a warning instead of rejecting it with an error. This helps developers write new "DATA{}" references to test reference outputs that have not yet been created. * The "ExternalProject" module learned to support lzma-compressed source tarballs with ".7z", ".tar.xz", and ".txz" extensions. * The "ExternalProject" module "ExternalProject_Add" command learned a new "BUILD_ALWAYS" option to cause the external project build step to run every time the host project is built. * The "ExternalProject" module "ExternalProject_Add" command learned a new "EXCLUDE_FROM_ALL" option to cause the external project target to have the "EXCLUDE_FROM_ALL" target property set. * The "ExternalProject" module "ExternalProject_Add_Step" command learned a new "EXCLUDE_FROM_MAIN" option to cause the step to not be a direct dependency of the main external project target. * The "ExternalProject" module "ExternalProject_Add" command learned a new "DOWNLOAD_NO_PROGRESS" option to disable progress output while downloading the source tarball. * The "FeatureSummary" module "feature_summary" API learned to accept multiple values for the "WHAT" option and combine them appropriately. * The "FindCUDA" module learned to support "fatbin" and "cubin" modules. * The "FindGTest" module "gtest_add_tests" macro learned a new "AUTO" option to automatically read the "SOURCES" target property of the test executable and scan the source files for tests to be added. * The "FindGLEW" module now provides imported targets. * The "FindGLUT" module now provides imported targets. * The "FindHg" module gained a new "Hg_WC_INFO" macro to help run "hg" to extract information about a Mercurial work copy. * The "FindOpenCL" module was introduced. * The "FindOpenGL" module now provides imported targets "OpenGL::GL" and "OpenGL::GLU" when the libraries are found. * The "FindOpenMP" module learned to support Fortran. * The "FindPkgConfig" module learned to use the "PKG_CONFIG" environment variable value as the "pkg-config" executable, if set. * The "FindZLIB" module now provides imported targets. * The "GenerateExportHeader" module "generate_export_header" function learned to allow use with *Object Libraries*. * The "InstallRequiredSystemLibraries" module gained a new "CMAKE_INSTALL_OPENMP_LIBRARIES" option to install MSVC OpenMP runtime libraries. * The "UseSWIG" module learned to detect the module name from ".i" source files if possible to avoid the need to set the "SWIG_MODULE_NAME" source file property explicitly. * The "WriteCompilerDetectionHeader" module was added to allow creation of a portable header file for compiler optional feature detection. Generator Expressions --------------------- * New "COMPILE_FEATURES" "generator expression" allows setting build properties based on available compiler features. CTest ----- * The "ctest_coverage()" command learned to read variable "CTEST_COVERAGE_EXTRA_FLAGS" to set "CoverageExtraFlags". * The "ctest_coverage()" command learned to support Intel coverage files with the "codecov" tool. * The "ctest_memcheck()" command learned to support sanitizer modes, including "AddressSanitizer", "MemorySanitizer", "ThreadSanitizer", and "UndefinedBehaviorSanitizer". Options may be set using the new "CTEST_MEMORYCHECK_SANITIZER_OPTIONS" variable. CPack ----- * "cpack(1)" gained an "IFW" generator to package using Qt Framework Installer tools. See the "CPackIFW" module. * "cpack(1)" gained "7Z" and "TXZ" generators supporting lzma- compressed archives. * The "CPackDeb" module learned a new "CPACK_DEBIAN_COMPRESSION_TYPE" variable to set the tarball compression type. * The "cpack(1)" "WiX" generator learned to support a "CPACK_WIX_ACL" installed file property to specify an Access Control List. Other ----- * The "cmake(1)" "-E" option learned a new "env" command. * The "cmake(1)" "-E tar" command learned to support lzma-compressed files. * *Object Libraries* may now have extra sources that do not compile to object files so long as they would not affect linking of a normal library (e.g. ".dat" is okay but not ".def"). * Visual Studio generators for VS 8 and later learned to support the "ASM_MASM" language. * The Visual Studio generators learned to treat ".hlsl" source files as High Level Shading Language sources (using "FXCompile" in ".vcxproj" files). A "VS_SHADER_TYPE" source file property was added to specify the Shader Type. New Diagnostics =============== * Policy "CMP0052" introduced to control directories in the "INTERFACE_INCLUDE_DIRECTORIES" of exported targets. Deprecated and Removed Features =============================== * In CMake 3.0 the "target_link_libraries()" command accidentally began allowing unquoted arguments to use "generator expressions" containing a (";" separated) list within them. For example: set(libs B C) target_link_libraries(A PUBLIC $) This is equivalent to writing: target_link_libraries(A PUBLIC $) and was never intended to work. It did not work in CMake 2.8.12. Such generator expressions should be in quoted arguments: set(libs B C) target_link_libraries(A PUBLIC "$") CMake 3.1 again requires the quotes for this to work correctly. * Callbacks established by the "variable_watch()" command will no longer receive the "ALLOWED_UNKNOWN_READ_ACCESS" access type when the undocumented "CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS" variable is set. Uninitialized variable accesses will always be reported as "UNKNOWN_READ_ACCESS". * The "CMakeDetermineVSServicePack" module now warns that it is deprecated and should not longer be used. Use the "CMAKE__COMPILER_VERSION" variable instead. * The "FindITK" module has been removed altogether. It was a thin- wrapper around "find_package(ITK ... NO_MODULE)". This produces much clearer error messages when ITK is not found. * The "FindVTK" module has been removed altogether. It was a thin- wrapper around "find_package(VTK ... NO_MODULE)". This produces much clearer error messages when VTK is not found. The module also provided compatibility support for finding VTK 4.0. This capability has been dropped. Other Changes ============= * The "cmake-gui(1)" learned to capture output from child processes started by the "execute_process()" command and display it in the output window. * The "cmake-language(7)" internal implementation of generator expression and list expansion parsers have been optimized and shows non-trivial speedup on large projects. * The Makefile generators learned to use response files with GNU tools on Windows to pass library directories and names to the linker. * When generating linker command-lines, CMake now avoids repeating items corresponding to SHARED library targets. * Support for the Open Watcom compiler has been overhauled. The "CMAKE__COMPILER_ID" is now "OpenWatcom", and the "CMAKE__COMPILER_VERSION" now uses the Open Watcom external version numbering. The external version numbers are lower than the internal version number by 11. * The "cmake-mode.el" major Emacs editing mode no longer treats "_" as part of words, making it more consistent with other major modes. ------------------------------------------------------------------- Changes made since CMake 3.1.0-rc1: Brad King (22): FindCurses: Include CheckLibraryExists before using it (#15220) Help: Clarify add_compile_options documentation (#15225) Help: Reference add_compile_options from add_definitions (#15225) KWSys: Fix configure_file call to use COPYONLY, not COPY_ONLY Qt4: Fix configure_file call to use COPYONLY, not COPY_ONLY FindIce: Drop use of :envvar: Sphinx markup Help: Drop TOC from latex manuals Help: Format add_library documented list of INTERFACE commands Help: Fix example in cmake-packages to avoid long line FindProtobuf: Cleanup reStructuredText documentation formatting Modules: Wrap long lines in pre-formatted documentation blocks Help: Tell latex to use a small font for cmake-language.7 productions Utilities/Sphinx: Fix html_favicon configuration Help: Update 3.1 release notes for dropping of FindITK and FindVTK Help: Wrap long lines in pre-formatted documentation blocks Help: Fix broken cross-references reported by 'nitpicky' option Xcode: Fix compiler path detection for iOS tools on Xcode <= 5.0 (#15237) ExternalProject: Restore logic to not download already-existing file Help: Link to GNUInstallDirs from CMAKE_INSTALL_PREFIX (#15246) Utilities/Sphinx: Add index entries for cross-references Help: Add 3.1 release note Emacs mode update CMake 3.1.0-rc2 Chuck Atkins (1): Workaround for short jump tables on PA-RISC. Clinton Stimpson (1): genex: Preserve order while evaluating TARGET_OBJECTS Daniele E. Domenichelli (1): Fix link line order when shared libraries are de-duplicated Iosif Neitzke (1): Help: Fix configure_file call to use COPYONLY, not COPY_ONLY J Decker (1): Watcom: Drop symfile linker option Nils Gladitz (1): Documentation: Fix minor typo thecommand -> the command Syohei YOSHIDA (1): cmake-mode.el: syntax of '_' should be treated as symbol ?dne Hovda (1): KWSys SystemInformation: Check for _SC_AIX_REALMEM before using it From brad.king at kitware.com Thu Nov 13 13:07:52 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Nov 2014 13:07:52 -0500 Subject: [cmake-developers] string SUBSTRING TRUNCATE mode In-Reply-To: <1476946.clnm8XJARf@caliban.sf-tec.de> References: <5464DA0E.9010808@kitware.com> <1476946.clnm8XJARf@caliban.sf-tec.de> Message-ID: <5464F378.4010605@kitware.com> On 11/13/2014 12:48 PM, Rolf Eike Beer wrote: > This should be a good addition, no? > > diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake > index 56d9b66..66717ef 100644 > --- a/Modules/CPackRPM.cmake > +++ b/Modules/CPackRPM.cmake > @@ -683,9 +683,7 @@ foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLIC > # Transform NAME --> Name e.g. PROVIDES --> Provides > # The Upper-case first letter and lowercase tail is the > # appropriate value required in the final RPM spec file. > - string(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH) > - math(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - 1") > - string(SUBSTRING ${_RPM_SPEC_HEADER} 1 ${_PACKAGE_HEADER_STRLENGTH} _PACKAGE_HEADER_TAIL) > + string(SUBSTRING ${_RPM_SPEC_HEADER} 1 -1 _PACKAGE_HEADER_TAIL) > string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) > string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) > set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") Yes, once the main change is in 'master' please add a topic to update call sites like this. Thanks, -Brad From dpolyanitsa at nvidia.com Thu Nov 13 13:08:01 2014 From: dpolyanitsa at nvidia.com (Dmitry Polyanitsa) Date: Thu, 13 Nov 2014 18:08:01 +0000 Subject: [cmake-developers] Update Nsight Tegra Project Revision Number Message-ID: Hello, I'd like to update the project rev number from 8 to 9 for the Nsight Tegra 2.0 projects. We had the need to increase the project number in a hotfix and would like CMake to emit that number as well. No other changes are needed. Attached is the formatted patch for the proposed change. -Dmitry -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Change-Nsight-Tegra-2.0-Project-Revision-Number-from.patch Type: application/octet-stream Size: 1207 bytes Desc: 0001-Change-Nsight-Tegra-2.0-Project-Revision-Number-from.patch URL: From eike at sf-mail.de Thu Nov 13 13:46:46 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Thu, 13 Nov 2014 19:46:46 +0100 Subject: [cmake-developers] string SUBSTRING TRUNCATE mode In-Reply-To: <5464F378.4010605@kitware.com> References: <1476946.clnm8XJARf@caliban.sf-tec.de> <5464F378.4010605@kitware.com> Message-ID: <1487783.NizaszzDfi@caliban.sf-tec.de> Am Donnerstag, 13. November 2014, 13:07:52 schrieben Sie: > On 11/13/2014 12:48 PM, Rolf Eike Beer wrote: > > This should be a good addition, no? > > > > diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake > > index 56d9b66..66717ef 100644 > > --- a/Modules/CPackRPM.cmake > > +++ b/Modules/CPackRPM.cmake > > @@ -683,9 +683,7 @@ foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS > > PROVIDES OBSOLETES PREFIX CONFLIC> > > # Transform NAME --> Name e.g. PROVIDES --> Provides > > # The Upper-case first letter and lowercase tail is the > > # appropriate value required in the final RPM spec file. > > > > - string(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH) > > - math(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - > > 1") - string(SUBSTRING ${_RPM_SPEC_HEADER} 1 > > ${_PACKAGE_HEADER_STRLENGTH} _PACKAGE_HEADER_TAIL) + string(SUBSTRING > > ${_RPM_SPEC_HEADER} 1 -1 _PACKAGE_HEADER_TAIL)> > > string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) > > string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) > > set(_PACKAGE_HEADER_NAME > > "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") > > Yes, once the main change is in 'master' please add a topic to > update call sites like this. This one is actually independent, as the -1 syntax was added by me years back. And AFAICT this is the only call site inside CMake itself that benefits from any of the advanced modes of SUBSTRING, there are very few call sites anyway. Eike -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From brad.king at kitware.com Thu Nov 13 14:07:40 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 13 Nov 2014 14:07:40 -0500 Subject: [cmake-developers] Update Nsight Tegra Project Revision Number In-Reply-To: References: Message-ID: <5465017C.9070702@kitware.com> On 11/13/2014 01:08 PM, Dmitry Polyanitsa wrote: > Attached is the formatted patch for the proposed change. Applied: VS: Change Nsight Tegra 2.0 Project Revision Number from 8 to 9 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bb3c87f1 Since this is an "environmental regression" I will include it in the next 3.1 release candidate. Thanks, -Brad From dpolyanitsa at nvidia.com Thu Nov 13 14:27:48 2014 From: dpolyanitsa at nvidia.com (Dmitry Polyanitsa) Date: Thu, 13 Nov 2014 19:27:48 +0000 Subject: [cmake-developers] Update Nsight Tegra Project Revision Number In-Reply-To: <5465017C.9070702@kitware.com> References: <5465017C.9070702@kitware.com> Message-ID: <38d7f2309eae4ab388d8901632e723cb@UKMAIL102.nvidia.com> Thank you! -Dmitry -----Original Message----- From: Brad King [mailto:brad.king at kitware.com] Sent: Thursday, November 13, 2014 10:08 PM To: Dmitry Polyanitsa Cc: cmake-developers at cmake.org Subject: Re: [cmake-developers] Update Nsight Tegra Project Revision Number On 11/13/2014 01:08 PM, Dmitry Polyanitsa wrote: > Attached is the formatted patch for the proposed change. Applied: VS: Change Nsight Tegra 2.0 Project Revision Number from 8 to 9 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bb3c87f1 Since this is an "environmental regression" I will include it in the next 3.1 release candidate. Thanks, -Brad From mantis at public.kitware.com Thu Nov 13 15:58:47 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Thu, 13 Nov 2014 15:58:47 -0500 Subject: [cmake-developers] =?utf-8?q?=5BCMake_0015251=5D=3A_=22The_CMAKE?= =?utf-8?q?=5FC=5FCOMPILER_=E2=80=A6_is_not_a_full_path_and_was_not?= =?utf-8?q?_found_in_the_PATH=22_if_using_CMakeDetermineSystem_and_?= =?utf-8?q?toolchain_file?= Message-ID: The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15251 ====================================================================== Reported By: Maxim Mikityanskiy Assigned To: ====================================================================== Project: CMake Issue ID: 15251 Category: CMake Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-13 15:58 EST Last Modified: 2014-11-13 15:58 EST ====================================================================== Summary: "The CMAKE_C_COMPILER ? is not a full path and was not found in the PATH" if using CMakeDetermineSystem and toolchain file Description: There is an issue that prevents any version of freerdp to build on Gentoo using CMake 3.0.2. At first, Gentoo's portage passes -DCMAKE_TOOLCHAIN_FILE=gentoo_toolchain.cmake to cmake command line; gentoo_toolchain.cmake contains following: SET (CMAKE_C_COMPILER x86_64-pc-linux-gnu-gcc) SET (CMAKE_CXX_COMPILER x86_64-pc-linux-gnu-g++) And when I try to build freerdp, the following message from CMake appears: cmake --no-warn-unused-cli -C /build/tmp/portage/net-misc/freerdp-1.1.0_beta1_p20130710-r2/work/freerdp-1.1.0_beta1_p20130710_build/gentoo_common_config.cmake -G Unix Makefiles -DCMAKE_INSTALL_PREFIX=/usr -DWITH_ALSA=ON -DWITH_CLIENT=ON -DWITH_CUPS=OFF -DWITH_DEBUG_ALL=OFF -DWITH_MANPAGES=OFF -DWITH_DIRECTFB=OFF -DWITH_FFMPEG=OFF -DWITH_GSTREAMER=OFF -DWITH_JPEG=ON -DWITH_PULSE=ON -DWITH_SERVER=OFF -DWITH_PCSC=OFF -DWITH_SSE2=ON -DCHANNEL_URBDRC=ON -DWITH_X11=ON -DWITH_XINERAMA=ON -DWITH_XV=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Gentoo -DCMAKE_INSTALL_DO_STRIP=OFF -DCMAKE_USER_MAKE_RULES_OVERRIDE=/build/tmp/portage/net-misc/freerdp-1.1.0_beta1_p20130710-r2/work/freerdp-1.1.0_beta1_p20130710_build/gentoo_rules.cmake -DCMAKE_TOOLCHAIN_FILE=/build/tmp/portage/net-misc/freerdp-1.1.0_beta1_p20130710-r2/work/freerdp-1.1.0_beta1_p20130710_build/gentoo_toolchain.cmake /build/tmp/portage/net-misc/freerdp-1.1.0_beta1_p20130710-r2/work/freerdp-1.1.0_beta1_p20130710 Not searching for unused variables given on the command line. loading initial cache file /build/tmp/portage/net-misc/freerdp-1.1.0_beta1_p20130710-r2/work/freerdp-1.1.0_beta1_p20130710_build/gentoo_common_config.cmake -- The C compiler identification is GNU 4.9.2 -- Check for working C compiler: /usr/lib64/ccache/bin/x86_64-pc-linux-gnu-gcc -- Check for working C compiler: /usr/lib64/ccache/bin/x86_64-pc-linux-gnu-gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Found PkgConfig: /usr/bin/x86_64-pc-linux-gnu-pkg-config (found version "0.28") -- FreeRDP GIT -- Git Revision n/a -- Performing Test Wno-unused-result -- Performing Test Wno-unused-result - Success -- Performing Test Wno-unused-but-set-variable -- Performing Test Wno-unused-but-set-variable - Success -- Performing Test Wno-deprecated-declarations -- Performing Test Wno-deprecated-declarations - Success -- Looking for include file fcntl.h -- Looking for include file fcntl.h - found -- Looking for include file unistd.h -- Looking for include file unistd.h - found -- Looking for include file stdint.h -- Looking for include file stdint.h - found -- Looking for include file inttypes.h -- Looking for include file inttypes.h - found -- Looking for include file sys/modem.h -- Looking for include file sys/modem.h - not found -- Looking for include file sys/filio.h -- Looking for include file sys/filio.h - not found -- Looking for include file sys/strtio.h -- Looking for include file sys/strtio.h - not found -- Looking for include file sys/select.h -- Looking for include file sys/select.h - found -- Performing Test HAVE_TM_GMTOFF -- Performing Test HAVE_TM_GMTOFF - Success -- Looking for include file pthread.h -- Looking for include file pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Looking for include file sys/eventfd.h -- Looking for include file sys/eventfd.h - found -- Finding recommended feature X11 for X11 (X11 client and server) -- Disable feature X11 using "-DWITH_X11=OFF" -- Found X11: /usr/lib64/libX11.so -- Skipping optional feature DirectFB for DirectFB (DirectFB client) -- Enable feature DirectFB using "-DWITH_DIRECTFB=ON" -- Finding required feature ZLIB for compression (data compression) -- Found ZLIB: /usr/lib64/libz.so (found version "1.2.8") -- Finding required feature OpenSSL for cryptography (encryption, certificate validation, hashing functions) -- Found OpenSSL: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so (found version "1.0.1j") -- Finding recommended feature ALSA for sound (audio input, audio output and multimedia redirection) -- Disable feature ALSA using "-DWITH_ALSA=OFF" -- Found ALSA: /usr/lib64/libasound.so (found version "1.0.28") -- Finding optional feature Pulse for sound (audio input, audio output and multimedia redirection) -- checking for module 'libpulse' -- found libpulse, version 5.0 -- Found Pulse: /usr/include -- Skipping optional feature Cups for printing (printer device redirection) -- Enable feature Cups using "-DWITH_CUPS=ON" -- Skipping optional feature PCSC for smart card (smart card device redirection) -- Enable feature PCSC using "-DWITH_PCSC=ON" -- Skipping recommended feature FFmpeg for multimedia (multimedia redirection, audio and video playback) -- Skipping recommended feature Gstreamer for multimedia (multimedia redirection, audio and video playback) -- Skipping optional feature IPP for performance (Intel Integrated Performance Primitives library) -- Enable feature IPP using "-DWITH_IPP=ON" -- Skipping optional feature NPP for performance (NVIDIA Performance Primitives library) -- Enable feature NPP using "-DWITH_NPP=ON" CMake Error at winpr/CMakeLists.txt:20 (project): The CMAKE_C_COMPILER: x86_64-pc-linux-gnu-gcc is not a full path and was not found in the PATH. Tell CMake where to find the compiler by setting either the environment variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. I tried to reproduce the bug with minimal CMakeLists.txt. The bug can be reproduced with the following script: mkdir src cat > CMakeLists.txt << "EOF" cmake_minimum_required(VERSION 3.0.2) project(test C) include(CMakeDetermineSystem) add_subdirectory(src) EOF cat > src/CMakeLists.txt << "EOF" cmake_minimum_required(VERSION 3.0.2) project(src C) EOF cat > toolchain.cmake << "EOF" set(CMAKE_C_COMPILER x86_64-pc-linux-gnu-gcc) EOF cmake . -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake You will see the following output: -- The C compiler identification is GNU 4.9.2 -- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc -- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done CMake Error at src/CMakeLists.txt:2 (project): The CMAKE_C_COMPILER: x86_64-pc-linux-gnu-gcc is not a full path and was not found in the PATH. Tell CMake where to find the compiler by setting either the environment variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. -- Configuring incomplete, errors occurred! See also "/tmp/test/CMakeFiles/CMakeOutput.log". I think that the reason of the bug is that CMake sets CMAKE_C_COMPILER=/usr/bin/x86_64-pc-linux-gnu-gcc after parsing toolchain file, but CMakeDetermineSystem module includes toolchain file again, and now CMAKE_C_COMPILER=x86_64-pc-linux-gnu-gcc, which leads to failure. Steps to Reproduce: Look at script above. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-13 15:58 Maxim MikityanskiyNew Issue ====================================================================== From domen.vrankar at gmail.com Fri Nov 14 02:26:15 2014 From: domen.vrankar at gmail.com (Domen Vrankar) Date: Fri, 14 Nov 2014 08:26:15 +0100 Subject: [cmake-developers] string SUBSTRING TRUNCATE mode In-Reply-To: <1487783.NizaszzDfi@caliban.sf-tec.de> References: <1476946.clnm8XJARf@caliban.sf-tec.de> <5464F378.4010605@kitware.com> <1487783.NizaszzDfi@caliban.sf-tec.de> Message-ID: >> > This should be a good addition, no? >> > >> > diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake >> > index 56d9b66..66717ef 100644 >> > --- a/Modules/CPackRPM.cmake >> > +++ b/Modules/CPackRPM.cmake >> > @@ -683,9 +683,7 @@ foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS >> > PROVIDES OBSOLETES PREFIX CONFLIC> >> > # Transform NAME --> Name e.g. PROVIDES --> Provides >> > # The Upper-case first letter and lowercase tail is the >> > # appropriate value required in the final RPM spec file. >> > >> > - string(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH) >> > - math(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - >> > 1") - string(SUBSTRING ${_RPM_SPEC_HEADER} 1 >> > ${_PACKAGE_HEADER_STRLENGTH} _PACKAGE_HEADER_TAIL) + string(SUBSTRING >> > ${_RPM_SPEC_HEADER} 1 -1 _PACKAGE_HEADER_TAIL)> >> > string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) >> > string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) >> > set(_PACKAGE_HEADER_NAME >> > "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") You're right. Can you provide a separate patch as it is not related to the new feature? > This one is actually independent, as the -1 syntax was added by me years back. > And AFAICT this is the only call site inside CMake itself that benefits from > any of the advanced modes of SUBSTRING, there are very few call sites anyway. I'm currently writing a patch for CPackRPM.cmake that will use SUBSTRING a bit more and the new patch already uses -1 syntax and also requires the new patch with which I'll be able to remove range checks with if statements on some locations. Domen From mantis at public.kitware.com Fri Nov 14 07:59:45 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Fri, 14 Nov 2014 07:59:45 -0500 Subject: [cmake-developers] [CMake 0015252]: find_package() may list considered but not accepted package configuration files more than once Message-ID: <8170ac6cb026cfd4e9f5d90f6e600c19@www.cmake.org> The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15252 ====================================================================== Reported By: Nils Gladitz Assigned To: ====================================================================== Project: CMake Issue ID: 15252 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-14 07:59 EST Last Modified: 2014-11-14 07:59 EST ====================================================================== Summary: find_package() may list considered but not accepted package configuration files more than once Description: If on windows a package is listed in HKEY_LOCAL_MACHINE\Software\Kitware\CMake\Packages\ and also installed under one of the standard ProgramFiles directories it seems to be checked twice. When no compatible package is found this is reflected in the diagnostic which will list the package after "The following configuration files were considered but not accepted:" twice. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-14 07:59 Nils Gladitz New Issue ====================================================================== From peter at pcc.me.uk Fri Nov 14 10:57:24 2014 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 14 Nov 2014 07:57:24 -0800 Subject: [cmake-developers] [wip/patch] Expose Ninja console pool feature for custom commands/targets In-Reply-To: <20141105233525.GA7567@erythro> References: <20141104002256.GA29444@pcc.me.uk> <20141105211213.GA9592@pcc.me.uk> <20141105214952.GA16571@erythro> <20141105230302.GB10722@pcc.me.uk> <20141105233525.GA7567@erythro> Message-ID: <20141114155724.GA2673@pcc.me.uk> On Wed, Nov 05, 2014 at 06:35:25PM -0500, Ben Boeckel wrote: > On Wed, Nov 05, 2014 at 15:03:02 -0800, Peter Collingbourne wrote: > > On Wed, Nov 05, 2014 at 04:49:52PM -0500, Ben Boeckel wrote: > > > For the testing of it, since only Ninja supports it, maybe it would be > > > possible to run a program which exits testing for isatty(STDIN_FILENO) > > > or isatty(STDOUT_FILENO). > > > > I considered that, and indeed this is how I tested the console pool feature > > in Ninja's test suite [1]. (That test disables itself if the test suite > > itself does not have access to the console.) > > > > The problem is that CTest does not give Ninja direct access to the console, > > so a test like the one Ninja uses wouldn't work, or at least it wouldn't > > provide coverage if the test suite is invoked in the normal way. I don't know > > enough about CTest to know if there is some way to get it to pass through > > console access. > > Hrm. Forgot about that :( . The best I can think of is to have certain > dashboards run it separately, but that means we still need some way to > get it to the dashboard and for it *not* to run on the other dashboards > as a always-fail (maybe WILL_FAIL TRUE to make sure it actually > *detects* it?). Anyways, I wouldn't worry about it too much due to the > many issues. > > > I would rather keep things simple and have this flag always be > > opportunistic. Remember that the build tool could be invoked with or without > > a terminal, so I would expect commands to normally do something sensible > > if it turns out not to be available. We might want to have a mechanism to > > control whether targets appear in IDEs, but that seems like it should be a > > separate feature. > > Good point. It was more to get the ideas out in the air than a formal > request for change. Okay, I've renamed the new flag to 'USES_TERMINAL' and merged to next. Thanks, -- Peter From DLRdave at aol.com Fri Nov 14 11:27:47 2014 From: DLRdave at aol.com (David Cole) Date: Fri, 14 Nov 2014 11:27:47 -0500 Subject: [cmake-developers] Failing CMake WinStorePhone tests Message-ID: Hi, The VSWinStorePhone tests are failing on my dashboard submissions: http://open.cdash.org/viewTest.php?onlyfailed&buildid=3570369 http://open.cdash.org/viewTest.php?onlyfailed&buildid=3570163 I just upgraded that machine to Windows 8.1 and Visual Studio 2013, and these dashboards run in a VS environment, but with the "Ninja" generator. Should I expect these tests to pass using Ninja, or is that beyond the scope of the WinStorePhone support...? (i.e. -- do you have to use a Visual Studio generator for this feature, or should also work with Ninja, jom or NMake Makefiles?) Thanks, David C. From brad.king at kitware.com Fri Nov 14 11:38:13 2014 From: brad.king at kitware.com (Brad King) Date: Fri, 14 Nov 2014 11:38:13 -0500 Subject: [cmake-developers] Failing CMake WinStorePhone tests In-Reply-To: References: Message-ID: <54662FF5.6040806@kitware.com> On 11/14/2014 11:27 AM, David Cole via cmake-developers wrote: > Should I expect these tests to pass using Ninja, or is that beyond the > scope of the WinStorePhone support...? The VS generator is needed for the feature, but the tests that are failing hard-code use of specific Visual Studio generators regardless of the main generator being tested. I'll defer to Gilles as for what the problem might be. -Brad From ruslan_baratov at yahoo.com Fri Nov 14 12:31:33 2014 From: ruslan_baratov at yahoo.com (Ruslan Baratov) Date: Fri, 14 Nov 2014 20:31:33 +0300 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <5464D65D.6030902@kitware.com> References: <5431B11C.3010209@yahoo.com> <54329100.8020502@kitware.com> <54338CF1.3070304@yahoo.com> <5433DBC1.5080800@kitware.com> <5435257B.80201@yahoo.com> <543531CC.7090103@kitware.com> <5437C6CA.3030201@yahoo.com> <543BE40C.4000404@kitware.com> <544FFC83.4090107@yahoo.com> <5450F03F.2040500@kitware.com> <54538976.5050007@yahoo.com> <5453912F.6000305@kitware.com> <546132DB.7020209@yahoo.com> <54625542.8050808@kitware.com> <5464B9A1.9050903@yahoo.com> <5464D65D.6030902@kitware.com> Message-ID: <54663C75.8000403@yahoo.com> ConvertToWindowsExtendedPath fix + tests -------------- next part -------------- >From e994378d61e64136043d9db614762e79927766cb Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 14 Nov 2014 21:09:35 +0400 Subject: [PATCH 1/6] Add class cmFileLockResult --- Source/cmFileLockResult.cxx | 111 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockResult.h | 85 +++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 Source/cmFileLockResult.cxx create mode 100644 Source/cmFileLockResult.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 + +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 // 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 -- 2.1.1 -------------- next part -------------- >From 75f6f8af99ef2f4aa5120b2603da051cef72974c Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 14 Nov 2014 21:12:05 +0400 Subject: [PATCH 2/6] Add class cmFileLock --- Source/cmFileLock.cxx | 77 +++++++++++++++++++++++++++ Source/cmFileLock.h | 74 ++++++++++++++++++++++++++ Source/cmFileLockUnix.cxx | 102 ++++++++++++++++++++++++++++++++++++ Source/cmFileLockWin32.cxx | 126 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 379 insertions(+) create mode 100644 Source/cmFileLock.cxx create mode 100644 Source/cmFileLock.h create mode 100644 Source/cmFileLockUnix.cxx create mode 100644 Source/cmFileLockWin32.cxx diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx new file mode 100644 index 0000000..f69c36a --- /dev/null +++ b/Source/cmFileLock.cxx @@ -0,0 +1,77 @@ +/*============================================================================ + 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 +#include "cmFileLockResult.h" + +// Common implementation + +cmFileLock::~cmFileLock() +{ + if (!this->Filename.empty()) + { + const cmFileLockResult result = this->Release(); + 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(-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..7c2803b --- /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 // HANDLE +#endif + +class cmFileLockResult; + +/** + * @brief Cross-platform file locking. + * @detail 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. + * @detail 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/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx new file mode 100644 index 0000000..519df3e --- /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 +#include // SEEK_SET +#include +#include // sleep + +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 != EAGAIN) + { + return cmFileLockResult::MakeSystem(); + } + } + else + { + return cmFileLockResult::MakeOk(); + } + if (seconds == 0) + { + return cmFileLockResult::MakeTimeout(); + } + --seconds; + ::sleep(1); + } +} + +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 = 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..a589ed9 --- /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 // 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(-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; + ::Sleep(1000); + } +} + +BOOL cmFileLock::LockFile(DWORD flags) +{ + const DWORD reserved = 0; + const unsigned long len = static_cast(-1); + static OVERLAPPED overlapped; + return LockFileEx( + this->File, + flags, + reserved, + len, + len, + &overlapped + ); +} -- 2.1.1 -------------- next part -------------- >From c24787dbc5f4dae5bdd542541c4854e63fdcabce Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 14 Nov 2014 21:12:38 +0400 Subject: [PATCH 3/6] Add class cmFileLockPool --- Source/cmFileLockPool.cxx | 198 ++++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockPool.h | 100 +++++++++++++++++++++++ 2 files changed, 298 insertions(+) create mode 100644 Source/cmFileLockPool.cxx create mode 100644 Source/cmFileLockPool.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 + +#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 List; + typedef List::iterator It; + typedef List::const_iterator CIt; + + List Locks; + }; + + typedef std::list List; + + typedef List::iterator It; + typedef List::const_iterator CIt; + + List FunctionScopes; + List FileScopes; + ScopePool ProcessScope; +}; + +#endif // cmFileLockPool_h -- 2.1.1 -------------- next part -------------- >From bf44fbdf33444f738eee8c83180c29862921d746 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 14 Nov 2014 21:13:32 +0400 Subject: [PATCH 4/6] New command 'file(LOCK ...)' --- Source/CMakeLists.txt | 6 ++ Source/cmFileCommand.cxx | 192 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileCommand.h | 1 + Source/cmGlobalGenerator.h | 6 ++ Source/cmLocalGenerator.cxx | 2 + Source/cmMakefile.cxx | 4 + bootstrap | 3 + 7 files changed, 214 insertions(+) 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/cmFileCommand.cxx b/Source/cmFileCommand.cxx index b0ddff4..7d5d4c7 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -23,6 +23,8 @@ #include "cm_curl.h" #endif +#include "cmFileLockResult.h" + #undef GetCurrentDirectory #include #include @@ -202,6 +204,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 +3508,192 @@ bool cmFileCommand::HandleGenerateCommand( } //---------------------------------------------------------------------------- +bool cmFileCommand::HandleLockCommand( + std::vector const& args) +{ + // 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(-1); + + // Parse arguments + if(args.size() < 2) + { + this->SetError("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->SetError(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: \"" << args[i] << "\"."; + this->SetError(e.str()); + return false; + } + } + } + else if (args[i] == "RESULT_VARIABLE") + { + ++i; + if (i >= args.size()) + { + this->SetError(": expected variable name after RESULT_VARIABLE"); + return false; + } + resultVariable = args[i]; + } + else if (args[i] == "TIMEOUT") + { + ++i; + if (i >= args.size()) + { + this->SetError(": expected timeout value after TIMEOUT"); + return false; + } + int scanned; + if(sscanf(args[i].c_str(), "%d", &scanned) != 1 || scanned < 0) + { + cmOStringStream e; + e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer."; + this->SetError(e.str()); + return false; + } + timeout = static_cast(scanned); + } + else + { + cmOStringStream e; + e << ": expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT"; + e << ", but got: \"" << args[i] << "\"."; + this->SetError(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 \"" << parentDir << "\" creation failed "; + e << "(check permissions)."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + FILE *file = cmsys::SystemTools::Fopen(path, "w"); + if (!file) + { + cmOStringStream e; + e << ": file \"" << path << "\" creation failed (check permissions)."; + this->SetError(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 \"" << path << "\" (" << result << ")."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + + if (!resultVariable.empty()) + { + this->Makefile->AddDefinition(resultVariable, result.c_str()); + } + + return true; +} + +//---------------------------------------------------------------------------- bool cmFileCommand::HandleTimestampCommand( std::vector 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 const& args); bool HandleGenerateCommand(std::vector const& args); + bool HandleLockCommand(std::vector const& args); private: void AddEvaluationFile(const std::string &inputName, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ddd7e91..00ba9a0 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -21,6 +21,7 @@ #include "cmExportSetMap.h" // For cmExportSetMap #include "cmGeneratorTarget.h" #include "cmGeneratorExpression.h" +#include "cmFileLockPool.h" #if defined(CMAKE_BUILD_WITH_CMAKE) # include @@ -341,6 +342,8 @@ public: bool GenerateCPackPropertiesFile(); + cmFileLockPool& GetFileLockPool() { return FileLockPool; } + protected: virtual void Generate(); @@ -488,6 +491,9 @@ private: // track targets to issue CMP0042 warning for. std::set CMP0042WarnTargets; + + // Pool of file locks + cmFileLockPool FileLockPool; }; #endif diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 69b56c6..27cb8d0 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -79,9 +79,11 @@ public: this->GG = lg->GetGlobalGenerator(); this->LG = this->GG->GetCurrentLocalGenerator(); this->GG->SetCurrentLocalGenerator(lg); + this->GG->GetFileLockPool().PushFileScope(); } ~cmLocalGeneratorCurrent() { + this->GG->GetFileLockPool().PopFileScope(); this->GG->SetCurrentLocalGenerator(this->LG); } }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8a8aadc..a94c752 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4426,6 +4426,8 @@ void cmMakefile::PushScope() this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PushFunctionScope(); } void cmMakefile::PopScope() @@ -4463,6 +4465,8 @@ void cmMakefile::PopScope() { this->Internal->VarUsageStack.top().insert(*it); } + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PopFunctionScope(); } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) diff --git a/bootstrap b/bootstrap index 94bed0e..19189d3 100755 --- a/bootstrap +++ b/bootstrap @@ -286,6 +286,9 @@ CMAKE_CXX_SOURCES="\ cmSystemTools \ cmTestGenerator \ cmVersion \ + cmFileLock \ + cmFileLockPool \ + cmFileLockResult \ cmFileTimeComparison \ cmGlobalUnixMakefileGenerator3 \ cmLocalUnixMakefileGenerator3 \ -- 2.1.1 -------------- next part -------------- >From 44de0f497e810aa43b115b4afbcff92be9d0d15d Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 14 Nov 2014 21:15:37 +0400 Subject: [PATCH 5/6] Update documentation of command file (LOCK option) --- Help/command/file.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 [DIRECTORY] [RELEASE] + [GUARD ] + [RESULT_VARIABLE ] + [TIMEOUT ]) + +Lock a file specified by ```` if no ``DIRECTORY`` option present and file +``/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 ```` value. Any errors will be interpreted as fatal if there is no +``RESULT_VARIABLE`` option. Otherwise result will be stored in ```` +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. -- 2.1.1 -------------- next part -------------- >From 8520bdd2182e9b27e191c36117b0c2a546975575 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 14 Nov 2014 21:27:04 +0400 Subject: [PATCH 6/6] Add tests for command 'file(LOCK ...)' --- .../RunCMake/file/LOCK-error-lock-fail-result.txt | 1 + .../RunCMake/file/LOCK-error-lock-fail-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-lock-fail.cmake | 6 ++++ Tests/RunCMake/file/LOCK-error-no-path-result.txt | 1 + Tests/RunCMake/file/LOCK-error-no-path-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-no-path.cmake | 1 + .../file/LOCK-error-unknown-option-result.txt | 1 + .../file/LOCK-error-unknown-option-stderr.txt | 5 +++ .../RunCMake/file/LOCK-error-unknown-option.cmake | 1 + Tests/RunCMake/file/LOCK-stdout.txt | 11 ++++++ Tests/RunCMake/file/LOCK.cmake | 40 ++++++++++++++++++++++ Tests/RunCMake/file/RunCMakeTest.cmake | 4 +++ .../file/subdir_test_unlock/CMakeLists.txt | 2 ++ 13 files changed, 81 insertions(+) create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-path-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-path-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-path.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option.cmake create mode 100644 Tests/RunCMake/file/LOCK-stdout.txt create mode 100644 Tests/RunCMake/file/LOCK.cmake create mode 100644 Tests/RunCMake/file/subdir_test_unlock/CMakeLists.txt 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..753b063 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-lock-fail-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-lock-fail.cmake:[0-9]+ \(file\): + 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-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-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..ec9d3aa --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-unknown-option-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at LOCK-error-unknown-option\.cmake:[0-9]+ \(file\): + 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..b13f46d 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -3,3 +3,7 @@ include(RunCMake) run_cmake(INSTALL-DIRECTORY) run_cmake(INSTALL-MESSAGE-bad) run_cmake(FileOpenFailRead) +run_cmake(LOCK) +run_cmake(LOCK-error-lock-fail) +run_cmake(LOCK-error-no-path) +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) -- 2.1.1 From Gilles.Khouzam at microsoft.com Fri Nov 14 12:23:39 2014 From: Gilles.Khouzam at microsoft.com (Gilles Khouzam) Date: Fri, 14 Nov 2014 17:23:39 +0000 Subject: [cmake-developers] Failing CMake WinStorePhone tests In-Reply-To: <54662FF5.6040806@kitware.com> References: <54662FF5.6040806@kitware.com> Message-ID: Hi David, Let me take a look at what's going on. -----Original Message----- From: Brad King [mailto:brad.king at kitware.com] Sent: Friday, November 14, 2014 08:38 To: David Cole Cc: cmake-developers at cmake.org; Gilles Khouzam Subject: Re: [cmake-developers] Failing CMake WinStorePhone tests On 11/14/2014 11:27 AM, David Cole via cmake-developers wrote: > Should I expect these tests to pass using Ninja, or is that beyond the > scope of the WinStorePhone support...? The VS generator is needed for the feature, but the tests that are failing hard-code use of specific Visual Studio generators regardless of the main generator being tested. I'll defer to Gilles as for what the problem might be. -Brad From DLRdave at aol.com Fri Nov 14 13:41:47 2014 From: DLRdave at aol.com (David Cole) Date: Fri, 14 Nov 2014 13:41:47 -0500 Subject: [cmake-developers] Failing CMake WinStorePhone tests In-Reply-To: References: <54662FF5.6040806@kitware.com> Message-ID: I was hoping you'd say that! :-) On Fri, Nov 14, 2014 at 12:23 PM, Gilles Khouzam wrote: > Hi David, > > Let me take a look at what's going on. > > -----Original Message----- > From: Brad King [mailto:brad.king at kitware.com] > Sent: Friday, November 14, 2014 08:38 > To: David Cole > Cc: cmake-developers at cmake.org; Gilles Khouzam > Subject: Re: [cmake-developers] Failing CMake WinStorePhone tests > > On 11/14/2014 11:27 AM, David Cole via cmake-developers wrote: >> Should I expect these tests to pass using Ninja, or is that beyond the >> scope of the WinStorePhone support...? > > The VS generator is needed for the feature, but the tests that are failing hard-code use of specific Visual Studio generators regardless of the main generator being tested. > > I'll defer to Gilles as for what the problem might be. > > -Brad > From brad.king at kitware.com Fri Nov 14 14:58:11 2014 From: brad.king at kitware.com (Brad King) Date: Fri, 14 Nov 2014 14:58:11 -0500 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <54663C75.8000403@yahoo.com> References: <5431B11C.3010209@yahoo.com> <54329100.8020502@kitware.com> <54338CF1.3070304@yahoo.com> <5433DBC1.5080800@kitware.com> <5435257B.80201@yahoo.com> <543531CC.7090103@kitware.com> <5437C6CA.3030201@yahoo.com> <543BE40C.4000404@kitware.com> <544FFC83.4090107@yahoo.com> <5450F03F.2040500@kitware.com> <54538976.5050007@yahoo.com> <5453912F.6000305@kitware.com> <546132DB.7020209@yahoo.com> <54625542.8050808@kitware.com> <5464B9A1.9050903@yahoo.com> <5464D65D.6030902@kitware.com> <54663C75.8000403@yahoo.com> Message-ID: <54665ED3.3060300@kitware.com> On 11/14/2014 12:31 PM, Ruslan Baratov wrote: > ConvertToWindowsExtendedPath fix + tests Thanks. I started testing on Linux so far. A few more comments: - Please add more test cases covering all the file(LOCK) argument processing error messages. - Please squash in the attached patch to your commit that adds the file(LOCK) command to CMake. We should not need to build it during bootstrap. - Instead of ::sleep you can use cmSystemTools::Delay() - We need to test whether failing to lock after a timeout actually works. I tried adding a line to Tests/RunCMake/file/LOCK.cmake: file(LOCK "${lfile}" TIMEOUT 3) at the end of the file, duplicating the one before it. I expected to see a 3 second delay followed by a lock failure. Instead it fails immediately. Is that expected? Thanks, -Brad -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-file-LOCK-Drop-this-API-during-CMake-bootstrap-build.patch Type: text/x-diff Size: 4306 bytes Desc: not available URL: From ruslan_baratov at yahoo.com Fri Nov 14 18:27:40 2014 From: ruslan_baratov at yahoo.com (Ruslan Baratov) Date: Sat, 15 Nov 2014 02:27:40 +0300 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <54665ED3.3060300@kitware.com> References: <5431B11C.3010209@yahoo.com> <54329100.8020502@kitware.com> <54338CF1.3070304@yahoo.com> <5433DBC1.5080800@kitware.com> <5435257B.80201@yahoo.com> <543531CC.7090103@kitware.com> <5437C6CA.3030201@yahoo.com> <543BE40C.4000404@kitware.com> <544FFC83.4090107@yahoo.com> <5450F03F.2040500@kitware.com> <54538976.5050007@yahoo.com> <5453912F.6000305@kitware.com> <546132DB.7020209@yahoo.com> <54625542.8050808@kitware.com> <5464B9A1.9050903@yahoo.com> <5464D65D.6030902@kitware.com> <54663C75.8000403@yahoo.com> <54665ED3.3060300@kitware.com> Message-ID: <54668FEC.5020203@yahoo.com> On 14-Nov-14 22:58, Brad King wrote: > - Please add more test cases covering all the file(LOCK) > argument processing error messages. Done. Also I've found parse issue which is based on `sscanf` behaviour, e.g. string '123xyz' will be successfully parsed as a integer (%d). Same issue for example in file(STRINGS) command: > cat script.cmake set(tmp "${CMAKE_CURRENT_LIST_DIR}/temp-file") file(WRITE "${tmp}" "qwertyuiopasdfghjklzxcvbnm") file(STRINGS "${tmp}" result LIMIT_INPUT 7) message("result(1): ${result}") file(STRINGS "${tmp}" result LIMIT_INPUT 7abc) # expected error message message("result(2): ${result}") > cmake -P script.cmake result(1): qwertyu result(2): qwertyu > > - Please squash in the attached patch to your commit that > adds the file(LOCK) command to CMake. We should not need > to build it during bootstrap. > > - Instead of ::sleep you can use cmSystemTools::Delay() Done > - We need to test whether failing to lock after a timeout > actually works. I tried adding a line to > Tests/RunCMake/file/LOCK.cmake: > > file(LOCK "${lfile}" TIMEOUT 3) > > at the end of the file, duplicating the one before it. > I expected to see a 3 second delay followed by a lock > failure. Instead it fails immediately. Is that expected? Yes, since we know that we already own the lock nothing will change after timeout - it still be locked by us. On linux you can test timeout by: > cat script.cmake file(LOCK "${CMAKE_CURRENT_LIST_DIR}/file-to-lock" TIMEOUT 5) execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 10) > cmake -P script.cmake & # start one instance in background > cmake -P script.cmake # start second instance, expected lock failed by timeout CMake Error at script.cmake:1 (file): file : error locking file "/.../file-to-lock" (Timeout reached). Ruslo -------------- next part -------------- >From aa6418cd5a9bad2dfa26aae657d354d02cc39d20 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 15 Nov 2014 02:10:45 +0300 Subject: [PATCH 1/6] Add class cmFileLockResult --- Source/cmFileLockResult.cxx | 111 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockResult.h | 85 +++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 Source/cmFileLockResult.cxx create mode 100644 Source/cmFileLockResult.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 + +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 // 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 -- 2.1.1 -------------- next part -------------- >From 430e477ff5f11605eed885e9efaf47c721e7d258 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 15 Nov 2014 02:11:10 +0300 Subject: [PATCH 2/6] Add class cmFileLock --- Source/cmFileLock.cxx | 77 +++++++++++++++++++++++++++ Source/cmFileLock.h | 74 ++++++++++++++++++++++++++ Source/cmFileLockUnix.cxx | 102 ++++++++++++++++++++++++++++++++++++ Source/cmFileLockWin32.cxx | 126 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 379 insertions(+) create mode 100644 Source/cmFileLock.cxx create mode 100644 Source/cmFileLock.h create mode 100644 Source/cmFileLockUnix.cxx create mode 100644 Source/cmFileLockWin32.cxx diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx new file mode 100644 index 0000000..f69c36a --- /dev/null +++ b/Source/cmFileLock.cxx @@ -0,0 +1,77 @@ +/*============================================================================ + 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 +#include "cmFileLockResult.h" + +// Common implementation + +cmFileLock::~cmFileLock() +{ + if (!this->Filename.empty()) + { + const cmFileLockResult result = this->Release(); + 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(-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..7c2803b --- /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 // HANDLE +#endif + +class cmFileLockResult; + +/** + * @brief Cross-platform file locking. + * @detail 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. + * @detail 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/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx new file mode 100644 index 0000000..3c01da8 --- /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 +#include // SEEK_SET +#include +#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 != 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 = 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 // 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(-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(-1); + static OVERLAPPED overlapped; + return LockFileEx( + this->File, + flags, + reserved, + len, + len, + &overlapped + ); +} -- 2.1.1 -------------- next part -------------- >From 0692906e52de15ae4d7b591b65e1c79012ba9a34 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 15 Nov 2014 02:11:27 +0300 Subject: [PATCH 3/6] Add class cmFileLockPool --- Source/cmFileLockPool.cxx | 198 ++++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockPool.h | 100 +++++++++++++++++++++++ 2 files changed, 298 insertions(+) create mode 100644 Source/cmFileLockPool.cxx create mode 100644 Source/cmFileLockPool.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 + +#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 List; + typedef List::iterator It; + typedef List::const_iterator CIt; + + List Locks; + }; + + typedef std::list List; + + typedef List::iterator It; + typedef List::const_iterator CIt; + + List FunctionScopes; + List FileScopes; + ScopePool ProcessScope; +}; + +#endif // cmFileLockPool_h -- 2.1.1 -------------- next part -------------- >From d10007c146256dc7b3778962c1911c52557c5cae Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 15 Nov 2014 02:11:52 +0300 Subject: [PATCH 4/6] New command 'file(LOCK ...)' --- Source/CMakeLists.txt | 6 ++ Source/cmFileCommand.cxx | 197 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileCommand.h | 1 + Source/cmGlobalGenerator.h | 10 +++ Source/cmLocalGenerator.cxx | 6 ++ Source/cmMakefile.cxx | 8 ++ 6 files changed, 228 insertions(+) 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/cmFileCommand.cxx b/Source/cmFileCommand.cxx index b0ddff4..78cb5b5 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,198 @@ bool cmFileCommand::HandleGenerateCommand( } //---------------------------------------------------------------------------- +bool cmFileCommand::HandleLockCommand( + std::vector 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(-1); + + // Parse arguments + if(args.size() < 2) + { + this->SetError("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->SetError(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: \"" << args[i] << "\"."; + this->SetError(e.str()); + return false; + } + } + } + else if (args[i] == "RESULT_VARIABLE") + { + ++i; + if (i >= args.size()) + { + this->SetError(": expected variable name after RESULT_VARIABLE"); + return false; + } + resultVariable = args[i]; + } + else if (args[i] == "TIMEOUT") + { + ++i; + if (i >= args.size()) + { + this->SetError(": expected timeout value after TIMEOUT"); + return false; + } + int scanned; + if(sscanf(args[i].c_str(), "%d", &scanned) != 1 || scanned < 0) + { + cmOStringStream e; + e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer."; + this->SetError(e.str()); + return false; + } + timeout = static_cast(scanned); + } + else + { + cmOStringStream e; + e << ": expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT"; + e << ", but got: \"" << args[i] << "\"."; + this->SetError(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 \"" << parentDir << "\" creation failed "; + e << "(check permissions)."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + FILE *file = cmsys::SystemTools::Fopen(path, "w"); + if (!file) + { + cmOStringStream e; + e << ": file \"" << path << "\" creation failed (check permissions)."; + this->SetError(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 \"" << path << "\" (" << result << ")."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + + if (!resultVariable.empty()) + { + this->Makefile->AddDefinition(resultVariable, result.c_str()); + } + + return true; +#else + static_cast(args); + this->SetError("sub-command LOCK not implemented in bootstrap cmake"); + return false; +#endif +} + +//---------------------------------------------------------------------------- bool cmFileCommand::HandleTimestampCommand( std::vector 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 const& args); bool HandleGenerateCommand(std::vector const& args); + bool HandleLockCommand(std::vector const& args); private: void AddEvaluationFile(const std::string &inputName, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ddd7e91..15fdcb8 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 #endif @@ -341,6 +342,10 @@ public: bool GenerateCPackPropertiesFile(); +#if defined(CMAKE_BUILD_WITH_CMAKE) + cmFileLockPool& GetFileLockPool() { return FileLockPool; } +#endif + protected: virtual void Generate(); @@ -488,6 +493,11 @@ private: // track targets to issue CMP0042 warning for. std::set CMP0042WarnTargets; + +#if defined(CMAKE_BUILD_WITH_CMAKE) + // Pool of file locks + cmFileLockPool FileLockPool; +#endif }; #endif diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 69b56c6..abafa0f 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 8a8aadc..5484421 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4426,6 +4426,10 @@ void cmMakefile::PushScope() this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PushFunctionScope(); +#endif } void cmMakefile::PopScope() @@ -4463,6 +4467,10 @@ void cmMakefile::PopScope() { this->Internal->VarUsageStack.top().insert(*it); } +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PopFunctionScope(); +#endif } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) -- 2.1.1 -------------- next part -------------- >From 7541ca63444bda42ff5d65905463f5c77fac3ee9 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 15 Nov 2014 02:12:36 +0300 Subject: [PATCH 5/6] Update documentation of command file (LOCK option) --- Help/command/file.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 [DIRECTORY] [RELEASE] + [GUARD ] + [RESULT_VARIABLE ] + [TIMEOUT ]) + +Lock a file specified by ```` if no ``DIRECTORY`` option present and file +``/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 ```` value. Any errors will be interpreted as fatal if there is no +``RESULT_VARIABLE`` option. Otherwise result will be stored in ```` +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. -- 2.1.1 -------------- next part -------------- >From 62db776f65115657dc130284b8940c815d4eb038 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 15 Nov 2014 02:13:33 +0300 Subject: [PATCH 6/6] Add tests for command 'file(LOCK ...)' --- .../file/LOCK-error-file-create-fail-result.txt | 1 + .../file/LOCK-error-file-create-fail-stderr.txt | 6 ++++ .../file/LOCK-error-file-create-fail.cmake | 3 ++ .../file/LOCK-error-guard-incorrect-result.txt | 1 + .../file/LOCK-error-guard-incorrect-stderr.txt | 4 +++ .../RunCMake/file/LOCK-error-guard-incorrect.cmake | 1 + .../file/LOCK-error-incorrect-timeout-result.txt | 1 + .../file/LOCK-error-incorrect-timeout-stderr.txt | 4 +++ .../file/LOCK-error-incorrect-timeout.cmake | 1 + .../RunCMake/file/LOCK-error-lock-fail-result.txt | 1 + .../RunCMake/file/LOCK-error-lock-fail-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-lock-fail.cmake | 6 ++++ .../file/LOCK-error-negative-timeout-result.txt | 1 + .../file/LOCK-error-negative-timeout-stderr.txt | 4 +++ .../file/LOCK-error-negative-timeout.cmake | 1 + .../file/LOCK-error-no-function-result.txt | 1 + .../file/LOCK-error-no-function-stderr.txt | 6 ++++ Tests/RunCMake/file/LOCK-error-no-function.cmake | 1 + Tests/RunCMake/file/LOCK-error-no-guard-result.txt | 1 + Tests/RunCMake/file/LOCK-error-no-guard-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-no-guard.cmake | 1 + Tests/RunCMake/file/LOCK-error-no-path-result.txt | 1 + Tests/RunCMake/file/LOCK-error-no-path-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-no-path.cmake | 1 + .../file/LOCK-error-no-result-variable-result.txt | 1 + .../file/LOCK-error-no-result-variable-stderr.txt | 4 +++ .../file/LOCK-error-no-result-variable.cmake | 1 + .../RunCMake/file/LOCK-error-no-timeout-result.txt | 1 + .../RunCMake/file/LOCK-error-no-timeout-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-no-timeout.cmake | 1 + .../file/LOCK-error-unknown-option-result.txt | 1 + .../file/LOCK-error-unknown-option-stderr.txt | 5 +++ .../RunCMake/file/LOCK-error-unknown-option.cmake | 1 + Tests/RunCMake/file/LOCK-stdout.txt | 11 ++++++ Tests/RunCMake/file/LOCK.cmake | 40 ++++++++++++++++++++++ Tests/RunCMake/file/RunCMakeTest.cmake | 12 +++++++ .../file/subdir_test_unlock/CMakeLists.txt | 2 ++ 37 files changed, 143 insertions(+) create mode 100644 Tests/RunCMake/file/LOCK-error-file-create-fail-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-file-create-fail-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-file-create-fail.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-guard-incorrect-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-guard-incorrect-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-guard-incorrect.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-negative-timeout-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-negative-timeout-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-negative-timeout.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-function-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-function-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-function.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-guard-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-guard-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-guard.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-path-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-path-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-path.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-result-variable-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-result-variable-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-result-variable.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-timeout-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-timeout-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-timeout.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option.cmake create mode 100644 Tests/RunCMake/file/LOCK-stdout.txt create mode 100644 Tests/RunCMake/file/LOCK.cmake create mode 100644 Tests/RunCMake/file/subdir_test_unlock/CMakeLists.txt 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..d0ce86f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-file-create-fail-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at LOCK-error-file-create-fail\.cmake:[0-9]+ \(file\): + 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..eda0f35 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-guard-incorrect-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-guard-incorrect\.cmake:[0-9]+ \(file\): + 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..53c6747 --- /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\): + 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.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..753b063 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-lock-fail-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-lock-fail.cmake:[0-9]+ \(file\): + 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..7e08d53 --- /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\): + 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..46ea08e --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-function-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at LOCK-error-no-function\.cmake:[0-9]+ \(file\): + 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..91a63e1 --- /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\): + 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..9edbfd7 --- /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\): + 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..35adf64 --- /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\): + 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-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..ec9d3aa --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-unknown-option-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at LOCK-error-unknown-option\.cmake:[0-9]+ \(file\): + 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..095feef 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -3,3 +3,15 @@ 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-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-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) -- 2.1.1 From eike at sf-mail.de Sat Nov 15 03:34:39 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Sat, 15 Nov 2014 09:34:39 +0100 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <54668FEC.5020203@yahoo.com> References: <5431B11C.3010209@yahoo.com> <54665ED3.3060300@kitware.com> <54668FEC.5020203@yahoo.com> Message-ID: <708024991.ylpfiUSqup@caliban.sf-tec.de> Am Samstag, 15. November 2014, 02:27:40 schrieb Ruslan Baratov via cmake- developers: > On 14-Nov-14 22:58, Brad King wrote: > > - Please add more test cases covering all the file(LOCK) > > > > argument processing error messages. > > Done. Also I've found parse issue which is based on `sscanf` behaviour, > e.g. string '123xyz' will be successfully parsed as a integer (%d). Same > issue for example in file(STRINGS) command: I use strtol()/strtoul() for this kind of this, which also has a less worrisome interface. Eike -- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From gjasny at googlemail.com Sat Nov 15 06:36:32 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Sat, 15 Nov 2014 12:36:32 +0100 Subject: [cmake-developers] [PATCH v3 1/2] Add continue keyword (#14013) In-Reply-To: <1416051393-1854-1-git-send-email-gjasny@googlemail.com> References: <1416051393-1854-1-git-send-email-gjasny@googlemail.com> Message-ID: <1416051393-1854-2-git-send-email-gjasny@googlemail.com> Original draft by Doug Barbieri. Signed-off-by: Gregor Jasny --- Help/command/continue.rst | 7 +++ Source/cmBootstrapCommands1.cxx | 2 + Source/cmContinueCommand.cxx | 21 +++++++++ Source/cmContinueCommand.h | 55 ++++++++++++++++++++++ Source/cmExecutionStatus.h | 7 +++ Source/cmForEachCommand.cxx | 4 ++ Source/cmIfCommand.cxx | 5 ++ Source/cmWhileCommand.cxx | 4 ++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/continue/CMakeLists.txt | 3 ++ Tests/RunCMake/continue/ContinueForeach-stdout.txt | 4 ++ Tests/RunCMake/continue/ContinueForeach.cmake | 8 ++++ .../continue/ContinueNestedForeach-stdout.txt | 6 +++ .../RunCMake/continue/ContinueNestedForeach.cmake | 13 +++++ Tests/RunCMake/continue/ContinueWhile-stdout.txt | 6 +++ Tests/RunCMake/continue/ContinueWhile.cmake | 10 ++++ Tests/RunCMake/continue/RunCMakeTest.cmake | 5 ++ 17 files changed, 161 insertions(+) create mode 100644 Help/command/continue.rst create mode 100644 Source/cmContinueCommand.cxx create mode 100644 Source/cmContinueCommand.h create mode 100644 Tests/RunCMake/continue/CMakeLists.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueWhile-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueWhile.cmake create mode 100644 Tests/RunCMake/continue/RunCMakeTest.cmake diff --git a/Help/command/continue.rst b/Help/command/continue.rst new file mode 100644 index 0000000..d377542 --- /dev/null +++ b/Help/command/continue.rst @@ -0,0 +1,7 @@ +continue +-------- + +Continue to the top of enclosing foreach or while loop. + +Continue allows the cmake script to abort the rest of a block in a foreach +or while loop, and start at the top of the next iteration. See also break(). 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& 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..d516ad2 --- /dev/null +++ b/Source/cmContinueCommand.cxx @@ -0,0 +1,21 @@ +/*============================================================================ + 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 const&, + cmExecutionStatus &status) +{ + status.SetContinueInvoked(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 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/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index e3f66c1..465ddab 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -67,6 +67,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/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/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 851c4cb..98e129d 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -81,6 +81,10 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, { return true; } + if (status.GetContinueInvoked()) + { + break; + } if(cmSystemTools::GetFatalErrorOccured() ) { return true; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index a99b46f..0099d4b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -99,6 +99,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/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/RunCMakeTest.cmake b/Tests/RunCMake/continue/RunCMakeTest.cmake new file mode 100644 index 0000000..c057282 --- /dev/null +++ b/Tests/RunCMake/continue/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(ContinueForeach) +run_cmake(ContinueNestedForeach) +run_cmake(ContinueWhile) -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Sat Nov 15 06:36:33 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Sat, 15 Nov 2014 12:36:33 +0100 Subject: [cmake-developers] [PATCH v3 2/2] Reject continue() without loop block (#14013) In-Reply-To: <1416051393-1854-1-git-send-email-gjasny@googlemail.com> References: <1416051393-1854-1-git-send-email-gjasny@googlemail.com> Message-ID: <1416051393-1854-3-git-send-email-gjasny@googlemail.com> To track the nested loop levels a counter is used. It gets incremented while entering a loop block (e.g. foreach or while) and gets decremented when leaving the block. Because scope borders for example at function borders must be taken into account the counter is put into a stack. With every new scope an empty counter is pushed on the stack, when leaving the scope the original value is restored. This enables easy querying if the continue (and later also break) command is properly nested within a loop scope. Signed-off-by: Gregor Jasny --- Source/cmContinueCommand.cxx | 7 ++++ Source/cmForEachCommand.cxx | 4 ++ Source/cmMakefile.cxx | 47 ++++++++++++++++++++++ Source/cmMakefile.h | 12 ++++++ Source/cmWhileCommand.cxx | 3 ++ .../RunCMake/continue/NoEnclosingBlock-result.txt | 1 + .../RunCMake/continue/NoEnclosingBlock-stderr.txt | 2 + Tests/RunCMake/continue/NoEnclosingBlock.cmake | 1 + .../continue/NoEnclosingBlockInFunction-result.txt | 1 + .../continue/NoEnclosingBlockInFunction-stderr.txt | 2 + .../continue/NoEnclosingBlockInFunction.cmake | 8 ++++ Tests/RunCMake/continue/RunCMakeTest.cmake | 2 + 12 files changed, 90 insertions(+) create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction.cmake diff --git a/Source/cmContinueCommand.cxx b/Source/cmContinueCommand.cxx index d516ad2..1cf2bc7 100644 --- a/Source/cmContinueCommand.cxx +++ b/Source/cmContinueCommand.cxx @@ -15,6 +15,13 @@ bool cmContinueCommand::InitialPass(std::vector const&, cmExecutionStatus &status) { + if(!this->Makefile->IsLoopBlock()) + { + this->SetError("A CONTINUE command was found outside of a proper " + "FOREACH or WHILE loop scope."); + return false; + } + status.SetContinueInvoked(true); return true; } diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 465ddab..4e16430 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -77,6 +77,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, } } } + mf.PopLoopBlock(); + // restore the variable to its prior value mf.AddDefinition(this->Args[0],oldDef.c_str()); return true; @@ -203,6 +205,8 @@ bool cmForEachCommand } this->Makefile->AddFunctionBlocker(f); + this->Makefile->PushLoopBlock(); + return true; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8a8aadc..4f652af 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -171,6 +171,9 @@ void cmMakefile::Initialize() // Protect the directory-level policies. this->PushPolicyBarrier(); + // push empty loop block + this->PushLoopBlockBarrier(); + // By default the check is not done. It is enabled by // cmListFileCache in the top level if necessary. this->CheckCMP0000 = false; @@ -3293,6 +3296,46 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError) } //---------------------------------------------------------------------------- +void cmMakefile::PushLoopBlock() +{ + if(this->LoopBlockCounter.empty()) + { + assert(false); + return; + } + + this->LoopBlockCounter.top()++; +} + +void cmMakefile::PopLoopBlock() +{ + if(this->LoopBlockCounter.empty() || this->LoopBlockCounter.top() <= 0) + { + assert(false); + return; + } + + this->LoopBlockCounter.top()--; +} + +void cmMakefile::PushLoopBlockBarrier() +{ + this->LoopBlockCounter.push(0); +} + +void cmMakefile::PopLoopBlockBarrier() +{ + assert(!this->LoopBlockCounter.empty() && this->LoopBlockCounter.top() == 0); + this->LoopBlockCounter.pop(); +} + +bool cmMakefile::IsLoopBlock() const +{ + assert(!this->LoopBlockCounter.empty()); + return !this->LoopBlockCounter.empty() && this->LoopBlockCounter.top() > 0; +} + +//---------------------------------------------------------------------------- bool cmMakefile::ExpandArguments( std::vector const& inArgs, std::vector& outArgs) const @@ -4426,10 +4469,14 @@ void cmMakefile::PushScope() this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); + + PushLoopBlockBarrier(); } void cmMakefile::PopScope() { + PopLoopBlockBarrier(); + cmDefinitions* current = &this->Internal->VarStack.top(); std::set init = this->Internal->VarInitStack.top(); std::set usage = this->Internal->VarUsageStack.top(); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 824513b..7c746fe 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -34,6 +34,8 @@ # include #endif +#include + class cmFunctionBlocker; class cmCommand; class cmInstallGenerator; @@ -885,6 +887,10 @@ public: void PopScope(); void RaiseScope(const std::string& var, const char *value); + // push and pop loop scopes + void PushLoopBlockBarrier(); + void PopLoopBlockBarrier(); + /** Helper class to push and pop scopes automatically. */ class ScopePushPop { @@ -945,6 +951,10 @@ public: void ClearMatches(); void StoreMatches(cmsys::RegularExpression& re); + void PushLoopBlock(); + void PopLoopBlock(); + bool IsLoopBlock() const; + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const std::string& name, cmTarget& target); @@ -1039,6 +1049,8 @@ private: void PushFunctionBlockerBarrier(); void PopFunctionBlockerBarrier(bool reportError = true); + std::stack LoopBlockCounter; + typedef std::map StringStringMap; StringStringMap MacrosMap; diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 98e129d..b8fbffe 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -95,6 +95,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, isTrue = conditionEvaluator.IsTrue( expandedArguments, errorString, messageType); } + mf.PopLoopBlock(); return true; } else @@ -142,6 +143,8 @@ bool cmWhileCommand f->Args = args; this->Makefile->AddFunctionBlocker(f); + this->Makefile->PushLoopBlock(); + return true; } 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..b3b3f96 --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt @@ -0,0 +1,2 @@ + continue A CONTINUE command was found outside of a proper FOREACH or WHILE + loop scope. 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..b3b3f96 --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt @@ -0,0 +1,2 @@ + continue A CONTINUE command was found outside of a proper FOREACH or WHILE + loop scope. 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 index c057282..f8fef6a 100644 --- a/Tests/RunCMake/continue/RunCMakeTest.cmake +++ b/Tests/RunCMake/continue/RunCMakeTest.cmake @@ -3,3 +3,5 @@ include(RunCMake) run_cmake(ContinueForeach) run_cmake(ContinueNestedForeach) run_cmake(ContinueWhile) +run_cmake(NoEnclosingBlock) +run_cmake(NoEnclosingBlockInFunction) -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Sat Nov 15 06:36:31 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Sat, 15 Nov 2014 12:36:31 +0100 Subject: [cmake-developers] [PATCH v3 0/2] Add continue keyword In-Reply-To: <545BDD58.9000207@kitware.com> References: <545BDD58.9000207@kitware.com> Message-ID: <1416051393-1854-1-git-send-email-gjasny@googlemail.com> Hello, the current version now properly checks for proper nesting of the continue keyword. To detect new scope blocks like for example a function() I hoked into the Push/PopScope functions. I have two questions: 1) The Scope variable stack is held in a 'internal' structure that gets special treatment in the cmMakefile copy ctor. I don't know the implications of storing my loop block counter stack directly as member of cmMakefile. Could you please advise? 2) The error message for an inproperly nested continue looks like this: continue A CONTINUE command was found outside of a proper FOREACH or WHILE loop scope. where is the continue coming from? Is it part of a (too short) call stack trace? Also I noticed that the CMakeFile is still processed after the error is shown. Is this desired behavior? Thanks, Gregor Gregor Jasny (2): Add continue keyword (#14013) Reject continue() without loop block (#14013) Help/command/continue.rst | 7 +++ Source/cmBootstrapCommands1.cxx | 2 + Source/cmContinueCommand.cxx | 28 +++++++++++ Source/cmContinueCommand.h | 55 ++++++++++++++++++++++ Source/cmExecutionStatus.h | 7 +++ Source/cmForEachCommand.cxx | 8 ++++ Source/cmIfCommand.cxx | 5 ++ Source/cmMakefile.cxx | 47 ++++++++++++++++++ Source/cmMakefile.h | 12 +++++ Source/cmWhileCommand.cxx | 7 +++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/continue/CMakeLists.txt | 3 ++ Tests/RunCMake/continue/ContinueForeach-stdout.txt | 4 ++ Tests/RunCMake/continue/ContinueForeach.cmake | 8 ++++ .../continue/ContinueNestedForeach-stdout.txt | 6 +++ .../RunCMake/continue/ContinueNestedForeach.cmake | 13 +++++ Tests/RunCMake/continue/ContinueWhile-stdout.txt | 6 +++ Tests/RunCMake/continue/ContinueWhile.cmake | 10 ++++ .../RunCMake/continue/NoEnclosingBlock-result.txt | 1 + .../RunCMake/continue/NoEnclosingBlock-stderr.txt | 2 + Tests/RunCMake/continue/NoEnclosingBlock.cmake | 1 + .../continue/NoEnclosingBlockInFunction-result.txt | 1 + .../continue/NoEnclosingBlockInFunction-stderr.txt | 2 + .../continue/NoEnclosingBlockInFunction.cmake | 8 ++++ Tests/RunCMake/continue/RunCMakeTest.cmake | 7 +++ 25 files changed, 251 insertions(+) create mode 100644 Help/command/continue.rst create mode 100644 Source/cmContinueCommand.cxx create mode 100644 Source/cmContinueCommand.h create mode 100644 Tests/RunCMake/continue/CMakeLists.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueWhile-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueWhile.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction.cmake create mode 100644 Tests/RunCMake/continue/RunCMakeTest.cmake -- 1.9.3 (Apple Git-50) From luisch at mint.cx Sun Nov 16 04:12:09 2014 From: luisch at mint.cx (=?UTF-8?B?44KR?=) Date: Sun, 16 Nov 2014 18:12:09 +0900 Subject: [cmake-developers] Cannot Find MFC on Visual Studio 2013(community) Message-ID: <546866D4.409@mint.cx> Hi all, I tried to 'FIND_PACKAGE(MFC)' on VS2013(community), but MFC not found. VS2013 has no mfc120.dll but has mfc120u.dll, so I make a patch for FindMFC.cmake, like > -DCOMPILE_DEFINITIONS:STRING=-D_AFXDLL >+ -DCOMPILE_DEFINITIONS:STRING=-D_UNICODE > OUTPUT_VARIABLE OUTPUT) and find successfully. This is not tested at other versions, but probably does correctly. thanks. From mantis at public.kitware.com Sun Nov 16 21:13:24 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Sun, 16 Nov 2014 21:13:24 -0500 Subject: [cmake-developers] [CMake 0015253]: Ninja generator causes build failure for ASM files via NASM Message-ID: <60026f8a46c3c05d793465f0dbe73e81@www.cmake.org> The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15253 ====================================================================== Reported By: karlhungus Assigned To: ====================================================================== Project: CMake Issue ID: 15253 Category: CMake Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-16 21:13 EST Last Modified: 2014-11-16 21:13 EST ====================================================================== Summary: Ninja generator causes build failure for ASM files via NASM Description: On Windows (haven't tested on other platforms), the Ninja generator for ASM files compiled with NASM adds the "/showIncludes" flag to the NASM command line in "rules.ninja": ############################################# # Rule for compiling ASM_NASM files. rule ASM_NASM_COMPILER deps = msvc command = C:\dev\bin\nasm.exe $FLAGS /showIncludes -f win64 -o $out $in description = Building ASM_NASM object $out This causes a build failure with the error message: "nasm: error: more than one input file specified" Using YASM instead of NASM turns this into a warning instead of an error, but inconvenient nonetheless. Removing "/showIncludes" from the above line in "rules.ninja" fixes the error. Steps to Reproduce: # Have nasm.exe in path # git clone https://boringssl.googlesource.com/boringssl mkdir build cd build cmake -GNinja .. ninja ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-16 21:13 karlhungus New Issue ====================================================================== From ahovda at openit.com Mon Nov 17 06:11:55 2014 From: ahovda at openit.com (=?ISO-8859-1?Q?=C5dne_Hovda?=) Date: Mon, 17 Nov 2014 12:11:55 +0100 Subject: [cmake-developers] HP-UX Curses questions Message-ID: Hi I'm suspecting that this block in FindCurses https://github.com/Kitware/CMake/blob/master/Modules/FindCurses.cmake#L182-L185 should go away, unless there is something I have missed. if (NOT CURSES_TINFO_HAS_CBREAK) find_library(CURSES_EXTRA_LIBRARY cur_colr HINTS "${_cursesLibDir}") find_library(CURSES_EXTRA_LIBRARY cur_colr ) endif() AFAICT, the cur_colr package was introduced in HP-UX 10.00 and marked as deprecated in 10.30 by X/OPEN curses (which replaced the even older HP curses in 10.10). In order to use cur_colr after 10.10 you should use the /usr/include/curses_colr when compiling. Since FindCurses doesn't even search that path I suggest either to take out the library block completely, since the support for cur_colr has never been complete or add support for the special include path and also a flag to set a preference on which kind of curses you want on HP-UX. There is no 64-bit version of cur_colr in 11.11PA and it will be gone completely in 11.31PA (http://h21007.www2.hp.com/portal/download/files/unprot/STK/HPUX_STK/impacts/i964.html) so without this change (and the other small change to enable Xcurses for cmake below) I can't compile ccmake on that platform right now. ?dne Hovda diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index a21ca89..f94bd09 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -179,11 +179,6 @@ if(NOT DEFINED CURSES_HAVE_CURSES_H) endif() endif() -if (NOT CURSES_TINFO_HAS_CBREAK) - find_library(CURSES_EXTRA_LIBRARY cur_colr HINTS "${_cursesLibDir}") - find_library(CURSES_EXTRA_LIBRARY cur_colr ) -endif() - find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}") find_library(CURSES_FORM_LIBRARY form ) diff --git a/Source/CursesDialog/form/form.priv.h b/Source/CursesDialog/form/form.priv.h index 3691f2f..889c6e4 100644 --- a/Source/CursesDialog/form/form.priv.h +++ b/Source/CursesDialog/form/form.priv.h @@ -34,7 +34,7 @@ #include "form.h" /* get around odd bug on aCC and itanium */ -#if defined(__hpux) && defined(__ia64) +#if defined(__hpux) #define getmaxx __getmaxx #define getmaxy __getmaxy #endif From gjasny at googlemail.com Mon Nov 17 06:51:06 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Mon, 17 Nov 2014 12:51:06 +0100 Subject: [cmake-developers] [PATCH v3 0/2] Add continue keyword In-Reply-To: <1416051393-1854-1-git-send-email-gjasny@googlemail.com> References: <545BDD58.9000207@kitware.com> <1416051393-1854-1-git-send-email-gjasny@googlemail.com> Message-ID: <5469E12A.3060005@googlemail.com> On 15/11/14 12:36, Gregor Jasny wrote: > the current version now properly checks for proper nesting > of the continue keyword. To detect new scope blocks like > for example a function() I hoked into the Push/PopScope > functions. I just noticed that return() handling is broken. I'm also working on a patch that checks for proper usage of break(). Thanks, Gregor From brad.king at kitware.com Mon Nov 17 10:06:40 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Nov 2014 10:06:40 -0500 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <708024991.ylpfiUSqup@caliban.sf-tec.de> References: <5431B11C.3010209@yahoo.com> <54665ED3.3060300@kitware.com> <54668FEC.5020203@yahoo.com> <708024991.ylpfiUSqup@caliban.sf-tec.de> Message-ID: <546A0F00.3090908@kitware.com> On 11/15/2014 03:34 AM, Rolf Eike Beer wrote: > Ruslan Baratov wrote: >> Done. Also I've found parse issue which is based on `sscanf` behaviour, >> e.g. string '123xyz' will be successfully parsed as a integer (%d). Same >> issue for example in file(STRINGS) command: > > I use strtol()/strtoul() for this kind of this, which also has a less > worrisome interface. Yes, please change to that so a proper error can be produced for the new API when "123xyz" is given as a timeout, for example. The file(STRINGS) command could be fixed with a separate change. In order to be compatible it should do something like "%u%c" and produce a warning if %c matched anything. On 11/14/2014 06:27 PM, Ruslan Baratov wrote: > On linux you can test timeout by: > > cat script.cmake > file(LOCK "${CMAKE_CURRENT_LIST_DIR}/file-to-lock" TIMEOUT 5) > execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 10) > > cmake -P script.cmake & # start one instance in background > > cmake -P script.cmake # start second instance, expected lock failed > by timeout > CMake Error at script.cmake:1 (file): > file : error locking file > "/.../file-to-lock" (Timeout > reached). Please look at adding a case to the test suite for this. An outer process could take the lock and then execute_process a child that tries to take the lock with a timeout. Then check that it fails as expected. Thanks, -Brad From brad.king at kitware.com Mon Nov 17 10:07:32 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Nov 2014 10:07:32 -0500 Subject: [cmake-developers] [PATCH v3 0/2] Add continue keyword In-Reply-To: <5469E12A.3060005@googlemail.com> References: <545BDD58.9000207@kitware.com> <1416051393-1854-1-git-send-email-gjasny@googlemail.com> <5469E12A.3060005@googlemail.com> Message-ID: <546A0F34.7080706@kitware.com> On 11/17/2014 06:51 AM, Gregor Jasny wrote: > I just noticed that return() handling is broken. I'm also > working on a patch that checks for proper usage of break(). Okay, thanks for looking into all of that! I'll wait for the re-roll with fixed return() handling. Thanks, -Brad From brad.king at kitware.com Mon Nov 17 10:36:34 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Nov 2014 10:36:34 -0500 Subject: [cmake-developers] HP-UX Curses questions In-Reply-To: References: Message-ID: <546A1602.5060703@kitware.com> On 11/17/2014 06:11 AM, ?dne Hovda wrote: > In order to use cur_colr after 10.10 you should use the > /usr/include/curses_colr when compiling. Since FindCurses doesn't even > search that path I suggest either to take out the library block > completely, since the support for cur_colr has never been complete or Thanks. I've applied the FindCurses part of the patch here: FindCurses: Drop search for deprecated HP-UX cur_colr library http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d931ba60 > diff --git a/Source/CursesDialog/form/form.priv.h > b/Source/CursesDialog/form/form.priv.h > index 3691f2f..889c6e4 100644 > --- a/Source/CursesDialog/form/form.priv.h > +++ b/Source/CursesDialog/form/form.priv.h > @@ -34,7 +34,7 @@ > #include "form.h" > > /* get around odd bug on aCC and itanium */ > -#if defined(__hpux) && defined(__ia64) > +#if defined(__hpux) > #define getmaxx __getmaxx > #define getmaxy __getmaxy > #endif What is the purpose of this part of the change? Should this block be conditional on use of cur_colr? Thanks, -Brad From brad.king at kitware.com Mon Nov 17 11:12:53 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Nov 2014 11:12:53 -0500 Subject: [cmake-developers] Cannot Find MFC on Visual Studio 2013 In-Reply-To: <546866D4.409@mint.cx> References: <546866D4.409@mint.cx> Message-ID: <546A1E85.4040401@kitware.com> On 11/16/2014 04:12 AM, ? wrote: > I tried to 'FIND_PACKAGE(MFC)' on VS2013(community), but MFC not found. > VS2013 has no mfc120.dll but has mfc120u.dll, > so I make a patch for FindMFC.cmake, This is not just the community edition but any VS 2013. The MBCS (non-unicode) versions of the MFC libraries are no longer installed by default but can be downloaded separately. This was fixed for the InstallRequiredSystemLibraries module here: InstallRequiredSystemLibraries: MBCS MFC is optional on VS 12 (#14903) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c0a6646d Thanks for looking into it for FindMFC. > + -DCOMPILE_DEFINITIONS:STRING=-D_UNICODE This works for VS 2013, but it breaks on older VS versions that do not have a unicode MFC library available. Also, an application cannot simply start using the unicode MFC if the application itself is not built with _UNICODE. I think we actually need two separate checks for the two separate libraries. The FindMFC module should be taught to check for the libraries with a separate MFC_HAVE_MFC_UNICODE cache entry. The old check can be renamed to MFC_HAVE_MFC_MBCS (and MFC_HAVE_MFC set to a copy of that result for compatibility with applications that look for it). Then the only problem is how to set MFC_FOUND based on the two results. For this we could use the COMPONENTS mechanism of find_package. Then an application could do one of: find_package(MFC) # found if mbcs libs are found find_package(MFC COMPONENTS mbcs) # found if mbcs libs are found find_package(MFC COMPONENTS unicode) # found if unicode libs are found find_package(MFC COMPONENTS mbcs unicode) # found if both are found The find module can check the MFC_FIND_COMPONENTS variable to see which parts the application wants. Thanks, -Brad From brad.king at kitware.com Mon Nov 17 11:47:43 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Nov 2014 11:47:43 -0500 Subject: [cmake-developers] Explicit custom command BYPRODUCTS Message-ID: <546A26AF.7080400@kitware.com> Hi Folks, Picking up from this old thread: explicit custom command side-effects (was: Severe regression caused by #14972 fixes) http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/11207/focus=11225 and this issue: Add explicit specification of custom command side effect outputs http://www.cmake.org/Bug/view.php?id=14963 On 10/08/2014 10:26 AM, Brad King wrote: > Both add_custom_target and add_custom_command can run operations that > produce side-effects. Both commands need a way to specify any side > effects they produce. Perhaps a new option like "GENERATES" can be > added for this. > The GENERATES value(s) would be marked with the GENERATED property. > For Ninja we would add extra outputs to the generated rule and > ask Ninja to restat them to avoid the always-rebuild case. For > other generators no additional build system content is needed. I chose the name "BYPRODUCTS" for the option and drafted support: Add an option for explicit BYPRODUCTS of custom commands (#14963) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e15a7075 ExternalProject: Add options to specify BYPRODUCTS (#14963) http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=557aef0b This was in 'next' over the weekend and is clean on the dashboard. To those that encountered problems requiring this feature, please try it out to see if it works correctly for your use case. Thanks, -Brad From brad.king at kitware.com Mon Nov 17 11:50:19 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Nov 2014 11:50:19 -0500 Subject: [cmake-developers] explicit custom command side-effects In-Reply-To: <543549A4.8070508@kitware.com> References: <5433949A.6060707@reactos.org> <543400EE.5090803@gmail.com> <543445D8.1000806@kitware.com> <5434EB8C.109@reactos.org> <54353915.3010200@kitware.com> <1032790C-7E57-471E-B81C-64C14AEBD69B@java.pl> <543549A4.8070508@kitware.com> Message-ID: <546A274B.4050903@kitware.com> On 10/08/2014 10:26 AM, Brad King wrote: > Both add_custom_target and add_custom_command can run operations that > produce side-effects. Both commands need a way to specify any side > effects they produce. Perhaps a new option like "GENERATES" can be > added for this. For reference in list archives, this thread is continued here: Explicit custom command BYPRODUCTS http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/11648 -Brad From gjasny at googlemail.com Mon Nov 17 14:00:51 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Mon, 17 Nov 2014 20:00:51 +0100 Subject: [cmake-developers] [PATCH v4 0/3] Add continue keyword Message-ID: <1416250854-1978-1-git-send-email-gjasny@googlemail.com> Hello, the current version now properly checks for proper nesting of the continue keyword. To detect new scope blocks like for example a function() I hoked into the Push/PopScope functions. I have some questions: 1) The Scope variable stack is held in a 'internal' structure that gets special treatment in the cmMakefile copy ctor. I don't know the implications of storing my loop block counter stack directly as member of cmMakefile. Could you please advise? 2) The error message for an inproperly nested continue looks like this: continue A CONTINUE command was found outside of a proper FOREACH or WHILE loop scope. where is the continue coming from? Is it part of a (too short) call stack trace? Also I noticed that the CMakeFile is still processed after the error is shown. Is this desired behavior? 3) The continue tests have a requirement for CMake version 3.1 in the CMakeLists.txt file. This needs to be bumped to 3.2 once the the version number got incremented to 3.2. 4) Is the new policy to reject misplaced break() commands really necessary? Thanks, Gregor https://github.com/gjasny/CMake/commits/feature/14013-continue-keyword *** BLURB HERE *** Gregor Jasny (3): Add continue keyword (#14013) Reject continue() without loop block (#14013) Reject break() without loop scope Help/command/continue.rst | 7 +++ Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0055.rst | 17 +++++++ Source/cmBootstrapCommands1.cxx | 2 + Source/cmBreakCommand.cxx | 33 +++++++++++++ Source/cmContinueCommand.cxx | 28 +++++++++++ Source/cmContinueCommand.h | 55 ++++++++++++++++++++++ Source/cmExecutionStatus.h | 7 +++ Source/cmForEachCommand.cxx | 12 +++++ Source/cmIfCommand.cxx | 5 ++ Source/cmMakefile.cxx | 48 +++++++++++++++++++ Source/cmMakefile.h | 21 +++++++++ Source/cmPolicies.cxx | 5 ++ Source/cmPolicies.h | 1 + Source/cmWhileCommand.cxx | 8 ++++ Tests/RunCMake/CMP0055/CMP0055-NEW-result.txt | 1 + Tests/RunCMake/CMP0055/CMP0055-NEW-stderr.txt | 4 ++ Tests/RunCMake/CMP0055/CMP0055-NEW.cmake | 4 ++ Tests/RunCMake/CMP0055/CMP0055-OLD-result.txt | 1 + Tests/RunCMake/CMP0055/CMP0055-OLD-stderr.txt | 1 + Tests/RunCMake/CMP0055/CMP0055-OLD.cmake | 4 ++ Tests/RunCMake/CMP0055/CMP0055-WARN-result.txt | 1 + Tests/RunCMake/CMP0055/CMP0055-WARN-stderr.txt | 9 ++++ Tests/RunCMake/CMP0055/CMP0055-WARN.cmake | 2 + Tests/RunCMake/CMP0055/CMakeLists.txt | 3 ++ Tests/RunCMake/CMP0055/RunCMakeTest.cmake | 5 ++ Tests/RunCMake/CMakeLists.txt | 3 ++ Tests/RunCMake/continue/CMakeLists.txt | 3 ++ .../RunCMake/continue/ContinueForEachInLists.cmake | 10 ++++ Tests/RunCMake/continue/ContinueForeach-stdout.txt | 4 ++ Tests/RunCMake/continue/ContinueForeach.cmake | 8 ++++ .../continue/ContinueNestedForeach-stdout.txt | 6 +++ .../RunCMake/continue/ContinueNestedForeach.cmake | 13 +++++ Tests/RunCMake/continue/ContinueWhile-stdout.txt | 6 +++ Tests/RunCMake/continue/ContinueWhile.cmake | 10 ++++ .../RunCMake/continue/NoEnclosingBlock-result.txt | 1 + .../RunCMake/continue/NoEnclosingBlock-stderr.txt | 2 + Tests/RunCMake/continue/NoEnclosingBlock.cmake | 1 + .../continue/NoEnclosingBlockInFunction-result.txt | 1 + .../continue/NoEnclosingBlockInFunction-stderr.txt | 2 + .../continue/NoEnclosingBlockInFunction.cmake | 8 ++++ Tests/RunCMake/continue/RunCMakeTest.cmake | 8 ++++ Tests/RunCMake/return/CMakeLists.txt | 3 ++ Tests/RunCMake/return/ReturnFromForeach-result.txt | 1 + Tests/RunCMake/return/ReturnFromForeach.cmake | 10 ++++ Tests/RunCMake/return/RunCMakeTest.cmake | 3 ++ 46 files changed, 388 insertions(+) create mode 100644 Help/command/continue.rst create mode 100644 Help/policy/CMP0055.rst create mode 100644 Source/cmContinueCommand.cxx create mode 100644 Source/cmContinueCommand.h create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN.cmake create mode 100644 Tests/RunCMake/CMP0055/CMakeLists.txt create mode 100644 Tests/RunCMake/CMP0055/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/continue/CMakeLists.txt create mode 100644 Tests/RunCMake/continue/ContinueForEachInLists.cmake create mode 100644 Tests/RunCMake/continue/ContinueForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueWhile-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueWhile.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction.cmake create mode 100644 Tests/RunCMake/continue/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/return/CMakeLists.txt create mode 100644 Tests/RunCMake/return/ReturnFromForeach-result.txt create mode 100644 Tests/RunCMake/return/ReturnFromForeach.cmake create mode 100644 Tests/RunCMake/return/RunCMakeTest.cmake -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Mon Nov 17 14:00:52 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Mon, 17 Nov 2014 20:00:52 +0100 Subject: [cmake-developers] [PATCH v4 1/3] Add continue keyword (#14013) In-Reply-To: <1416250854-1978-1-git-send-email-gjasny@googlemail.com> References: <1416250854-1978-1-git-send-email-gjasny@googlemail.com> Message-ID: <1416250854-1978-2-git-send-email-gjasny@googlemail.com> Original draft by Doug Barbieri. Signed-off-by: Gregor Jasny --- Help/command/continue.rst | 7 +++ Source/cmBootstrapCommands1.cxx | 2 + Source/cmContinueCommand.cxx | 21 +++++++++ Source/cmContinueCommand.h | 55 ++++++++++++++++++++++ Source/cmExecutionStatus.h | 7 +++ Source/cmForEachCommand.cxx | 4 ++ Source/cmIfCommand.cxx | 5 ++ Source/cmWhileCommand.cxx | 4 ++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/continue/CMakeLists.txt | 3 ++ Tests/RunCMake/continue/ContinueForeach-stdout.txt | 4 ++ Tests/RunCMake/continue/ContinueForeach.cmake | 8 ++++ .../continue/ContinueNestedForeach-stdout.txt | 6 +++ .../RunCMake/continue/ContinueNestedForeach.cmake | 13 +++++ Tests/RunCMake/continue/ContinueWhile-stdout.txt | 6 +++ Tests/RunCMake/continue/ContinueWhile.cmake | 10 ++++ Tests/RunCMake/continue/RunCMakeTest.cmake | 5 ++ 17 files changed, 161 insertions(+) create mode 100644 Help/command/continue.rst create mode 100644 Source/cmContinueCommand.cxx create mode 100644 Source/cmContinueCommand.h create mode 100644 Tests/RunCMake/continue/CMakeLists.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueWhile-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueWhile.cmake create mode 100644 Tests/RunCMake/continue/RunCMakeTest.cmake diff --git a/Help/command/continue.rst b/Help/command/continue.rst new file mode 100644 index 0000000..d377542 --- /dev/null +++ b/Help/command/continue.rst @@ -0,0 +1,7 @@ +continue +-------- + +Continue to the top of enclosing foreach or while loop. + +Continue allows the cmake script to abort the rest of a block in a foreach +or while loop, and start at the top of the next iteration. See also break(). 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& 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..d516ad2 --- /dev/null +++ b/Source/cmContinueCommand.cxx @@ -0,0 +1,21 @@ +/*============================================================================ + 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 const&, + cmExecutionStatus &status) +{ + status.SetContinueInvoked(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 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/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index e3f66c1..465ddab 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -67,6 +67,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/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/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 851c4cb..98e129d 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -81,6 +81,10 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, { return true; } + if (status.GetContinueInvoked()) + { + break; + } if(cmSystemTools::GetFatalErrorOccured() ) { return true; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index a99b46f..0099d4b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -99,6 +99,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/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/RunCMakeTest.cmake b/Tests/RunCMake/continue/RunCMakeTest.cmake new file mode 100644 index 0000000..c057282 --- /dev/null +++ b/Tests/RunCMake/continue/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(ContinueForeach) +run_cmake(ContinueNestedForeach) +run_cmake(ContinueWhile) -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Mon Nov 17 14:00:53 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Mon, 17 Nov 2014 20:00:53 +0100 Subject: [cmake-developers] [PATCH v4 2/3] Reject continue() without loop block (#14013) In-Reply-To: <1416250854-1978-1-git-send-email-gjasny@googlemail.com> References: <1416250854-1978-1-git-send-email-gjasny@googlemail.com> Message-ID: <1416250854-1978-3-git-send-email-gjasny@googlemail.com> To track the nested loop levels a counter is used. It gets incremented while entering a loop block (e.g. foreach or while) and gets decremented when leaving the block. Because scope borders for example at function borders must be taken into account the counter is put into a stack. With every new scope an empty counter is pushed on the stack, when leaving the scope the original value is restored. This enables easy querying if the continue (and later also break) command is properly nested within a loop scope. Signed-off-by: Gregor Jasny --- Source/cmContinueCommand.cxx | 7 ++++ Source/cmForEachCommand.cxx | 8 ++++ Source/cmMakefile.cxx | 48 ++++++++++++++++++++++ Source/cmMakefile.h | 21 ++++++++++ Source/cmWhileCommand.cxx | 4 ++ Tests/RunCMake/CMakeLists.txt | 1 + .../RunCMake/continue/ContinueForEachInLists.cmake | 10 +++++ .../RunCMake/continue/NoEnclosingBlock-result.txt | 1 + .../RunCMake/continue/NoEnclosingBlock-stderr.txt | 2 + Tests/RunCMake/continue/NoEnclosingBlock.cmake | 1 + .../continue/NoEnclosingBlockInFunction-result.txt | 1 + .../continue/NoEnclosingBlockInFunction-stderr.txt | 2 + .../continue/NoEnclosingBlockInFunction.cmake | 8 ++++ Tests/RunCMake/continue/RunCMakeTest.cmake | 3 ++ Tests/RunCMake/return/CMakeLists.txt | 3 ++ Tests/RunCMake/return/ReturnFromForeach-result.txt | 1 + Tests/RunCMake/return/ReturnFromForeach.cmake | 10 +++++ Tests/RunCMake/return/RunCMakeTest.cmake | 3 ++ 18 files changed, 134 insertions(+) create mode 100644 Tests/RunCMake/continue/ContinueForEachInLists.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction.cmake create mode 100644 Tests/RunCMake/return/CMakeLists.txt create mode 100644 Tests/RunCMake/return/ReturnFromForeach-result.txt create mode 100644 Tests/RunCMake/return/ReturnFromForeach.cmake create mode 100644 Tests/RunCMake/return/RunCMakeTest.cmake diff --git a/Source/cmContinueCommand.cxx b/Source/cmContinueCommand.cxx index d516ad2..1cf2bc7 100644 --- a/Source/cmContinueCommand.cxx +++ b/Source/cmContinueCommand.cxx @@ -15,6 +15,13 @@ bool cmContinueCommand::InitialPass(std::vector const&, cmExecutionStatus &status) { + if(!this->Makefile->IsLoopBlock()) + { + this->SetError("A CONTINUE command was found outside of a proper " + "FOREACH or WHILE loop scope."); + return false; + } + status.SetContinueInvoked(true); return true; } diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 465ddab..03d6590 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -27,6 +27,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, // if this is the endofreach for this statement if (!this->Depth) { + cmMakefile::LoopBlockPop loopBlockPop(&mf); + // Remove the function blocker for this scope or bail. cmsys::auto_ptr fb(mf.RemoveFunctionBlocker(this, lff)); @@ -77,6 +79,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, } } } + // restore the variable to its prior value mf.AddDefinition(this->Args[0],oldDef.c_str()); return true; @@ -203,6 +206,8 @@ bool cmForEachCommand } this->Makefile->AddFunctionBlocker(f); + this->Makefile->PushLoopBlock(); + return true; } @@ -246,5 +251,8 @@ bool cmForEachCommand::HandleInMode(std::vector const& args) } this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr + + this->Makefile->PushLoopBlock(); + return true; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8a8aadc..2795e83 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -171,6 +171,9 @@ void cmMakefile::Initialize() // Protect the directory-level policies. this->PushPolicyBarrier(); + // push empty loop block + this->PushLoopBlockBarrier(); + // By default the check is not done. It is enabled by // cmListFileCache in the top level if necessary. this->CheckCMP0000 = false; @@ -3293,6 +3296,47 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError) } //---------------------------------------------------------------------------- +void cmMakefile::PushLoopBlock() +{ + if(this->LoopBlockCounter.empty()) + { + assert(false); + return; + } + + this->LoopBlockCounter.top()++; +} + +void cmMakefile::PopLoopBlock() +{ + if(this->LoopBlockCounter.empty() || this->LoopBlockCounter.top() <= 0) + { + assert(false); + return; + } + + this->LoopBlockCounter.top()--; +} + +void cmMakefile::PushLoopBlockBarrier() +{ + this->LoopBlockCounter.push(0); +} + +void cmMakefile::PopLoopBlockBarrier() +{ + assert(!this->LoopBlockCounter.empty()); + assert(this->LoopBlockCounter.top() == 0); + this->LoopBlockCounter.pop(); +} + +bool cmMakefile::IsLoopBlock() const +{ + assert(!this->LoopBlockCounter.empty()); + return !this->LoopBlockCounter.empty() && this->LoopBlockCounter.top() > 0; +} + +//---------------------------------------------------------------------------- bool cmMakefile::ExpandArguments( std::vector const& inArgs, std::vector& outArgs) const @@ -4426,10 +4470,14 @@ void cmMakefile::PushScope() this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); + + PushLoopBlockBarrier(); } void cmMakefile::PopScope() { + PopLoopBlockBarrier(); + cmDefinitions* current = &this->Internal->VarStack.top(); std::set init = this->Internal->VarInitStack.top(); std::set usage = this->Internal->VarUsageStack.top(); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 824513b..809c77d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -34,6 +34,8 @@ # include #endif +#include + class cmFunctionBlocker; class cmCommand; class cmInstallGenerator; @@ -123,6 +125,15 @@ public: }; friend class LexicalPushPop; + class LoopBlockPop + { + public: + LoopBlockPop(cmMakefile* mf) { this->Makefile = mf; } + ~LoopBlockPop() { this->Makefile->PopLoopBlock(); } + private: + cmMakefile* Makefile; + }; + /** * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. @@ -885,6 +896,10 @@ public: void PopScope(); void RaiseScope(const std::string& var, const char *value); + // push and pop loop scopes + void PushLoopBlockBarrier(); + void PopLoopBlockBarrier(); + /** Helper class to push and pop scopes automatically. */ class ScopePushPop { @@ -945,6 +960,10 @@ public: void ClearMatches(); void StoreMatches(cmsys::RegularExpression& re); + void PushLoopBlock(); + void PopLoopBlock(); + bool IsLoopBlock() const; + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const std::string& name, cmTarget& target); @@ -1039,6 +1058,8 @@ private: void PushFunctionBlockerBarrier(); void PopFunctionBlockerBarrier(bool reportError = true); + std::stack LoopBlockCounter; + typedef std::map StringStringMap; StringStringMap MacrosMap; diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 98e129d..47edb03 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -27,6 +27,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, // if this is the endwhile for this while loop then execute if (!this->Depth) { + cmMakefile::LoopBlockPop loopBlockPop(&mf); + // Remove the function blocker for this scope or bail. cmsys::auto_ptr fb(mf.RemoveFunctionBlocker(this, lff)); @@ -142,6 +144,8 @@ bool cmWhileCommand f->Args = args; this->Makefile->AddFunctionBlocker(f); + this->Makefile->PushLoopBlock(); + return true; } diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 0099d4b..24d0c93 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -109,6 +109,7 @@ add_RunCMake_test(include_directories) add_RunCMake_test(list) add_RunCMake_test(message) add_RunCMake_test(project) +add_RunCMake_test(return) add_RunCMake_test(string) add_RunCMake_test(try_compile) add_RunCMake_test(set) 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/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..b3b3f96 --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt @@ -0,0 +1,2 @@ + continue A CONTINUE command was found outside of a proper FOREACH or WHILE + loop scope. 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..b3b3f96 --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt @@ -0,0 +1,2 @@ + continue A CONTINUE command was found outside of a proper FOREACH or WHILE + loop scope. 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 index c057282..f85154f 100644 --- a/Tests/RunCMake/continue/RunCMakeTest.cmake +++ b/Tests/RunCMake/continue/RunCMakeTest.cmake @@ -1,5 +1,8 @@ include(RunCMake) run_cmake(ContinueForeach) +run_cmake(ContinueForEachInLists) run_cmake(ContinueNestedForeach) run_cmake(ContinueWhile) +run_cmake(NoEnclosingBlock) +run_cmake(NoEnclosingBlockInFunction) diff --git a/Tests/RunCMake/return/CMakeLists.txt b/Tests/RunCMake/return/CMakeLists.txt new file mode 100644 index 0000000..2d75985 --- /dev/null +++ b/Tests/RunCMake/return/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/return/ReturnFromForeach-result.txt b/Tests/RunCMake/return/ReturnFromForeach-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/return/ReturnFromForeach-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/return/ReturnFromForeach.cmake b/Tests/RunCMake/return/ReturnFromForeach.cmake new file mode 100644 index 0000000..c71cf33 --- /dev/null +++ b/Tests/RunCMake/return/ReturnFromForeach.cmake @@ -0,0 +1,10 @@ +function(foo) + foreach(i RANGE 1 3) + foreach(j RANGE 1 3) + return() + message(FATAL_ERROR "unexpected") + endforeach() + endforeach() +endfunction(foo) + +foo() diff --git a/Tests/RunCMake/return/RunCMakeTest.cmake b/Tests/RunCMake/return/RunCMakeTest.cmake new file mode 100644 index 0000000..2cc6c9d --- /dev/null +++ b/Tests/RunCMake/return/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(ReturnFromForeach) -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Mon Nov 17 14:00:54 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Mon, 17 Nov 2014 20:00:54 +0100 Subject: [cmake-developers] [PATCH v4 3/3] Reject break() without loop scope In-Reply-To: <1416250854-1978-1-git-send-email-gjasny@googlemail.com> References: <1416250854-1978-1-git-send-email-gjasny@googlemail.com> Message-ID: <1416250854-1978-4-git-send-email-gjasny@googlemail.com> Signed-off-by: Gregor Jasny --- Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0055.rst | 17 +++++++++++++ Source/cmBreakCommand.cxx | 33 ++++++++++++++++++++++++++ Source/cmPolicies.cxx | 5 ++++ Source/cmPolicies.h | 1 + Tests/RunCMake/CMP0055/CMP0055-NEW-result.txt | 1 + Tests/RunCMake/CMP0055/CMP0055-NEW-stderr.txt | 4 ++++ Tests/RunCMake/CMP0055/CMP0055-NEW.cmake | 4 ++++ Tests/RunCMake/CMP0055/CMP0055-OLD-result.txt | 1 + Tests/RunCMake/CMP0055/CMP0055-OLD-stderr.txt | 1 + Tests/RunCMake/CMP0055/CMP0055-OLD.cmake | 4 ++++ Tests/RunCMake/CMP0055/CMP0055-WARN-result.txt | 1 + Tests/RunCMake/CMP0055/CMP0055-WARN-stderr.txt | 9 +++++++ Tests/RunCMake/CMP0055/CMP0055-WARN.cmake | 2 ++ Tests/RunCMake/CMP0055/CMakeLists.txt | 3 +++ Tests/RunCMake/CMP0055/RunCMakeTest.cmake | 5 ++++ Tests/RunCMake/CMakeLists.txt | 1 + 17 files changed, 93 insertions(+) create mode 100644 Help/policy/CMP0055.rst create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN.cmake create mode 100644 Tests/RunCMake/CMP0055/CMakeLists.txt create mode 100644 Tests/RunCMake/CMP0055/RunCMakeTest.cmake diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 7074bd5..742fd63 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -112,3 +112,4 @@ All Policies /policy/CMP0052 /policy/CMP0053 /policy/CMP0054 + /policy/CMP0055 diff --git a/Help/policy/CMP0055.rst b/Help/policy/CMP0055.rst new file mode 100644 index 0000000..1c7783d --- /dev/null +++ b/Help/policy/CMP0055.rst @@ -0,0 +1,17 @@ +CMP0055 +------- + +Disallow break() outside of loop contexts. + +CMake 3.1.0 and lower allowed to put a :command:`break` command outside of +a loop context. This was undefined behavior. + +The OLD behavior for this policy is to allow +:command:`break` to be placed outside of loop contexts. +The NEW behavior for this policy is to issue an error if a misplaced break +is found. + +This policy was introduced in CMake version 3.2. +CMake version |release| warns when the policy is not set and uses +OLD behavior. Use the cmake_policy command to set it to OLD or +NEW explicitly. diff --git a/Source/cmBreakCommand.cxx b/Source/cmBreakCommand.cxx index b70e400..ae1781a 100644 --- a/Source/cmBreakCommand.cxx +++ b/Source/cmBreakCommand.cxx @@ -15,6 +15,39 @@ bool cmBreakCommand::InitialPass(std::vector const&, cmExecutionStatus &status) { + if(!this->Makefile->IsLoopBlock()) + { + bool issueMessage = true; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) + { + case cmPolicies::WARN: + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0055)) << "\n"; + break; + case cmPolicies::OLD: + issueMessage = false; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + messageType = cmake::FATAL_ERROR; + break; + } + + if (issueMessage) + { + e << "A BREAK command was found outside of a proper " + "FOREACH or WHILE loop scope."; + this->Makefile->IssueMessage(messageType, e.str()); + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + status.SetBreakInvoked(true); return true; } diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index a420f59..1527add 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -364,6 +364,11 @@ cmPolicies::cmPolicies() CMP0054, "CMP0054", "Only interpret if() arguments as variables or keywords when unquoted.", 3,1,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0055, "CMP0055", + "Disallow break() outside of loop contexts.", + 3,2,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 7c73da8..5e0bea0 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -111,6 +111,7 @@ public: CMP0053, ///< Simplify variable reference and escape sequence evaluation CMP0054, ///< Only interpret if() arguments as variables /// or keywords when unquoted. + CMP0055, ///< Disallow break() outside of loop contexts /** \brief Always the last entry. * diff --git a/Tests/RunCMake/CMP0055/CMP0055-NEW-result.txt b/Tests/RunCMake/CMP0055/CMP0055-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0055/CMP0055-NEW-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-NEW-stderr.txt new file mode 100644 index 0000000..421b5d3 --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0055-NEW.cmake:4 \(break\): + A BREAK 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/CMP0055/CMP0055-NEW.cmake b/Tests/RunCMake/CMP0055/CMP0055-NEW.cmake new file mode 100644 index 0000000..53ac214 --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0055 NEW) + +break() diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-result.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD.cmake b/Tests/RunCMake/CMP0055/CMP0055-OLD.cmake new file mode 100644 index 0000000..57195c2 --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-OLD.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0055 OLD) + +break() diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-result.txt b/Tests/RunCMake/CMP0055/CMP0055-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-WARN-stderr.txt new file mode 100644 index 0000000..6e74b1e --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-WARN-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMP0055-WARN.cmake:2 \(break\): + Policy CMP0055 is not set: Disallow break\(\) outside of loop contexts. Run + "cmake --help-policy CMP0055" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + A BREAK command was found outside of a proper FOREACH or WHILE loop scope. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN.cmake b/Tests/RunCMake/CMP0055/CMP0055-WARN.cmake new file mode 100644 index 0000000..373a95a --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-WARN.cmake @@ -0,0 +1,2 @@ + +break() diff --git a/Tests/RunCMake/CMP0055/CMakeLists.txt b/Tests/RunCMake/CMP0055/CMakeLists.txt new file mode 100644 index 0000000..2d75985 --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0055/RunCMakeTest.cmake b/Tests/RunCMake/CMP0055/RunCMakeTest.cmake new file mode 100644 index 0000000..a033839 --- /dev/null +++ b/Tests/RunCMake/CMP0055/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0055-OLD) +run_cmake(CMP0055-NEW) +run_cmake(CMP0055-WARN) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 24d0c93..ec7ddf7 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -49,6 +49,7 @@ add_RunCMake_test(CMP0050) add_RunCMake_test(CMP0051) add_RunCMake_test(CMP0053) add_RunCMake_test(CMP0054) +add_RunCMake_test(CMP0055) add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(CompilerChange) -- 1.9.3 (Apple Git-50) From daniel at pfeifer-mail.de Mon Nov 17 14:09:55 2014 From: daniel at pfeifer-mail.de (Daniel Pfeifer) Date: Mon, 17 Nov 2014 19:09:55 +0000 Subject: [cmake-developers] [CMake] target_include_directories target issue References: <2851609.MeQsze1Sbj@envy> Message-ID: FWD to developers list. I think this is a documentation issue. Luis Felipe Dominguez Vega schrieb am Mon Nov 17 2014 at 5:42:55 PM: > I can't see into the source code of cmake, into the > cmTargetIncludeDirectoriesCommand.cxx somethink like import the > INCLUDE_DIRECTORIES from target passed to target_include_directories, may > an > error in the documentation? > ----------------------------------------------------------- > On Sunday 16 November 2014 11:56:05 AM Wojciech Mamrak wrote: > > Hello, > > > > the docs claim: > > > > "Specify include directories or targets to use when compiling a given > > target." > > > > Here is a little test of it. Project directory: > > > > Foo > > CMakeLists.txt > > FooSrc > > a.h > > a.cpp > > Bar > > main.cpp > > > > And CMakeLists.txt: > > > > cmake_minimum_required(VERSION 3.0) > > > > project(FooBar) > > > > add_library(Foo FooSrc/a.h FooSrc/a.cpp) > > > > target_include_directories(Foo PUBLIC G:/some_directory) > > > > if (TARGET Foo) > > message("Foo is a target!") > > endif() > > > > add_executable(Bar Bar/main.cpp) > > > > target_include_directories(Bar PRIVATE Foo) > > > > According to the docs, Bar's include directories should contain at > > least "G:/some_directory", but it contains > > "${PROJECT_SOURCE_DIR}/Foo". Why? > > > > If I replace the last line with target_link_libraries(Bar PRIVATE > > Foo), then Bar's include directories meet my expectations. > > > > regards > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at http://www.kitware.com/ > opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad.king at kitware.com Mon Nov 17 14:39:52 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Nov 2014 14:39:52 -0500 Subject: [cmake-developers] [PATCH v4 0/3] Add continue keyword In-Reply-To: <1416250854-1978-1-git-send-email-gjasny@googlemail.com> References: <1416250854-1978-1-git-send-email-gjasny@googlemail.com> Message-ID: <546A4F08.8010209@kitware.com> On 11/17/2014 02:00 PM, Gregor Jasny wrote: > the current version now properly checks for proper nesting > of the continue keyword. Cool, thanks. > 1) The Scope variable stack is held in a 'internal' structure > that gets special treatment in the cmMakefile copy ctor. > I don't know the implications of storing my loop block > counter stack directly as member of cmMakefile. Could you > please advise? IIRC the cmMakefile copy ctor is used in CPack, but only in a context where nothing but the top-level scope is in place. You should be able to store the member in cmMakefile. > 2) The error message for an inproperly nested continue looks > like this: > > continue A CONTINUE command was found outside of a proper FOREACH or WHILE > loop scope. > > where is the continue coming from? Is it part of a (too short) > call stack trace? Also I noticed that the CMakeFile is still > processed after the error is shown. Is this desired behavior? It comes from use of SetError and "return false", the old error reporting mechanism. Instead you can do: this->Makefile->IssueMessage(cmake::FATAL_ERROR, ...); cmSystemTools::SetFatalErrorOccured(); return true; > 3) The continue tests have a requirement for CMake version 3.1 > in the CMakeLists.txt file. This needs to be bumped to 3.2 once > the the version number got incremented to 3.2. You can use a dated version like 3.1.20141117 to request a dev version. > 4) Is the new policy to reject misplaced break() commands really > necessary? Yes, we need old code to continue to work even if it is wrong in this regard. Thanks, -Brad From gauthier.lamaison at gmail.com Mon Nov 17 14:46:21 2014 From: gauthier.lamaison at gmail.com (Gauthier Lamaison) Date: Mon, 17 Nov 2014 20:46:21 +0100 Subject: [cmake-developers] [PATCH] CPackRPM: unset temporary component variable fixed Message-ID: Hi there, First, I would like to thank you for your amazing work on CMake, CPack and CTest. I've been trying to make multiple RPMs using components, but it appears that the component variables such as CPACK_RPM__PACKAGE_REQUIRES are not correctly unset. Worse, they are propagated to other components (that's how I found myself having my devel RPM package requirements in my libs RPM package...) Please find attach a small patch that fixes the problem (at least in my case). Thank you, Gauthier -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: CPackRPM_Unset_variables.patch Type: text/x-patch Size: 1460 bytes Desc: not available URL: From brad.king at kitware.com Mon Nov 17 14:50:28 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Nov 2014 14:50:28 -0500 Subject: [cmake-developers] target_include_directories target issue In-Reply-To: References: <2851609.MeQsze1Sbj@envy> Message-ID: <546A5184.4090903@kitware.com> On 11/17/2014 02:09 PM, Daniel Pfeifer wrote: > FWD to developers list. I think this is a documentation issue. > > Luis Felipe Dominguez Vega schrieb am Mon Nov 17 2014 at 5:42:55 PM: > > I can't see into the source code of cmake, into the > cmTargetIncludeDirectoriesComm__and.cxx somethink like import the > INCLUDE_DIRECTORIES from target passed to target_include_directories, may an > error in the documentation? The command was first added with that capability but was never released like that due to ambiguity of target names and relative paths. I've fixed the docs: Help: target_include_directories does not allow target names http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1d22ee67 See commit message for details. Thanks, -Brad From brad.king at kitware.com Mon Nov 17 15:09:34 2014 From: brad.king at kitware.com (Brad King) Date: Mon, 17 Nov 2014 15:09:34 -0500 Subject: [cmake-developers] [PATCH] CPackRPM: unset temporary component variable fixed In-Reply-To: References: Message-ID: <546A55FE.2040909@kitware.com> On 11/17/2014 02:46 PM, Gauthier Lamaison wrote: > I've been trying to make multiple RPMs using components, but it appears > that the component variables such as CPACK_RPM__PACKAGE_REQUIRES > are not correctly unset. Worse, they are propagated to other components > (that's how I found myself having my devel RPM package requirements in my > libs RPM package...) > > Please find attach a small patch that fixes the problem (at least in my case). Thanks. This looks like a more complete version of commit v2.8.9~136^2: CPackRPM: avoid leakage of RPM directive from one component to another. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7321c94e CPackRPM bug - empty per-component REQUIRES http://www.cmake.org/Bug/view.php?id=13248 Would a CPackRPM maintainer please review the logic updates? Thanks, -Brad From mantis at public.kitware.com Mon Nov 17 15:11:38 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Mon, 17 Nov 2014 15:11:38 -0500 Subject: [cmake-developers] [CMake 0015254]: AUTOMOC ignores Q_OBJECT if preceded by non-whitespace characters Message-ID: The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15254 ====================================================================== Reported By: Jonnhy Fisher Assigned To: ====================================================================== Project: CMake Issue ID: 15254 Category: CMake Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-17 15:11 EST Last Modified: 2014-11-17 15:11 EST ====================================================================== Summary: AUTOMOC ignores Q_OBJECT if preceded by non-whitespace characters Description: A header file like class A : public QObject { Q_OBJECT }; or class A : public QObject { /* */ Q_OBJECT }; with CMAKE_AUTOMOC will actually not run moc on that file, while class A : public QObject { Q_OBJECT; }; will run moc. Apparently there may only be whitespace in front of Q_OBJECT to trigger automoc. This is not documented and kind of surprising. Steps to Reproduce: enable AUTOMOC put a some none-whitespace before Q_OBJECT ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-17 15:11 Jonnhy Fisher New Issue ====================================================================== From domen.vrankar at gmail.com Mon Nov 17 17:05:14 2014 From: domen.vrankar at gmail.com (Domen Vrankar) Date: Mon, 17 Nov 2014 23:05:14 +0100 Subject: [cmake-developers] [PATCH] CPackRPM: unset temporary component variable fixed In-Reply-To: <546A55FE.2040909@kitware.com> References: <546A55FE.2040909@kitware.com> Message-ID: 2014-11-17 21:09 GMT+01:00 Brad King : > On 11/17/2014 02:46 PM, Gauthier Lamaison wrote: >> I've been trying to make multiple RPMs using components, but it appears >> that the component variables such as CPACK_RPM__PACKAGE_REQUIRES >> are not correctly unset. Worse, they are propagated to other components >> (that's how I found myself having my devel RPM package requirements in my >> libs RPM package...) >> >> Please find attach a small patch that fixes the problem (at least in my case). > > Thanks. This looks like a more complete version of commit v2.8.9~136^2: > > CPackRPM: avoid leakage of RPM directive from one component to another. > http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7321c94e > CPackRPM bug - empty per-component REQUIRES > http://www.cmake.org/Bug/view.php?id=13248 > > Would a CPackRPM maintainer please review the logic updates? Patch looks OK. Can you please apply it? Regards, Domen From domen.vrankar at gmail.com Mon Nov 17 17:22:01 2014 From: domen.vrankar at gmail.com (Domen Vrankar) Date: Mon, 17 Nov 2014 23:22:01 +0100 Subject: [cmake-developers] [PATCH] CPackRPM: unset temporary component variable fixed In-Reply-To: References: <546A55FE.2040909@kitware.com> Message-ID: 2014-11-17 23:05 GMT+01:00 Domen Vrankar : > 2014-11-17 21:09 GMT+01:00 Brad King : >> On 11/17/2014 02:46 PM, Gauthier Lamaison wrote: >>> I've been trying to make multiple RPMs using components, but it appears >>> that the component variables such as CPACK_RPM__PACKAGE_REQUIRES >>> are not correctly unset. Worse, they are propagated to other components >>> (that's how I found myself having my devel RPM package requirements in my >>> libs RPM package...) >>> >>> Please find attach a small patch that fixes the problem (at least in my case). >> >> Thanks. This looks like a more complete version of commit v2.8.9~136^2: >> >> CPackRPM: avoid leakage of RPM directive from one component to another. >> http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7321c94e >> CPackRPM bug - empty per-component REQUIRES >> http://www.cmake.org/Bug/view.php?id=13248 >> >> Would a CPackRPM maintainer please review the logic updates? > > Patch looks OK. Can you please apply it? Gauthier would you also be willing to write a test for this patch? You could extend the test that is already on master branch of git repository in directory cmake/Tests/CPackComponentsForAll. MyLibCPackConfig-IgnoreGroup.cmake.in contains the location where you can set component variables - if(CPACK_GENERATOR MATCHES "RPM") section RunCPackVerifyResult.cmake contains checking of expected results (see the end of the script) Since the component variables logic is written in a for loop test of one variable would be enough. Thanks, Domen From Geoffrey.Viola at asirobots.com Mon Nov 17 17:16:26 2014 From: Geoffrey.Viola at asirobots.com (Geoffrey Viola) Date: Mon, 17 Nov 2014 22:16:26 +0000 Subject: [cmake-developers] Initial Attempt at Green Hill MULTI IDE Generator Support In-Reply-To: <545A7C44.6040305@kitware.com> References: <0543633b28c7431f93808182fc1e26e1@CO1PR07MB208.namprd07.prod.outlook.com> <543D2BBC.1010306@kitware.com> <0b5b33c4d1f0472782e260f9e5bce980@CO1PR07MB208.namprd07.prod.outlook.com> <544E4C9F.3050408@kitware.com> <64abd7ba273245b686146aa67acb7e8a@DM2PR0701MB1020.namprd07.prod.outlook.com> <545A7C44.6040305@kitware.com> Message-ID: Thanks for the feedback. I made some changes and rebased on the trunk. > The hunk in Modules/CMakeSystemSpecificInformation.cmake is now just removing a blank line so it should not be needed. Removed >> +message("GHS-DetermineCompiler.cmake") > >This looks like a leftover debugging message. Removed >> there are a few changes to find boost libraries with this generator. >[snip] >> -if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) >> +if ("Windows" STREQUAL ${CMAKE_HOST_SYSTEM_NAME} AND >> + Boost_USE_STATIC_LIBS AND NOT CYGWIN) > >Why does the host affect the library prefix for binaries meant for the target platform? I'm still unsure if the WIN32 cmake variables is the target, platform or both. I originally thought this check should be based on the host, but it should be based on the target platform. I added a special case for the GHS Multi platform. >> Some of the code is C++11. I'm not sure if that is an issue. > > It is. We build on compilers that barely support C++98. I removed usages of nullptr and std::anyof with a lamda expression. >> Also, it skips the step where it determines the compiler by using the >> force compiler macro. I don't see any other cmake module using this >> functionality. >[snip] >> +set(CMAKE_SYSTEM_NAME "GHS-MULTI") >> +set(CMAKE_SYSTEM_PROCESSOR "ARM") >... >> +include(CMakeForceCompiler) >> +CMAKE_FORCE_CXX_COMPILER("cxarm" "GhsMultiArmCXX") > >Those APIs are meant for use in a CMAKE_TOOLCHAIN_FILE. > >The cmGlobalGhsMultiGenerator::EnableLanguage method should be able to take care of those. This is the first time we've had a generator that locks to a specific target >platform (and implicitly cross-compiles). > >Is CMAKE_SYSTEM_VERSION always hard-coded on a given system or should the user be able to choose it in some way? Platform/GHS-MULTI-C.cmake and Platform/GHS-MULTI-CXX.cmake have been moved into the enable language method. The cmake system version can be changed with the GHS_COMP_ROOT cache variable. The version variable is not currently being used internally, since I've only tested it on what I think is the latest version. There was a bug in the previous use of find_program for CMAKE_MAKE_PROGRAM, where I thought the paths were interpreted as a regular expression. Geoffrey Viola SOFTWARE ENGINEER T +1.435.755.2980 ext 1077 M +1.215.896.6521 asirobots.com -----Original Message----- From: Brad King [mailto:brad.king at kitware.com] Sent: Wednesday, November 05, 2014 12:37 PM To: Geoffrey Viola Cc: cmake-developers at cmake.org Subject: Re: [cmake-developers] Initial Attempt at Green Hill MULTI IDE Generator Support On 11/05/2014 01:11 PM, Geoffrey Viola wrote: > I rebased and squashed the previous commits and made some new changes. Thanks. Here are more comments. The hunk in Modules/CMakeSystemSpecificInformation.cmake is now just removing a blank line so it should not be needed. > +message("GHS-DetermineCompiler.cmake") This looks like a leftover debugging message. > there are a few changes to find boost libraries with this generator. [snip] > -if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) > +if ("Windows" STREQUAL ${CMAKE_HOST_SYSTEM_NAME} AND > + Boost_USE_STATIC_LIBS AND NOT CYGWIN) Why does the host affect the library prefix for binaries meant for the target platform? > Some of the code is C++11. I'm not sure if that is an issue. It is. We build on compilers that barely support C++98. > Also, it skips the step where it determines the compiler by using the > force compiler macro. I don't see any other cmake module using this > functionality. [snip] > +set(CMAKE_SYSTEM_NAME "GHS-MULTI") > +set(CMAKE_SYSTEM_PROCESSOR "ARM") ... > +include(CMakeForceCompiler) > +CMAKE_FORCE_CXX_COMPILER("cxarm" "GhsMultiArmCXX") Those APIs are meant for use in a CMAKE_TOOLCHAIN_FILE. The cmGlobalGhsMultiGenerator::EnableLanguage method should be able to take care of those. This is the first time we've had a generator that locks to a specific target platform (and implicitly cross-compiles). Is CMAKE_SYSTEM_VERSION always hard-coded on a given system or should the user be able to choose it in some way? Thanks, -Brad This message contains confidential information and is intended only for the recipient. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately if you have received this e-mail by mistake and delete this e-mail from your system. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Added-some-support-for-a-Green-Hill-MULTI.patch Type: application/octet-stream Size: 50910 bytes Desc: 0001-Added-some-support-for-a-Green-Hill-MULTI.patch URL: From gauthier.lamaison at gmail.com Mon Nov 17 18:00:48 2014 From: gauthier.lamaison at gmail.com (Gauthier Lamaison) Date: Tue, 18 Nov 2014 00:00:48 +0100 Subject: [cmake-developers] [PATCH] CPackRPM: unset temporary component variable fixed In-Reply-To: References: <546A55FE.2040909@kitware.com> Message-ID: > Gauthier would you also be willing to write a test for this patch? > Sure ! I'll dig into that. > You could extend the test that is already on master branch of git > repository in directory cmake/Tests/CPackComponentsForAll. > MyLibCPackConfig-IgnoreGroup.cmake.in contains the location where you > can set component variables - if(CPACK_GENERATOR MATCHES "RPM") > section > RunCPackVerifyResult.cmake contains checking of expected results (see > the end of the script) > Found it. Thanks, Gauthier -------------- next part -------------- An HTML attachment was scrubbed... URL: From ruslan_baratov at yahoo.com Mon Nov 17 18:45:05 2014 From: ruslan_baratov at yahoo.com (Ruslan Baratov) Date: Tue, 18 Nov 2014 02:45:05 +0300 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <546A0F00.3090908@kitware.com> References: <5431B11C.3010209@yahoo.com> <54665ED3.3060300@kitware.com> <54668FEC.5020203@yahoo.com> <708024991.ylpfiUSqup@caliban.sf-tec.de> <546A0F00.3090908@kitware.com> Message-ID: <546A8881.5050205@yahoo.com> On 17-Nov-14 18:06, Brad King wrote: > Yes, please change to that so a proper error can be produced for the new > API when "123xyz" is given as a timeout, for example. Function added cmSystemTools::StringToInt > Please look at adding a case to the test suite for this. An outer > process could take the lock and then execute_process a child that > tries to take the lock with a timeout. Then check that it fails > as expected. Done Ruslo -------------- next part -------------- >From 9a3e5728173d2b5e4381d3c65556534298f7bb27 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Tue, 18 Nov 2014 02:32:27 +0300 Subject: [PATCH 1/7] Add function cmSystemTools::StringToInt --- Source/cmSystemTools.cxx | 7 +++++++ Source/cmSystemTools.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 3247f7f..9664983 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2925,3 +2925,10 @@ std::vector cmSystemTools::tokenize(const std::string& str, } return tokens; } + +//---------------------------------------------------------------------------- +bool cmSystemTools::StringToInt(const char* str, int* value) { + char unused; + const int result = sscanf(str, "%d%c", value, &unused); + return (result == 1); +} 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 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 { -- 2.1.1 -------------- next part -------------- >From 9e7e463d51a8944c8951540114e0e34824a239f5 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Tue, 18 Nov 2014 02:33:46 +0300 Subject: [PATCH 2/7] Add class cmFileLockResult --- Source/cmFileLockResult.cxx | 111 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockResult.h | 85 +++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 Source/cmFileLockResult.cxx create mode 100644 Source/cmFileLockResult.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 + +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 // 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 -- 2.1.1 -------------- next part -------------- >From 0b2c39c736c5a9e4d7c9bf1cefda8e6682ee5961 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Tue, 18 Nov 2014 02:34:07 +0300 Subject: [PATCH 3/7] Add class cmFileLock --- Source/cmFileLock.cxx | 77 +++++++++++++++++++++++++++ Source/cmFileLock.h | 74 ++++++++++++++++++++++++++ Source/cmFileLockUnix.cxx | 102 ++++++++++++++++++++++++++++++++++++ Source/cmFileLockWin32.cxx | 126 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 379 insertions(+) create mode 100644 Source/cmFileLock.cxx create mode 100644 Source/cmFileLock.h create mode 100644 Source/cmFileLockUnix.cxx create mode 100644 Source/cmFileLockWin32.cxx diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx new file mode 100644 index 0000000..f69c36a --- /dev/null +++ b/Source/cmFileLock.cxx @@ -0,0 +1,77 @@ +/*============================================================================ + 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 +#include "cmFileLockResult.h" + +// Common implementation + +cmFileLock::~cmFileLock() +{ + if (!this->Filename.empty()) + { + const cmFileLockResult result = this->Release(); + 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(-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..7c2803b --- /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 // HANDLE +#endif + +class cmFileLockResult; + +/** + * @brief Cross-platform file locking. + * @detail 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. + * @detail 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/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx new file mode 100644 index 0000000..3c01da8 --- /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 +#include // SEEK_SET +#include +#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 != 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 = 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 // 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(-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(-1); + static OVERLAPPED overlapped; + return LockFileEx( + this->File, + flags, + reserved, + len, + len, + &overlapped + ); +} -- 2.1.1 -------------- next part -------------- >From 857e10281eba52362c58c66f5830836ede2ad9f8 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Tue, 18 Nov 2014 02:34:21 +0300 Subject: [PATCH 4/7] Add class cmFileLockPool --- Source/cmFileLockPool.cxx | 198 ++++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockPool.h | 100 +++++++++++++++++++++++ 2 files changed, 298 insertions(+) create mode 100644 Source/cmFileLockPool.cxx create mode 100644 Source/cmFileLockPool.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 + +#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 List; + typedef List::iterator It; + typedef List::const_iterator CIt; + + List Locks; + }; + + typedef std::list List; + + typedef List::iterator It; + typedef List::const_iterator CIt; + + List FunctionScopes; + List FileScopes; + ScopePool ProcessScope; +}; + +#endif // cmFileLockPool_h -- 2.1.1 -------------- next part -------------- >From 80297a173a3d7f734538d0c8bd6c9bc354c8ba73 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Tue, 18 Nov 2014 02:35:32 +0300 Subject: [PATCH 5/7] New command 'file(LOCK ...)' --- Source/CMakeLists.txt | 6 ++ Source/cmFileCommand.cxx | 197 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileCommand.h | 1 + Source/cmGlobalGenerator.h | 10 +++ Source/cmLocalGenerator.cxx | 6 ++ Source/cmMakefile.cxx | 8 ++ 6 files changed, 228 insertions(+) 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/cmFileCommand.cxx b/Source/cmFileCommand.cxx index b0ddff4..231600a 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,198 @@ bool cmFileCommand::HandleGenerateCommand( } //---------------------------------------------------------------------------- +bool cmFileCommand::HandleLockCommand( + std::vector 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(-1); + + // Parse arguments + if(args.size() < 2) + { + this->SetError("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->SetError(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: \"" << args[i] << "\"."; + this->SetError(e.str()); + return false; + } + } + } + else if (args[i] == "RESULT_VARIABLE") + { + ++i; + if (i >= args.size()) + { + this->SetError(": expected variable name after RESULT_VARIABLE"); + return false; + } + resultVariable = args[i]; + } + else if (args[i] == "TIMEOUT") + { + ++i; + if (i >= args.size()) + { + this->SetError(": 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->SetError(e.str()); + return false; + } + timeout = static_cast(scanned); + } + else + { + cmOStringStream e; + e << ": expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT"; + e << ", but got: \"" << args[i] << "\"."; + this->SetError(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 \"" << parentDir << "\" creation failed "; + e << "(check permissions)."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + FILE *file = cmsys::SystemTools::Fopen(path, "w"); + if (!file) + { + cmOStringStream e; + e << ": file \"" << path << "\" creation failed (check permissions)."; + this->SetError(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 \"" << path << "\" (" << result << ")."; + this->SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + + if (!resultVariable.empty()) + { + this->Makefile->AddDefinition(resultVariable, result.c_str()); + } + + return true; +#else + static_cast(args); + this->SetError("sub-command LOCK not implemented in bootstrap cmake"); + return false; +#endif +} + +//---------------------------------------------------------------------------- bool cmFileCommand::HandleTimestampCommand( std::vector 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 const& args); bool HandleGenerateCommand(std::vector const& args); + bool HandleLockCommand(std::vector const& args); private: void AddEvaluationFile(const std::string &inputName, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ddd7e91..15fdcb8 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 #endif @@ -341,6 +342,10 @@ public: bool GenerateCPackPropertiesFile(); +#if defined(CMAKE_BUILD_WITH_CMAKE) + cmFileLockPool& GetFileLockPool() { return FileLockPool; } +#endif + protected: virtual void Generate(); @@ -488,6 +493,11 @@ private: // track targets to issue CMP0042 warning for. std::set CMP0042WarnTargets; + +#if defined(CMAKE_BUILD_WITH_CMAKE) + // Pool of file locks + cmFileLockPool FileLockPool; +#endif }; #endif diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 69b56c6..abafa0f 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 8a8aadc..5484421 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4426,6 +4426,10 @@ void cmMakefile::PushScope() this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PushFunctionScope(); +#endif } void cmMakefile::PopScope() @@ -4463,6 +4467,10 @@ void cmMakefile::PopScope() { this->Internal->VarUsageStack.top().insert(*it); } +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PopFunctionScope(); +#endif } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) -- 2.1.1 -------------- next part -------------- >From 5f296559e3ea87965e9842a463cadf77205f9859 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Tue, 18 Nov 2014 02:36:02 +0300 Subject: [PATCH 6/7] Update documentation of command file (LOCK option) --- Help/command/file.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 [DIRECTORY] [RELEASE] + [GUARD ] + [RESULT_VARIABLE ] + [TIMEOUT ]) + +Lock a file specified by ```` if no ``DIRECTORY`` option present and file +``/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 ```` value. Any errors will be interpreted as fatal if there is no +``RESULT_VARIABLE`` option. Otherwise result will be stored in ```` +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. -- 2.1.1 -------------- next part -------------- >From c026af8f576ece2cf3e95eeb5afd8422ca14013d Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Tue, 18 Nov 2014 02:37:40 +0300 Subject: [PATCH 7/7] Add tests for command 'file(LOCK ...)' --- .../file/LOCK-error-file-create-fail-result.txt | 1 + .../file/LOCK-error-file-create-fail-stderr.txt | 6 ++++ .../file/LOCK-error-file-create-fail.cmake | 3 ++ .../file/LOCK-error-guard-incorrect-result.txt | 1 + .../file/LOCK-error-guard-incorrect-stderr.txt | 4 +++ .../RunCMake/file/LOCK-error-guard-incorrect.cmake | 1 + .../file/LOCK-error-incorrect-timeout-result.txt | 1 + .../file/LOCK-error-incorrect-timeout-stderr.txt | 4 +++ .../LOCK-error-incorrect-timeout-trail-result.txt | 1 + .../LOCK-error-incorrect-timeout-trail-stderr.txt | 4 +++ .../file/LOCK-error-incorrect-timeout-trail.cmake | 1 + .../file/LOCK-error-incorrect-timeout.cmake | 1 + .../RunCMake/file/LOCK-error-lock-fail-result.txt | 1 + .../RunCMake/file/LOCK-error-lock-fail-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-lock-fail.cmake | 6 ++++ .../file/LOCK-error-negative-timeout-result.txt | 1 + .../file/LOCK-error-negative-timeout-stderr.txt | 4 +++ .../file/LOCK-error-negative-timeout.cmake | 1 + .../file/LOCK-error-no-function-result.txt | 1 + .../file/LOCK-error-no-function-stderr.txt | 6 ++++ Tests/RunCMake/file/LOCK-error-no-function.cmake | 1 + Tests/RunCMake/file/LOCK-error-no-guard-result.txt | 1 + Tests/RunCMake/file/LOCK-error-no-guard-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-no-guard.cmake | 1 + Tests/RunCMake/file/LOCK-error-no-path-result.txt | 1 + Tests/RunCMake/file/LOCK-error-no-path-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-no-path.cmake | 1 + .../file/LOCK-error-no-result-variable-result.txt | 1 + .../file/LOCK-error-no-result-variable-stderr.txt | 4 +++ .../file/LOCK-error-no-result-variable.cmake | 1 + .../RunCMake/file/LOCK-error-no-timeout-result.txt | 1 + .../RunCMake/file/LOCK-error-no-timeout-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-no-timeout.cmake | 1 + Tests/RunCMake/file/LOCK-error-timeout-result.txt | 1 + Tests/RunCMake/file/LOCK-error-timeout-stderr.txt | 9 +++++ Tests/RunCMake/file/LOCK-error-timeout-stdout.txt | 1 + Tests/RunCMake/file/LOCK-error-timeout.cmake | 22 ++++++++++++ .../file/LOCK-error-unknown-option-result.txt | 1 + .../file/LOCK-error-unknown-option-stderr.txt | 5 +++ .../RunCMake/file/LOCK-error-unknown-option.cmake | 1 + Tests/RunCMake/file/LOCK-stdout.txt | 11 ++++++ Tests/RunCMake/file/LOCK.cmake | 40 ++++++++++++++++++++++ Tests/RunCMake/file/RunCMakeTest.cmake | 14 ++++++++ Tests/RunCMake/file/background.bat | 4 +++ Tests/RunCMake/file/background.sh | 4 +++ Tests/RunCMake/file/file-to-lock | 0 .../file/subdir_test_unlock/CMakeLists.txt | 2 ++ Tests/RunCMake/file/timeout-script.cmake | 2 ++ 48 files changed, 194 insertions(+) create mode 100644 Tests/RunCMake/file/LOCK-error-file-create-fail-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-file-create-fail-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-file-create-fail.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-guard-incorrect-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-guard-incorrect-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-guard-incorrect.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-negative-timeout-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-negative-timeout-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-negative-timeout.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-function-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-function-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-function.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-guard-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-guard-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-guard.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-path-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-path-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-path.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-result-variable-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-result-variable-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-result-variable.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-timeout-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-timeout-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-timeout.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-timeout-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-timeout-stderr.txt create mode 100755 Tests/RunCMake/file/LOCK-error-timeout-stdout.txt create mode 100644 Tests/RunCMake/file/LOCK-error-timeout.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option.cmake create mode 100644 Tests/RunCMake/file/LOCK-stdout.txt create mode 100644 Tests/RunCMake/file/LOCK.cmake create mode 100755 Tests/RunCMake/file/background.bat create mode 100755 Tests/RunCMake/file/background.sh create mode 100644 Tests/RunCMake/file/file-to-lock create mode 100644 Tests/RunCMake/file/subdir_test_unlock/CMakeLists.txt create mode 100755 Tests/RunCMake/file/timeout-script.cmake 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..d0ce86f --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-file-create-fail-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at LOCK-error-file-create-fail\.cmake:[0-9]+ \(file\): + 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..eda0f35 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-guard-incorrect-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-guard-incorrect\.cmake:[0-9]+ \(file\): + 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..53c6747 --- /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\): + 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..b3b11b8 --- /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\): + 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..753b063 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-lock-fail-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LOCK-error-lock-fail.cmake:[0-9]+ \(file\): + 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..7e08d53 --- /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\): + 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..46ea08e --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-no-function-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at LOCK-error-no-function\.cmake:[0-9]+ \(file\): + 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..91a63e1 --- /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\): + 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..9edbfd7 --- /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\): + 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..35adf64 --- /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\): + 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..a813426 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-timeout-stderr.txt @@ -0,0 +1,9 @@ +Output:[ ]* +Error: CMake Error at .*.timeout-script\.cmake:[0-9]+ \(file\): + 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 100755 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..8b05b35 --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-timeout.cmake @@ -0,0 +1,22 @@ +if(WIN32) + set(ext "bat") +else() + set(ext "sh") +endif() + +set(background "${CMAKE_CURRENT_LIST_DIR}/background.${ext}") + +set(script "${CMAKE_CURRENT_LIST_DIR}/timeout-script.cmake") +execute_process( + COMMAND "${background}" "${CMAKE_COMMAND}" -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..ec9d3aa --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-unknown-option-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at LOCK-error-unknown-option\.cmake:[0-9]+ \(file\): + 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/background.bat b/Tests/RunCMake/file/background.bat new file mode 100755 index 0000000..15e676c --- /dev/null +++ b/Tests/RunCMake/file/background.bat @@ -0,0 +1,4 @@ + at echo OFF + +START /B %1 %2 %3 +%1 %2 %3 diff --git a/Tests/RunCMake/file/background.sh b/Tests/RunCMake/file/background.sh new file mode 100755 index 0000000..1b9f167 --- /dev/null +++ b/Tests/RunCMake/file/background.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +$@ & +$@ diff --git a/Tests/RunCMake/file/file-to-lock b/Tests/RunCMake/file/file-to-lock new file mode 100644 index 0000000..e69de29 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 100755 index 0000000..87865db --- /dev/null +++ b/Tests/RunCMake/file/timeout-script.cmake @@ -0,0 +1,2 @@ +file(LOCK "${CMAKE_CURRENT_LIST_DIR}/file-to-lock" TIMEOUT 5) +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 10) -- 2.1.1 From Gilles.Khouzam at microsoft.com Mon Nov 17 20:08:25 2014 From: Gilles.Khouzam at microsoft.com (Gilles Khouzam) Date: Tue, 18 Nov 2014 01:08:25 +0000 Subject: [cmake-developers] Failing CMake WinStorePhone tests In-Reply-To: References: <54662FF5.6040806@kitware.com> Message-ID: <3af8b457747049ab929bea417357e4b9@CY1PR0301MB0713.namprd03.prod.outlook.com> Hi David, Can you give me some information on your current setup? What build of VS do you have installed, which options? I think that the detection logic for the tests is missing some cases. I'm guessing that this is similar to what I recently fixed in CMake for the express editions, the same detection logic might need to be moved over to the test script. -----Original Message----- From: David Cole [mailto:DLRdave at aol.com] Sent: Friday, November 14, 2014 10:42 To: Gilles Khouzam Cc: Brad King; cmake-developers at cmake.org Subject: Re: [cmake-developers] Failing CMake WinStorePhone tests I was hoping you'd say that! :-) On Fri, Nov 14, 2014 at 12:23 PM, Gilles Khouzam wrote: > Hi David, > > Let me take a look at what's going on. > > -----Original Message----- > From: Brad King [mailto:brad.king at kitware.com] > Sent: Friday, November 14, 2014 08:38 > To: David Cole > Cc: cmake-developers at cmake.org; Gilles Khouzam > Subject: Re: [cmake-developers] Failing CMake WinStorePhone tests > > On 11/14/2014 11:27 AM, David Cole via cmake-developers wrote: >> Should I expect these tests to pass using Ninja, or is that beyond >> the scope of the WinStorePhone support...? > > The VS generator is needed for the feature, but the tests that are failing hard-code use of specific Visual Studio generators regardless of the main generator being tested. > > I'll defer to Gilles as for what the problem might be. > > -Brad > From ahovda at openit.com Tue Nov 18 06:16:22 2014 From: ahovda at openit.com (=?windows-1252?Q?=C5dne_Hovda?=) Date: Tue, 18 Nov 2014 12:16:22 +0100 Subject: [cmake-developers] HP-UX Curses questions In-Reply-To: <546A1602.5060703@kitware.com> References: <546A1602.5060703@kitware.com> Message-ID: <546B2A86.2070201@openit.com> On 17.11.2014 16:36, Brad King wrote: >> /* get around odd bug on aCC and itanium */ >> -#if defined(__hpux) && defined(__ia64) >> +#if defined(__hpux) >> #define getmaxx __getmaxx >> #define getmaxy __getmaxy >> #endif > > What is the purpose of this part of the change? Should this block > be conditional on use of cur_colr? First off, I'm by no means an expert on curses, I'm just trying to resolve the issues with compiling a 64-bit HPPA package on HP-UX 11.11, which fails due to the cur_colr library not being available in 64-bit. X/Open Curses does not specify the getmax[xy]() functions/macros, only getmaxyx(), so the Xcurses lib on HP-UX does not export those functions and AFAIKT in some other implementations these functions are simply header macros. cur_colr happens to provide getmax[xy] as functions. It's really difficult to get the complete picture since there are so many iterations and implementations, especially on old UNIX machines, but from checking the ones I have access to, both AIX 5.1, Solaris 8, HP-UX 11.11, 11.23, RHEL 3 and onwards all have getmaxyx() (with _XOPEN_SOURCE_EXTENDED). So for CMake's part - of course depending on how old systems you want to support - the better solution would probably be to just use getmaxyx() everywhere in cmForm as is already the case in ccmake. I'm using GCC on all platforms except Windows, so I have not tested my changes with aCC, Xlc and the Sun compiler, but ccmake builds fine on sol8sparc, aix51, hp-ux11.11pa, hp-ux11.23ia and Linux in both 32 and 64 bit mode. Also, I don't have a Mac to test on. I've pushed my changes to https://github.com/aadnehovda/CMake/tree/curses-hpux-fix and can create a pull request if you think this is okay. Best regards, ?dne Hovda From brad.king at kitware.com Tue Nov 18 09:34:42 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Nov 2014 09:34:42 -0500 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <546A8881.5050205@yahoo.com> References: <5431B11C.3010209@yahoo.com> <54665ED3.3060300@kitware.com> <54668FEC.5020203@yahoo.com> <708024991.ylpfiUSqup@caliban.sf-tec.de> <546A0F00.3090908@kitware.com> <546A8881.5050205@yahoo.com> Message-ID: <546B5902.2080701@kitware.com> On 11/17/2014 6:45 PM, Ruslan Baratov wrote: > Done Thanks for the updates. I'll try this out again when I get a chance. -Brad From brad.king at kitware.com Tue Nov 18 09:35:40 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Nov 2014 09:35:40 -0500 Subject: [cmake-developers] Initial Attempt at Green Hill MULTI IDE Generator Support In-Reply-To: References: <0543633b28c7431f93808182fc1e26e1@CO1PR07MB208.namprd07.prod.outlook.com> <543D2BBC.1010306@kitware.com> <0b5b33c4d1f0472782e260f9e5bce980@CO1PR07MB208.namprd07.prod.outlook.com> <544E4C9F.3050408@kitware.com> <64abd7ba273245b686146aa67acb7e8a@DM2PR0701MB1020.namprd07.prod.outlook.com> <545A7C44.6040305@kitware.com> Message-ID: <546B593C.3060706@kitware.com> On 11/17/2014 5:16 PM, Geoffrey Viola wrote: > Thanks for the feedback. I made some changes and rebased on the trunk. Great. I'll try it out again when I get a chance. > The cmake system version can be changed with the GHS_COMP_ROOT cache > variable. Okay, so the version is determined by the tools used, and there is exactly one version at a given GHS_COMP_ROOT? Thanks, -Brad From brad.king at kitware.com Tue Nov 18 09:37:01 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Nov 2014 09:37:01 -0500 Subject: [cmake-developers] HP-UX Curses questions In-Reply-To: <546B2A86.2070201@openit.com> References: <546A1602.5060703@kitware.com> <546B2A86.2070201@openit.com> Message-ID: <546B598D.4080104@kitware.com> On 11/18/2014 6:16 AM, ?dne Hovda wrote: > X/Open Curses does not specify the getmax[xy]() functions/macros, only > getmaxyx() Yes, it makes sense to use well-defined APIs. Thanks for explaining. > I've pushed my changes to > https://github.com/aadnehovda/CMake/tree/curses-hpux-fix and can create > a pull request if you think this is okay. No PR is needed. I've fetched from there. Please read CONTRIBUTING.rst, though we can finish this one with your branch on Github. This hunk: > -#else > -/* figure out which curses.h to include */ > -# if defined(CURSES_HAVE_NCURSES_H) > -# include > -# elif defined(CURSES_HAVE_NCURSES_NCURSES_H) > -# include > -# elif defined(CURSES_HAVE_NCURSES_CURSES_H) > -# include > -# else > -# include > -# endif removes a bunch of logic when __hpux is not defined. I think that is still needed on all platforms to include the proper curses headers. That should be able to subsume the hpux case now. Please revise or explain. Thanks, -Brad From brad.king at kitware.com Tue Nov 18 09:37:26 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Nov 2014 09:37:26 -0500 Subject: [cmake-developers] [PATCH] CPackRPM: unset temporary component variable fixed In-Reply-To: References: <546A55FE.2040909@kitware.com> Message-ID: <546B59A6.20903@kitware.com> On 11/17/2014 5:22 PM, Domen Vrankar wrote: >> Patch looks OK. Can you please apply it? Applied here: CPackRPM: Unset temporary component variables before re-use http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=51a60973 > Gauthier would you also be willing to write a test for this patch? We can add this as another patch when it is ready. Thanks, -Brad From ahovda at openit.com Tue Nov 18 09:48:12 2014 From: ahovda at openit.com (=?UTF-8?B?w4VkbmUgSG92ZGE=?=) Date: Tue, 18 Nov 2014 15:48:12 +0100 Subject: [cmake-developers] HP-UX Curses questions In-Reply-To: <546B598D.4080104@kitware.com> References: <546A1602.5060703@kitware.com> <546B2A86.2070201@openit.com> <546B598D.4080104@kitware.com> Message-ID: <546B5C2C.1080602@openit.com> On 18.11.2014 15:37, Brad King wrote: >> -#else >> -/* figure out which curses.h to include */ >> -# if defined(CURSES_HAVE_NCURSES_H) >> -# include >> -# elif defined(CURSES_HAVE_NCURSES_NCURSES_H) >> -# include >> -# elif defined(CURSES_HAVE_NCURSES_CURSES_H) >> -# include >> -# else >> -# include >> -# endif > > removes a bunch of logic when __hpux is not defined. I think that > is still needed on all platforms to include the proper curses > headers. That should be able to subsume the hpux case now. > Please revise or explain. The idea is that ccmake includes form.h which has the same block, already picking the correct curses header. I guess that could fail somewhat in case you use a system provided libform + form.h, but I didn't see that option in the ccmake CMakeLists.txt file. Btw, /usr/include/form.h on my linux machine also includes the ncurses.h header so maybe it could actually work. ?dne Hovda From brad.king at kitware.com Tue Nov 18 10:09:24 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Nov 2014 10:09:24 -0500 Subject: [cmake-developers] HP-UX Curses questions In-Reply-To: <546B5C2C.1080602@openit.com> References: <546A1602.5060703@kitware.com> <546B2A86.2070201@openit.com> <546B598D.4080104@kitware.com> <546B5C2C.1080602@openit.com> Message-ID: <546B6124.40007@kitware.com> On 11/18/2014 9:48 AM, ?dne Hovda wrote: > The idea is that ccmake includes form.h which has the same block, Thanks. I've adjusted the commit messages, rebased, and merged for testing in 'next': ccmake: Remove incomplete support for cur_colr on old HP-UX http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ee3d06a4 ccmake: Use standard getmaxyx instead of non-standard getmax[xy] http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=44f02b42 ccmake: Cleanup and simplify conditional blocks for HP-UX http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7a687292 Thanks, -Brad From alinm.elena at gmail.com Tue Nov 18 10:10:47 2014 From: alinm.elena at gmail.com (Alin Marin Elena) Date: Tue, 18 Nov 2014 15:10:47 +0000 Subject: [cmake-developers] FindOpenMP and gfortran Message-ID: Dear All, I tried today FindOpenMP from 3.1.0 rc2 and gfortran (4.8.3) both on a opensuse box... I had the surprise to get failure to find the openmp. After some digging I have found the route causes. 1. gfortran thinks .F files are fixed form a simple test CMakeLists.txt to show the issue project(hello Fortran) #set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Utils") find_package(OpenMP REQUIRED) error:: Performing Fortran SOURCE FILE Test OpenMP_FLAG_DETECTED failed with the following output: Change Dir: /home/alin/playground/ testopenmpcmake/build-error/CMakeFiles/CMakeTmp Run Build Command:"/usr/bin/gmake" "cmTryCompileExec2926444443/fast" /usr/bin/gmake -f CMakeFiles/cmTryCompileExec2926444443.dir/build.make CMakeFiles/cmTryCompileExec2926444443.dir/build gmake[1]: Entering directory '/home/alin/playground/testopenmpcmake/build-error/CMakeFiles/CMakeTmp' /usr/bin/cmake -E cmake_progress_report /home/alin/playground/testopenmpcmake/build-error/CMakeFiles/CMakeTmp/CMakeFiles 1 Building Fortran object CMakeFiles/cmTryCompileExec2926444443.dir/src.F.o /usr/bin/gfortran -DOpenMP_FLAG_DETECTED -fopenmp -c /home/alin/playground/testopenmpcmake/build-error/CMakeFiles/CMakeTmp/src.F -o CMakeFiles/cmTryCompil eExec2926444443.dir/src.F.o /home/alin/playground/testopenmpcmake/build-error/CMakeFiles/CMakeTmp/src.F:2.1: program test 1 Error: Non-numeric character in statement label at (1) /home/alin/playground/testopenmpcmake/build-error/CMakeFiles/CMakeTmp/src.F:2.1: more to follow. I have found two workarounds each of them have pros and cons in which I will not enter as I do not have a strong feeling for any of the solutions. 1. change .F to .F90 in CheckFortranSourceCompiles.cmake 2. the fortran test in FindOpenMP.cmake shall be provided in fixed form (add 6 empty spaces in front of the character of each line) the original bug/feature was introduced by this https://www.cmake.org/Bug/view.php?id=14656&history=1 regards, Alin Without Questions there are no Answers! ______________________________________________________________________ Dr. Alin Marin ELENA http://alin.elenaworld.net/ ______________________________________________________________________ From gjasny at googlemail.com Tue Nov 18 10:34:28 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 18 Nov 2014 16:34:28 +0100 Subject: [cmake-developers] [PATCH v5 0/4] Add continue keyword Message-ID: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> Hello, Changes compared to v4: * Use new style error reporting in cmContinueCommand.cxx * Reject any given arguments to continue() * CMP0055: Reject any arguments to break, too. I put both checks: the loop block check and the empty arguments check into the same policy. Please drop me a note if you want to have an extra policy per check. Thanks, Gregor Gregor Jasny (4): Add continue keyword (#14013) Reject continue() without loop block (#14013) Reject continue with arguments (#14013) Strict checks for break() command Help/command/continue.rst | 7 +++ Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0055.rst | 17 ++++++ Source/cmBootstrapCommands1.cxx | 2 + Source/cmBreakCommand.cxx | 68 +++++++++++++++++++++- Source/cmContinueCommand.cxx | 40 +++++++++++++ Source/cmContinueCommand.h | 55 +++++++++++++++++ Source/cmExecutionStatus.h | 7 +++ Source/cmForEachCommand.cxx | 12 ++++ Source/cmIfCommand.cxx | 5 ++ Source/cmMakefile.cxx | 48 +++++++++++++++ Source/cmMakefile.h | 21 +++++++ Source/cmPolicies.cxx | 5 ++ Source/cmPolicies.h | 1 + Source/cmWhileCommand.cxx | 8 +++ .../CMP0055/CMP0055-NEW-Out-of-Scope-result.txt | 1 + .../CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt | 4 ++ .../CMP0055/CMP0055-NEW-Out-of-Scope.cmake | 4 ++ .../CMP0055-NEW-Reject-Arguments-result.txt | 1 + .../CMP0055-NEW-Reject-Arguments-stderr.txt | 4 ++ .../CMP0055/CMP0055-NEW-Reject-Arguments.cmake | 6 ++ .../CMP0055/CMP0055-OLD-Out-of-Scope-result.txt | 1 + .../CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt | 1 + .../CMP0055/CMP0055-OLD-Out-of-Scope.cmake | 4 ++ .../CMP0055-OLD-Reject-Arguments-result.txt | 1 + .../CMP0055-OLD-Reject-Arguments-stderr.txt | 1 + .../CMP0055/CMP0055-OLD-Reject-Arguments.cmake | 6 ++ .../CMP0055/CMP0055-WARN-Out-of-Scope-result.txt | 1 + .../CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt | 9 +++ .../CMP0055/CMP0055-WARN-Out-of-Scope.cmake | 2 + .../CMP0055-WARN-Reject-Arguments-result.txt | 1 + .../CMP0055-WARN-Reject-Arguments-stderr.txt | 10 ++++ .../CMP0055/CMP0055-WARN-Reject-Arguments.cmake | 4 ++ Tests/RunCMake/CMP0055/CMakeLists.txt | 3 + Tests/RunCMake/CMP0055/RunCMakeTest.cmake | 9 +++ Tests/RunCMake/CMakeLists.txt | 3 + Tests/RunCMake/continue/CMakeLists.txt | 3 + .../RunCMake/continue/ContinueForEachInLists.cmake | 10 ++++ Tests/RunCMake/continue/ContinueForeach-stdout.txt | 4 ++ Tests/RunCMake/continue/ContinueForeach.cmake | 8 +++ .../continue/ContinueNestedForeach-stdout.txt | 6 ++ .../RunCMake/continue/ContinueNestedForeach.cmake | 13 +++++ Tests/RunCMake/continue/ContinueWhile-stdout.txt | 6 ++ Tests/RunCMake/continue/ContinueWhile.cmake | 10 ++++ .../continue/NoArgumentsToContinue-result.txt | 1 + .../continue/NoArgumentsToContinue-stderr.txt | 1 + .../RunCMake/continue/NoArgumentsToContinue.cmake | 3 + .../RunCMake/continue/NoEnclosingBlock-result.txt | 1 + .../RunCMake/continue/NoEnclosingBlock-stderr.txt | 2 + Tests/RunCMake/continue/NoEnclosingBlock.cmake | 1 + .../continue/NoEnclosingBlockInFunction-result.txt | 1 + .../continue/NoEnclosingBlockInFunction-stderr.txt | 2 + .../continue/NoEnclosingBlockInFunction.cmake | 8 +++ Tests/RunCMake/continue/RunCMakeTest.cmake | 9 +++ Tests/RunCMake/return/CMakeLists.txt | 3 + Tests/RunCMake/return/ReturnFromForeach-result.txt | 1 + Tests/RunCMake/return/ReturnFromForeach.cmake | 10 ++++ Tests/RunCMake/return/RunCMakeTest.cmake | 3 + 58 files changed, 478 insertions(+), 1 deletion(-) create mode 100644 Help/command/continue.rst create mode 100644 Help/policy/CMP0055.rst create mode 100644 Source/cmContinueCommand.cxx create mode 100644 Source/cmContinueCommand.h create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments.cmake create mode 100644 Tests/RunCMake/CMP0055/CMakeLists.txt create mode 100644 Tests/RunCMake/CMP0055/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/continue/CMakeLists.txt create mode 100644 Tests/RunCMake/continue/ContinueForEachInLists.cmake create mode 100644 Tests/RunCMake/continue/ContinueForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueWhile-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueWhile.cmake create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue-result.txt create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction.cmake create mode 100644 Tests/RunCMake/continue/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/return/CMakeLists.txt create mode 100644 Tests/RunCMake/return/ReturnFromForeach-result.txt create mode 100644 Tests/RunCMake/return/ReturnFromForeach.cmake create mode 100644 Tests/RunCMake/return/RunCMakeTest.cmake -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Tue Nov 18 10:34:29 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 18 Nov 2014 16:34:29 +0100 Subject: [cmake-developers] [PATCH v5 1/4] Add continue keyword (#14013) In-Reply-To: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> Message-ID: <1416324872-54012-2-git-send-email-gjasny@googlemail.com> Original draft by Doug Barbieri. Signed-off-by: Gregor Jasny --- Help/command/continue.rst | 7 +++ Source/cmBootstrapCommands1.cxx | 2 + Source/cmContinueCommand.cxx | 21 +++++++++ Source/cmContinueCommand.h | 55 ++++++++++++++++++++++ Source/cmExecutionStatus.h | 7 +++ Source/cmForEachCommand.cxx | 4 ++ Source/cmIfCommand.cxx | 5 ++ Source/cmWhileCommand.cxx | 4 ++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/continue/CMakeLists.txt | 3 ++ Tests/RunCMake/continue/ContinueForeach-stdout.txt | 4 ++ Tests/RunCMake/continue/ContinueForeach.cmake | 8 ++++ .../continue/ContinueNestedForeach-stdout.txt | 6 +++ .../RunCMake/continue/ContinueNestedForeach.cmake | 13 +++++ Tests/RunCMake/continue/ContinueWhile-stdout.txt | 6 +++ Tests/RunCMake/continue/ContinueWhile.cmake | 10 ++++ Tests/RunCMake/continue/RunCMakeTest.cmake | 5 ++ 17 files changed, 161 insertions(+) create mode 100644 Help/command/continue.rst create mode 100644 Source/cmContinueCommand.cxx create mode 100644 Source/cmContinueCommand.h create mode 100644 Tests/RunCMake/continue/CMakeLists.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueWhile-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueWhile.cmake create mode 100644 Tests/RunCMake/continue/RunCMakeTest.cmake diff --git a/Help/command/continue.rst b/Help/command/continue.rst new file mode 100644 index 0000000..d377542 --- /dev/null +++ b/Help/command/continue.rst @@ -0,0 +1,7 @@ +continue +-------- + +Continue to the top of enclosing foreach or while loop. + +Continue allows the cmake script to abort the rest of a block in a foreach +or while loop, and start at the top of the next iteration. See also break(). 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& 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..d516ad2 --- /dev/null +++ b/Source/cmContinueCommand.cxx @@ -0,0 +1,21 @@ +/*============================================================================ + 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 const&, + cmExecutionStatus &status) +{ + status.SetContinueInvoked(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 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/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index e3f66c1..465ddab 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -67,6 +67,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/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/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 851c4cb..98e129d 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -81,6 +81,10 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, { return true; } + if (status.GetContinueInvoked()) + { + break; + } if(cmSystemTools::GetFatalErrorOccured() ) { return true; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index a99b46f..0099d4b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -99,6 +99,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/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/RunCMakeTest.cmake b/Tests/RunCMake/continue/RunCMakeTest.cmake new file mode 100644 index 0000000..c057282 --- /dev/null +++ b/Tests/RunCMake/continue/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(ContinueForeach) +run_cmake(ContinueNestedForeach) +run_cmake(ContinueWhile) -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Tue Nov 18 10:34:30 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 18 Nov 2014 16:34:30 +0100 Subject: [cmake-developers] [PATCH v5 2/4] Reject continue() without loop block (#14013) In-Reply-To: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> Message-ID: <1416324872-54012-3-git-send-email-gjasny@googlemail.com> To track the nested loop levels a counter is used. It gets incremented while entering a loop block (e.g. foreach or while) and gets decremented when leaving the block. Because scope borders for example at function borders must be taken into account the counter is put into a stack. With every new scope an empty counter is pushed on the stack, when leaving the scope the original value is restored. This enables easy querying if the continue (and later also break) command is properly nested within a loop scope. Signed-off-by: Gregor Jasny --- Source/cmContinueCommand.cxx | 9 ++++ Source/cmForEachCommand.cxx | 8 ++++ Source/cmMakefile.cxx | 48 ++++++++++++++++++++++ Source/cmMakefile.h | 21 ++++++++++ Source/cmWhileCommand.cxx | 4 ++ Tests/RunCMake/CMakeLists.txt | 1 + .../RunCMake/continue/ContinueForEachInLists.cmake | 10 +++++ .../RunCMake/continue/NoEnclosingBlock-result.txt | 1 + .../RunCMake/continue/NoEnclosingBlock-stderr.txt | 2 + Tests/RunCMake/continue/NoEnclosingBlock.cmake | 1 + .../continue/NoEnclosingBlockInFunction-result.txt | 1 + .../continue/NoEnclosingBlockInFunction-stderr.txt | 2 + .../continue/NoEnclosingBlockInFunction.cmake | 8 ++++ Tests/RunCMake/continue/RunCMakeTest.cmake | 3 ++ Tests/RunCMake/return/CMakeLists.txt | 3 ++ Tests/RunCMake/return/ReturnFromForeach-result.txt | 1 + Tests/RunCMake/return/ReturnFromForeach.cmake | 10 +++++ Tests/RunCMake/return/RunCMakeTest.cmake | 3 ++ 18 files changed, 136 insertions(+) create mode 100644 Tests/RunCMake/continue/ContinueForEachInLists.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction.cmake create mode 100644 Tests/RunCMake/return/CMakeLists.txt create mode 100644 Tests/RunCMake/return/ReturnFromForeach-result.txt create mode 100644 Tests/RunCMake/return/ReturnFromForeach.cmake create mode 100644 Tests/RunCMake/return/RunCMakeTest.cmake diff --git a/Source/cmContinueCommand.cxx b/Source/cmContinueCommand.cxx index d516ad2..8b249c2 100644 --- a/Source/cmContinueCommand.cxx +++ b/Source/cmContinueCommand.cxx @@ -15,6 +15,15 @@ bool cmContinueCommand::InitialPass(std::vector const&, 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); return true; } diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 465ddab..03d6590 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -27,6 +27,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, // if this is the endofreach for this statement if (!this->Depth) { + cmMakefile::LoopBlockPop loopBlockPop(&mf); + // Remove the function blocker for this scope or bail. cmsys::auto_ptr fb(mf.RemoveFunctionBlocker(this, lff)); @@ -77,6 +79,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, } } } + // restore the variable to its prior value mf.AddDefinition(this->Args[0],oldDef.c_str()); return true; @@ -203,6 +206,8 @@ bool cmForEachCommand } this->Makefile->AddFunctionBlocker(f); + this->Makefile->PushLoopBlock(); + return true; } @@ -246,5 +251,8 @@ bool cmForEachCommand::HandleInMode(std::vector const& args) } this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr + + this->Makefile->PushLoopBlock(); + return true; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8a8aadc..2795e83 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -171,6 +171,9 @@ void cmMakefile::Initialize() // Protect the directory-level policies. this->PushPolicyBarrier(); + // push empty loop block + this->PushLoopBlockBarrier(); + // By default the check is not done. It is enabled by // cmListFileCache in the top level if necessary. this->CheckCMP0000 = false; @@ -3293,6 +3296,47 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError) } //---------------------------------------------------------------------------- +void cmMakefile::PushLoopBlock() +{ + if(this->LoopBlockCounter.empty()) + { + assert(false); + return; + } + + this->LoopBlockCounter.top()++; +} + +void cmMakefile::PopLoopBlock() +{ + if(this->LoopBlockCounter.empty() || this->LoopBlockCounter.top() <= 0) + { + assert(false); + return; + } + + this->LoopBlockCounter.top()--; +} + +void cmMakefile::PushLoopBlockBarrier() +{ + this->LoopBlockCounter.push(0); +} + +void cmMakefile::PopLoopBlockBarrier() +{ + assert(!this->LoopBlockCounter.empty()); + assert(this->LoopBlockCounter.top() == 0); + this->LoopBlockCounter.pop(); +} + +bool cmMakefile::IsLoopBlock() const +{ + assert(!this->LoopBlockCounter.empty()); + return !this->LoopBlockCounter.empty() && this->LoopBlockCounter.top() > 0; +} + +//---------------------------------------------------------------------------- bool cmMakefile::ExpandArguments( std::vector const& inArgs, std::vector& outArgs) const @@ -4426,10 +4470,14 @@ void cmMakefile::PushScope() this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); + + PushLoopBlockBarrier(); } void cmMakefile::PopScope() { + PopLoopBlockBarrier(); + cmDefinitions* current = &this->Internal->VarStack.top(); std::set init = this->Internal->VarInitStack.top(); std::set usage = this->Internal->VarUsageStack.top(); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 824513b..809c77d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -34,6 +34,8 @@ # include #endif +#include + class cmFunctionBlocker; class cmCommand; class cmInstallGenerator; @@ -123,6 +125,15 @@ public: }; friend class LexicalPushPop; + class LoopBlockPop + { + public: + LoopBlockPop(cmMakefile* mf) { this->Makefile = mf; } + ~LoopBlockPop() { this->Makefile->PopLoopBlock(); } + private: + cmMakefile* Makefile; + }; + /** * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. @@ -885,6 +896,10 @@ public: void PopScope(); void RaiseScope(const std::string& var, const char *value); + // push and pop loop scopes + void PushLoopBlockBarrier(); + void PopLoopBlockBarrier(); + /** Helper class to push and pop scopes automatically. */ class ScopePushPop { @@ -945,6 +960,10 @@ public: void ClearMatches(); void StoreMatches(cmsys::RegularExpression& re); + void PushLoopBlock(); + void PopLoopBlock(); + bool IsLoopBlock() const; + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const std::string& name, cmTarget& target); @@ -1039,6 +1058,8 @@ private: void PushFunctionBlockerBarrier(); void PopFunctionBlockerBarrier(bool reportError = true); + std::stack LoopBlockCounter; + typedef std::map StringStringMap; StringStringMap MacrosMap; diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 98e129d..47edb03 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -27,6 +27,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, // if this is the endwhile for this while loop then execute if (!this->Depth) { + cmMakefile::LoopBlockPop loopBlockPop(&mf); + // Remove the function blocker for this scope or bail. cmsys::auto_ptr fb(mf.RemoveFunctionBlocker(this, lff)); @@ -142,6 +144,8 @@ bool cmWhileCommand f->Args = args; this->Makefile->AddFunctionBlocker(f); + this->Makefile->PushLoopBlock(); + return true; } diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 0099d4b..24d0c93 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -109,6 +109,7 @@ add_RunCMake_test(include_directories) add_RunCMake_test(list) add_RunCMake_test(message) add_RunCMake_test(project) +add_RunCMake_test(return) add_RunCMake_test(string) add_RunCMake_test(try_compile) add_RunCMake_test(set) 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/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..982fda3 --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt @@ -0,0 +1,2 @@ + A CONTINUE command was found outside of a proper FOREACH or WHILE loop + scope. 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..982fda3 --- /dev/null +++ b/Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt @@ -0,0 +1,2 @@ + A CONTINUE command was found outside of a proper FOREACH or WHILE loop + scope. 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 index c057282..f85154f 100644 --- a/Tests/RunCMake/continue/RunCMakeTest.cmake +++ b/Tests/RunCMake/continue/RunCMakeTest.cmake @@ -1,5 +1,8 @@ include(RunCMake) run_cmake(ContinueForeach) +run_cmake(ContinueForEachInLists) run_cmake(ContinueNestedForeach) run_cmake(ContinueWhile) +run_cmake(NoEnclosingBlock) +run_cmake(NoEnclosingBlockInFunction) diff --git a/Tests/RunCMake/return/CMakeLists.txt b/Tests/RunCMake/return/CMakeLists.txt new file mode 100644 index 0000000..2d75985 --- /dev/null +++ b/Tests/RunCMake/return/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/return/ReturnFromForeach-result.txt b/Tests/RunCMake/return/ReturnFromForeach-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/return/ReturnFromForeach-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/return/ReturnFromForeach.cmake b/Tests/RunCMake/return/ReturnFromForeach.cmake new file mode 100644 index 0000000..c71cf33 --- /dev/null +++ b/Tests/RunCMake/return/ReturnFromForeach.cmake @@ -0,0 +1,10 @@ +function(foo) + foreach(i RANGE 1 3) + foreach(j RANGE 1 3) + return() + message(FATAL_ERROR "unexpected") + endforeach() + endforeach() +endfunction(foo) + +foo() diff --git a/Tests/RunCMake/return/RunCMakeTest.cmake b/Tests/RunCMake/return/RunCMakeTest.cmake new file mode 100644 index 0000000..2cc6c9d --- /dev/null +++ b/Tests/RunCMake/return/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(ReturnFromForeach) -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Tue Nov 18 10:34:31 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 18 Nov 2014 16:34:31 +0100 Subject: [cmake-developers] [PATCH v5 3/4] Reject continue with arguments (#14013) In-Reply-To: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> Message-ID: <1416324872-54012-4-git-send-email-gjasny@googlemail.com> Signed-off-by: Gregor Jasny --- Source/cmContinueCommand.cxx | 12 +++++++++++- Tests/RunCMake/continue/NoArgumentsToContinue-result.txt | 1 + Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt | 1 + Tests/RunCMake/continue/NoArgumentsToContinue.cmake | 3 +++ Tests/RunCMake/continue/RunCMakeTest.cmake | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue-result.txt create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue.cmake diff --git a/Source/cmContinueCommand.cxx b/Source/cmContinueCommand.cxx index 8b249c2..ce70dd6 100644 --- a/Source/cmContinueCommand.cxx +++ b/Source/cmContinueCommand.cxx @@ -12,7 +12,7 @@ #include "cmContinueCommand.h" // cmContinueCommand -bool cmContinueCommand::InitialPass(std::vector const&, +bool cmContinueCommand::InitialPass(std::vector const &args, cmExecutionStatus &status) { if(!this->Makefile->IsLoopBlock()) @@ -25,6 +25,16 @@ bool cmContinueCommand::InitialPass(std::vector const&, } 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/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..d968a62 --- /dev/null +++ b/Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt @@ -0,0 +1 @@ + The CONTINUE command does not accept any arguments. 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/RunCMakeTest.cmake b/Tests/RunCMake/continue/RunCMakeTest.cmake index f85154f..37caf9c 100644 --- a/Tests/RunCMake/continue/RunCMakeTest.cmake +++ b/Tests/RunCMake/continue/RunCMakeTest.cmake @@ -4,5 +4,6 @@ run_cmake(ContinueForeach) run_cmake(ContinueForEachInLists) run_cmake(ContinueNestedForeach) run_cmake(ContinueWhile) +run_cmake(NoArgumentsToContinue) run_cmake(NoEnclosingBlock) run_cmake(NoEnclosingBlockInFunction) -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Tue Nov 18 10:34:32 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 18 Nov 2014 16:34:32 +0100 Subject: [cmake-developers] [PATCH v5 4/4] Strict checks for break() command In-Reply-To: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> Message-ID: <1416324872-54012-5-git-send-email-gjasny@googlemail.com> Reject break() without loop scope or any arguments Signed-off-by: Gregor Jasny --- Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0055.rst | 17 ++++++ Source/cmBreakCommand.cxx | 68 +++++++++++++++++++++- Source/cmPolicies.cxx | 5 ++ Source/cmPolicies.h | 1 + .../CMP0055/CMP0055-NEW-Out-of-Scope-result.txt | 1 + .../CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt | 4 ++ .../CMP0055/CMP0055-NEW-Out-of-Scope.cmake | 4 ++ .../CMP0055-NEW-Reject-Arguments-result.txt | 1 + .../CMP0055-NEW-Reject-Arguments-stderr.txt | 4 ++ .../CMP0055/CMP0055-NEW-Reject-Arguments.cmake | 6 ++ .../CMP0055/CMP0055-OLD-Out-of-Scope-result.txt | 1 + .../CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt | 1 + .../CMP0055/CMP0055-OLD-Out-of-Scope.cmake | 4 ++ .../CMP0055-OLD-Reject-Arguments-result.txt | 1 + .../CMP0055-OLD-Reject-Arguments-stderr.txt | 1 + .../CMP0055/CMP0055-OLD-Reject-Arguments.cmake | 6 ++ .../CMP0055/CMP0055-WARN-Out-of-Scope-result.txt | 1 + .../CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt | 9 +++ .../CMP0055/CMP0055-WARN-Out-of-Scope.cmake | 2 + .../CMP0055-WARN-Reject-Arguments-result.txt | 1 + .../CMP0055-WARN-Reject-Arguments-stderr.txt | 10 ++++ .../CMP0055/CMP0055-WARN-Reject-Arguments.cmake | 4 ++ Tests/RunCMake/CMP0055/CMakeLists.txt | 3 + Tests/RunCMake/CMP0055/RunCMakeTest.cmake | 9 +++ Tests/RunCMake/CMakeLists.txt | 1 + 26 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 Help/policy/CMP0055.rst create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope.cmake create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-result.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-stderr.txt create mode 100644 Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments.cmake create mode 100644 Tests/RunCMake/CMP0055/CMakeLists.txt create mode 100644 Tests/RunCMake/CMP0055/RunCMakeTest.cmake diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 7074bd5..742fd63 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -112,3 +112,4 @@ All Policies /policy/CMP0052 /policy/CMP0053 /policy/CMP0054 + /policy/CMP0055 diff --git a/Help/policy/CMP0055.rst b/Help/policy/CMP0055.rst new file mode 100644 index 0000000..5be09ab --- /dev/null +++ b/Help/policy/CMP0055.rst @@ -0,0 +1,17 @@ +CMP0055 +------- + +Strict checking for break() command. + +CMake 3.1.0 and lower allowed to put a :command:`break` command outside of +a loop context and also ignored any given arguments. This was undefined behavior. + +The OLD behavior for this policy is to allow +:command:`break` to be placed outside of loop contexts and ignores any arguments. +The NEW behavior for this policy is to issue an error if a misplaced break or any +arguments are found. + +This policy was introduced in CMake version 3.2. +CMake version |release| warns when the policy is not set and uses +OLD behavior. Use the cmake_policy command to set it to OLD or +NEW explicitly. diff --git a/Source/cmBreakCommand.cxx b/Source/cmBreakCommand.cxx index b70e400..ff527db 100644 --- a/Source/cmBreakCommand.cxx +++ b/Source/cmBreakCommand.cxx @@ -12,10 +12,76 @@ #include "cmBreakCommand.h" // cmBreakCommand -bool cmBreakCommand::InitialPass(std::vector const&, +bool cmBreakCommand::InitialPass(std::vector const &args, cmExecutionStatus &status) { + if(!this->Makefile->IsLoopBlock()) + { + bool issueMessage = true; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) + { + case cmPolicies::WARN: + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0055)) << "\n"; + break; + case cmPolicies::OLD: + issueMessage = false; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + messageType = cmake::FATAL_ERROR; + break; + } + + if(issueMessage) + { + e << "A BREAK command was found outside of a proper " + "FOREACH or WHILE loop scope."; + this->Makefile->IssueMessage(messageType, e.str()); + if(messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + status.SetBreakInvoked(true); + + if(!args.empty()) + { + bool issueMessage = true; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) + { + case cmPolicies::WARN: + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0055)) << "\n"; + break; + case cmPolicies::OLD: + issueMessage = false; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + messageType = cmake::FATAL_ERROR; + break; + } + + if(issueMessage) + { + e << "The BREAK command does not accept any arguments."; + this->Makefile->IssueMessage(messageType, e.str()); + if(messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + return true; } diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index a420f59..64b87b7 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -364,6 +364,11 @@ cmPolicies::cmPolicies() CMP0054, "CMP0054", "Only interpret if() arguments as variables or keywords when unquoted.", 3,1,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0055, "CMP0055", + "Strict checking for break() command.", + 3,2,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 7c73da8..46ecc22 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -111,6 +111,7 @@ public: CMP0053, ///< Simplify variable reference and escape sequence evaluation CMP0054, ///< Only interpret if() arguments as variables /// or keywords when unquoted. + CMP0055, ///< Strict checking for break() command. /** \brief Always the last entry. * diff --git a/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-result.txt b/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt new file mode 100644 index 0000000..27e8140 --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0055-NEW-Out-of-Scope.cmake:4 \(break\): + A BREAK 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/CMP0055/CMP0055-NEW-Out-of-Scope.cmake b/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope.cmake new file mode 100644 index 0000000..53ac214 --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-Out-of-Scope.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0055 NEW) + +break() diff --git a/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-result.txt b/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-stderr.txt new file mode 100644 index 0000000..32947af --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0055-NEW-Reject-Arguments.cmake:5 \(break\): + The BREAK command does not accept any arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments.cmake b/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments.cmake new file mode 100644 index 0000000..52eaa6a --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-NEW-Reject-Arguments.cmake @@ -0,0 +1,6 @@ + +cmake_policy(SET CMP0055 NEW) + +foreach(i RANGE 1 2) + break(1) +endforeach() \ No newline at end of file diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-result.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope.cmake b/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope.cmake new file mode 100644 index 0000000..57195c2 --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0055 OLD) + +break() diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-result.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments.cmake b/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments.cmake new file mode 100644 index 0000000..d8fdddf --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments.cmake @@ -0,0 +1,6 @@ + +cmake_policy(SET CMP0055 OLD) + +foreach(i RANGE 1 2) + break(1) +endforeach() \ No newline at end of file diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-result.txt b/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt new file mode 100644 index 0000000..ad850ac --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMP0055-WARN-Out-of-Scope.cmake:2 \(break\): + Policy CMP0055 is not set: Strict checking for break\(\) command. Run "cmake + --help-policy CMP0055" for policy details. Use the cmake_policy command to + set the policy and suppress this warning. + + A BREAK command was found outside of a proper FOREACH or WHILE loop scope. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope.cmake b/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope.cmake new file mode 100644 index 0000000..373a95a --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-WARN-Out-of-Scope.cmake @@ -0,0 +1,2 @@ + +break() diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-result.txt b/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-stderr.txt new file mode 100644 index 0000000..16551ec --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning \(dev\) at CMP0055-WARN-Reject-Arguments.cmake:3 \(break\): + Policy CMP0055 is not set: Strict checking for break\(\) command. Run "cmake + --help-policy CMP0055" for policy details. Use the cmake_policy command to + set the policy and suppress this warning. + + The BREAK command does not accept any arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + diff --git a/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments.cmake b/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments.cmake new file mode 100644 index 0000000..ec6b90f --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMP0055-WARN-Reject-Arguments.cmake @@ -0,0 +1,4 @@ + +foreach(i RANGE 1 2) + break(1) +endforeach() diff --git a/Tests/RunCMake/CMP0055/CMakeLists.txt b/Tests/RunCMake/CMP0055/CMakeLists.txt new file mode 100644 index 0000000..2d75985 --- /dev/null +++ b/Tests/RunCMake/CMP0055/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0055/RunCMakeTest.cmake b/Tests/RunCMake/CMP0055/RunCMakeTest.cmake new file mode 100644 index 0000000..efcfcab --- /dev/null +++ b/Tests/RunCMake/CMP0055/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCMake) + +run_cmake(CMP0055-OLD-Out-of-Scope) +run_cmake(CMP0055-NEW-Out-of-Scope) +run_cmake(CMP0055-WARN-Out-of-Scope) + +run_cmake(CMP0055-OLD-Reject-Arguments) +run_cmake(CMP0055-NEW-Reject-Arguments) +run_cmake(CMP0055-WARN-Reject-Arguments) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 24d0c93..ec7ddf7 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -49,6 +49,7 @@ add_RunCMake_test(CMP0050) add_RunCMake_test(CMP0051) add_RunCMake_test(CMP0053) add_RunCMake_test(CMP0054) +add_RunCMake_test(CMP0055) add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(CompilerChange) -- 1.9.3 (Apple Git-50) From Geoffrey.Viola at asirobots.com Tue Nov 18 10:44:36 2014 From: Geoffrey.Viola at asirobots.com (Geoffrey Viola) Date: Tue, 18 Nov 2014 15:44:36 +0000 Subject: [cmake-developers] Initial Attempt at Green Hill MULTI IDE Generator Support In-Reply-To: <546B593C.3060706@kitware.com> References: <0543633b28c7431f93808182fc1e26e1@CO1PR07MB208.namprd07.prod.outlook.com> <543D2BBC.1010306@kitware.com> <0b5b33c4d1f0472782e260f9e5bce980@CO1PR07MB208.namprd07.prod.outlook.com> <544E4C9F.3050408@kitware.com> <64abd7ba273245b686146aa67acb7e8a@DM2PR0701MB1020.namprd07.prod.outlook.com> <545A7C44.6040305@kitware.com> <546B593C.3060706@kitware.com> Message-ID: <383b3e2601784ae08e111c5aca5f2397@DM2PR0701MB1020.namprd07.prod.outlook.com> >> The cmake system version can be changed with the GHS_COMP_ROOT cache >> variable. > >Okay, so the version is determined by the tools used, and there is exactly one version at a given GHS_COMP_ROOT? Yeah, the CMAKE_SYSTEM_VERSION variable is dependent on the compiler directory name. From what I've seen, it is a year concatenated with a two digit number. All the compiler executables are in this versioned folder. Geoffrey Viola SOFTWARE ENGINEER T +1.435.755.2980 ext 1077 M +1.215.896.6521 asirobots.com -----Original Message----- From: Brad King [mailto:brad.king at kitware.com] Sent: Tuesday, November 18, 2014 7:36 AM To: Geoffrey Viola Cc: cmake-developers at cmake.org Subject: Re: [cmake-developers] Initial Attempt at Green Hill MULTI IDE Generator Support On 11/17/2014 5:16 PM, Geoffrey Viola wrote: > Thanks for the feedback. I made some changes and rebased on the trunk. Great. I'll try it out again when I get a chance. > The cmake system version can be changed with the GHS_COMP_ROOT cache > variable. Okay, so the version is determined by the tools used, and there is exactly one version at a given GHS_COMP_ROOT? Thanks, -Brad This message contains confidential information and is intended only for the recipient. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately if you have received this e-mail by mistake and delete this e-mail from your system. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. From brad.king at kitware.com Tue Nov 18 10:48:46 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 18 Nov 2014 10:48:46 -0500 Subject: [cmake-developers] [PATCH v5 0/4] Add continue keyword In-Reply-To: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> Message-ID: <546B6A5E.3000601@kitware.com> On 11/18/2014 10:34 AM, Gregor Jasny wrote: > Changes compared to v4: > * Use new style error reporting in cmContinueCommand.cxx > * Reject any given arguments to continue() > * CMP0055: Reject any arguments to break, too. Thanks. I'll try this series out when I get a chance. > I put both checks: the loop block check and the empty arguments > check into the same policy. Please drop me a note if you want to > have an extra policy per check. Fine with me! -Brad From ben.boeckel at kitware.com Tue Nov 18 11:19:47 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Tue, 18 Nov 2014 11:19:47 -0500 Subject: [cmake-developers] [PATCH v5 0/4] Add continue keyword In-Reply-To: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> Message-ID: <20141118161947.GB8165@megas.kitwarein.com> On Tue, Nov 18, 2014 at 16:34:28 +0100, Gregor Jasny wrote: > Changes compared to v4: > * Use new style error reporting in cmContinueCommand.cxx > * Reject any given arguments to continue() > * CMP0055: Reject any arguments to break, too. Untested, but from a (very) quick skim, I don't see anything wrong. I thought of a test for break() while looking at it. I wonder if we should fix anything about it and if so, make continue behave in an analogous way before it might also need a policy[1]: -------- loop.cmake --------- function (my_breakf) break() endfunction () macro (my_breakm) break() endmacro () foreach (a IN ITEMS 1 2 3) my_breakf() message("-->${a}<--") endforeach () foreach (a IN ITEMS 4 5 6) my_breakm() message("-->${a}<--") endforeach () -------- loop.cmake --------- Which prints: -->1<-- -->2<-- -->3<-- without any error messages (e.g., about using break() outside a loop?which doesn't seem to happen anyways, so maybe this is moot). I don't see any existing tests about break inside of a function or macro having an effect on the caller's logic. Thoughts? --Ben [1]Though it might be better to fix, if necessary, both with one policy so that they're always the same and there is no case where continue has NEW behavior and break OLD behavior. From gjasny at googlemail.com Tue Nov 18 12:06:30 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Tue, 18 Nov 2014 18:06:30 +0100 Subject: [cmake-developers] [PATCH v5 0/4] Add continue keyword In-Reply-To: <20141118161947.GB8165@megas.kitwarein.com> References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> <20141118161947.GB8165@megas.kitwarein.com> Message-ID: <546B7C96.4010606@googlemail.com> On 18/11/14 17:19, Ben Boeckel wrote: > On Tue, Nov 18, 2014 at 16:34:28 +0100, Gregor Jasny wrote: >> Changes compared to v4: >> * Use new style error reporting in cmContinueCommand.cxx >> * Reject any given arguments to continue() >> * CMP0055: Reject any arguments to break, too. > I wonder if we should > fix anything about it and if so, make continue behave in an analogous > way You want to make continue() bug compatible to break()? > before it might also need a policy[1]: > > -------- loop.cmake --------- > function (my_breakf) > break() > endfunction () > > macro (my_breakm) > break() > endmacro () > > foreach (a IN ITEMS 1 2 3) > my_breakf() > message("-->${a}<--") > endforeach () > > foreach (a IN ITEMS 4 5 6) > my_breakm() > message("-->${a}<--") > endforeach () > -------- loop.cmake --------- > > Which prints: > > -->1<-- > -->2<-- > -->3<-- So the break in the macro worked, the break in the function got ignored. This is expected behavior. The macro currently does not form an own scope. Also variables set inside escape into the calling scope. The function forms an own scope (due to the Push/PopScope call). I think it is sane behavior that a macro does not form a scope / loop context behavior. Or do you read macro like "macro function"? > without any error messages (e.g., about using break() outside a This is because CMP0055 defaults to OLD here. If you add "cmake_policy(SET CMP0055 NEW)" here you'll get a nice error. > loop?which doesn't seem to happen anyways, so maybe this is moot). I > don't see any existing tests about break inside of a function or macro > having an effect on the caller's logic. What do you mean with 'effect' here? From ben.boeckel at kitware.com Tue Nov 18 12:31:15 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Tue, 18 Nov 2014 12:31:15 -0500 Subject: [cmake-developers] [PATCH v5 0/4] Add continue keyword In-Reply-To: <546B7C96.4010606@googlemail.com> References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> <20141118161947.GB8165@megas.kitwarein.com> <546B7C96.4010606@googlemail.com> Message-ID: <20141118173115.GA21019@megas.kitwarein.com> On Tue, Nov 18, 2014 at 18:06:30 +0100, Gregor Jasny wrote: > On 18/11/14 17:19, Ben Boeckel wrote: > > I wonder if we should > > fix anything about it and if so, make continue behave in an analogous > > way > > You want to make continue() bug compatible to break()? There are two parts here: 1) is there something wrong with the break() example (looking closer at CMP0055 shows that, yes, there is)? 2) if so, do we make continue() act like it before or while fixing break()? My concern is that with CMP0055 as-is, there is a case where continue() works as break() *should* but break() is set to an OLD policy and now they can have completely different semantics. If we decide that the example *does* show a problem, I'd like *one* policy for continue() and break() at the same time. Maybe it's not an issue because continue() is a completely new command and already basically moves you up to requiring 3.2 anyways in which case the mix-and-match behavior is only a problem with an explicit-OLD policy setting. > So the break in the macro worked, the break in the function got ignored. > This is expected behavior. The macro currently does not form an own > scope. Also variables set inside escape into the calling scope. > > The function forms an own scope (due to the Push/PopScope call). > > I think it is sane behavior that a macro does not form a scope / loop > context behavior. Or do you read macro like "macro function"? I guess I should have been more clear: the behavior exhibited is what I expected given my experience with macros and functions. It's more of a "do we fix it?". > > without any error messages (e.g., about using break() outside a > > This is because CMP0055 defaults to OLD here. If you add > "cmake_policy(SET CMP0055 NEW)" here you'll get a nice error. I think that this and the argument rule should be separate policies (removing arguments is easy; refactoring out a now-unallowed behavior might be harder depending on how deep down a macro calls break()). > > loop?which doesn't seem to happen anyways, so maybe this is moot). I > > don't see any existing tests about break inside of a function or macro > > having an effect on the caller's logic. > > What do you mean with 'effect' here? Calling a macro mutates your control flow (e.g., calling return()) in ways functions can't (and there's no distinction between macros and functions at the callsite). --Ben From mantis at public.kitware.com Tue Nov 18 13:16:20 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 18 Nov 2014 13:16:20 -0500 Subject: [cmake-developers] [CMake 0015255]: CPack Error: Error executing: /usr/bin/Rez during build Message-ID: <365e0eefcf3280727cdbeb374b933e94@public.kitware.com> The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15255 ====================================================================== Reported By: Alan Reed Assigned To: ====================================================================== Project: CMake Issue ID: 15255 Category: CPack Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-18 13:16 EST Last Modified: 2014-11-18 13:16 EST ====================================================================== Summary: CPack Error: Error executing: /usr/bin/Rez during build Description: The following error report appears when I run cpack on my 64bit minimac . The issue also occurs on cpack 3.0.2 and as below on 3.1.0-rc2 CPack Error: Error executing: /usr/bin/Rez "/Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/sla.r" -a -o "/Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/temp-udco.dmg" CPack Error: Error adding SLA. /Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/sla.r:15: ### /usr/bin/Rez - String spans lines. /Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/sla.r:16: ### /usr/bin/Rez - String spans lines. /Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/sla.r: ### /usr/bin/Rez - Since errors occurred, /Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/temp-udco.dmg's resource fork was not completely updated. /Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/sla.r: ### /usr/bin/Rez - SysError -43 during set file info. CPack Error: Problem compressing the directory CPack Error: Error when generating package: com3cd make: *** [package] Error 1 swd14:trunk alanreed$ Steps to Reproduce: swd14:trunk alanreed$ cat macosbuild.sh #!/bin/bash rm -rf build-mac /Applications/CMake.app/Contents/bin/cmake --version /Applications/CMake.app/Contents/bin/cpack --version /Applications/CMake.app/Contents/bin/cmake -G "Unix Makefiles" -H. -Bbuild-mac cd build-mac make make package cp -R _CPack_Packages/Darwin/Bundle/com3cd-3.0.0-Darwin/com3mx.app .. swd14:trunk alanreed$ Additional Information: swd14:trunk alanreed$ cat macosbuild.sh #!/bin/bash rm -rf build-mac /Applications/CMake.app/Contents/bin/cmake --version /Applications/CMake.app/Contents/bin/cpack --version /Applications/CMake.app/Contents/bin/cmake -G "Unix Makefiles" -H. -Bbuild-mac cd build-mac make make package cp -R _CPack_Packages/Darwin/Bundle/com3cd-3.0.0-Darwin/com3mx.app .. swd14:trunk alanreed$ swd14:trunk alanreed$ swd14:trunk alanreed$ swd14:trunk alanreed$ sh macosbuild.sh cmake version 3.1.0-rc2 CMake suite maintained and supported by Kitware (kitware.com/cmake). cpack version 3.1.0-rc2 CMake suite maintained and supported by Kitware (kitware.com/cmake). -- The C compiler identification is AppleClang 4.2.0.4250028 -- The CXX compiler identification is AppleClang 4.2.0.4250028 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Found wxWidgets: TRUE -- Framework QTKit found at /System/Library/Frameworks/QTKit.framework -- Configuring done -- Generating done -- Build files have been written to: /Users/alanreed/Desktop/trunk/build-mac Scanning dependencies of target com3mx [100%] Building CXX object CMakeFiles/com3mx.dir/com4b.cpp.o Linking CXX executable com3mx [100%] Built target com3mx [100%] Built target com3mx Run CPack packaging tool... CPack: Create package using Bundle CPack: Install projects CPack: - Run preinstall target for: com3cd CPack: - Install project: com3cd CPack: Create package CPack Error: Error executing: /usr/bin/Rez "/Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/sla.r" -a -o "/Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/temp-udco.dmg" CPack Error: Error adding SLA. /Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/sla.r:15: ### /usr/bin/Rez - String spans lines. /Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/sla.r:16: ### /usr/bin/Rez - String spans lines. /Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/sla.r: ### /usr/bin/Rez - Since errors occurred, /Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/temp-udco.dmg's resource fork was not completely updated. /Users/alanreed/Desktop/trunk/build-mac/_CPack_Packages/Darwin/Bundle/sla.r: ### /usr/bin/Rez - SysError -43 during set file info. CPack Error: Problem compressing the directory CPack Error: Error when generating package: com3cd make: *** [package] Error 1 swd14:trunk alanreed$ ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-18 13:16 Alan Reed New Issue ====================================================================== From DLRdave at aol.com Tue Nov 18 13:30:57 2014 From: DLRdave at aol.com (David Cole) Date: Tue, 18 Nov 2014 13:30:57 -0500 Subject: [cmake-developers] [PATCH v5 0/4] Add continue keyword In-Reply-To: <20141118173115.GA21019@megas.kitwarein.com> References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> <20141118161947.GB8165@megas.kitwarein.com> <546B7C96.4010606@googlemail.com> <20141118173115.GA21019@megas.kitwarein.com> Message-ID: Putting continue, break or return inside of a macro definition is a practice that should itself be discouraged... (I know, people will probably still have cases of it, but it doesn't seem like that's what any sane person would label a good practice, let alone a best practice...) On Tue, Nov 18, 2014 at 12:31 PM, Ben Boeckel wrote: > On Tue, Nov 18, 2014 at 18:06:30 +0100, Gregor Jasny wrote: >> On 18/11/14 17:19, Ben Boeckel wrote: >> > I wonder if we should >> > fix anything about it and if so, make continue behave in an analogous >> > way >> >> You want to make continue() bug compatible to break()? > > There are two parts here: > > 1) is there something wrong with the break() example (looking closer > at CMP0055 shows that, yes, there is)? > 2) if so, do we make continue() act like it before or while fixing > break()? > > My concern is that with CMP0055 as-is, there is a case where continue() > works as break() *should* but break() is set to an OLD policy and now > they can have completely different semantics. If we decide that the > example *does* show a problem, I'd like *one* policy for continue() and > break() at the same time. Maybe it's not an issue because continue() is > a completely new command and already basically moves you up to requiring > 3.2 anyways in which case the mix-and-match behavior is only a problem > with an explicit-OLD policy setting. > >> So the break in the macro worked, the break in the function got ignored. >> This is expected behavior. The macro currently does not form an own >> scope. Also variables set inside escape into the calling scope. >> >> The function forms an own scope (due to the Push/PopScope call). >> >> I think it is sane behavior that a macro does not form a scope / loop >> context behavior. Or do you read macro like "macro function"? > > I guess I should have been more clear: the behavior exhibited is what I > expected given my experience with macros and functions. It's more of a > "do we fix it?". > >> > without any error messages (e.g., about using break() outside a >> >> This is because CMP0055 defaults to OLD here. If you add >> "cmake_policy(SET CMP0055 NEW)" here you'll get a nice error. > > I think that this and the argument rule should be separate policies > (removing arguments is easy; refactoring out a now-unallowed behavior > might be harder depending on how deep down a macro calls break()). > >> > loop?which doesn't seem to happen anyways, so maybe this is moot). I >> > don't see any existing tests about break inside of a function or macro >> > having an effect on the caller's logic. >> >> What do you mean with 'effect' here? > > Calling a macro mutates your control flow (e.g., calling return()) in > ways functions can't (and there's no distinction between macros and > functions at the callsite). > > --Ben > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake-developers From eike at sf-mail.de Tue Nov 18 13:51:18 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Tue, 18 Nov 2014 19:51:18 +0100 Subject: [cmake-developers] [PATCH v5 0/4] Add continue keyword In-Reply-To: <20141118173115.GA21019@megas.kitwarein.com> References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> <546B7C96.4010606@googlemail.com> <20141118173115.GA21019@megas.kitwarein.com> Message-ID: <3235737.ZtTQVuA9uv@caliban.sf-tec.de> Am Dienstag, 18. November 2014, 12:31:15 schrieb Ben Boeckel: > On Tue, Nov 18, 2014 at 18:06:30 +0100, Gregor Jasny wrote: > > On 18/11/14 17:19, Ben Boeckel wrote: > > > I wonder if we should > > > fix anything about it and if so, make continue behave in an analogous > > > way > > > > You want to make continue() bug compatible to break()? > > There are two parts here: > > 1) is there something wrong with the break() example (looking closer > at CMP0055 shows that, yes, there is)? > 2) if so, do we make continue() act like it before or while fixing > break()? > > My concern is that with CMP0055 as-is, there is a case where continue() > works as break() *should* but break() is set to an OLD policy and now > they can have completely different semantics. If we decide that the > example *does* show a problem, I'd like *one* policy for continue() and > break() at the same time. Maybe it's not an issue because continue() is > a completely new command and already basically moves you up to requiring > 3.2 anyways in which case the mix-and-match behavior is only a problem > with an explicit-OLD policy setting. continue() inside a function, but not inside a loop inside this function, should just be a hard error. Everything else is insane. And if it would be my decision I would just fix break() to behave the same, as everything else is just nonsense. It did not serve any useful purpose until now, so everyone could just remove that command from the function without losing anything. Noone could have ever assumed this to work, it did not do anything, so just kill it. Eike -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From DLRdave at aol.com Tue Nov 18 16:20:29 2014 From: DLRdave at aol.com (David Cole) Date: Tue, 18 Nov 2014 16:20:29 -0500 Subject: [cmake-developers] Failing CMake WinStorePhone tests In-Reply-To: <3af8b457747049ab929bea417357e4b9@CY1PR0301MB0713.namprd03.prod.outlook.com> References: <54662FF5.6040806@kitware.com> <3af8b457747049ab929bea417357e4b9@CY1PR0301MB0713.namprd03.prod.outlook.com> Message-ID: I just put VS 2013 Professional on it within the last two weeks. It might be the original release of VS 2013... I have to install Update 4 for it, but won't be able to get to that until tomorrow. So: original VS 2013 Pro, all optional components installed. Will this magically go away if I apply the Update 4 tomorrow....? Let me know if you need more specific information, or if you'd like me to try something before you push a commit with a fix. Thanks, David On Mon, Nov 17, 2014 at 8:08 PM, Gilles Khouzam wrote: > Hi David, > > Can you give me some information on your current setup? What build of VS do you have installed, which options? I think that the detection logic for the tests is missing some cases. I'm guessing that this is similar to what I recently fixed in CMake for the express editions, the same detection logic might need to be moved over to the test script. > > -----Original Message----- > From: David Cole [mailto:DLRdave at aol.com] > Sent: Friday, November 14, 2014 10:42 > To: Gilles Khouzam > Cc: Brad King; cmake-developers at cmake.org > Subject: Re: [cmake-developers] Failing CMake WinStorePhone tests > > I was hoping you'd say that! :-) > > On Fri, Nov 14, 2014 at 12:23 PM, Gilles Khouzam wrote: >> Hi David, >> >> Let me take a look at what's going on. >> >> -----Original Message----- >> From: Brad King [mailto:brad.king at kitware.com] >> Sent: Friday, November 14, 2014 08:38 >> To: David Cole >> Cc: cmake-developers at cmake.org; Gilles Khouzam >> Subject: Re: [cmake-developers] Failing CMake WinStorePhone tests >> >> On 11/14/2014 11:27 AM, David Cole via cmake-developers wrote: >>> Should I expect these tests to pass using Ninja, or is that beyond >>> the scope of the WinStorePhone support...? >> >> The VS generator is needed for the feature, but the tests that are failing hard-code use of specific Visual Studio generators regardless of the main generator being tested. >> >> I'll defer to Gilles as for what the problem might be. >> >> -Brad >> From mantis at public.kitware.com Tue Nov 18 18:14:43 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Wed, 19 Nov 2014 00:14:43 +0100 Subject: [cmake-developers] [CMake 0015256]: Ninja handling of CMake depends and output files is not correct Message-ID: The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15256 ====================================================================== Reported By: Stephen Kelly Assigned To: ====================================================================== Project: CMake Issue ID: 15256 Category: CMake Reproducibility: have not tried Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-19 00:14 CET Last Modified: 2014-11-19 00:14 CET ====================================================================== Summary: Ninja handling of CMake depends and output files is not correct Description: Given this test code: cmake_minimum_required(VERSION 2.8) project(cmaketest) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/input_file.txt" "${CMAKE_CURRENT_BINARY_DIR}/confi_file.txt" ) If cmake is run, then input_file.txt is touched, then ninja is run, then ninja correctly re-runs cmake, but also reports that no work need be done: $ ninja [1/1] Re-running CMake... -- Configuring done -- Generating done -- Build files have been written to: /home/stephen/dev/src/playground/cmake/build ninja: no work to do. If confi_file.txt is then deleted, and ninja is run, ninja does not re-run cmake to re-create the output file. The same 'no work to do' message can be seen by creating a try_compile: try_compile(RES "${CMAKE_CURRENT_BINARY_DIR}/testbin" "${CMAKE_CURRENT_SOURCE_DIR}/tc_input.cpp" ) message("RES: ${RES}") Run cmake, and change the tc_input.cpp. this->Makefile->AddCMakeDependFile(this->Input.c_str()); and this->Makefile->AddCMakeOutputFile(outputFileName.c_str()); are called at the appropriate places, but the appropriate Ninja content is apparently not created. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-19 00:14 Stephen Kelly New Issue ====================================================================== From fraser.hutchison at gmail.com Tue Nov 18 18:18:20 2014 From: fraser.hutchison at gmail.com (Fraser Hutchison) Date: Tue, 18 Nov 2014 23:18:20 +0000 Subject: [cmake-developers] Patch for new warning caused by CMP0054 Message-ID: <546BD3BC.7080302@gmail.com> An HTML attachment was scrubbed... URL: -------------- next part -------------- From 9c0cd531876c60ad12e5df443bc3026a97a04404 Mon Sep 17 00:00:00 2001 From: Fraser Hutchison Date: Tue, 18 Nov 2014 22:55:52 +0000 Subject: [PATCH] Removed quoted instances of MSVC to avoid generating warnings via CMP0054. --- Modules/CMakeFindBinUtils.cmake | 10 +++++----- Modules/Compiler/AppleClang-CXX.cmake | 2 +- Modules/Compiler/Clang-CXX.cmake | 2 +- Modules/Compiler/Clang.cmake | 4 ++-- Modules/Platform/Windows-Clang.cmake | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 50cb972..d2991d2 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -30,11 +30,11 @@ # License text for the above reference.) # if it's the MS C/CXX compiler, search for link -if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC" - OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC" - OR CMAKE_Fortran_SIMULATE_ID STREQUAL "MSVC" - OR CMAKE_C_COMPILER_ID STREQUAL "MSVC" - OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" +if(CMAKE_C_SIMULATE_ID STREQUAL MSVC + OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC + OR CMAKE_Fortran_SIMULATE_ID STREQUAL MSVC + OR CMAKE_C_COMPILER_ID STREQUAL MSVC + OR CMAKE_CXX_COMPILER_ID STREQUAL MSVC OR (CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")) diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 0372e18..0cabca4 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -1,6 +1,6 @@ include(Compiler/Clang) __compiler_clang(CXX) -if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") +if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 780a072..bc88405 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -1,7 +1,7 @@ include(Compiler/Clang) __compiler_clang(CXX) -if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") +if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index eeba119..b964fce 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -18,8 +18,8 @@ if(__COMPILER_CLANG) endif() set(__COMPILER_CLANG 1) -if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC" - OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") +if(CMAKE_C_SIMULATE_ID STREQUAL MSVC + OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) macro(__compiler_clang lang) endmacro() else() diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 4c936fe..d37b969 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -18,8 +18,8 @@ if(__WINDOWS_CLANG) endif() set(__WINDOWS_CLANG 1) -if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC" - OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") +if(CMAKE_C_SIMULATE_ID STREQUAL MSVC + OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) include(Platform/Windows-MSVC) macro(__windows_compiler_clang lang) __windows_compiler_msvc(${lang}) -- 1.9.4.msysgit.1 From steveire at gmail.com Tue Nov 18 18:50:53 2014 From: steveire at gmail.com (Stephen Kelly) Date: Wed, 19 Nov 2014 00:50:53 +0100 Subject: [cmake-developers] Explicit custom command BYPRODUCTS References: <546A26AF.7080400@kitware.com> Message-ID: Brad King wrote: > This was in 'next' over the weekend and is clean on the dashboard. > > To those that encountered problems requiring this feature, please > try it out to see if it works correctly for your use case. I didn't fully review the branch, but I looked at commit 6e1c359f (QtAutogen: Regenerate qrc files if their input changes (#15074), 2014-09-17), which includes a work-around for this issue, and I didn't really see how it should be changed to use the byproducts API yet. I'll have another look in a few days I hope. Thanks, Steve. From ahovda at openit.com Tue Nov 18 19:23:16 2014 From: ahovda at openit.com (=?windows-1252?Q?=C5dne_Hovda?=) Date: Wed, 19 Nov 2014 01:23:16 +0100 Subject: [cmake-developers] HP-UX Curses questions In-Reply-To: References: Message-ID: Hi Brad Thanks a lot! FWIW, I have attached a small patch which adds CMAKE_USE_SYSTEM_FORM enabling support for using libform.so as an alternative to the embedded cmForm library. I have tested it on RHEL and Ubuntu and it works fine. (Solaris also has libform, but using that results in a core dump). Nothing critical, obviously, but maybe distro packagers find it somewhat useful. Best regards, ?dne Hovda -------------- next part -------------- >From 9c18272fd576a28e35e0913e3cb99c08b9fdd8bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85dne=20Hovda?= Date: Tue, 18 Nov 2014 21:47:02 +0100 Subject: [PATCH] Add CMAKE_USE_SYSTEM_FORM option for libform instead of embedded cmForm. --- CMakeLists.txt | 6 +++++- Source/CursesDialog/CMakeLists.txt | 18 +++++++++++++++--- Utilities/cmThirdParty.h.in | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58e0a1f..6bd1e41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) # Allow the user to enable/disable all system utility library options by # defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}. - set(UTILITIES BZIP2 CURL EXPAT LIBARCHIVE LIBLZMA ZLIB) + set(UTILITIES BZIP2 CURL EXPAT LIBARCHIVE LIBLZMA ZLIB FORM) foreach(util ${UTILITIES}) if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util} AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES) @@ -95,6 +95,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) "${CMAKE_USE_SYSTEM_LIBRARY_BZIP2}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON) CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_LIBLZMA "Use system-installed liblzma" "${CMAKE_USE_SYSTEM_LIBRARY_LIBLZMA}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON) + option(CMAKE_USE_SYSTEM_FORM "Use system-installed libform" "${CMAKE_USE_SYSTEM_LIBRARY_LIBFORM}") # Mention to the user what system libraries are being used. foreach(util ${UTILITIES}) @@ -383,6 +384,9 @@ macro (CMAKE_BUILD_UTILITIES) find_package(Curses QUIET) if (CURSES_LIBRARY) option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" ON) + if(CMAKE_USE_SYSTEM_FORM AND NOT CURSES_FORM_LIBRARY) + message( FATAL_ERROR "CMAKE_USE_SYSTEM_FORM in ON but libform is not found!" ) + endif() else () message("Curses libraries were not found. Curses GUI for CMake will not be built.") set(BUILD_CursesDialog 0) diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt index 548f5a5..7d4e88c 100644 --- a/Source/CursesDialog/CMakeLists.txt +++ b/Source/CursesDialog/CMakeLists.txt @@ -26,13 +26,25 @@ set( CURSES_SRCS CursesDialog/ccmake ) -include_directories(${CMake_SOURCE_DIR}/Source/CursesDialog/form - ${CMake_BINARY_DIR}/Source/CursesDialog/form) +if( NOT CMAKE_USE_SYSTEM_FORM ) + include_directories(${CMake_SOURCE_DIR}/Source/CursesDialog/form + ${CMake_BINARY_DIR}/Source/CursesDialog/form) +endif() include_directories(${CURSES_INCLUDE_PATH}) add_executable(ccmake ${CURSES_SRCS} ) target_link_libraries(ccmake CMakeLib) -target_link_libraries(ccmake cmForm) +if(CMAKE_USE_SYSTEM_FORM) + target_link_libraries(ccmake + ${CURSES_FORM_LIBRARY} + ${CURSES_LIBRARY} + ) + if(CURSES_EXTRA_LIBRARY) + target_link_libraries(ccmake ${CURSES_EXTRA_LIBRARY}) + endif() +else() + target_link_libraries(ccmake cmForm) +endif() install(TARGETS ccmake DESTINATION bin) diff --git a/Utilities/cmThirdParty.h.in b/Utilities/cmThirdParty.h.in index b0b5779..726c843 100644 --- a/Utilities/cmThirdParty.h.in +++ b/Utilities/cmThirdParty.h.in @@ -19,6 +19,7 @@ #cmakedefine CMAKE_USE_SYSTEM_BZIP2 #cmakedefine CMAKE_USE_SYSTEM_LIBARCHIVE #cmakedefine CMAKE_USE_SYSTEM_LIBLZMA +#cmakedefine CMAKE_USE_SYSTEM_FORM #cmakedefine CTEST_USE_XMLRPC #endif -- 1.8.3.1 From eike at sf-mail.de Wed Nov 19 01:29:31 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Wed, 19 Nov 2014 07:29:31 +0100 Subject: [cmake-developers] Patch for new warning caused by CMP0054 In-Reply-To: <546BD3BC.7080302@gmail.com> References: <546BD3BC.7080302@gmail.com> Message-ID: <4541766.QJt4xtII0P@caliban.sf-tec.de> Fraser Hutchison wrote: > Hi there, > > CMake 3.1 (both release candidates) now generate a CMP0054 warning when > configuring the following CMakeLists.txt in a clean build folder with MSVC > as the generator: > > cmake_minimum_required(VERSION 2.8) > enable_language(ASM_MASM) > > The warning is: > > CMake Warning (dev) at E:/Program Files (x86)/CMake > 3/share/cmake-3.1/Modules/CMakeFindBinUtils.cmake:33 (if): Policy CMP0054 > is not set: Only interpret if() arguments as variables or keywords when > unquoted. Run "cmake --help-policy CMP0054" for policy details. Use the > cmake_policy command to set the policy and suppress this warning. > > Quoted variables like "MSVC" will no longer be dereferenced when the > policy is set to NEW. Since the policy is not set the OLD behavior will be > used. > > I can see the file in question has been updated (presumably since RC2) to > not quote the left-hand variables: > http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/CMakeFindBinUtils. > cmake;h=50cb9721272f98bc2ffe73e95ae57c3156251188;hb=HEAD but even with these > updates, the quoted "MSVC" args generate the warning. > > I've attached a trivial patch removing all remaining instances of quoted > "MSVC"s. Nope, this is wrong. What you now do is to compare it to the variable MSVC, which is true or false (or undefined). This wants to be compared to the string MSVC, so this probably needs to be changed to if ("x${foo}" STREQUAL "xMSVC") Greetings, Eike -- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From fraser.hutchison at gmail.com Wed Nov 19 04:26:20 2014 From: fraser.hutchison at gmail.com (Fraser Hutchison) Date: Wed, 19 Nov 2014 09:26:20 +0000 Subject: [cmake-developers] Patch for new warning caused by CMP0054 In-Reply-To: <4541766.QJt4xtII0P@caliban.sf-tec.de> References: <546BD3BC.7080302@gmail.com> <4541766.QJt4xtII0P@caliban.sf-tec.de> Message-ID: <546C623C.90901@gmail.com> An HTML attachment was scrubbed... URL: -------------- next part -------------- >From d51f9d44b7229aefd1bcdc2dd5dcb6f63f9fc8ae Mon Sep 17 00:00:00 2001 From: Fraser Hutchison Date: Wed, 19 Nov 2014 09:21:27 +0000 Subject: [PATCH] Adjusted quoted instances of MSVC to avoid generating warnings. --- Modules/CMakeFindBinUtils.cmake | 10 +++++----- Modules/Compiler/AppleClang-CXX.cmake | 2 +- Modules/Compiler/Clang-CXX.cmake | 2 +- Modules/Compiler/Clang.cmake | 4 ++-- Modules/Platform/Windows-Clang.cmake | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 50cb972..376a6dc 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -30,11 +30,11 @@ # License text for the above reference.) # if it's the MS C/CXX compiler, search for link -if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC" - OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC" - OR CMAKE_Fortran_SIMULATE_ID STREQUAL "MSVC" - OR CMAKE_C_COMPILER_ID STREQUAL "MSVC" - OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" +if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" + OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" + OR "x${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "xMSVC" + OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC" + OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" OR (CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")) diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 0372e18..c1acae6 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -1,6 +1,6 @@ include(Compiler/Clang) __compiler_clang(CXX) -if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") +if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 780a072..6fe0b56 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -1,7 +1,7 @@ include(Compiler/Clang) __compiler_clang(CXX) -if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") +if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index eeba119..701089c 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -18,8 +18,8 @@ if(__COMPILER_CLANG) endif() set(__COMPILER_CLANG 1) -if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC" - OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") +if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" + OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") macro(__compiler_clang lang) endmacro() else() diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 4c936fe..da19a3d 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -18,8 +18,8 @@ if(__WINDOWS_CLANG) endif() set(__WINDOWS_CLANG 1) -if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC" - OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") +if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" + OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") include(Platform/Windows-MSVC) macro(__windows_compiler_clang lang) __windows_compiler_msvc(${lang}) -- 1.9.4.msysgit.1 From gjasny at googlemail.com Wed Nov 19 07:45:57 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Wed, 19 Nov 2014 13:45:57 +0100 Subject: [cmake-developers] [PATCH v5 0/4] Add continue keyword In-Reply-To: References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> <20141118161947.GB8165@megas.kitwarein.com> <546B7C96.4010606@googlemail.com> <20141118173115.GA21019@megas.kitwarein.com> Message-ID: <546C9105.10000@googlemail.com> On 18/11/14 19:30, David Cole wrote: > Putting continue, break or return inside of a macro definition is a > practice that should itself be discouraged... Agreed. But this is beyond the scope of the 'continue' patch. I can work on a patch for a new policy that forbids these types of commands within a macro later. But before jumping in I'd like to see some consensus among the cmake developers that patch is actually wanted. Thanks, Gregor From ben.boeckel at kitware.com Wed Nov 19 11:05:48 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Wed, 19 Nov 2014 11:05:48 -0500 Subject: [cmake-developers] Patch for new warning caused by CMP0054 In-Reply-To: <546BD3BC.7080302@gmail.com> References: <546BD3BC.7080302@gmail.com> Message-ID: <20141119160548.GA6120@megas.kitwarein.com> On Tue, Nov 18, 2014 at 23:18:20 +0000, Fraser Hutchison wrote: > -if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC" > - OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC" > - OR CMAKE_Fortran_SIMULATE_ID STREQUAL "MSVC" > - OR CMAKE_C_COMPILER_ID STREQUAL "MSVC" > - OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" > +if(CMAKE_C_SIMULATE_ID STREQUAL MSVC > + OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC > + OR CMAKE_Fortran_SIMULATE_ID STREQUAL MSVC > + OR CMAKE_C_COMPILER_ID STREQUAL MSVC > + OR CMAKE_CXX_COMPILER_ID STREQUAL MSVC I think you misinterpreted the warning message. It is saying that with OLD behavior MSVC will be dereferenced (which is bad here because we want to use it as a string) and with NEW behavior, MSVC is just a string (and a change in behavior, hence the warning). Given: CMAKE_CXX_SIMULATE_ID -> MSVC MSVC -> 1 This now does: "MSVC" STREQUAL "1" In fact, this is what CMake will do with CMP0054 set to OLD *anyways* and these are actual bugs (and always have been; the dequoting of the left side was done by me in a massive sweep, but the right side issue was missed). These should be changed to: "x${var}" STREQUAL "xMSVC" Though, an easier fix may be to push_scope() and set CMP0054 to NEW in these files. --Ben From ben.boeckel at kitware.com Wed Nov 19 11:07:28 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Wed, 19 Nov 2014 11:07:28 -0500 Subject: [cmake-developers] Patch for new warning caused by CMP0054 In-Reply-To: <20141119160548.GA6120@megas.kitwarein.com> References: <546BD3BC.7080302@gmail.com> <20141119160548.GA6120@megas.kitwarein.com> Message-ID: <20141119160728.GA6554@megas.kitwarein.com> On Wed, Nov 19, 2014 at 11:05:48 -0500, Ben Boeckel wrote: And I now see Rolf's reply. Should have waited for email to refresh. --Ben From mantis at public.kitware.com Wed Nov 19 14:03:19 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Wed, 19 Nov 2014 14:03:19 -0500 Subject: [cmake-developers] [CMake 0015257]: CMake from command line using wrong generator Message-ID: The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15257 ====================================================================== Reported By: Javier Assigned To: ====================================================================== Project: CMake Issue ID: 15257 Category: CMake Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-19 14:03 EST Last Modified: 2014-11-19 14:03 EST ====================================================================== Summary: CMake from command line using wrong generator Description: I'm trying to generate NMake Makefiles with cmake from the command line, but I'm getting the wrong generator: c:\gitbuild\x>cmake ?G "NMake Makefiles" c:\gitbuild\cc_vob\tcs -- Building for: Visual Studio 8 2005 -- The C compiler identification is MSVC 14.0.50727 -- The CXX compiler identification is MSVC 14.0.50727 -- Check for working C compiler using: Visual Studio 8 2005 -- Check for working C compiler using: Visual Studio 8 2005 -- works -- Detecting C compiler ABI info Steps to Reproduce: 1) I open a Visual Studio 2005 command line (yes 2005, it's a legacy project). 2) I add cmake path: set PATH="c:\Program Files (x86)\CMake 2.8\bin";%path% 3) I run: cmake ?G "NMake Makefiles" c:\gitbuild\cc_vob\tcs 4) Instead of generating nmake makefiles, I get a VS Solution: -- Building for: Visual Studio 8 2005 -- The C compiler identification is MSVC 14.0.50727 -- The CXX compiler identification is MSVC 14.0.50727 Additional Information: - If I don't add CMake bin to Path variable, it sometimes uses the correct generator, however, I have to call cmake with a fully qualified name: c:\gitbuild\p>"c:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -G "NMake Makefiles" ..\cc_vob\tcs -- The C compiler identification is MSVC 14.0.50727 -- The CXX compiler identification is MSVC 14.0.50727 -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/cl.exe -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done - I'm using Visual Studio Command Line Prompt shell (x86). ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-19 14:03 Javier New Issue ====================================================================== From rleigh at codelibre.net Wed Nov 19 14:23:33 2014 From: rleigh at codelibre.net (Roger Leigh) Date: Wed, 19 Nov 2014 19:23:33 +0000 Subject: [cmake-developers] [PATCH] New module FindLibDl Message-ID: <20141119192333.GP1657@codelibre.net> libdl (for dlopen, dlsym) is part of (or an extention to) the standard library/linker on many platforms. It doesn't currently have support in CMake, though there are a few independent implementations shown up by Google. Given that there are several upstreams and that it's a basic component of several different POSIX systems, having support in CMake would be quite beneficial. I've tested the attached patch on FreeBSD, Linux and MacOS X. Kind regards, Roger -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools `- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800 -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-FindLibDl-New-module-to-find-libdl.patch Type: text/x-diff Size: 4007 bytes Desc: not available URL: From nilsgladitz at gmail.com Wed Nov 19 14:35:53 2014 From: nilsgladitz at gmail.com (Nils Gladitz) Date: Wed, 19 Nov 2014 20:35:53 +0100 Subject: [cmake-developers] [PATCH] New module FindLibDl In-Reply-To: <20141119192333.GP1657@codelibre.net> References: <20141119192333.GP1657@codelibre.net> Message-ID: <546CF119.3020600@gmail.com> On 19.11.2014 20:23, Roger Leigh wrote: > libdl (for dlopen, dlsym) is part of (or an extention to) the > standard library/linker on many platforms. It doesn't currently > have support in CMake, though there are a few independent > implementations shown up by Google. Given that there are > several upstreams and that it's a basic component of several > different POSIX systems, having support in CMake would be quite > beneficial. There is http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_DL_LIBS.html which is set up by the platform modules. Nils From rleigh at codelibre.net Wed Nov 19 14:53:25 2014 From: rleigh at codelibre.net (Roger Leigh) Date: Wed, 19 Nov 2014 19:53:25 +0000 Subject: [cmake-developers] [PATCH] New module FindLibDl In-Reply-To: <546CF119.3020600@gmail.com> References: <20141119192333.GP1657@codelibre.net> <546CF119.3020600@gmail.com> Message-ID: <20141119195325.GQ1657@codelibre.net> On Wed, Nov 19, 2014 at 08:35:53PM +0100, Nils Gladitz wrote: > On 19.11.2014 20:23, Roger Leigh wrote: > >libdl (for dlopen, dlsym) is part of (or an extention to) the > >standard library/linker on many platforms. It doesn't currently > >have support in CMake, though there are a few independent > >implementations shown up by Google. Given that there are > >several upstreams and that it's a basic component of several > >different POSIX systems, having support in CMake would be quite > >beneficial. > > There is http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_DL_LIBS.html > which is set up by the platform modules. That's great to know, thanks. However, do I still need to independently check for ? How do I know that I have a working dlopen? E.g., on FreeBSD where CMAKE_DL_LIBS would be empty how do I know it's there without a functional check? Thanks, Roger -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools `- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800 From chuck.atkins at kitware.com Wed Nov 19 15:52:36 2014 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Wed, 19 Nov 2014 15:52:36 -0500 Subject: [cmake-developers] ProcessUNIX and ANSI != POSIX Message-ID: I've added an extra configure check in KWSys for ProcessUNIX.c to test for the required POSIX function sigaction. Previously the build would mysteriously fail if it's not available (if building in strict ANSI mode, for instance); now at least the failure will be at configure time and for reasonably clear reasons. http://review.source.kitware.com/#/c/18065/ - Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From fraser.hutchison at gmail.com Wed Nov 19 16:02:35 2014 From: fraser.hutchison at gmail.com (Fraser Hutchison) Date: Wed, 19 Nov 2014 21:02:35 +0000 Subject: [cmake-developers] Patch for new warning caused by CMP0054 In-Reply-To: <20141119160728.GA6554@megas.kitwarein.com> References: <546BD3BC.7080302@gmail.com> <20141119160548.GA6120@megas.kitwarein.com> <20141119160728.GA6554@megas.kitwarein.com> Message-ID: <546D056B.2020408@gmail.com> Yeah - no worries. I understand my previous mistake and what's in the patch should now be OK I think. However, I'm more than happy if you want to fix this another way and reject the patch - but it'd be good to nail this before v3.1 is released since it's pretty trivial. Cheers, Fraser. On 19/11/2014 16:07, Ben Boeckel wrote: > On Wed, Nov 19, 2014 at 11:05:48 -0500, Ben Boeckel wrote: > > > And I now see Rolf's reply. Should have waited for email to refresh. > > --Ben From ben.boeckel at kitware.com Wed Nov 19 16:42:08 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Wed, 19 Nov 2014 16:42:08 -0500 Subject: [cmake-developers] Patch for new warning caused by CMP0054 In-Reply-To: <546D056B.2020408@gmail.com> References: <546BD3BC.7080302@gmail.com> <20141119160548.GA6120@megas.kitwarein.com> <20141119160728.GA6554@megas.kitwarein.com> <546D056B.2020408@gmail.com> Message-ID: <20141119214208.GA26315@megas.kitwarein.com> On Wed, Nov 19, 2014 at 21:02:35 +0000, Fraser Hutchison wrote: > Yeah - no worries. I understand my previous mistake and what's in the > patch should now be OK I think. However, I'm more than happy if you > want to fix this another way and reject the patch - but it'd be good to > nail this before v3.1 is released since it's pretty trivial. Yep, it looks sane to me (100% untested from my side though). --Ben From DLRdave at aol.com Thu Nov 20 07:07:27 2014 From: DLRdave at aol.com (David Cole) Date: Thu, 20 Nov 2014 07:07:27 -0500 Subject: [cmake-developers] Failing CMake WinStorePhone tests Message-ID: Well, after installing the Update 4 to VS 2013 yesterday, and letting the dashboards run their usual course overnight ... the WinStorePhone tests seem to work just fine now. So: must be some difference in VS 2013 "out of the box" and "Update 4" that was to blame. I'm perfectly ok with saying "you gotta have the latest update of VS" for the WinStorePhone tests to work. Does that match your expectations? Thanks, and sorry for the temporary noise.... David C. On Tue, Nov 18, 2014 at 4:20 PM, David Cole wrote: > I just put VS 2013 Professional on it within the last two weeks. It > might be the original release of VS 2013... I have to install Update 4 > for it, but won't be able to get to that until tomorrow. > > So: original VS 2013 Pro, all optional components installed. > > Will this magically go away if I apply the Update 4 tomorrow....? > > Let me know if you need more specific information, or if you'd like me > to try something before you push a commit with a fix. > > Thanks, > David > > > On Mon, Nov 17, 2014 at 8:08 PM, Gilles Khouzam > wrote: >> Hi David, >> >> Can you give me some information on your current setup? What build of VS do you have installed, which options? I think that the detection logic for the tests is missing some cases. I'm guessing that this is similar to what I recently fixed in CMake for the express editions, the same detection logic might need to be moved over to the test script. >> >> -----Original Message----- >> From: David Cole [mailto:DLRdave at aol.com] >> Sent: Friday, November 14, 2014 10:42 >> To: Gilles Khouzam >> Cc: Brad King; cmake-developers at cmake.org >> Subject: Re: [cmake-developers] Failing CMake WinStorePhone tests >> >> I was hoping you'd say that! :-) >> >> On Fri, Nov 14, 2014 at 12:23 PM, Gilles Khouzam wrote: >>> Hi David, >>> >>> Let me take a look at what's going on. >>> >>> -----Original Message----- >>> From: Brad King [mailto:brad.king at kitware.com] >>> Sent: Friday, November 14, 2014 08:38 >>> To: David Cole >>> Cc: cmake-developers at cmake.org; Gilles Khouzam >>> Subject: Re: [cmake-developers] Failing CMake WinStorePhone tests >>> >>> On 11/14/2014 11:27 AM, David Cole via cmake-developers wrote: >>>> Should I expect these tests to pass using Ninja, or is that beyond >>>> the scope of the WinStorePhone support...? >>> >>> The VS generator is needed for the feature, but the tests that are failing hard-code use of specific Visual Studio generators regardless of the main generator being tested. >>> >>> I'll defer to Gilles as for what the problem might be. >>> >>> -Brad >>> From arekm at maven.pl Thu Nov 20 08:10:55 2014 From: arekm at maven.pl (Arkadiusz =?utf-8?q?Mi=C5=9Bkiewicz?=) Date: Thu, 20 Nov 2014 14:10:55 +0100 Subject: [cmake-developers] _IMPORT_PREFIX and using full paths Message-ID: <201411201410.55548.arekm@maven.pl> Hello. Trying to build kde frameworks and got weird problem, when building kauth which uses kcoreaddons : "CMake Error in src/CMakeLists.txt: Imported target "KF5::CoreAddons" includes non-existent path "/include/KF5/KCoreAddons" in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include: * The path was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and references files it does not provide. " that's because: /usr/lib64/cmake/KF5CoreAddons/KF5CoreAddonsTargets.cmake contains: 44 set_target_properties(KF5::CoreAddons PROPERTIES 45 INTERFACE_COMPILE_DEFINITIONS "KCOREADDONS_LIB" 46 INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/KF5/KCoreAddons;${_IMPORT_PREFIX}/include/KF5" 47 INTERFACE_LINK_LIBRARIES "Qt5::Core" 48 ) 49 and since I'm using full paths (and not relative paths) the _IMPORT_PREFIX is empty [1] thus I'm ending up with invalid "/include/KF5" path. Shouldn't cmake generate full paths like INTERFACE_INCLUDE_DIRECTORIES "/usr/include/KF5/KCoreAddons;/usr/include/KF5" in such case? Tested on 3.0.2 and 3.1.0rc2. 1. http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmExportInstallFileGenerator.cxx;h=89071c052ce28a82f57e06d96b2b7d519259c2f0;hb=HEAD#l72 KF5CoreAddonsTargets.cmake file: http://sprunge.us/bGDE kcoreaddons build log, including cmake options used: http://sprunge.us/hINb irc discussion about the problem: http://sprunge.us/ZKBa -- Arkadiusz Mi?kiewicz, arekm / ( maven.pl | pld-linux.org ) From nilsgladitz at gmail.com Thu Nov 20 08:28:43 2014 From: nilsgladitz at gmail.com (Nils Gladitz) Date: Thu, 20 Nov 2014 14:28:43 +0100 Subject: [cmake-developers] FindOpenMP and gfortran In-Reply-To: References: Message-ID: <546DEC8B.7060100@gmail.com> On 11/18/2014 04:10 PM, Alin Marin Elena wrote: > the original bug/feature was introduced by this > https://www.cmake.org/Bug/view.php?id=14656&history=1 @Brad: Could this be fixed in time for 3.1? Nils From brad.king at kitware.com Thu Nov 20 08:32:05 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Nov 2014 08:32:05 -0500 Subject: [cmake-developers] FindOpenMP and gfortran In-Reply-To: <546DEC8B.7060100@gmail.com> References: <546DEC8B.7060100@gmail.com> Message-ID: <546DED55.1030702@kitware.com> On 11/20/2014 8:28 AM, Nils Gladitz wrote: > On 11/18/2014 04:10 PM, Alin Marin Elena wrote: >> the original bug/feature was introduced by this >> https://www.cmake.org/Bug/view.php?id=14656&history=1 > > @Brad: Could this be fixed in time for 3.1? Yes, since it is a regression. On 11/18/2014 10:10 AM, Alin Marin Elena wrote: > 2. the fortran test in FindOpenMP.cmake shall be provided in fixed > form (add 6 empty spaces in front of the character of each line) Please use this approach in a topic based of origin/release. Thanks, -Brad From nilsgladitz at gmail.com Thu Nov 20 08:57:21 2014 From: nilsgladitz at gmail.com (Nils Gladitz) Date: Thu, 20 Nov 2014 14:57:21 +0100 Subject: [cmake-developers] FindOpenMP and gfortran In-Reply-To: <546DED55.1030702@kitware.com> References: <546DEC8B.7060100@gmail.com> <546DED55.1030702@kitware.com> Message-ID: <546DF341.5060206@gmail.com> On 11/20/2014 02:32 PM, Brad King wrote: > On 11/18/2014 10:10 AM, Alin Marin Elena wrote: >> 2. the fortran test in FindOpenMP.cmake shall be provided in fixed >> form (add 6 empty spaces in front of the character of each line) > > Please use this approach in a topic based of origin/release. Thanks, done. @Alin I hope you don't mind that I took the liberty :) Nils From brad.king at kitware.com Thu Nov 20 08:59:20 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Nov 2014 08:59:20 -0500 Subject: [cmake-developers] Patch for new warning caused by CMP0054 In-Reply-To: <546C623C.90901@gmail.com> References: <546BD3BC.7080302@gmail.com> <4541766.QJt4xtII0P@caliban.sf-tec.de> <546C623C.90901@gmail.com> Message-ID: <546DF3B8.5050007@kitware.com> On 11/19/2014 4:26 AM, Fraser Hutchison wrote: > I've attached an updated patch Thanks. Applied here: Avoid if() quoted auto-dereference when checking for "MSVC" http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d52cd36 and backported for the 'release' branch here: Avoid if() quoted auto-dereference when checking for "MSVC" http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=543c4304 They had to be separately applied due to conflicts. The latter will be merged to 'release' for 3.1.0-rc3. Thanks, -Brad From brad.king at kitware.com Thu Nov 20 09:11:07 2014 From: brad.king at kitware.com (Brad King) Date: Thu, 20 Nov 2014 09:11:07 -0500 Subject: [cmake-developers] FindOpenMP and gfortran In-Reply-To: <546DF341.5060206@gmail.com> References: <546DEC8B.7060100@gmail.com> <546DED55.1030702@kitware.com> <546DF341.5060206@gmail.com> Message-ID: <546DF67B.2010601@kitware.com> On 11/20/2014 8:57 AM, Nils Gladitz wrote: > Thanks, done. > > @Alin I hope you don't mind that I took the liberty :) Alin, the commit is here: FindOpenMP: Use fixed form Fortran test program http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7d633ebf Please try it out so we know it fixes your use case. Thanks, -Brad From fraser.hutchison at gmail.com Thu Nov 20 13:16:13 2014 From: fraser.hutchison at gmail.com (Fraser Hutchison) Date: Thu, 20 Nov 2014 18:16:13 +0000 Subject: [cmake-developers] Patch for new warning caused by CMP0054 In-Reply-To: <546DF3B8.5050007@kitware.com> References: <546BD3BC.7080302@gmail.com> <4541766.QJt4xtII0P@caliban.sf-tec.de> <546C623C.90901@gmail.com> <546DF3B8.5050007@kitware.com> Message-ID: <546E2FED.2090108@gmail.com> On 20/11/2014 13:59, Brad King wrote: > The latter will be merged to 'release' for 3.1.0-rc3. Thanks very much. Fraser. From steveire at gmail.com Thu Nov 20 18:29:11 2014 From: steveire at gmail.com (Stephen Kelly) Date: Fri, 21 Nov 2014 00:29:11 +0100 Subject: [cmake-developers] _IMPORT_PREFIX and using full paths References: <201411201410.55548.arekm@maven.pl> Message-ID: Arkadiusz Mi?kiewicz wrote: > > Hello. > > Trying to build kde frameworks and got weird problem, when building kauth > which uses kcoreaddons : Can you put all of this into a bug report please? http://public.kitware.com/Bug/bug_report_page.php Remember: paste the important info, not pastebin links. Thanks, Steve. From mantis at public.kitware.com Fri Nov 21 02:32:26 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Fri, 21 Nov 2014 02:32:26 -0500 Subject: [cmake-developers] [CMake 0015258]: 3.0.2-3.1rc2: _IMPORT_PREFIX always used even if absolute paths are in use - thus breaking build Message-ID: <0dbb3557cf37c9a3583d3f20494179ff@public.kitware.com> The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15258 ====================================================================== Reported By: Arkadiusz Miskiewicz Assigned To: ====================================================================== Project: CMake Issue ID: 15258 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-21 02:32 EST Last Modified: 2014-11-21 02:32 EST ====================================================================== Summary: 3.0.2-3.1rc2: _IMPORT_PREFIX always used even if absolute paths are in use - thus breaking build Description: cmake 3.0.2 and 3.1rc2 shows this behaviour. Anyway kde frameworks 5.4 in kcoreaddons generates via cmake KF5CoreAddonsTargets.cmake which contains: /usr/lib64/cmake/KF5CoreAddons/KF5CoreAddonsTargets.cmake contains: 44 set_target_properties(KF5::CoreAddons PROPERTIES 45 INTERFACE_COMPILE_DEFINITIONS "KCOREADDONS_LIB" 46 INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/KF5/KCoreAddons;${_IMPORT_PREFIX}/include/KF5" 47 INTERFACE_LINK_LIBRARIES "Qt5::Core" 48 ) 49 Note _IMPORT_PREFIX is being used there. Now according to this code: http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmExportInstallFileGenerator.cxx;h=89071c052ce28a82f57e06d96b2b7d519259c2f0;hb=HEAD#l72 _IMPORT_PREFIX is empty if using absolute paths. Thus I'm ending up with invalid "/include/KF5/KcoreAdons" paths. That's becomes visible when trying to build for example kauth which uses kcoreaddons: "CMake Error in src/CMakeLists.txt: Imported target "KF5::CoreAddons" includes non-existent path "/include/KF5/KCoreAddons" in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include: * The path was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and references files it does not provide. Steps to Reproduce: Build kcoreaddons using such options: + CC=x86_64-pld-linux-gcc CXX=x86_64-pld-linux-g++ CPPFLAGS= /usr/bin/cmake '-DCMAKE_VERBOSE_MAKEFILE=ON' '-DCMAKE_BUILD_TYPE=PLD' '-DCMAKE_INSTALL_LIBDIR:PATH=/usr/lib64' '-DCMAKE_INSTALL_PREFIX:PATH=/usr' '-DSYSCONF_INSTALL_DIR:PATH=/etc' '-DCMAKE_CXX_FLAGS_PLD=-O2 -fwrapv -pipe -Wformat -Werror=format-security -gdwarf-4 -fno-debug-types-section -fvar-tracking-assignments -g2 -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC -march=x86-64 -gdwarf-4 -fno-debug-types-section -fvar-tracking-assignments -g2 -DNDEBUG -DQT_NO_DEBUG' '-DCMAKE_C_FLAGS_PLD=-O2 -fwrapv -pipe -Wformat -Werror=format-security -gdwarf-4 -fno-debug-types-section -fvar-tracking-assignments -g2 -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC -march=x86-64 -gdwarf-4 -fno-debug-types-section -fvar-tracking-assignments -g2 -DNDEBUG -DQT_NO_DEBUG' '-DCMAKE_Fortran_FLAGS_PLD=-O2 -fwrapv -pipe -Wformat -Werror=format-security -gdwarf-4 -fno-debug-types-section -fvar-tracking-assignments -g2 -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC -march=x86-64 -gdwarf-4 -fno-debug-types-section -fvar-tracking-assignments -g2 -DNDEBUG -DQT_NO_DEBUG' '-DCMAKE_EXE_LINKER_FLAGS_PLD=-Wl,--as-needed -Wl,--no-copy-dt-needed-entries -Wl,-z,relro -Wl,-z,combreloc ' '-DCMAKE_SHARED_LINKER_FLAGS_PLD=-Wl,--as-needed -Wl,--no-copy-dt-needed-entries -Wl,-z,relro -Wl,-z,combreloc ' '-DCMAKE_MODULE_LINKER_FLAGS_PLD=-Wl,--as-needed -Wl,--no-copy-dt-needed-entries -Wl,-z,relro -Wl,-z,combreloc ' '-DLIB_SUFFIX=64' '-DBUILD_SHARED_LIBS:BOOL=ON' '-DKDE_INSTALL_USE_QT_SYS_PATHS=ON' '-DBIN_INSTALL_DIR=/usr/bin' ../ then build kauth using the same options. I assume it's unrealistic to expect cmake developers to do such compilations to reproduce. Anyway looking into how cmake generated KF5CoreAddonsTargets.cmake always using _IMPORT_PREFIX and the fact that _IMPORT_PREFIX is empty if using absolute paths should be enough to figure the problem out. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-21 02:32 Arkadiusz MiskiewiczNew Issue ====================================================================== From mantis at public.kitware.com Fri Nov 21 08:10:49 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Fri, 21 Nov 2014 08:10:49 -0500 Subject: [cmake-developers] [CMake 0015259]: Source file properties are lost, if the name of the file is not specified case sensitive. Message-ID: <182c6f800bcb688000ca01b0c5e01065@www.cmake.org> The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15259 ====================================================================== Reported By: Alexander Markert Assigned To: ====================================================================== Project: CMake Issue ID: 15259 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-21 08:10 EST Last Modified: 2014-11-21 08:10 EST ====================================================================== Summary: Source file properties are lost, if the name of the file is not specified case sensitive. Description: If you add a source file and the file name is not specified case sensitive, then CMake corrects the name - that is ok. But if you specify additional properties for the file via SET_SOURCE_FILES_PROPERTIES, the settings are lost! This is only true for CMake 3.1.0, CMake 3.0.2 worked fine. Steps to Reproduce: Add a source file with a name, which is not case sensitive and set an additional propery via SET_SOURCE_FILES_PROPERTIES. Example of CMakeLists.txt: # Name is actually WarningsAsError.cpp, but warningaserror.cpp is used SET(FileWarningAsError warningaserror.cpp) SET(Files main.cpp ${FileWarningAsError}) # option /WX is lost SET_SOURCE_FILES_PROPERTIES(${FileWarningAsError} PROPERTIES COMPILE_FLAGS "/WX") ADD_EXECUTABLE(CaseInsensitive ${Files}) Additional Information: Please find attached a configuration file and a batch file, which generated the given projects with CMake 3.1.0 and CMake 3.0.2. The paths to CMake have to be adjusted in CallCMake.bat. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-21 08:10 Alexander MarkertNew Issue 2014-11-21 08:10 Alexander MarkertFile Added: DummyProject.7z ====================================================================== From alinm.elena at gmail.com Fri Nov 21 11:37:50 2014 From: alinm.elena at gmail.com (Alin Marin Elena) Date: Fri, 21 Nov 2014 16:37:50 +0000 Subject: [cmake-developers] FindOpenMP and gfortran In-Reply-To: <546DF67B.2010601@kitware.com> References: <546DEC8B.7060100@gmail.com> <546DED55.1030702@kitware.com> <546DF341.5060206@gmail.com> <546DF67B.2010601@kitware.com> Message-ID: Hi, I have applied the patch on top of the official rc2 tar ball, rebuild the rpm and everything works as expected! Thanks Alin Without Questions there are no Answers! ______________________________________________________________________ Dr. Alin Marin ELENA http://alin.elenaworld.net/ ______________________________________________________________________ On 20 November 2014 14:11, Brad King wrote: > On 11/20/2014 8:57 AM, Nils Gladitz wrote: >> Thanks, done. >> >> @Alin I hope you don't mind that I took the liberty :) > > Alin, the commit is here: > > FindOpenMP: Use fixed form Fortran test program > http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7d633ebf > > Please try it out so we know it fixes your use case. > > Thanks, > -Brad From chuck.atkins at kitware.com Fri Nov 21 14:59:38 2014 From: chuck.atkins at kitware.com (Chuck Atkins) Date: Fri, 21 Nov 2014 14:59:38 -0500 Subject: [cmake-developers] [PATCH] New module FindLibDl In-Reply-To: <20141119195325.GQ1657@codelibre.net> References: <20141119192333.GP1657@codelibre.net> <546CF119.3020600@gmail.com> <20141119195325.GQ1657@codelibre.net> Message-ID: Hi Roger, > However, do I still need to independently check for ? How do I know that I have a working dlopen? dlopen defined in dlfcn.h is part of POSIX so generally if you're on a *nix system then you can rely on it being there. The associated library, however, is a different story, hence CMAKE_DL_LIBS. So then your code would be: ----- Begin fooUnix.c ----- ... #include ... void foo() { void *dl = dlopen(...); ... } ... ----- End fooUnix.c ----- ----- Begin CMakeLists.txt ----- ... if(UNIX) add_library(FooLib fooUnix.c) if(CMAKE_DL_LIBS) target_link_libraries(FooLib ${CMAKE_DL_LIBS}) endif() endif() ... ----- End CMakeLists.txt ----- which is actually overkill since you could avoid the if(CMAKE_DL_LIBS) check entirely since passing an empty library list to target_link_libraries is still valid. - Chuck -------------- next part -------------- An HTML attachment was scrubbed... URL: From ydginster at gmail.com Fri Nov 21 16:25:13 2014 From: ydginster at gmail.com (Evgeny Kalishenko) Date: Sat, 22 Nov 2014 01:25:13 +0400 Subject: [cmake-developers] [PATCH] Preinstall requirements support for CPack RPM generator In-Reply-To: <4982937.QGZPQ7vsBa@caliban.sf-tec.de> References: <544E5CF6.6050608@kitware.com> <4982937.QGZPQ7vsBa@caliban.sf-tec.de> Message-ID: To my mind issue http://public.kitware.com/Bug/view.php?id=14769 can be resolved after the patch 2014-10-27 21:34 GMT+04:00 Rolf Eike Beer : > Am Montag, 27. Oktober 2014, 10:55:50 schrieb Brad King: > > On 10/27/2014 10:41 AM, Rolf Eike Beer wrote: > > >> if("${_RPM_SPEC_HEADER}" MATCHES "REQUIRES_PRE" OR > > >> "${_RPM_SPEC_HEADER}" MATCHES "REQUIRES_POST") > > > > > > This should really be using STREQUAL and not using dereferences on the > > > left hand side. > > > > Thanks. Actually I mentioned that in my first review in this thread > > but forgot to check that it had been resolved in updated patches. > > > > It doesn't matter though because the second commit replaces that > > line with different logic anyway. > > Why not use that logic from the beginning then? > > Eike -- ? ?????????, ??????? ????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.boeckel at kitware.com Sat Nov 22 11:16:59 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Sat, 22 Nov 2014 11:16:59 -0500 Subject: [cmake-developers] New RelWithDebInfo flags? Message-ID: <20141122161659.GA23646@bronto-burt.dev.benboeckel.net> Hi, I just discovered today that it looks like GCC 4.8 shipped with a new optimization level: -Og Optimize debugging experience. -Og enables optimizations that do not interfere with debugging. It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience. Would using this (if available) rather than -O2 in RelWithDebInfo configurations be something developers would want? Mailing list thread about the patch: https://gcc.gnu.org/ml/gcc-patches/2012-09/msg00097.html Thanks, --Ben From clinton at elemtech.com Sat Nov 22 12:12:22 2014 From: clinton at elemtech.com (clinton at elemtech.com) Date: Sat, 22 Nov 2014 10:12:22 -0700 (MST) Subject: [cmake-developers] New RelWithDebInfo flags? In-Reply-To: <20141122161659.GA23646@bronto-burt.dev.benboeckel.net> References: <20141122161659.GA23646@bronto-burt.dev.benboeckel.net> Message-ID: <405778741.265268.1416676342982.JavaMail.zimbra@elemtech.com> ----- Original Message ----- > Hi, > > I just discovered today that it looks like GCC 4.8 shipped with a new > optimization level: > > -Og Optimize debugging experience. -Og enables optimizations that do > not interfere with debugging. It should be the optimization level > of choice for the standard edit-compile-debug cycle, offering a > reasonable level of optimization while maintaining fast > compilation and a good debugging experience. > > Would using this (if available) rather than -O2 in RelWithDebInfo > configurations be something developers would want? > > Mailing list thread about the patch: > > https://gcc.gnu.org/ml/gcc-patches/2012-09/msg00097.html Perhaps not if people are using that configuration to build release binaries and stripping debug symbols from it. In my opinion, it *does* interfere with debugging, because of optimization done on stack variables. You may or may not be able to see their value at certain times. Its annoying enough that I go back to not having -Og for development, and have a separate build directory if I want optimization. The program flow while debugging is uninterrupted though, which is nice. Clint From ben.boeckel at kitware.com Sat Nov 22 13:20:16 2014 From: ben.boeckel at kitware.com (Ben Boeckel) Date: Sat, 22 Nov 2014 13:20:16 -0500 Subject: [cmake-developers] New RelWithDebInfo flags? In-Reply-To: <405778741.265268.1416676342982.JavaMail.zimbra@elemtech.com> References: <20141122161659.GA23646@bronto-burt.dev.benboeckel.net> <405778741.265268.1416676342982.JavaMail.zimbra@elemtech.com> Message-ID: <20141122182016.GA28929@bronto-burt.dev.benboeckel.net> On Sat, Nov 22, 2014 at 10:12:22 -0700, clinton at elemtech.com wrote: > Perhaps not if people are using that configuration to build release > binaries and stripping debug symbols from it. Ah, true. Maybe it would be better for Debug than RelWithDebInfo? > In my opinion, it *does* interfere with debugging, because of > optimization done on stack variables. You may or may not be able to > see their value at certain times. Its annoying enough that I go back > to not having -Og for development, and have a separate build directory > if I want optimization. Hrm. That's unfortunate. That's usually where my issues come in (though you can sometimes get their values by walking up or down the stack looking for unoptimized values which become those stack variables. > The program flow while debugging is uninterrupted though, which is > nice. Yeah, 'n' being unpredictable is annoying. Too easy to accidentally skip the important bits :( . --Ben From maikzimmermann5 at gmail.com Sun Nov 23 09:02:15 2014 From: maikzimmermann5 at gmail.com (Maik Zimmermann) Date: Sun, 23 Nov 2014 15:02:15 +0100 Subject: [cmake-developers] compile error in master using mingw-w64 Message-ID: Hi, the current master does not compile using the mingw-w64 toolchain (gcc version 4.6.3). Note that v3.1.0-rc2 is not affected by this. Here is the error: [333/454] Building CXX object Source/C...Lib.dir/cmGlobalNinjaGenerator.cxx.obj FAILED: C:\Development\MinGW64\bin\c++.exe -DCMAKE_BUILD_WITH_CMAKE -DCURL_STA TICLIB -DLIBARCHIVE_STATIC -DUNICODE -D_UNICODE -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W -Wshadow -Wpointer-arith -Wformat-security -Wundef -O 3 -DNDEBUG -IUtilities -IC:/Projects/cmake/cmake/Utilities -ISource -IC:/Project s/cmake/cmake/Source -IUtilities/cmcompress -IC:/Projects/cmake/cmake/Source/CTe st -MMD -MT Source/CMakeFiles/CMakeLib.dir/cmGlobalNinjaGenerator.cxx.obj -MF So urce/CMakeFiles/CMakeLib.dir/cmGlobalNinjaGenerator.cxx.obj.d -o Source/CMakeFil es/CMakeLib.dir/cmGlobalNinjaGenerator.cxx.obj -c C:/Projects/cmake/cmake/Source /cmGlobalNinjaGenerator.cxx In file included from C:/Projects/cmake/cmake/Source/cmGlobalNinjaGenerator.cxx: 14:0: C:/Projects/cmake/cmake/Source/cmGeneratorExpressionEvaluationFile.h:39:64: erro r: 'mode_t' has not been declared I bisected it to : commit 81afbbc09bac6913e2b83f7eb68923ff5b1911d5 Author: Stephen Kelly Date: Tue Jul 22 15:10:57 2014 +0200 file(GENERATE): Use permissions of input file if present. The patch attache fixes the error for me, but I'm not sure if this is the right way to fix it. I noted that the mingw build on the dashboard are not failing. MinGW seems to define mode_t in either fcntl.h or sys/types.h, depending on the version. So the correct thing to do might be to check for the correct header to include. If you want me to do this, I can have a look at this during the next week. Thanks, Maik Zimmermann -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-mode_t-not-defined-using-mingw-toolchain.patch Type: application/octet-stream Size: 692 bytes Desc: not available URL: From mantis at public.kitware.com Sun Nov 23 13:30:07 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Sun, 23 Nov 2014 13:30:07 -0500 Subject: [cmake-developers] [CMake 0015260]: Compilation error for cmake-3.1.0-rc2 with gcc-4.8.2 Message-ID: <0403c89c5dde2f807010844bc1523e77@public.kitware.com> The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15260 ====================================================================== Reported By: szukw000 Assigned To: ====================================================================== Project: CMake Issue ID: 15260 Category: (No Category) Reproducibility: have not tried Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-23 13:30 EST Last Modified: 2014-11-23 13:30 EST ====================================================================== Summary: Compilation error for cmake-3.1.0-rc2 with gcc-4.8.2 Description: LINUX, gcc-4.8.2 ================== /sources/CMAKE/cmake-3.1.0-rc2/Source/cmArchiveWrite.cxx: In function 'void cm_archive_entry_copy_sourcepath(archive_entry*, const string&)': /sources/CMAKE/cmake-3.1.0-rc2/Source/cmArchiveWrite.cxx:43:75: error: 'archive_entry_copy_sourcepath_w' was not declared in this scope archive_entry_copy_sourcepath_w(e, cmsys::Encoding::ToWide(file).c_str()); ^ /sources/CMAKE/cmake-3.1.0-rc2/Source/cmArchiveWrite.cxx: In constructor 'cmArchiveWrite::cmArchiveWrite(std::ostream&, cmArchiveWrite::Compress, cmArchiveWrite::Type)': /sources/CMAKE/cmake-3.1.0-rc2/Source/cmArchiveWrite.cxx:164:53: error: 'archive_write_set_format_7zip' was not declared in this scope if(archive_write_set_format_7zip(this->Archive) != ARCHIVE_OK) ^ make[2]: *** [Source/CMakeFiles/CMakeLib.dir/cmArchiveWrite.cxx.o] Error 1 make[1]: *** [Source/CMakeFiles/CMakeLib.dir/all] Error 2 make: *** [all] Error 2 winfried ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-23 13:30 szukw000 New Issue ====================================================================== From mantis at public.kitware.com Mon Nov 24 07:58:23 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Mon, 24 Nov 2014 07:58:23 -0500 Subject: [cmake-developers] [CMake 0015261]: regex match when not matched do not clear cmake_match_0 and 1 var Message-ID: The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15261 ====================================================================== Reported By: zezadas Assigned To: ====================================================================== Project: CMake Issue ID: 15261 Category: (No Category) Reproducibility: have not tried Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-24 07:58 EST Last Modified: 2014-11-24 07:58 EST ====================================================================== Summary: regex match when not matched do not clear cmake_match_0 and 1 var Description: when regex match is not matched the var are not reseted, and keep the last value, that bug propagates to other cmake and generate bad regex match Steps to Reproduce: regex match something that exists regex match something that not exists regex match value, is the first match value Additional Information: for example compiling gwenview from kde repo, it says that jpeglib as unknown version 2060, but in this case the file it searched not matched the regexp and the 2060 is from another cmakte that match version of lcms ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-24 07:58 zezadas New Issue ====================================================================== From mantis at public.kitware.com Mon Nov 24 09:38:38 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Mon, 24 Nov 2014 09:38:38 -0500 Subject: [cmake-developers] [CMake 0015262]: Visual Studio Generators: selection of runtime Message-ID: <4e9acc481c2e0cac902cbeeebeb4256d@www.cmake.org> The following issue has been SUBMITTED. ====================================================================== https://www.cmake.org/Bug/view.php?id=15262 ====================================================================== Reported By: Daniel Franke Assigned To: ====================================================================== Project: CMake Issue ID: 15262 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-24 09:38 EST Last Modified: 2014-11-24 09:38 EST ====================================================================== Summary: Visual Studio Generators: selection of runtime Description: On Windows with Intel Fortran and QuickWin libraries: we tried to use cmake-2.8.12 to generate a VS10 project to build applications with Intel Fortran and the quickwin libraries. In order for this to work, the runtime has to be specified as "QuickWin", not the default "MultiThreadedDLL". Right now this is only possible once the project is generated, by opening VS10, manually changing the runtime, saving, then building. Obviously a big roadblock for automated builds. Browsing the cmake sources, there does not seem to be any support for changing this key parameter (see cmVisualStudioGeneratorOptions::ParseFinish in cmVisualStudioGeneratorOptions.cxx)? If this is the case, appropriate options to change the defaults by setting variables would be highly desirable. To note: google found a similar report on the cmake mailing-list, but that seemed to have gone nowhere [1]. [1] http://www.cmake.org/pipermail/cmake/2011-December/048030.html ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-24 09:38 Daniel Franke New Issue ====================================================================== From DLRdave at aol.com Mon Nov 24 13:45:08 2014 From: DLRdave at aol.com (David Cole) Date: Mon, 24 Nov 2014 13:45:08 -0500 Subject: [cmake-developers] Recent GetPrerequisites changes Message-ID: Eike, The changes you made in this commit: http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ec36e1c2afe7c8258588dd51a9fe75b7fb523206 appear to have introduced a change in behavior such that the test is running recursive dependency checks instead of just direct dependency checks. Evidence: 11/18: test passed in under 3 seconds: http://open.cdash.org/testDetails.php?test=294732956&build=3575799 updates: http://open.cdash.org/viewUpdate.php?buildid=3577230 11/19: test fails, times out after 10 minutes: http://open.cdash.org/testDetails.php?test=294964093&build=3577230 I think the root of the problem is the tests for ARGV1, ARGV2, etc. that you made are not equivalent to the previous code in the case of a nested function call: (a function calling a function ... or deeper -- weird stuff happens if you call a function with fewer than its declared arguments -- i.e. there is no ARGV2 variable within a function called with only one argument, but there may be in the parent scope if it's called from a function that does get called with 2 or more args) So.... some of the "needless" variable dereferencing you removed is actually needed. Would you mind reverting those commits, or modifying them such that the new behavior is identical to the older behavior, please? Thanks, David C. From eike at sf-mail.de Mon Nov 24 15:10:44 2014 From: eike at sf-mail.de (Rolf Eike Beer) Date: Mon, 24 Nov 2014 21:10:44 +0100 Subject: [cmake-developers] Recent GetPrerequisites changes In-Reply-To: References: Message-ID: <2418748.MLi0cKzc2Z@eto> David Cole wrote: > Eike, > > The changes you made in this commit: > > http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ec36e1c2afe7c8258588d > d51a9fe75b7fb523206 > > appear to have introduced a change in behavior such that the test is > running recursive dependency checks instead of just direct dependency > checks. > > Evidence: > 11/18: test passed in under 3 seconds: > http://open.cdash.org/testDetails.php?test=294732956&build=3575799 > updates: http://open.cdash.org/viewUpdate.php?buildid=3577230 > 11/19: test fails, times out after 10 minutes: > http://open.cdash.org/testDetails.php?test=294964093&build=3577230 > > I think the root of the problem is the tests for ARGV1, ARGV2, etc. > that you made are not equivalent to the previous code in the case of a > nested function call: (a function calling a function ... or deeper -- > weird stuff happens if you call a function with fewer than its > declared arguments -- i.e. there is no ARGV2 variable within a > function called with only one argument, but there may be in the parent > scope if it's called from a function that does get called with 2 or > more args) I remember slightly that there once was a discussion about something like that. Sounds creepy. > So.... some of the "needless" variable dereferencing you removed is > actually needed. > > Would you mind reverting those commits, or modifying them such that > the new behavior is identical to the older behavior, please? Sure. Eike -- From DLRdave at aol.com Mon Nov 24 16:04:17 2014 From: DLRdave at aol.com (David Cole) Date: Mon, 24 Nov 2014 16:04:17 -0500 Subject: [cmake-developers] Recent GetPrerequisites changes In-Reply-To: <2418748.MLi0cKzc2Z@eto> References: <2418748.MLi0cKzc2Z@eto> Message-ID: On Mon, Nov 24, 2014 at 3:10 PM, Rolf Eike Beer wrote: > David Cole wrote: >> Eike, >> >> The changes you made in this commit: >> >> http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ec36e1c2afe7c8258588d >> d51a9fe75b7fb523206 >> >> appear to have introduced a change in behavior such that the test is >> running recursive dependency checks instead of just direct dependency >> checks. >> >> Evidence: >> 11/18: test passed in under 3 seconds: >> http://open.cdash.org/testDetails.php?test=294732956&build=3575799 >> updates: http://open.cdash.org/viewUpdate.php?buildid=3577230 >> 11/19: test fails, times out after 10 minutes: >> http://open.cdash.org/testDetails.php?test=294964093&build=3577230 >> >> I think the root of the problem is the tests for ARGV1, ARGV2, etc. >> that you made are not equivalent to the previous code in the case of a >> nested function call: (a function calling a function ... or deeper -- >> weird stuff happens if you call a function with fewer than its >> declared arguments -- i.e. there is no ARGV2 variable within a >> function called with only one argument, but there may be in the parent >> scope if it's called from a function that does get called with 2 or >> more args) > > I remember slightly that there once was a discussion about something like > that. Sounds creepy. > Yes it does. I should figure it out this time and write it down somewhere... And then fix it, but probably with a policy to preserve the subtle old behavior for a while. Not sure I'll have time to tackle it any time soon. >> So.... some of the "needless" variable dereferencing you removed is >> actually needed. >> >> Would you mind reverting those commits, or modifying them such that >> the new behavior is identical to the older behavior, please? > > Sure. > Thanks a bunch. D From mantis at public.kitware.com Tue Nov 25 01:58:38 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 25 Nov 2014 01:58:38 -0500 Subject: [cmake-developers] [CMake 0015263]: FindOSG/FindOpenThreads does not work when only debug libraries are installed Message-ID: The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15263 ====================================================================== Reported By: Christian Ehrlicher Assigned To: ====================================================================== Project: CMake Issue ID: 15263 Category: Modules Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-25 01:58 EST Last Modified: 2014-11-25 01:58 EST ====================================================================== Summary: FindOSG/FindOpenThreads does not work when only debug libraries are installed Description: When only the Debug versions of OSG/OpenThreads libraries are installed, cmake is unable to find the libraries. The problem is, that Findosg_functions.cmake only add the debug library to '${module_uc}_LIBRARIES' but later on FIND_PACKAGE_HANDLE_STANDARD_ARGS() is called with '${module_uc}_LIBRARY' which is only filled when the release version of OSG is found. Simple fix: change '${module_uc}_LIBRARY' to '${module_uc}_LIBRARIES' in the FPHSA - call and all is working as expected. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-25 01:58 Christian EhrlicherNew Issue ====================================================================== From mantis at public.kitware.com Tue Nov 25 04:22:08 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Tue, 25 Nov 2014 04:22:08 -0500 Subject: [cmake-developers] [CMake 0015264]: check_cxx_compiler_flag fails to use linker flags Message-ID: <3e9a4a9f0df08ad4490642284e588bca@www.cmake.org> The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15264 ====================================================================== Reported By: Evgeniy Stepanov Assigned To: ====================================================================== Project: CMake Issue ID: 15264 Category: CMake Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-25 04:22 EST Last Modified: 2014-11-25 04:22 EST ====================================================================== Summary: check_cxx_compiler_flag fails to use linker flags Description: check_cxx_compiler_flag test compilation AND linking of a test source file, but it fails to use linker flags when doing so. In certain configurations, custom compiler flags used by the project require custom linker flags. For example, if I've got libc++ in a non-standard location, I would use CMAKE_CXX_FLAGS=-stdlib=libc++ CMAKE_EXE_LINKER_FLAGS=-L/path/to/libc++ CMAKE_MODULE_LINKER_FLAGS=-L/path/to/libc++ CMAKE_SHARED_LINKER_FLAGS=-L/path/to/libc++. In this situation, check_cxx_compiler_flag uses compiler flags, but not linker flags, which fails linking if there is no system-wide installation of libc++. See also: http://llvm.org/bugs/show_bug.cgi?id=19071 Note that there is a similar problem with the compiler test ("Check for working CXX compiler"). It uses CMAKE_CXX_FLAGS and env['LDFLAGS']. It does not use any of CMAKE_*_LINKER_FLAGS or env['CXXFLAGS']. It does not make any sense to me. Let me know if I should file it as a separate issue. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-25 04:22 Evgeniy StepanovNew Issue ====================================================================== From brad.king at kitware.com Tue Nov 25 11:41:46 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Nov 2014 11:41:46 -0500 Subject: [cmake-developers] [PATCH] New module FindLibDl In-Reply-To: References: <20141119192333.GP1657@codelibre.net> <546CF119.3020600@gmail.com> <20141119195325.GQ1657@codelibre.net> Message-ID: <5474B14A.9090909@kitware.com> On 11/21/2014 02:59 PM, Chuck Atkins wrote: > dlopen defined in dlfcn.h is part of POSIX so generally if you're > on a *nix system then you can rely on it being there. The associated > library, however, is a different story, hence CMAKE_DL_LIBS. My initial reaction to Roger's post was to say that CMAKE_DL_LIBS was created very early in CMake and I think a module like FindLibDl would supersede it. However, Chuck raises a valid point. The dlfcn.h header may be in a toolchain-defined path so "finding" it ourselves may get the wrong one. We don't have find modules for "unistd.h" for example. Perhaps it is simplest to update the documentation of CMAKE_DL_LIBS to explain this. -Brad From brad.king at kitware.com Tue Nov 25 11:50:54 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Nov 2014 11:50:54 -0500 Subject: [cmake-developers] HP-UX Curses questions In-Reply-To: References: Message-ID: <5474B36E.5040005@kitware.com> On 11/18/2014 07:23 PM, ?dne Hovda wrote: > FWIW, I have attached a small patch which adds CMAKE_USE_SYSTEM_FORM > enabling support for using libform.so as an alternative to the embedded > cmForm library. Thanks. Applied with minor tweaks: ccmake: Add CMAKE_USE_SYSTEM_FORM option to use libform instead of cmForm http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6b045c3b Please test this version. Thanks, -Brad From rleigh at codelibre.net Tue Nov 25 13:14:22 2014 From: rleigh at codelibre.net (Roger Leigh) Date: Tue, 25 Nov 2014 18:14:22 +0000 Subject: [cmake-developers] [PATCH] New module FindLibDl In-Reply-To: <5474B14A.9090909@kitware.com> References: <20141119192333.GP1657@codelibre.net> <546CF119.3020600@gmail.com> <20141119195325.GQ1657@codelibre.net> <5474B14A.9090909@kitware.com> Message-ID: <20141125181422.GZ1657@codelibre.net> On Tue, Nov 25, 2014 at 11:41:46AM -0500, Brad King wrote: > On 11/21/2014 02:59 PM, Chuck Atkins wrote: > > dlopen defined in dlfcn.h is part of POSIX so generally if you're > > on a *nix system then you can rely on it being there. The associated > > library, however, is a different story, hence CMAKE_DL_LIBS. > > My initial reaction to Roger's post was to say that CMAKE_DL_LIBS was > created very early in CMake and I think a module like FindLibDl would > supersede it. However, Chuck raises a valid point. The dlfcn.h header > may be in a toolchain-defined path so "finding" it ourselves may get > the wrong one. We don't have find modules for "unistd.h" for example. > > Perhaps it is simplest to update the documentation of CMAKE_DL_LIBS > to explain this. I don't have a problem with using CMAKE_DL_LIBS, but I am reluctant to use it unconditionally. While it's true that most current unix systems support it, looking at POSIX.1-2001 it's in XSI as an optional interface so isn't strictly guaranteed to be present. It would be really nice to have an an accompanying variable e.g. CMAKE_DL_FOUND which confirms that it's safe to use, since I can't infer this from an empty CMAKE_DL_LIBS when it's part of the standard library. It would be equally nice to know if common-but-nonstandard extensions such as dladdr(3) were safe to use. Regards, Roger -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools `- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800 From brad.king at kitware.com Tue Nov 25 13:29:22 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Nov 2014 13:29:22 -0500 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <546A8881.5050205@yahoo.com> References: <5431B11C.3010209@yahoo.com> <54665ED3.3060300@kitware.com> <54668FEC.5020203@yahoo.com> <708024991.ylpfiUSqup@caliban.sf-tec.de> <546A0F00.3090908@kitware.com> <546A8881.5050205@yahoo.com> Message-ID: <5474CA82.6090509@kitware.com> On 11/17/2014 06:45 PM, Ruslan Baratov wrote: > Done Thanks. Here are some more comments: * Please rebase on current 'master' to resolve conflicts. * The background.(bat|sh) files need to have quoting to work with spaces in the path. Please try running tests with a source/build tree with spaces. * The error messages currently use "SetError(...); return false;". That is why you need the ": " to get the prompt. Instead you can use IssueMessage as shown in the hunk below for one example. Indented lines in the message will be printed as preformatted blocks so you do not have to worry about variations in the line wrapping of expected test output. * Please use shorter timeouts in the test if possible to make it run faster. If they become spurious/problematic then we can lengthen them later. * Instead of background scripts, can you have a parent process take a lock, run a child with a timed out lock, and then release the lock? Then the timeout can be just 0.1s in the child and there is no race. Thanks, -Brad diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 8e63892..fb64b5a 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3679,10 +3679,10 @@ bool cmFileCommand::HandleLockCommand( if (resultVariable.empty() && !fileLockResult.IsOk()) { cmOStringStream e; - e << ": error locking file \"" << path << "\" (" << result << ")."; - this->SetError(e.str()); + e << "error locking file\n " << path << "\n(" << result << ")."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); cmSystemTools::SetFatalErrorOccured(); - return false; + return true; } if (!resultVariable.empty()) From brad.king at kitware.com Tue Nov 25 14:39:05 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Nov 2014 14:39:05 -0500 Subject: [cmake-developers] compile error in master using mingw-w64 In-Reply-To: References: Message-ID: <5474DAD9.4000609@kitware.com> On 11/23/2014 09:02 AM, Maik Zimmermann wrote: > I noted that the mingw build on the dashboard are not failing. It is likely specific to the 64-bit version. Would you be able to run a nightly build for mingw-w64? Instructions are here: http://www.cmake.org/Wiki/CMake/Git/Dashboard > MinGW seems to define mode_t in either fcntl.h or sys/types.h IIRC, POSIX says sys/types.h defines mode_t. We include sys/types.h unconditionally already in some other sources, so try adding that to cmStandardIncludes.h. It can go just above the #include line. Thanks, -Brad From brad.king at kitware.com Tue Nov 25 14:49:15 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Nov 2014 14:49:15 -0500 Subject: [cmake-developers] [PATCH v5 0/4] Add continue keyword In-Reply-To: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> References: <1416324872-54012-1-git-send-email-gjasny@googlemail.com> Message-ID: <5474DD3B.8000007@kitware.com> On 11/18/2014 10:34 AM, Gregor Jasny wrote: > Changes compared to v4: > * Use new style error reporting in cmContinueCommand.cxx > * Reject any given arguments to continue() > * CMP0055: Reject any arguments to break, too. > > I put both checks: the loop block check and the empty arguments > check into the same policy. Please drop me a note if you want to > have an extra policy per check. Looks good. I factored out the 'RunCMake.return' test into its own commit: return: Add test for returning inside a foreach loop http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d124c411 Then I reordered the changes to add the break() policy first: Track nested loop levels in CMake language with a stack of counters http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bae604d9 break: Add policy CMP0055 to check calls strictly http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d54617d0 I took the liberty to preserve your sign-off lines even though they are no longer exactly what you sent. Let me know if I should drop them or if you still sign off the new commits. The remaining changes are in the attached patch. It applies based on the above-linked commit d54617d0. Please revise it to add more context to the -stderr.txt files in the expected test output. See the hunk below as an example. All the other RunCMake tests that check errors like this have context too. Thanks, -Brad $ git diff |cat diff --git a/Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt b/Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt index d968a62..66be462 100644 --- a/Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt +++ b/Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt @@ -1 +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\) -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-continue-Add-a-new-CMake-language-command-for-loop-c.patch Type: text/x-diff Size: 19023 bytes Desc: not available URL: From brad.king at kitware.com Tue Nov 25 15:06:10 2014 From: brad.king at kitware.com (Brad King) Date: Tue, 25 Nov 2014 15:06:10 -0500 Subject: [cmake-developers] Initial Attempt at Green Hill MULTI IDE Generator Support In-Reply-To: References: <0543633b28c7431f93808182fc1e26e1@CO1PR07MB208.namprd07.prod.outlook.com> <543D2BBC.1010306@kitware.com> <0b5b33c4d1f0472782e260f9e5bce980@CO1PR07MB208.namprd07.prod.outlook.com> <544E4C9F.3050408@kitware.com> <64abd7ba273245b686146aa67acb7e8a@DM2PR0701MB1020.namprd07.prod.outlook.com> <545A7C44.6040305@kitware.com> Message-ID: <5474E132.2010705@kitware.com> On 11/17/2014 05:16 PM, Geoffrey Viola wrote: > I made some changes and rebased on the trunk. Thanks. Here are a few minor comments: * The hunk in Modules/CMakeDetermineCompilerId.cmake is now just a whitespace change, so please drop it. * Please ensure C++ sources do not have lines exceeding 79 columns. * Please avoid trailing whitespace on source lines. Next we need to add tests. Since CMake won't build with this generator we need to add tests using the generator as part of the test suite when the needed tools are available. Look in Tests/CMakeLists.txt for uses of add_test_VSWinStorePhone as an example of how this is done for another target platform. You can either add a new test directory with dedicated code covering capabilities of the generator, or re-use some of the existing tests to see if they build under the new generator, or both. Once you get tests working, please look at submitting an experimental build to our dashboard and posting a link to it. You can do that from the build tree of CMake with ctest -C Debug -D Experimental (or with whatever configuration you built locally). Thanks, -Brad From ruslan_baratov at yahoo.com Tue Nov 25 18:24:35 2014 From: ruslan_baratov at yahoo.com (Ruslan Baratov) Date: Wed, 26 Nov 2014 02:24:35 +0300 Subject: [cmake-developers] New command 'file(LOCK_DIRECTORY ...)' In-Reply-To: <5474CA82.6090509@kitware.com> References: <5431B11C.3010209@yahoo.com> <54665ED3.3060300@kitware.com> <54668FEC.5020203@yahoo.com> <708024991.ylpfiUSqup@caliban.sf-tec.de> <546A0F00.3090908@kitware.com> <546A8881.5050205@yahoo.com> <5474CA82.6090509@kitware.com> Message-ID: <54750FB3.6080903@yahoo.com> On 25-Nov-14 21:29, Brad King wrote: > * The background.(bat|sh) files need to have quoting to work with > spaces in the path. Please try running tests with a source/build > tree with spaces. > > * Instead of background scripts, can you have a parent process take > a lock, run a child with a timed out lock, and then release the > lock? Test updated, no need to use 'background.*' scripts indeed. > * The error messages currently use "SetError(...); return false;". > That is why you need the ": " to get the prompt. Instead you can > use IssueMessage as shown in the hunk below for one example. 's,SetError,IssueMessage,g' done I'm not quite sure about when do I need to use 'return false'/'return true', so I leave 'return false' everywhere. > > > * Please use shorter timeouts in the test if possible to make it run > faster. If they become spurious/problematic then we can lengthen > them later. > > * ... Then the timeout can be just 0.1s in the child and there > is no race. I've set timeout to 1 sec (minimal unsigned integer). Ruslo. -------------- next part -------------- >From 6b874aa940a86f9a789cfae23a8c47d609587d61 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Wed, 26 Nov 2014 01:45:26 +0300 Subject: [PATCH 1/7] Add function cmSystemTools::StringToInt --- Source/cmSystemTools.cxx | 7 +++++++ Source/cmSystemTools.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index baac7b8..e247481 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2923,3 +2923,10 @@ std::vector cmSystemTools::tokenize(const std::string& str, } return tokens; } + +//---------------------------------------------------------------------------- +bool cmSystemTools::StringToInt(const char* str, int* value) { + char unused; + const int result = sscanf(str, "%d%c", value, &unused); + return (result == 1); +} 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 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 { -- 2.1.1 -------------- next part -------------- >From 569bc681c0a980b87cd94184cfb83b44122d92a0 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Wed, 26 Nov 2014 01:46:14 +0300 Subject: [PATCH 2/7] Add class cmFileLockResult --- Source/cmFileLockResult.cxx | 111 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockResult.h | 85 +++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 Source/cmFileLockResult.cxx create mode 100644 Source/cmFileLockResult.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 + +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 // 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 -- 2.1.1 -------------- next part -------------- >From 68b527c3e292a2e8ad63ec2356c3edf3b064742a Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Wed, 26 Nov 2014 01:48:12 +0300 Subject: [PATCH 3/7] Add class cmFileLock --- Source/cmFileLock.cxx | 77 +++++++++++++++++++++++++++ Source/cmFileLock.h | 74 ++++++++++++++++++++++++++ Source/cmFileLockUnix.cxx | 102 ++++++++++++++++++++++++++++++++++++ Source/cmFileLockWin32.cxx | 126 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 379 insertions(+) create mode 100644 Source/cmFileLock.cxx create mode 100644 Source/cmFileLock.h create mode 100644 Source/cmFileLockUnix.cxx create mode 100644 Source/cmFileLockWin32.cxx diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx new file mode 100644 index 0000000..f69c36a --- /dev/null +++ b/Source/cmFileLock.cxx @@ -0,0 +1,77 @@ +/*============================================================================ + 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 +#include "cmFileLockResult.h" + +// Common implementation + +cmFileLock::~cmFileLock() +{ + if (!this->Filename.empty()) + { + const cmFileLockResult result = this->Release(); + 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(-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..7c2803b --- /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 // HANDLE +#endif + +class cmFileLockResult; + +/** + * @brief Cross-platform file locking. + * @detail 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. + * @detail 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/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx new file mode 100644 index 0000000..3c01da8 --- /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 +#include // SEEK_SET +#include +#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 != 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 = 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 // 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(-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(-1); + static OVERLAPPED overlapped; + return LockFileEx( + this->File, + flags, + reserved, + len, + len, + &overlapped + ); +} -- 2.1.1 -------------- next part -------------- >From 7a82d57372450fdf8de5b8f339596a60618ec635 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Wed, 26 Nov 2014 01:48:37 +0300 Subject: [PATCH 4/7] Add class cmFileLockPool --- Source/cmFileLockPool.cxx | 198 ++++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileLockPool.h | 100 +++++++++++++++++++++++ 2 files changed, 298 insertions(+) create mode 100644 Source/cmFileLockPool.cxx create mode 100644 Source/cmFileLockPool.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 + +#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 List; + typedef List::iterator It; + typedef List::const_iterator CIt; + + List Locks; + }; + + typedef std::list List; + + typedef List::iterator It; + typedef List::const_iterator CIt; + + List FunctionScopes; + List FileScopes; + ScopePool ProcessScope; +}; + +#endif // cmFileLockPool_h -- 2.1.1 -------------- next part -------------- >From 38e149c68a538dfeb1dbe6760fa4bcd351685cf0 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Wed, 26 Nov 2014 01:49:25 +0300 Subject: [PATCH 5/7] New command 'file(LOCK ...)' --- Source/CMakeLists.txt | 6 ++ Source/cmFileCommand.cxx | 203 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmFileCommand.h | 1 + Source/cmGlobalGenerator.h | 10 +++ Source/cmLocalGenerator.cxx | 6 ++ Source/cmMakefile.cxx | 8 ++ 6 files changed, 234 insertions(+) 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/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 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(-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(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(args); + this->SetError("sub-command LOCK not implemented in bootstrap cmake"); + return false; +#endif +} + +//---------------------------------------------------------------------------- bool cmFileCommand::HandleTimestampCommand( std::vector 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 const& args); bool HandleGenerateCommand(std::vector const& args); + bool HandleLockCommand(std::vector const& args); private: void AddEvaluationFile(const std::string &inputName, 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 #endif @@ -348,6 +349,10 @@ public: std::set 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 > FilenameTargetDepends; + +#if defined(CMAKE_BUILD_WITH_CMAKE) + // Pool of file locks + cmFileLockPool FileLockPool; +#endif }; #endif 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 61807b2..a72d410 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4487,6 +4487,10 @@ void cmMakefile::PushScope() this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PushFunctionScope(); +#endif } void cmMakefile::PopScope() @@ -4524,6 +4528,10 @@ void cmMakefile::PopScope() { this->Internal->VarUsageStack.top().insert(*it); } +#if defined(CMAKE_BUILD_WITH_CMAKE) + this->GetLocalGenerator()->GetGlobalGenerator()-> + GetFileLockPool().PopFunctionScope(); +#endif } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) -- 2.1.1 -------------- next part -------------- >From 46183c9a6f2eb4bdc2ca9fe8caf646eb62ac91b7 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Wed, 26 Nov 2014 01:50:01 +0300 Subject: [PATCH 6/7] Update documentation of command file (LOCK option) --- Help/command/file.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 [DIRECTORY] [RELEASE] + [GUARD ] + [RESULT_VARIABLE ] + [TIMEOUT ]) + +Lock a file specified by ```` if no ``DIRECTORY`` option present and file +``/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 ```` value. Any errors will be interpreted as fatal if there is no +``RESULT_VARIABLE`` option. Otherwise result will be stored in ```` +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. -- 2.1.1 -------------- next part -------------- >From be707b2971e96b8597e1bc742dfbfeb0a09b491a Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Wed, 26 Nov 2014 01:51:29 +0300 Subject: [PATCH 7/7] Add tests for command 'file(LOCK ...)' --- .../file/LOCK-error-file-create-fail-result.txt | 1 + .../file/LOCK-error-file-create-fail-stderr.txt | 8 +++++ .../file/LOCK-error-file-create-fail.cmake | 3 ++ .../file/LOCK-error-guard-incorrect-result.txt | 1 + .../file/LOCK-error-guard-incorrect-stderr.txt | 6 ++++ .../RunCMake/file/LOCK-error-guard-incorrect.cmake | 1 + .../file/LOCK-error-incorrect-timeout-result.txt | 1 + .../file/LOCK-error-incorrect-timeout-stderr.txt | 4 +++ .../LOCK-error-incorrect-timeout-trail-result.txt | 1 + .../LOCK-error-incorrect-timeout-trail-stderr.txt | 4 +++ .../file/LOCK-error-incorrect-timeout-trail.cmake | 1 + .../file/LOCK-error-incorrect-timeout.cmake | 1 + .../RunCMake/file/LOCK-error-lock-fail-result.txt | 1 + .../RunCMake/file/LOCK-error-lock-fail-stderr.txt | 6 ++++ Tests/RunCMake/file/LOCK-error-lock-fail.cmake | 6 ++++ .../file/LOCK-error-negative-timeout-result.txt | 1 + .../file/LOCK-error-negative-timeout-stderr.txt | 4 +++ .../file/LOCK-error-negative-timeout.cmake | 1 + .../file/LOCK-error-no-function-result.txt | 1 + .../file/LOCK-error-no-function-stderr.txt | 8 +++++ Tests/RunCMake/file/LOCK-error-no-function.cmake | 1 + Tests/RunCMake/file/LOCK-error-no-guard-result.txt | 1 + Tests/RunCMake/file/LOCK-error-no-guard-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-no-guard.cmake | 1 + Tests/RunCMake/file/LOCK-error-no-path-result.txt | 1 + Tests/RunCMake/file/LOCK-error-no-path-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-no-path.cmake | 1 + .../file/LOCK-error-no-result-variable-result.txt | 1 + .../file/LOCK-error-no-result-variable-stderr.txt | 4 +++ .../file/LOCK-error-no-result-variable.cmake | 1 + .../RunCMake/file/LOCK-error-no-timeout-result.txt | 1 + .../RunCMake/file/LOCK-error-no-timeout-stderr.txt | 4 +++ Tests/RunCMake/file/LOCK-error-no-timeout.cmake | 1 + Tests/RunCMake/file/LOCK-error-timeout-result.txt | 1 + Tests/RunCMake/file/LOCK-error-timeout-stderr.txt | 14 ++++++++ Tests/RunCMake/file/LOCK-error-timeout-stdout.txt | 1 + Tests/RunCMake/file/LOCK-error-timeout.cmake | 17 +++++++++ .../file/LOCK-error-unknown-option-result.txt | 1 + .../file/LOCK-error-unknown-option-stderr.txt | 6 ++++ .../RunCMake/file/LOCK-error-unknown-option.cmake | 1 + Tests/RunCMake/file/LOCK-stdout.txt | 11 ++++++ Tests/RunCMake/file/LOCK.cmake | 40 ++++++++++++++++++++++ Tests/RunCMake/file/RunCMakeTest.cmake | 14 ++++++++ .../file/subdir_test_unlock/CMakeLists.txt | 2 ++ Tests/RunCMake/file/timeout-script.cmake | 5 +++ 45 files changed, 198 insertions(+) create mode 100644 Tests/RunCMake/file/LOCK-error-file-create-fail-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-file-create-fail-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-file-create-fail.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-guard-incorrect-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-guard-incorrect-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-guard-incorrect.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout-trail.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-incorrect-timeout.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-lock-fail.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-negative-timeout-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-negative-timeout-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-negative-timeout.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-function-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-function-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-function.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-guard-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-guard-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-guard.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-path-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-path-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-path.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-result-variable-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-result-variable-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-result-variable.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-no-timeout-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-timeout-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-no-timeout.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-timeout-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-timeout-stderr.txt create mode 100755 Tests/RunCMake/file/LOCK-error-timeout-stdout.txt create mode 100644 Tests/RunCMake/file/LOCK-error-timeout.cmake create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option-result.txt create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option-stderr.txt create mode 100644 Tests/RunCMake/file/LOCK-error-unknown-option.cmake create mode 100644 Tests/RunCMake/file/LOCK-stdout.txt create mode 100644 Tests/RunCMake/file/LOCK.cmake create mode 100644 Tests/RunCMake/file/subdir_test_unlock/CMakeLists.txt create mode 100755 Tests/RunCMake/file/timeout-script.cmake 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..1eaa9e9 --- /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..f659ec9 --- /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..914ae0c --- /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..6253c5d --- /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..47008ad --- /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..6d984d3 --- /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..f6ad76f --- /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..7407b6c --- /dev/null +++ b/Tests/RunCMake/file/LOCK-error-timeout-stderr.txt @@ -0,0 +1,14 @@ +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 100755 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..d126d39 --- /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 100755 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) -- 2.1.1 From christopher at gittner.org Wed Nov 26 04:47:34 2014 From: christopher at gittner.org (Christopher Gittner) Date: Wed, 26 Nov 2014 09:47:34 +0000 Subject: [cmake-developers] [PATCH] Add wxWidgets Version 3.0.1 and 3.0.2 Message-ID: <5475A1AB.9030003@gittner.org> Hi, this patch adds Versions 3.0.1 and 3.0.2 to the FindwxWidgets Module Best regards Christopher Gittner -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Add-wxWidgets-Versions-3.0.1-3.0.2.patch Type: text/x-patch Size: 711 bytes Desc: not available URL: From oliver.steven at gmail.com Wed Nov 26 09:39:27 2014 From: oliver.steven at gmail.com (Steven Oliver) Date: Wed, 26 Nov 2014 09:39:27 -0500 Subject: [cmake-developers] Patch for FindIconv support Message-ID: Hello everyone, This is my first post to this mailing list. So don't rail me too hard if my patch is way off base. The patch is attached. I actually wrote it quite a while ago but never got around to submitting it. Please take a good look at it and let me know what issues you see with it. Thank you, Steven N. Oliver -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Add-new-FindIconv-module.patch Type: application/octet-stream Size: 1977 bytes Desc: not available URL: From brad.king at kitware.com Wed Nov 26 10:17:33 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 26 Nov 2014 10:17:33 -0500 Subject: [cmake-developers] [PATCH] Add wxWidgets Version 3.0.1 and 3.0.2 In-Reply-To: <5475A1AB.9030003@gittner.org> References: <5475A1AB.9030003@gittner.org> Message-ID: <5475EF0D.3080104@kitware.com> On 11/26/2014 4:47 AM, Christopher Gittner wrote: > this patch adds Versions 3.0.1 and 3.0.2 to the FindwxWidgets Module Applied: FindwxWidgets: Add versions 3.0.1 and 3.0.2 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=75dee2f2 Thanks, -Brad From brad.king at kitware.com Wed Nov 26 10:26:44 2014 From: brad.king at kitware.com (Brad King) Date: Wed, 26 Nov 2014 10:26:44 -0500 Subject: [cmake-developers] Patch for FindIconv support In-Reply-To: References: Message-ID: <5475F134.6030809@kitware.com> On 11/26/2014 9:39 AM, Steven Oliver wrote: > The patch is attached. I actually wrote it quite a while ago but never > got around to submitting it. Please take a good look at it and let me > know what issues you see with it. Thanks for working on this! Here are some comments: * Please read the cmake-developer(7) manual section on modules: http://www.cmake.org/cmake/help/v3.1/manual/cmake-developer.7.html#modules * The documentation needs to be updated to the reStructuredText system. See the man page for details. * The find_library cache entry should be ICONV_LIBRARY, but may the be copied to ICONV_LIBRARIES for consumption by callers. See the man page section on standard variable names. * The CMAKE_REQUIRED_ variable settings around the check code should be saved and restored in case the calling project is accumulating them. * Does the ICONV_SECOND_ARGUMENT_IS_CONST check code actually fail to compile when the second argument is not const? Some C compilers may just warn about the incompatible pointer type but still work. * Please avoid trailing whitespace on lines. Thanks, -Brad From mantis at public.kitware.com Wed Nov 26 17:18:11 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Wed, 26 Nov 2014 17:18:11 -0500 Subject: [cmake-developers] [CMake 0015266]: GET_PROPERTY and SET_PROPERTY need update for installed file properties Message-ID: The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15266 ====================================================================== Reported By: David Golub Assigned To: ====================================================================== Project: CMake Issue ID: 15266 Category: Documentation Reproducibility: N/A Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-26 17:18 EST Last Modified: 2014-11-26 17:18 EST ====================================================================== Summary: GET_PROPERTY and SET_PROPERTY need update for installed file properties Description: CMake 3.1 adds properties for installed files, which appear to be manipulable using GET_PROPERTY(INSTALL) and SET_PROPERTY(INSTALL). However, the documentation for GET_PROPERTY and SET_PROPERTY has not been updated to reflect the new property type. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-26 17:18 David Golub New Issue ====================================================================== From cld72 at cornell.edu Wed Nov 26 23:32:15 2014 From: cld72 at cornell.edu (Christopher Dembia) Date: Wed, 26 Nov 2014 20:32:15 -0800 Subject: [cmake-developers] Fix man page description for ctest -j Message-ID: -------------- next part -------------- A non-text attachment was scrubbed... Name: ctest-parallel-man.patch Type: text/x-patch Size: 794 bytes Desc: not available URL: From petteri.lapinlampi at gmail.com Thu Nov 27 02:07:08 2014 From: petteri.lapinlampi at gmail.com (Petteri Lapinlampi) Date: Thu, 27 Nov 2014 09:07:08 +0200 Subject: [cmake-developers] Support for IAR msp430 compiler needed Message-ID: Hi, I'm trying to use CMake (v3.0.2) in a project utilizing the IAR msp430 compiler (icc430.exe). Apparently CMake does not support this compiler yet. Are there plans to add support for this compiler or any workarounds? --Petteri -------------- next part -------------- An HTML attachment was scrubbed... URL: From mantis at public.kitware.com Fri Nov 28 02:44:37 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Fri, 28 Nov 2014 02:44:37 -0500 Subject: [cmake-developers] [CMake 0015267]: FindOpenGL.cmake imported targets are broken on windows Message-ID: The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15267 ====================================================================== Reported By: Nils Gladitz Assigned To: ====================================================================== Project: CMake Issue ID: 15267 Category: Modules Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-28 02:44 EST Last Modified: 2014-11-28 02:44 EST ====================================================================== Summary: FindOpenGL.cmake imported targets are broken on windows Description: On window the OpenGL libraries are linked by library name rather than filename. For visual studio OPENGL_gl_LIBRARY is for example set to "opengl32". The IMPORTED_LOCATION of the imported target OpenGL::GL target is also set to "opengl32". Since IMPORTED_LOCATION is expected to be a path this fails with e.g. ninja at build time with: ninja: error: 'opengl32', needed by 'bin\foobar.dll', missing and no known rule to make it ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-28 02:44 Nils Gladitz New Issue ====================================================================== From hannes.mezger at ascolab.com Fri Nov 28 09:31:52 2014 From: hannes.mezger at ascolab.com (Hannes Mezger) Date: Fri, 28 Nov 2014 15:31:52 +0100 Subject: [cmake-developers] Patch for FindOpenSSL.cmake Message-ID: <54788758.8070200@ascolab.com> Hi, some applications only need the OpenSSL crypto library and want to avoid linking against the SSL library, this is currently not possible. This patch adds the variables OPENSSL_CRYPTO_LIBRARY and OPENSSL_SSL_LIBRARY which are set to the respective library; this allows to be more specific when linking against OpenSSL. Cheers, Hannes -------------- next part -------------- From 820599eda8a5a0c8a7eaa05f8e4cdf7d5819bfcf Mon Sep 17 00:00:00 2001 From: Hannes Mezger Date: Fri, 28 Nov 2014 15:21:53 +0100 Subject: [PATCH] Add variables OPENSSL_CRYPTO_LIBRARY and OPENSSL_SSL_LIBRARY Some applications only need the OpenSSL crypto library and want to avoid linking against the SSL library, this is currently not possible. This patch adds the variables OPENSSL_CRYPTO_LIBRARY and OPENSSL_SSL_LIBRARY which are set to the respective library; this allows to be more specific when linking against OpenSSL. --- Modules/FindOpenSSL.cmake | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 340b417..175ac70 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -16,10 +16,12 @@ # # :: # -# OPENSSL_FOUND - system has the OpenSSL library -# OPENSSL_INCLUDE_DIR - the OpenSSL include directory -# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL -# OPENSSL_VERSION - This is set to $major.$minor.$revision$path (eg. 0.9.8s) +# OPENSSL_FOUND - System has the OpenSSL library +# OPENSSL_INCLUDE_DIR - The OpenSSL include directory +# OPENSSL_CRYPTO_LIBRARY - The OpenSSL crypto library +# OPENSSL_SSL_LIBRARY - The OpenSSL SSL library +# OPENSSL_LIBRARIES - All OpenSSL libraries +# OPENSSL_VERSION - This is set to $major.$minor.$revision$patch (eg. 0.9.8s) #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -153,6 +155,8 @@ if(WIN32 AND NOT CYGWIN) mark_as_advanced(LIB_EAY_LIBRARY_DEBUG LIB_EAY_LIBRARY_RELEASE SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE) + set( OPENSSL_SSL_LIBRARY ${SSL_EAY_LIBRARY} ) + set( OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_LIBRARY} ) set( OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} ) elseif(MINGW) # same player, for MinGW @@ -181,6 +185,8 @@ if(WIN32 AND NOT CYGWIN) ) mark_as_advanced(SSL_EAY LIB_EAY) + set( OPENSSL_SSL_LIBRARY ${SSL_EAY} ) + set( OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} ) set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) unset(LIB_EAY_NAMES) unset(SSL_EAY_NAMES) @@ -207,6 +213,8 @@ if(WIN32 AND NOT CYGWIN) ) mark_as_advanced(SSL_EAY LIB_EAY) + set( OPENSSL_SSL_LIBRARY ${SSL_EAY} ) + set( OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} ) set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) endif() else() @@ -331,4 +339,4 @@ else () ) endif () -mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) +mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES OPENSSL_SSL_LIBRARY OPENSSL_CRYPTO_LIBRARY) -- 1.9.4.msysgit.0 From mantis at public.kitware.com Fri Nov 28 11:19:18 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Fri, 28 Nov 2014 11:19:18 -0500 Subject: [cmake-developers] [CMake 0015268]: FindOpenGL.cmake incorrectly depends on X11 on Linux Message-ID: <9df960df782144e7135246b0e149f4c4@www.cmake.org> The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15268 ====================================================================== Reported By: GreatEmerald Assigned To: ====================================================================== Project: CMake Issue ID: 15268 Category: Modules Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-28 11:19 EST Last Modified: 2014-11-28 11:19 EST ====================================================================== Summary: FindOpenGL.cmake incorrectly depends on X11 on Linux Description: Currently on Linux the FindOpenGL.cmake module includes FindX11.cmake. That is not right, because there is little reason to ever link against X11 explicitly, and the checks will outright fail on Wayland. Furthermore, having FindX11 included adds quite a bit more complexity to builds (takes more time, doesn't work if you don't have a C compiler enabled etc.), and projects can always use find_package(X11) manually if need be. Additional Information: It seems that the blanket check for X11 was added back in 2002, and didn't change much since: https://github.com/Kitware/CMake/commit/079e8469abd4a2b404fd460ff41012e8d8b6fd1d ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-28 11:19 GreatEmerald New Issue ====================================================================== From cedric.perthuis at gmail.com Fri Nov 28 18:48:57 2014 From: cedric.perthuis at gmail.com (Cedric Perthuis) Date: Fri, 28 Nov 2014 23:48:57 +0000 (UTC) Subject: [cmake-developers] Windows shader compile options References: <275c0f79a0274db39a920d60c97fa930@CY1PR0301MB0713.namprd03.prod.outlook.com> Message-ID: Gilles Khouzam writes: > > > > Hi Christopher, > ? > We added the support for shaders but have only added the basic support to include shaders. Let me check what can be done to add the other properties. > ? > ? > Gilles Khouzam > Senior Development Lead > Microsoft OSG > ? > From: cmake-developers [mailto:cmake-developers-bounces cmake.org] > On Behalf Of Christopher MaughanSent: Wednesday, September 24, 2014 05:29To: cmake-developers cmake.orgSubject: [cmake-developers] Windows shader compile options > ? > > I've been playing with the Windows shader options.? I can see that it's now possible to set the following: > > ? > > set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel) > set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_TYPE Vertex) > > > > ? > > > Which is cool, but I can't see if there's a way to specify the other options to the shader compiler, such as output header file, shader model, etc.? Is there a way to do > that, or is it a TODO? > > > > > Hi, First, thanks for adding shader support. I'd like to reiterate Christopher's request and push for entry point + shader models as the 2 most important features to add. Without configuring them, often shaders won't compile at all and will break the build. As a workardound, we can add fake empty empty main() function, but it's kind of defeating the purpose. Also, it would be nice if the Visual Studio FXCompile custom build tool had another option to compile both a Vertex and a Pixel shader from the same file. And while we're at it, this could be generalized to include as many compilation as the user wants: the FXCompile custom build tool could offer an interface to add as many { entry point, shader type } options. output format and shader model can probably be common for all the shaders in the file. We can probably use an fx target to do this, but it's not necessarily portable. Once it's available in the custom build tool, it would be great to support it in Cmake. Thanks! From cedric.perthuis at gmail.com Sat Nov 29 00:51:33 2014 From: cedric.perthuis at gmail.com (Cedric Perthuis) Date: Fri, 28 Nov 2014 21:51:33 -0800 Subject: [cmake-developers] Patch pull request: support for shader entry point and shader model for Visual Studio FXCompiler custom tool build Message-ID: Hi, I would like to suggest the following patch. It allows the user to specify the shader entry point and the shader model for a given shader source file. Currently, with cmake 3.1 rc2, if you try to add a file with the extension ".hlsl" to the list of the sources, and generate a visual studio 2013 project, it will automatically configure the shader compilation custom tool on that file and will use the Visual Studio defaults. It will rarely be a good default behavior, in particular the entry point of shaders varies a lot. Advanced project will very rarely use "main" as entry point. If the entry point is not configured properly, the shader compilation will error out, which will fail the global compilation of the project. So it's actually a pretty serious breakage. It would be better in that case, to have the option to not have the shader tool automatically configured on ".hlsl" files. For Vertex and Pixel shaders, there's also a common practice which consists in having both the vertex and the pixel shader in the same file. When users do this, they rarely use "main" as entry point, but rather things like "mainPS", "mainVS". So, here's a patch to address this. I tested it with the following: set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_MODEL 5.0) set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRY_POINT mainPS) Thanks, Cedric >From 537f8c4b1d0dbf79271a9a47363c8c395b3da249 Mon Sep 17 00:00:00 2001 From: cperthuis Date: Fri, 28 Nov 2014 21:34:22 -0800 Subject: [PATCH] added VS_SHADER_ENTRY_POINT and VS_SHADER_MODEL file properties for Visual Studio shader custom tool --- Source/cmVisualStudio10TargetGenerator.cxx | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f591fc8..2e9f108 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_ENTRY_POINT")) + { + shaderEntryPoint = se; + toolHasSettings = true; + } + // Figure out which entry point to use if any + if (const char* sm = sf->GetProperty("VS_SHADER_MODEL")) + { + shaderModel = sm; + toolHasSettings = true; + } } else if(ext == "jpg" || ext == "png") @@ -1295,7 +1309,18 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) (*this->BuildFileStream) << cmVS10EscapeXML(shaderType) << "\n"; } - + if(!shaderEntryPoint.empty()) + { + this->WriteString("", 3); + (*this->BuildFileStream) << cmVS10EscapeXML(shaderEntryPoint) + << "\n"; + } + if(!shaderModel.empty()) + { + this->WriteString("", 3); + (*this->BuildFileStream) << cmVS10EscapeXML(shaderModel) + << "\n"; + } this->WriteString("BuildFileStream) << tool << ">\n"; } -- 1.9.4.msysgit.2 -------------- next part -------------- An HTML attachment was scrubbed... URL: From gjasny at googlemail.com Sat Nov 29 11:56:17 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Sat, 29 Nov 2014 17:56:17 +0100 Subject: [cmake-developers] [PATCH v6] Add continue keyword In-Reply-To: <5474DD3B.8000007@kitware.com> References: <5474DD3B.8000007@kitware.com> Message-ID: <1417280178-28999-1-git-send-email-gjasny@googlemail.com> Hello, as requested I added more context to the -stderr.txt files. Additionally I added a continue command reference to the cmake-language spec. Thanks, Gregor Gregor Jasny (1): continue: Add a new CMake language command for loop continuation (#14013) Help/command/break.rst | 2 + Help/command/continue.rst | 12 +++++ Help/manual/cmake-commands.7.rst | 1 + Help/manual/cmake-language.7.rst | 6 ++- Help/release/dev/add-continue-command.rst | 6 +++ Source/cmBootstrapCommands1.cxx | 2 + Source/cmContinueCommand.cxx | 40 ++++++++++++++++ Source/cmContinueCommand.h | 55 ++++++++++++++++++++++ Source/cmExecutionStatus.h | 7 +++ Source/cmForEachCommand.cxx | 4 ++ Source/cmIfCommand.cxx | 5 ++ Source/cmWhileCommand.cxx | 4 ++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/continue/CMakeLists.txt | 3 ++ .../RunCMake/continue/ContinueForEachInLists.cmake | 10 ++++ Tests/RunCMake/continue/ContinueForeach-stdout.txt | 4 ++ Tests/RunCMake/continue/ContinueForeach.cmake | 8 ++++ .../continue/ContinueNestedForeach-stdout.txt | 6 +++ .../RunCMake/continue/ContinueNestedForeach.cmake | 13 +++++ Tests/RunCMake/continue/ContinueWhile-stdout.txt | 6 +++ Tests/RunCMake/continue/ContinueWhile.cmake | 10 ++++ .../continue/NoArgumentsToContinue-result.txt | 1 + .../continue/NoArgumentsToContinue-stderr.txt | 4 ++ .../RunCMake/continue/NoArgumentsToContinue.cmake | 3 ++ .../RunCMake/continue/NoEnclosingBlock-result.txt | 1 + .../RunCMake/continue/NoEnclosingBlock-stderr.txt | 5 ++ Tests/RunCMake/continue/NoEnclosingBlock.cmake | 1 + .../continue/NoEnclosingBlockInFunction-result.txt | 1 + .../continue/NoEnclosingBlockInFunction-stderr.txt | 6 +++ .../continue/NoEnclosingBlockInFunction.cmake | 8 ++++ Tests/RunCMake/continue/RunCMakeTest.cmake | 9 ++++ 31 files changed, 242 insertions(+), 2 deletions(-) create mode 100644 Help/command/continue.rst create mode 100644 Help/release/dev/add-continue-command.rst create mode 100644 Source/cmContinueCommand.cxx create mode 100644 Source/cmContinueCommand.h create mode 100644 Tests/RunCMake/continue/CMakeLists.txt create mode 100644 Tests/RunCMake/continue/ContinueForEachInLists.cmake create mode 100644 Tests/RunCMake/continue/ContinueForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueWhile-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueWhile.cmake create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue-result.txt create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction.cmake create mode 100644 Tests/RunCMake/continue/RunCMakeTest.cmake -- 1.9.3 (Apple Git-50) From gjasny at googlemail.com Sat Nov 29 11:56:18 2014 From: gjasny at googlemail.com (Gregor Jasny) Date: Sat, 29 Nov 2014 17:56:18 +0100 Subject: [cmake-developers] [PATCH v6] continue: Add a new CMake language command for loop continuation (#14013) In-Reply-To: <1417280178-28999-1-git-send-email-gjasny@googlemail.com> References: <1417280178-28999-1-git-send-email-gjasny@googlemail.com> Message-ID: <1417280178-28999-2-git-send-email-gjasny@googlemail.com> Inspired-by: Doug Barbieri Signed-off-by: Gregor Jasny --- Help/command/break.rst | 2 + Help/command/continue.rst | 12 +++++ Help/manual/cmake-commands.7.rst | 1 + Help/manual/cmake-language.7.rst | 6 ++- Help/release/dev/add-continue-command.rst | 6 +++ Source/cmBootstrapCommands1.cxx | 2 + Source/cmContinueCommand.cxx | 40 ++++++++++++++++ Source/cmContinueCommand.h | 55 ++++++++++++++++++++++ Source/cmExecutionStatus.h | 7 +++ Source/cmForEachCommand.cxx | 4 ++ Source/cmIfCommand.cxx | 5 ++ Source/cmWhileCommand.cxx | 4 ++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/continue/CMakeLists.txt | 3 ++ .../RunCMake/continue/ContinueForEachInLists.cmake | 10 ++++ Tests/RunCMake/continue/ContinueForeach-stdout.txt | 4 ++ Tests/RunCMake/continue/ContinueForeach.cmake | 8 ++++ .../continue/ContinueNestedForeach-stdout.txt | 6 +++ .../RunCMake/continue/ContinueNestedForeach.cmake | 13 +++++ Tests/RunCMake/continue/ContinueWhile-stdout.txt | 6 +++ Tests/RunCMake/continue/ContinueWhile.cmake | 10 ++++ .../continue/NoArgumentsToContinue-result.txt | 1 + .../continue/NoArgumentsToContinue-stderr.txt | 4 ++ .../RunCMake/continue/NoArgumentsToContinue.cmake | 3 ++ .../RunCMake/continue/NoEnclosingBlock-result.txt | 1 + .../RunCMake/continue/NoEnclosingBlock-stderr.txt | 5 ++ Tests/RunCMake/continue/NoEnclosingBlock.cmake | 1 + .../continue/NoEnclosingBlockInFunction-result.txt | 1 + .../continue/NoEnclosingBlockInFunction-stderr.txt | 6 +++ .../continue/NoEnclosingBlockInFunction.cmake | 8 ++++ Tests/RunCMake/continue/RunCMakeTest.cmake | 9 ++++ 31 files changed, 242 insertions(+), 2 deletions(-) create mode 100644 Help/command/continue.rst create mode 100644 Help/release/dev/add-continue-command.rst create mode 100644 Source/cmContinueCommand.cxx create mode 100644 Source/cmContinueCommand.h create mode 100644 Tests/RunCMake/continue/CMakeLists.txt create mode 100644 Tests/RunCMake/continue/ContinueForEachInLists.cmake create mode 100644 Tests/RunCMake/continue/ContinueForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueNestedForeach.cmake create mode 100644 Tests/RunCMake/continue/ContinueWhile-stdout.txt create mode 100644 Tests/RunCMake/continue/ContinueWhile.cmake create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue-result.txt create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue-stderr.txt create mode 100644 Tests/RunCMake/continue/NoArgumentsToContinue.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlock.cmake create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-result.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction-stderr.txt create mode 100644 Tests/RunCMake/continue/NoEnclosingBlockInFunction.cmake create mode 100644 Tests/RunCMake/continue/RunCMakeTest.cmake 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/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/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/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& 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..ce70dd6 --- /dev/null +++ b/Source/cmContinueCommand.cxx @@ -0,0 +1,40 @@ +/*============================================================================ + 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 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 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/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/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/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/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..66be462 --- /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) -- 1.9.3 (Apple Git-50) From mantis at public.kitware.com Sun Nov 30 11:39:26 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Sun, 30 Nov 2014 11:39:26 -0500 Subject: [cmake-developers] [CMake 0015269]: Toolchain file not loaded without C language enabled Message-ID: <91a820b274d1cc7cd01921c880e2c6a1@public.kitware.com> The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15269 ====================================================================== Reported By: David Zemon Assigned To: ====================================================================== Project: CMake Issue ID: 15269 Category: CMake Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-11-30 11:39 EST Last Modified: 2014-11-30 11:39 EST ====================================================================== Summary: Toolchain file not loaded without C language enabled Description: Problem: My toolchain file is not being loaded. Apparent Cause: Any time the C language is not enabled (by either 'project' or 'enable_langauge'). Normally, I have the toolchain file loaded with a file at the top of my root CMakeLists.txt file that reads: set(CMAKE_TOOLCHAIN_FILE ${PROPWARE_PATH}/PropellerToolchain.cmake) but in an effort to try and debug this, I've also added the definition to my command line. No change occurred. Steps to Reproduce: Reproducing the problem is straight-forward, but requires installing a toolchain as was deemed too complicated in my previous bug. For those willing to try, see instructions here: http://public.kitware.com/Bug/view.php?id=15155 I have not yet been able to reproduce this with a desktop build, but will report back if that changes. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-30 11:39 David Zemon New Issue ====================================================================== From mantis at public.kitware.com Sun Nov 30 16:18:44 2014 From: mantis at public.kitware.com (Mantis Bug Tracker) Date: Sun, 30 Nov 2014 16:18:44 -0500 Subject: [cmake-developers] [CMake 0015270]: cmake can't find Boost libs at CentOS 6 correctly Message-ID: <9b82fee4022a228dfc24b15bf32264ca@public.kitware.com> The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15270 ====================================================================== Reported By: pavel.odintsov Assigned To: ====================================================================== Project: CMake Issue ID: 15270 Category: CMake Reproducibility: always Severity: major Priority: high Status: new ====================================================================== Date Submitted: 2014-11-30 16:18 EST Last Modified: 2014-11-30 16:18 EST ====================================================================== Summary: cmake can't find Boost libs at CentOS 6 correctly Description: Hello! I tried to use find_package capability for my project: https://github.com/FastVPSEestiOu/fastnetmon/blob/master/CMakeLists.txt It work perfectly at Debian 7 Wheezy with 2.8.9-1. But I got this critical errors on CentOS 6 with modern cmake-2.8.12.2-4.el6.x86_64: cmake .. -- The C compiler identification is GNU 4.4.7 -- The CXX compiler identification is GNU 4.4.7 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done CMake Error at /usr/lib64/boost/Boost.cmake:536 (message): The imported target "boost_date_time-static" references the file "/usr/lib64/lib64/libboost_date_time.a" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib64/boost/Boost.cmake" but not all the files it references. Call Stack (most recent call first): /usr/lib64/boost/BoostConfig.cmake:28 (include) /usr/share/cmake/Modules/FindBoost.cmake:177 (find_package) CMakeLists.txt:30 (find_package) -- Configuring incomplete, errors occurred! See also "/usr/src/fastnetmon/build/CMakeFiles/CMakeOutput.log". Please help me... ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-11-30 16:18 pavel.odintsov New Issue ====================================================================== From daniele.domenichelli at gmail.com Sun Nov 30 16:38:32 2014 From: daniele.domenichelli at gmail.com (Daniele E. Domenichelli) Date: Sun, 30 Nov 2014 22:38:32 +0100 Subject: [cmake-developers] [Review request] Topic ExternalProject_TEST_EXCLUDE_FROM_MAIN Message-ID: <547B8E58.6070604@gmail.com> Hello all, Please review the topic ExternalProject_TEST_EXCLUDE_FROM_MAIN. This patch adds an TEST_EXCLUDE_FROM_MAIN option to ExternalProject_Add. If this option is enabled, the test step is created with the EXCLUDE_FROM_MAIN option, and if TEST_BEFORE_INSTALL is enabled, the install step does not depend on the test step. This means that the test step is never executed, unless the test target is explicitly created by calling ExternalProject_Add_StepTarget, or by passing it with the STEP_TARGETS option, or with the EP_STEP_TARGETS directory property. These is the only commit in the topic: * ExternalProject: Add TEST_EXCLUDE_FROM_MAIN option http://www.cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=ced29ab Cheers, Daniele