MantisBT - CMake
View Issue Details
0011874CMakeCMakepublic2011-02-17 01:352016-06-10 14:31
Yuchen Deng 
Kitware Robot 
normalfeaturealways
closedmoved 
Windows/UnixWindows XP SP3 / ArchLinux
 
 
0011874: If directory does not exist when use chdir command, we can auto create it.
Author: Yuchen Deng <loaden@gmail.com> 2011-02-17 14:09:41
Committer: Yuchen Deng <loaden@gmail.com> 2011-02-17 14:09:41
Parent: 8caed602080c6e052adec1d38dba8a37d3a76f58 (KWSys Nightly Date Stamp)
Child: 55846016b48bd286654ebd20d5b6f48256a2abe9 (Merge branch 'master' into loaden-master)
Branches: loaden-master, master, remotes/loaden/loaden-master
Follows: v2.8.4
Precedes:

    If directory does not exist when use chdir command, we can auto create it.
    This hack can support eclipse cdt best.
    In eclipse cdt, we usally use command like "cmake -E chdir ${ProjDirPath}/build cmake .." of a "Make Target".
    Then we can easy run cmake config.

------------------------------- Source/cmake.cxx -------------------------------
index bab0aaf..7fd191d 100644
@@ -1269,9 +1269,17 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
       std::string directory = args[2];
       if(!cmSystemTools::FileExists(directory.c_str()))
         {
- cmSystemTools::Error("Directory does not exist for chdir command: ",
+ if (cmSystemTools::MakeDirectory(directory.c_str()))
+ {
+ cmSystemTools::Message("Directory does not exist for chdir command, so auto create now: ",
+ args[2].c_str());
+ }
+ else
+ {
+ cmSystemTools::Error("Directory does not exist for chdir command: ",
                              args[2].c_str());
- return 1;
+ return 1;
+ }
         }
 
       std::string command = "\"";
Always.
None.
No tags attached.
png 2.png (22,323) 2011-04-04 19:53
https://public.kitware.com/Bug/file/3800/2.png
png
Issue History
2011-02-17 01:35Yuchen DengNew Issue
2011-03-30 01:34Yuchen DengNote Added: 0025962
2011-03-30 01:36Yuchen DengNote Edited: 0025962bug_revision_view_page.php?bugnote_id=25962#r265
2011-04-04 03:37Yuchen DengNote Added: 0026030
2011-04-04 12:57David ColeNote Added: 0026082
2011-04-04 19:53Yuchen DengNote Added: 0026090
2011-04-04 19:53Yuchen DengFile Added: 2.png
2011-04-05 15:25David ColeNote Added: 0026099
2011-04-05 15:27David ColeNote Added: 0026100
2011-04-05 21:40Yuchen DengNote Added: 0026111
2011-04-05 21:40Yuchen DengNote Added: 0026112
2011-04-05 21:41Yuchen DengNote Edited: 0026111bug_revision_view_page.php?bugnote_id=26111#r296
2011-04-06 11:22David ColeNote Added: 0026122
2011-04-07 01:26Yuchen DengNote Added: 0026128
2012-08-11 11:09David ColeStatusnew => backlog
2012-08-11 11:09David ColeNote Added: 0030248
2016-06-10 14:28Kitware RobotNote Added: 0041802
2016-06-10 14:28Kitware RobotStatusbacklog => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0025962)
Yuchen Deng   
2011-03-30 01:34   
(edited on: 2011-03-30 01:36)
[code]
      if(!cmSystemTools::FileExists(directory.c_str()))
        {
        if(cmSystemTools::MakeDirectory(directory.c_str()))
          {
          cmSystemTools::Message("Directory does not exist for chdir command, so auto create now: ",
          args[2].c_str());
          }
        else
         {
         cmSystemTools::Error("Directory does not exist for chdir command: ",
                                      args[2].c_str());
         return 1;
         }
       }
[/code]

(0026030)
Yuchen Deng   
2011-04-04 03:37   
OR, Changed:
if(!cmSystemTools::FileExists(directory.c_str()))
TO:
if(!cmSystemTools::FileExists(directory.c_str()) && !cmSystemTools::MakeDirectory(directory.c_str()))

??
(0026082)
David Cole   
2011-04-04 12:57   
We *could* do this, but should we?

I'm not convinced this is necessarily a good idea.

Do you have a use case for this, which is a compelling argument for auto-creating directories via the "cd" command...?
(0026090)
Yuchen Deng   
2011-04-04 19:53   
I am using 'Make Target' to control everything.

e.g.
----
Build = cmake -E chdir ${ProjDirPath}/Build nmake
CMake_Debug = cmake -E chdir ${ProjDirPath}/Build cmake -DCMAKE_BUILD_TYPE=Debug ..
----

When using 'cmake -E chdir ${ProjDirPath}/Build', I can using 'Out-of-source' build in Eclipse CDT.

But, If don't use chdir, It's seems no way to implemention 'Out-of-source' build.
(0026099)
David Cole   
2011-04-05 15:25   
Can you use...

    CMake_Debug = cmake -E make_directory ${ProjDirPath}/Build && cmake -E chdir ${ProjDirPath}/Build cmake -DCMAKE_BUILD_TYPE=Debug ..

...instead?
(0026100)
David Cole   
2011-04-05 15:27   
Are you aware that there are already Eclipse specific generators for CMake projects?

On Windows, the bottom of the cmake --help output is this:

  Eclipse CDT4 - MinGW Makefiles
                              = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - NMake Makefiles
                              = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Unix Makefiles
                              = Generates Eclipse CDT 4.0 project files.
(0026111)
Yuchen Deng   
2011-04-05 21:40   
(edited on: 2011-04-05 21:41)
Can you use...
    CMake_Debug = cmake -E make_directory ${ProjDirPath}/Build && cmake -E chdir ${ProjDirPath}/Build cmake -DCMAKE_BUILD_TYPE=Debug ..
...instead?
-------------
Thanks! This command can not work with CDT.

I found a way to solved it *ONLY* in Windows OS.
But it is no cross-platform.
--------
cmd /C "if not exist Build (mkdir Build && chdir Build && cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug .. && nmake) else chdir Build && cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug .. && nmake"

(0026112)
Yuchen Deng   
2011-04-05 21:40   
Are you aware that there are already Eclipse specific generators for CMake projects?
------------
Yes, I noticed it.
But it can not support MSVC in Windows.
(0026122)
David Cole   
2011-04-06 11:22   
Doesn't "Eclipse CDT4 - NMake Makefiles" mean that it will use "nmake" and "cl" ... ?
(0026128)
Yuchen Deng   
2011-04-07 01:26   
Doesn't "Eclipse CDT4 - NMake Makefiles" mean that it will use "nmake" and "cl" ... ?
--------
Oh, I don't noticed this option.
But after test and find there have some issue about this.
e.g. cl.exe can't support "Discovery Options" of CDT.
And I am using CDT8 now, seems not compatible from CDT4 to CDT8.
And seems does not look flexible.

So, I am using "NMake Makefiles" generator still.
Many thanks!
(0030248)
David Cole   
2012-08-11 11:09   
Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0041802)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.