new arch
[cmake.git] / Source / cmake.h
blob9029b44179b9d4b973e29915662d6ee6c26a77d3
1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmake.h,v $
5 Language: C++
6 Date: $Date: 2002-09-06 17:03:17 $
7 Version: $Revision: 1.17 $
9 Copyright (c) 2002 Insight Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 // This class represents a cmake invocation. It is the top level class when
18 // running cmake. Most cmake based GUIS should primarily create an instance
19 // of this class and communicate with it.
21 #include "cmStandardIncludes.h"
22 #include "cmSystemTools.h"
24 class cmGlobalGenerator;
25 class cmLocalGenerator;
26 class cmCacheManager;
27 class cmMakefile;
29 class cmake
31 public:
32 ///! construct an instance of cmake
33 cmake();
34 ///! destruct an instance of cmake
35 ~cmake();
37 /**
38 * Return major and minor version numbers for cmake.
40 static unsigned int GetMajorVersion();
41 static unsigned int GetMinorVersion();
42 static const char *GetReleaseVersion();
44 //@{
45 /**
46 * Set/Get the home directory (or output directory) in the project. The
47 * home directory is the top directory of the project. It is where
48 * cmake was run. Remember that CMake processes
49 * CMakeLists files by recursing up the tree starting at the StartDirectory
50 * and going up until it reaches the HomeDirectory.
52 void SetHomeDirectory(const char* dir);
53 const char* GetHomeDirectory() const
55 return m_cmHomeDirectory.c_str();
57 void SetHomeOutputDirectory(const char* lib);
58 const char* GetHomeOutputDirectory() const
60 return m_HomeOutputDirectory.c_str();
62 //@}
64 //@{
65 /**
66 * Set/Get the start directory (or output directory). The start directory
67 * is the directory of the CMakeLists.txt file that started the current
68 * round of processing. Remember that CMake processes CMakeLists files by
69 * recursing up the tree starting at the StartDirectory and going up until
70 * it reaches the HomeDirectory.
72 void SetStartDirectory(const char* dir)
74 m_cmStartDirectory = dir;
75 cmSystemTools::ConvertToUnixSlashes(m_cmStartDirectory);
77 const char* GetStartDirectory() const
79 return m_cmStartDirectory.c_str();
81 void SetStartOutputDirectory(const char* lib)
83 m_StartOutputDirectory = lib;
84 cmSystemTools::ConvertToUnixSlashes(m_StartOutputDirectory);
86 const char* GetStartOutputDirectory() const
88 return m_StartOutputDirectory.c_str();
90 //@}
92 /**
93 * Handle a command line invocation of cmake.
95 int Run(const std::vector<std::string>&args);
97 /**
98 * Generate the SourceFilesList from the SourceLists. This should only be
99 * done once to be safe. The argument is a list of command line
100 * arguments. The first argument should be the name or full path
101 * to the command line version of cmake. For building a GUI,
102 * you would pass in the following arguments:
103 * /path/to/cmake -H/path/to/source -B/path/to/build
104 * If you only want to parse the CMakeLists.txt files,
105 * but not actually generate the makefiles, use buildMakefiles = false.
107 int Generate();
110 * Configure the cmMakefiles. This routine will create a GlobalGenerator if
111 * one has not already been set. It will then Call Configure on the
112 * GlobalGenerator. This in turn will read in an process all the CMakeList
113 * files for the tree. It will not produce any actual Makefiles, or
114 * workspaces. Generate does that. */
115 int Configure(const char *cmakeexec, const std::vector<std::string> *args = 0);
117 ///! Create a GlobalGenerator
118 cmGlobalGenerator* CreateGlobalGenerator(const char* name);
120 ///! Return the global generator assigned to this instance of cmake
121 cmGlobalGenerator* GetGlobalGenerator() { return m_GlobalGenerator; };
123 ///! Return the global generator assigned to this instance of cmake
124 void SetGlobalGenerator(cmGlobalGenerator *);
126 ///! Get the names of the current registered generators
127 void GetRegisteredGenerators(std::vector<std::string>& names);
129 ///! get the cmCachemManager used by this invocation of cmake
130 cmCacheManager *GetCacheManager() { return m_CacheManager; }
133 * Given a variable name, return its value (as a string).
135 const char* GetCacheDefinition(const char*) const;
137 /**
138 * Execute commands during the build process. Supports options such
139 * as echo, remove file etc.
141 static int CMakeCommand(std::vector<std::string>&);
144 * Is cmake in the process of a local cmake invocation. If so, we know the
145 * cache is already configured and ready to go.
147 bool GetLocal()
149 return m_Local;
152 ///! Display command line useage
153 void Usage(const char *program);
155 ///! Parse command line arguments
156 void SetArgs(const std::vector<std::string>&);
158 protected:
159 cmGlobalGenerator *m_GlobalGenerator;
160 cmCacheManager *m_CacheManager;
161 std::string m_cmHomeDirectory;
162 std::string m_HomeOutputDirectory;
163 std::string m_cmStartDirectory;
164 std::string m_StartOutputDirectory;
166 ///! Parse command line arguments that might set cache values
167 void SetCacheArgs(const std::vector<std::string>&);
169 ///! read in a cmake list file to initialize the cache
170 void ReadListFile(const char *path);
173 * Generate CMAKE_ROOT and CMAKE_COMMAND cache entries
175 int AddCMakePaths(const char *arg0);
177 ///! used by Run
178 int LocalGenerate();
180 private:
181 bool m_Verbose;
182 bool m_Local;