Commit 283d3a0b authored by Bill Hoffman's avatar Bill Hoffman
Browse files

ENH: added a config setup file for CMakeSetup. Cleaned up the names of the...

ENH: added a config setup file for CMakeSetup.   Cleaned up the names of the source and binary directories
parent 38f5ab85
......@@ -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
......
......@@ -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
......
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 =
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
//{{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
......
......@@ -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)
{
......
......@@ -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)
{
......
......@@ -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());
}
......
#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++)
{
......
#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;
}
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment