Commit aa3ca2b4 authored by Bill Hoffman's avatar Bill Hoffman
Browse files

ENH: CMake and configure now use SUBDIRS in CMakeLists.txt to find all the...

ENH: CMake and configure now use SUBDIRS in CMakeLists.txt to find all the directories of the system.
parent e2ad65d3
......@@ -4,14 +4,14 @@
#------------------------------------------------------------------------------
# Include all variable settings
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_OBJ_DIR@/CMake/CMakeVariables.make@MAKEQUOTE@
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_CONFIG_DIR@/CMake/CMakeVariables.make@MAKEQUOTE@
#------------------------------------------------------------------------------
# Include user-editable defines.
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_OBJ_DIR@/CMakeLocal.make@MAKEQUOTE@
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_CONFIG_DIR@/CMakeLocal.make@MAKEQUOTE@
#------------------------------------------------------------------------------
# Include General Build Rules
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_OBJ_DIR@/CMake/CMakeRules.make@MAKEQUOTE@
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_CONFIG_DIR@/CMake/CMakeRules.make@MAKEQUOTE@
# include simple rules for building .o files
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_OBJ_DIR@/CMake/CMakeSimpleRules.make@MAKEQUOTE@
# include simple rules for building .o files from source files
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_CONFIG_DIR@/CMake/CMakeSimpleRules.make@MAKEQUOTE@
#
# Makefile for
......@@ -10,18 +10,18 @@ all: CMakeTargets.make ${OBJ_SUB_DIRS} ${EXECUTABLES} ${SUBDIR_BUILD} ${BUILD_LI
#------------------------------------------------------------------------------
${CMAKE}: @fullSrcDir@/CMake/Source/*.cxx @fullSrcDir@/CMake/Source/*.h
cd @CMAKE_OBJ_DIR@/CMake/Source; ${MAKE} CMakeBuildTargets
${CMAKE}: ${topdir}/CMake/Source/*.cxx ${topdir}/CMake/Source/*.h
cd ${CMAKE_CONFIG_DIR}/CMake/Source; ${MAKE} CMakeBuildTargets
depend: ${CMAKE}
${CMAKE} ${srcdir}/CMakeLists.txt -S${srcdir} -I${srcdir} ${INCLUDE_FLAGS}
${MAKE} -${MAKEFLAGS} CMakeTargets.make
clean: ${SUBDIR_CLEAN}
rm -f ${SRC_OBJ} ${EXECUTABLES}
CMakeTargets.make: ${CMAKE} ${srcdir}/CMakeLists.txt
${CMAKE} ${srcdir}/CMakeLists.txt -S${srcdir} -I${srcdir} ${INCLUDE_FLAGS}
${CMAKE} ${srcdir}/CMakeLists.txt -S${srcdir} -H${topdir} -B${CMAKE_CONFIG_DIR}
#------------------------------------------------------------------------------
# rules for the normal library
......
#empty file used by configure to generate initial targets.make files
#if you find this as a make error, then the autoconf system is not
#working, send for help on the insight mailing list...
# ***** BEGIN VARIBLES THAT CAN BE OVERRIDDEN IN CMakeLocal.make.in **************
# CMakeLocal.make.in should be in the directory where you run configure
# in, which need not be the source directory
# use this to add targets to the default all
# so they are built when make is run by default
LOCAL_BUILD_TARGETS =
# use this flag to add -L and -l options to the link line
LOCAL_LINK_FLAGS =
# use this flag to add -I flags to the compile line
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
USER_CFLAGS = @CFLAGS@
# use this flag to add compiler options like -g -O, etc
# for the "C++" compiler, for gcc these default to -g -O2
USER_CXXFLAGS = @CXXFLAGS@
# ***** END VARIBLES THAT CAN BE OVERRIDDEN IN CMakeLocal.make.in **************
# This is the path to the top of the Source tree
topdir = @fullSrcDir@
CONFIG_DIR = @CMAKE_OBJ_DIR@
# This is the directory configure was run in
# where the binaries will be placed
CMAKE_CONFIG_DIR = @CMAKE_CONFIG_DIR@
# the standard shell for make
SHELL = /bin/sh
CMAKE_OBJ_DIR = ${CONFIG_DIR}
RANLIB = @RANLIB@
CC = @CC@
CFLAGS = @ITK_SHLIB_CFLAGS@ @ANSI_CFLAGS@
......@@ -82,31 +110,21 @@ LIB_INSTALL_DIR = $(INSTALL_ROOT)$(exec_prefix)/lib
BIN_INSTALL_DIR = $(INSTALL_ROOT)$(exec_prefix)/bin
# set up the path to the rulesgen program
CMAKE = @CMAKE_OBJ_DIR@/CMake/Source/CMakeBuildTargets
CMAKE = @CMAKE_CONFIG_DIR@/CMake/Source/CMakeBuildTargets
KIT_OBJ = ${SRC_OBJ} ${EXTRA_KIT_OBJ}
# ***** BEGIN VARIBLES THAT CAN BE OVERRIDDEN IN CMakeLocal.make.in **************
LOCAL_BUILD_TARGETS =
LOCAL_LINK_FLAGS =
USER_CFLAGS = @CFLAGS@
USER_CXXFLAGS = @CXXFLAGS@
# ***** END VARIBLES THAT CAN BE OVERRIDDEN IN CMakeLocal.make.in **************
# compile line flags
INCLUDE_FLAGS = -I. \
-I${CONFIG_DIR}/Code/Insight3DParty/vxl \
-I${CONFIG_DIR} \
-I${topdir}/Code/Common \
-I${topdir}/Code/Insight3DParty/vxl
# C++ compile flags, INCLUDE_FLAGS is set in CMakeTargets.make which
# is generated by CMakeBuildTargets, see CMake/Source
CXX_FLAGS = ${CPPFLAGS} ${USER_CXXFLAGS} ${CXXFLAGS} \
${KIT_FLAGS} ${INCLUDE_FLAGS}
CC_FLAGS = ${CPPFLAGS} ${USER_CFLAGS} ${CFLAGS}
# C compile flags, INCLUDE_FLAGS is set in CMakeTargets.make which
# is generated by CMakeBuildTargets, see CMake/Source
CC_FLAGS = ${CPPFLAGS} ${USER_CFLAGS} ${CFLAGS} ${INCLUDE_FLAGS}
srcdir = @srcdir@
VPATH = @srcdir@
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_OBJ_DIR@/CMake/CMakeMaster.make@MAKEQUOTE@
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_CONFIG_DIR@/CMake/CMakeMaster.make@MAKEQUOTE@
......@@ -32,9 +32,11 @@ CMakeBuildTargets -> Unix program to read CMakeLists.txt and generate CMakeT
makefile fragments:
CMakeMaster.make -> main file to be included by makefiles
CMakeVariables.make -> all make varibles are set in this file
CMakeRules.make -> All build rules are here
CMakeRules.make -> All build rules are here (except Simple Rules)
CMakeSimpleRules.make -> simple build rules for .o to .cxx, this is separate to be able
to build CMakeBuildTargets itself.
CMakeLocal.make -> Place for hand configuration
CMakeTargets.make -> generated rules for make style build
CMakeTargets.make -> generated rules for make style build in each directory
MakefileTemplate.make -> master makefile template used by configure to generate Makefiles
Unix install:
......@@ -50,7 +52,6 @@ make
TODO:
Fix cmUnixMakefile.cxx and cmDSPMakefile.cxx
to read libraries and -I stuff from a config file
configure stuff for windows should be a copy configure file
read in depend regular expression from a file
......@@ -16,15 +16,20 @@ main(int ac, char** av)
for(int i =2; i < ac; i++)
{
std::string arg = av[i];
if(arg.find("-I",0) != std::string::npos)
if(arg.find("-S",0) != std::string::npos)
{
std::string path = arg.substr(2);
md.AddSearchPath(path.c_str());
mf->SetCurrentDirectory(path.c_str());
}
if(arg.find("-S",0) != std::string::npos)
if(arg.find("-B",0) != std::string::npos)
{
std::string path = arg.substr(2);
mf->SetCurrentDirectory(path.c_str());
mf->SetOutputHomeDirectory(path.c_str());
}
if(arg.find("-H",0) != std::string::npos)
{
std::string path = arg.substr(2);
mf->SetHomeDirectory(path.c_str());
}
}
}
......
#include "cmDSWBuilder.h"
#include "cmDSPBuilder.h"
#include <iostream>
void SetArgs(cmPCBuilder& builder, int ac, char** av)
{
for(int i =2; i < ac; i++)
{
std::string arg = av[i];
if(arg.find("-H",0) != std::string::npos)
{
std::string path = arg.substr(2);
builder.SetHomeDirectory(path.c_str());
}
if(arg.find("-D",0) != std::string::npos)
{
std::string path = arg.substr(2);
builder.SetCurrentDirectory(path.c_str());
}
}
}
main(int ac, char** av)
{
if(ac < 3)
{
std::cerr << "Usage: " << av[0] <<
" Makefile.in -[DSP|DSW] -Hinsighthome -Dcurrentdir ..." << std::endl;
return -1;
}
std::string arg = av[2];
if(arg.find("-DSP", 0) != std::string::npos)
{
cmDSPBuilder builder;
builder.SetInputMakefilePath(av[1]);
SetArgs(builder, ac, av);
builder.CreateDSPFile();
}
else
{
cmDSWBuilder builder;
builder.SetInputMakefilePath(av[1]);
SetArgs(builder, ac, av);
builder.CreateDSWFile();
}
return 0;
}
......@@ -11,9 +11,6 @@ Package=<5>
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name pcbuilderCMD
End Project Dependency
Begin Project Dependency
Project_Dep_Name CMakeSetupCMD
End Project Dependency
......
#include "cmDSWBuilder.h"
#include "cmDSPBuilder.h"
#include "cmDSWMakefile.h"
#include "cmDSPMakefile.h"
#include <iostream>
void SetArgs(cmPCBuilder& builder, int ac, char** av)
void SetArgs(cmMakefile& builder, int ac, char** av)
{
for(int i =3; i < ac; i++)
{
......@@ -16,7 +16,7 @@ void SetArgs(cmPCBuilder& builder, int ac, char** av)
{
std::string path = arg.substr(2);
std::cerr << "set makefile dir " << path.c_str() << std::endl;
builder.SetMakefileDirectory(path.c_str());
builder.SetCurrentDirectory(path.c_str());
}
if(arg.find("-O",0) != std::string::npos)
{
......@@ -45,17 +45,17 @@ main(int ac, char** av)
std::string arg = av[2];
if(arg.find("-DSP", 0) != std::string::npos)
{
cmDSPBuilder builder;
cmDSPMakefile builder;
SetArgs(builder, ac, av);
builder.SetInputMakefilePath(av[1]);
builder.CreateDSPFile();
builder.ReadMakefile(av[1]);
builder.OutputDSPFile();
}
else
{
cmDSWBuilder builder;
cmDSWMakefile builder;
SetArgs(builder, ac, av);
builder.SetInputMakefilePath(av[1]);
builder.CreateDSWFile();
builder.ReadMakefile(av[1]);
builder.OutputDSWFile();
}
return 0;
}
......
......@@ -99,6 +99,10 @@ SOURCE=.\cmClassFile.cxx
# End Source File
# Begin Source File
SOURCE=.\cmCollectFlags.cxx
# End Source File
# Begin Source File
SOURCE=.\cmDirectory.cxx
# End Source File
# Begin Source File
......
// CMakeSetupDialogDlg.cpp : implementation file
//
#include "stdafx.h"
#include "pcbuilder.h"
#include "CMakeSetupDialog.h"
#include "../itkDSWBuilder.h"
#include "../itkVC60Configure.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP();
/////////////////////////////////////////////////////////////////////////////
// CMakeSetupDialog dialog
CMakeSetupDialog::CMakeSetupDialog(CWnd* pParent /*=NULL*/)
: CDialog(CMakeSetupDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CMakeSetupDialog)
m_WhereITK = _T("");
m_WhereBuildITK = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_WhereITK = _T("");
this->LoadFromRegistry();
}
void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMakeSetupDialog)
DDX_Text(pDX, IDC_WhereITK, m_WhereITK);
DDX_Text(pDX, IDC_WhereITK2, m_WhereBuildITK);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog)
//{{AFX_MSG_MAP(CMakeSetupDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_CHANGE(IDC_WhereITK, OnChangeEdit1)
ON_BN_CLICKED(IDC_BUTTON2, OnBrowse)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP();
/////////////////////////////////////////////////////////////////////////////
// CMakeSetupDialog message handlers
BOOL CMakeSetupDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CMakeSetupDialog::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMakeSetupDialog::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMakeSetupDialog::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMakeSetupDialog::OnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CMakeSetupDialog::OnBrowse()
{
this->UpdateData();
Browse(m_WhereITK, "Enter Path to Insight Source");
this->UpdateData(false);
}
bool CMakeSetupDialog::Browse(CString &result, const char *title)
{
// don't know what to do with initial right now...
char szPathName[4096];
BROWSEINFO bi;
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = (LPTSTR)szPathName;
bi.lpszTitle = title;
bi.ulFlags = BIF_BROWSEINCLUDEFILES ;
bi.lpfn = NULL;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
bool bSuccess = (bool)SHGetPathFromIDList(pidl, szPathName);
if(bSuccess)
{
result = szPathName;
}
return bSuccess;
}
void CMakeSetupDialog::OnOK()
{
// get all the info from the screen
this->UpdateData();
// configure the system for VC60
itkVC60Configure config;
config.SetWhereITK(m_WhereITK);
config.SetWhereBuildITK(m_WhereBuildITK);
config.Configure();
itkDSWBuilder builder;
// Set the ITK home directory
builder.SetHomeDirectory(m_WhereITK);
// Set the Makefile.in file
CString makefileIn = m_WhereITK;
makefileIn += "/Makefile.in";
builder.SetInputMakefilePath(makefileIn);
// Set the output directory
builder.SetOutputDirectory(m_WhereBuildITK);
// set the directory which contains the Makefile.in
builder.SetMakefileDirectory(m_WhereITK);
// Create the master DSW file and all children dsp files for ITK
builder.CreateDSWFile();
CDialog::OnOK();
this->SaveToRegistry();
}
void CMakeSetupDialog::OnButton3()
{
this->UpdateData();
Browse(m_WhereBuildITK, "Enter Path to Insight Build");
this->UpdateData(false);
}
void CMakeSetupDialog::SaveToRegistry()
{
HKEY hKey;
DWORD dwDummy;
if(RegCreateKeyEx(HKEY_CURRENT_USER,
_T("Software\\Kitware\\ITK PCBuilder\\Settings"),
0, "", REG_OPTION_NON_VOLATILE, KEY_READ|KEY_WRITE,
NULL, &hKey, &dwDummy) != ERROR_SUCCESS)
{
return;
}
else
{
RegSetValueEx(hKey, _T("WhereITK"), 0, REG_SZ,
(CONST BYTE *)(const char *)m_WhereITK,
m_WhereITK.GetLength());
RegSetValueEx(hKey, _T("WhereBuildITK"), 0, REG_SZ,
(CONST BYTE *)(const char *)m_WhereBuildITK,
m_WhereBuildITK.GetLength());
}
RegCloseKey(hKey);
}
void CMakeSetupDialog::ReadRegistryValue(HKEY hKey,
CString *val,
char *key,
char *adefault)
{
DWORD dwType, dwSize;
char *pb;
dwType = REG_SZ;
pb = val->GetBuffer(MAX_PATH);
dwSize = MAX_PATH;
if(RegQueryValueEx(hKey,_T(key), NULL, &dwType,
(BYTE *)pb, &dwSize) != ERROR_SUCCESS)
{
val->ReleaseBuffer();
*val = _T(adefault);
}
else
{
val->ReleaseBuffer();
}
}
void CMakeSetupDialog::LoadFromRegistry()
{