diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2000-09-18 13:19:38 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2000-09-18 13:19:38 (GMT) |
commit | 283d3a0b734750a3bddfda9569894639571cf567 (patch) | |
tree | ac2ab120894feb883aeb5dce12a3e1af911c9bc4 | |
parent | 38f5ab8527a20caa7b7a2b867a1596ac05321e6b (diff) | |
download | CMake-283d3a0b734750a3bddfda9569894639571cf567.zip CMake-283d3a0b734750a3bddfda9569894639571cf567.tar.gz CMake-283d3a0b734750a3bddfda9569894639571cf567.tar.bz2 |
ENH: added a config setup file for CMakeSetup. Cleaned up the names of the source and binary directories
-rw-r--r-- | CMakeRules.make.in | 4 | ||||
-rw-r--r-- | CMakeVariables.make.in | 10 | ||||
-rw-r--r-- | README | 15 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeSetup.dsp | 4 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeSetup.rc | 14 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeSetupDialog.cpp | 17 | ||||
-rw-r--r-- | Source/MFCDialog/resource.h | 8 | ||||
-rw-r--r-- | Source/cmDSPMakefile.cxx | 6 | ||||
-rw-r--r-- | Source/cmDSPWriter.cxx | 6 | ||||
-rw-r--r-- | Source/cmMakeDepend.cxx | 4 | ||||
-rw-r--r-- | Source/cmUnixMakefile.cxx | 4 | ||||
-rw-r--r-- | Source/cmWindowsConfigure.cxx | 79 | ||||
-rw-r--r-- | Source/cmWindowsConfigure.h | 2 |
13 files changed, 137 insertions, 36 deletions
diff --git a/CMakeRules.make.in b/CMakeRules.make.in index 16ea523..307b9f6 100644 --- a/CMakeRules.make.in +++ b/CMakeRules.make.in @@ -6,14 +6,14 @@ # #------------------------------------------------------------------------------ # -all: CMakeTargets.make ${OBJ_SUB_DIRS} ${EXECUTABLES} ${SUBDIR_BUILD} ${BUILD_LIB_FILE} ${LOCAL_BUILD_TARGETS} ${CMAKE} +all: CMakeTargets.make ${LOCAL_BUILD_TARGETS} ${BUILD_LIB_FILE} ${EXECUTABLES} ${SUBDIR_BUILD} ${CMAKE} #------------------------------------------------------------------------------ ${CMAKE}: ${topdir}/CMake/Source/*.cxx ${topdir}/CMake/Source/*.h cd ${CMAKE_CONFIG_DIR}/CMake/Source; ${MAKE} CMakeBuildTargets -depend: ${CMAKE} +depend: ${CMAKE} ${SUBDIR_DEPEND} ${MAKE} -${MAKEFLAGS} CMakeTargets.make diff --git a/CMakeVariables.make.in b/CMakeVariables.make.in index ac81b12..1e8246b 100644 --- a/CMakeVariables.make.in +++ b/CMakeVariables.make.in @@ -3,15 +3,19 @@ # CMakeLocal.make.in should be in the directory where you run configure # in, which need not be the source directory +# The following LOCAL_* variables can be overridden in the CMakeLists.txt +# files directly, inside the VERBATIM section. However, that will +# not be used on the windows build, so keep it to unix things. +# # use this to add targets to the default all # so they are built when make is run by default -LOCAL_BUILD_TARGETS = +# LOCAL_BUILD_TARGETS = # use this flag to add -L and -l options to the link line -LOCAL_LINK_FLAGS = +# LOCAL_LINK_FLAGS = # use this flag to add -I flags to the compile line -LOCAL_INCLUDE_FLAGS = +# LOCAL_INCLUDE_FLAGS = # use this flag to add compiler options like -g -O, etc # for the "C" compiler, for gcc these default to -g -O2 @@ -1,14 +1,29 @@ CMakeLists.txt -> File in each directory that contains classes, exe, etc CMakeLists.txt contains the following: +# build targets WIN32_CLASSES = UNIX_CLASSES = ABSTRACT_CLASSES = SUBDIRS = EXECUTABLES = +# make flags +# make flags can use these varibles: +# ${CMAKE_BINARY_DIR} The root of the build tree where the binaries are +# ${CMAKE_SOURCE_ROOT} The root of the source tree where configure is +INCLUDE_DIRECTORIES = +LINK_DIRECTORIES = +LINK_LIBRARIES = # use the same name as ME = +WIN32_LIBRARIES = +UNIX_LIBRARIES = + +# name of the library to build ME = + +# add make commands BEGIN MAKE VERBATIM ... # copy stuff into CMakeTargets.make directly +LOCAL_BUILD_TARGETS = // These are done first before anything else END MAKE VERBATIM TEMPLATE_INSTANCE_DIR = diff --git a/Source/MFCDialog/CMakeSetup.dsp b/Source/MFCDialog/CMakeSetup.dsp index 8a800e0..359c315 100644 --- a/Source/MFCDialog/CMakeSetup.dsp +++ b/Source/MFCDialog/CMakeSetup.dsp @@ -144,10 +144,6 @@ SOURCE=..\cmWindowsConfigure.cxx # End Source File
# Begin Source File
-SOURCE=..\itkVC60Configure.cxx
-# End Source File
-# Begin Source File
-
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
diff --git a/Source/MFCDialog/CMakeSetup.rc b/Source/MFCDialog/CMakeSetup.rc index 14794cb..ac37e1d 100644 --- a/Source/MFCDialog/CMakeSetup.rc +++ b/Source/MFCDialog/CMakeSetup.rc @@ -95,10 +95,10 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,260,23,50,14 EDITTEXT IDC_WhereSource,13,27,135,13,ES_AUTOHSCROLL PUSHBUTTON "Browse...",IDC_BUTTON2,150,28,43,13 - LTEXT "Where is the Insight Source",IDC_STATIC,14,15,104,9 - EDITTEXT IDC_WhereBuild,16,67,133,13,ES_AUTOHSCROLL + LTEXT "Where is the source code:",IDC_STATIC,15,15,104,9 + EDITTEXT IDC_WhereBuild,14,67,133,13,ES_AUTOHSCROLL PUSHBUTTON "Browse...",IDC_BUTTON3,151,66,43,13 - LTEXT "Where do you want to build the binaries",IDC_STATIC,16, + LTEXT "Where do you want to build the binaries:",IDC_STATIC,16, 56,128,9 END @@ -161,14 +161,6 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 48 END - - IDD_CMAKESETUPDIALOG_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 313 - TOPMARGIN, 7 - BOTTOMMARGIN, 193 - END END #endif // APSTUDIO_INVOKED diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index f3dc17b..38ddb71 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -5,7 +5,7 @@ #include "CMakeSetup.h" #include "CMakeSetupDialog.h" #include "../cmDSWMakefile.h" -#include "../itkVC60Configure.h" +#include "../cmWindowsConfigure.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -227,10 +227,21 @@ void CMakeSetupDialog::OnOK() this->UpdateData(); // configure the system for VC60 - itkVC60Configure config; + cmWindowsConfigure config; config.SetWhereSource(m_WhereSource); config.SetWhereBuild(m_WhereBuild); - config.Configure(); + std::string configSrc; + configSrc = m_WhereSource; + configSrc += "/CMakeSetupConfig.MSC"; + if(!config.Configure(configSrc.c_str())) + { + std::string error = "Error: in configuring system from: "; + error += configSrc; + error += "\nProject NOT created!"; + ::MessageBox(0, error.c_str(), "config ERROR", MB_OK); + return; + } + cmDSWMakefile builder; // Set the ITK home directory diff --git a/Source/MFCDialog/resource.h b/Source/MFCDialog/resource.h index 51c21d9..0c1b2b7 100644 --- a/Source/MFCDialog/resource.h +++ b/Source/MFCDialog/resource.h @@ -1,15 +1,15 @@ //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. -// Used by pcbuilder.rc +// Used by CMakeSetup.rc // #define IDM_ABOUTBOX 0x0010 #define IDD_ABOUTBOX 100 #define IDS_ABOUTBOX 101 -#define IDD_CMakeSetupDialog_DIALOG 102 +#define IDD_CMakeSetupDialog_DIALOG 102 #define IDR_MAINFRAME 128 -#define IDC_WhereSource 1001 +#define IDC_WhereSource 1001 #define IDC_BUTTON2 1002 -#define IDC_WhereBuild 1003 +#define IDC_WhereBuild 1003 #define IDC_BUTTON3 1004 // Next default values for new objects diff --git a/Source/cmDSPMakefile.cxx b/Source/cmDSPMakefile.cxx index 34625cd..3fa6c06 100644 --- a/Source/cmDSPMakefile.cxx +++ b/Source/cmDSPMakefile.cxx @@ -21,9 +21,9 @@ void cmDSPMakefile::OutputDSPFile() for(i = includes.begin(); i != includes.end(); ++i) { std::string include = *i; - cmSystemTools::ReplaceString(include, "${CMAKE_CONFIG_DIR}", + cmSystemTools::ReplaceString(include, "${CMAKE_BINARY_DIR}", this->GetOutputHomeDirectory() ); - cmSystemTools::ReplaceString(include, "${srcdir}", + cmSystemTools::ReplaceString(include, "${CMAKE_SOURCE_ROOT}", this->GetHomeDirectory() ); m_IncludeOptions += "/I \""; m_IncludeOptions += include; @@ -48,7 +48,7 @@ void cmDSPMakefile::OutputDSPFile() { m_DebugLibraryOptions += " /LIBPATH:\""; m_DebugLibraryOptions += *i; - cmSystemTools::ReplaceString(m_DebugLibraryOptions, "${CMAKE_CONFIG_DIR}", + cmSystemTools::ReplaceString(m_DebugLibraryOptions, "${CMAKE_BINARY_DIR}", this->GetOutputHomeDirectory() ); if(i->find("Debug") == std::string::npos) { diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx index 34625cd..3fa6c06 100644 --- a/Source/cmDSPWriter.cxx +++ b/Source/cmDSPWriter.cxx @@ -21,9 +21,9 @@ void cmDSPMakefile::OutputDSPFile() for(i = includes.begin(); i != includes.end(); ++i) { std::string include = *i; - cmSystemTools::ReplaceString(include, "${CMAKE_CONFIG_DIR}", + cmSystemTools::ReplaceString(include, "${CMAKE_BINARY_DIR}", this->GetOutputHomeDirectory() ); - cmSystemTools::ReplaceString(include, "${srcdir}", + cmSystemTools::ReplaceString(include, "${CMAKE_SOURCE_ROOT}", this->GetHomeDirectory() ); m_IncludeOptions += "/I \""; m_IncludeOptions += include; @@ -48,7 +48,7 @@ void cmDSPMakefile::OutputDSPFile() { m_DebugLibraryOptions += " /LIBPATH:\""; m_DebugLibraryOptions += *i; - cmSystemTools::ReplaceString(m_DebugLibraryOptions, "${CMAKE_CONFIG_DIR}", + cmSystemTools::ReplaceString(m_DebugLibraryOptions, "${CMAKE_BINARY_DIR}", this->GetOutputHomeDirectory() ); if(i->find("Debug") == std::string::npos) { diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx index ea1e6b5..d684160 100644 --- a/Source/cmMakeDepend.cxx +++ b/Source/cmMakeDepend.cxx @@ -48,9 +48,9 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile) std::vector<std::string>::iterator j; for(j = includes.begin(); j != includes.end(); ++j) { - cmSystemTools::ReplaceString(*j, "${CMAKE_CONFIG_DIR}", + cmSystemTools::ReplaceString(*j, "${CMAKE_BINARY_DIR}", m_Makefile->GetOutputHomeDirectory() ); - cmSystemTools::ReplaceString(*j, "${srcdir}", + cmSystemTools::ReplaceString(*j, "${CMAKE_SOURCE_ROOT}", m_Makefile->GetHomeDirectory() ); this->AddSearchPath(j->c_str()); } diff --git a/Source/cmUnixMakefile.cxx b/Source/cmUnixMakefile.cxx index 83f215c..1cac1a1 100644 --- a/Source/cmUnixMakefile.cxx +++ b/Source/cmUnixMakefile.cxx @@ -1,4 +1,5 @@ #include "cmUnixMakefile.h" +#include "cmSystemTools.h" #include <fstream> #include <iostream> @@ -143,6 +144,9 @@ void cmUnixMakefile::OutputMakefile(const char* file) linkLibs += " "; } linkLibs += " ${LOCAL_LINK_FLAGS} "; + cmSystemTools::ReplaceString(linkLibs, "${CMAKE_BINARY_DIR}", + this->GetOutputHomeDirectory() ); + cout << "link libs = " << linkLibs.c_str() << endl; // Now create rules for all of the executables to be built for(int i = 0; i < m_Classes.size(); i++) { diff --git a/Source/cmWindowsConfigure.cxx b/Source/cmWindowsConfigure.cxx index 68439d9..0014265 100644 --- a/Source/cmWindowsConfigure.cxx +++ b/Source/cmWindowsConfigure.cxx @@ -1,2 +1,81 @@ #include "cmWindowsConfigure.h" +#include "cmSystemTools.h" +#include <fstream> +#include <windows.h> + + +bool cmWindowsConfigure::Configure(const char* file) +{ + std::ifstream fin(file); + if(!fin) + { + return false; + } + char inbuf[5001]; + while(fin.getline(inbuf, 5000) ) + { + std::string inputLine = inbuf; + if(inputLine[0] != '#') + { + std::string destDir; + std::string fromFile; + std::string toFile; + std::string::size_type pos = inputLine.find(':'); + if(pos != std::string::npos) + { + destDir = inputLine.substr(0, pos); + std::string::size_type nextPos = inputLine.find(':', pos+1); + if(nextPos != std::string::npos) + { + std::string toFileName = inputLine.substr(pos+1, nextPos-pos-1); + fromFile = inputLine.substr(nextPos+1); + toFile = destDir; + toFile += "/"; + toFile += toFileName; + cmSystemTools::ReplaceString(toFile, "${CMAKE_BINARY_DIR}", + m_WhereBuild.c_str() ); + cmSystemTools::ReplaceString(toFile, "${CMAKE_SOURCE_ROOT}", + m_WhereSource.c_str() ); + cmSystemTools::ReplaceString(fromFile, "${CMAKE_BINARY_DIR}", + m_WhereBuild.c_str() ); + cmSystemTools::ReplaceString(fromFile, "${CMAKE_SOURCE_ROOT}", + m_WhereSource.c_str() ); + cmSystemTools::ReplaceString(destDir, "${CMAKE_BINARY_DIR}", + m_WhereBuild.c_str() ); + cmSystemTools::ReplaceString(destDir, "${CMAKE_SOURCE_ROOT}", + m_WhereSource.c_str() ); + } + } + if(destDir != "" && fromFile != "" && toFile != "") + { + if(!cmSystemTools::MakeDirectory(destDir.c_str()) ) + { + std::string error = "Error: can not create directory: "; + error += destDir; + MessageBox(0, error.c_str(), "config ERROR", MB_OK); + return false; + } + if(!CopyFile(fromFile.c_str(), toFile.c_str(), FALSE)) + { + std::string error = "Error: can not copy : "; + error += fromFile; + error += " to "; + error += toFile; + MessageBox(0, error.c_str(), "config ERROR", MB_OK); + return false; + } + } + else if (inputLine != "") + { + std::string error = "Error in parsing : "; + error += file; + error += " in line:\n "; + error += inputLine; + MessageBox(0, error.c_str(), "config ERROR", MB_OK); + return false; + } + } + } + return true; +} diff --git a/Source/cmWindowsConfigure.h b/Source/cmWindowsConfigure.h index e0a7413..fa3059b 100644 --- a/Source/cmWindowsConfigure.h +++ b/Source/cmWindowsConfigure.h @@ -40,7 +40,7 @@ public: { m_WhereBuild = dir; } - virtual void Configure() = 0; + virtual bool Configure(const char* input); protected: std::string m_WhereSource; std::string m_WhereBuild; |