From d715fba1cb8d97d58cba912cb42359a7f7e8ff22 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Jul 2003 14:32:30 -0400 Subject: [PATCH] ENH: Added use of KWSYS_HEADER macro in c and cxx files to include kwsys headers through their configured namespace. --- Source/kwsys/Base64.c | 3 ++- Source/kwsys/CMakeLists.txt | 5 +--- Source/kwsys/Directory.cxx | 9 +++---- Source/kwsys/EncodeExecutable.c | 3 ++- Source/kwsys/ProcessUNIX.c | 3 ++- Source/kwsys/ProcessWin32.c | 3 ++- Source/kwsys/RegularExpression.cxx | 4 +++- Source/kwsys/SystemTools.cxx | 7 +++--- Source/kwsys/kwsysPrivate.h | 38 ++++++++++++++++++++++++++++++ 9 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 Source/kwsys/kwsysPrivate.h diff --git a/Source/kwsys/Base64.c b/Source/kwsys/Base64.c index 34d60482c..41f6ef4c5 100644 --- a/Source/kwsys/Base64.c +++ b/Source/kwsys/Base64.c @@ -15,7 +15,8 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ #define KWSYS_IN_BASE64_C -#include +#include "kwsysPrivate.h" +#include KWSYS_HEADER(Base64.h) /*--------------------------------------------------------------------------*/ static const unsigned char kwsysBase64EncodeTable[65] = diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 423a4b918..6f0b9fea1 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -304,11 +304,8 @@ IF(KWSYS_LIBRARY_INSTALL_DIR) ENDIF(KWSYS_LIBRARY_INSTALL_DIR) # For building kwsys itself, we use a macro defined on the command -# line to configure the namespace in the C and C++ source files. The -# source files must also include their headers without the namespae -# prefix, so we add the header directory to the include path directly. +# line to configure the namespace in the C and C++ source files. ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}") -INCLUDE_DIRECTORIES(BEFORE ${KWSYS_HEADER_DIR}) #----------------------------------------------------------------------------- # Process execution on windows needs to build a forwarding executable diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx index 5e409b6d9..40447c4e6 100644 --- a/Source/kwsys/Directory.cxx +++ b/Source/kwsys/Directory.cxx @@ -14,12 +14,13 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#include +#include "kwsysPrivate.h" +#include KWSYS_HEADER(Directory.hxx) -#include +#include KWSYS_HEADER(Configure.hxx) -#include -#include +#include KWSYS_HEADER(std/string) +#include KWSYS_HEADER(std/vector) namespace KWSYS_NAMESPACE { diff --git a/Source/kwsys/EncodeExecutable.c b/Source/kwsys/EncodeExecutable.c index 2994129d0..4797d2952 100644 --- a/Source/kwsys/EncodeExecutable.c +++ b/Source/kwsys/EncodeExecutable.c @@ -50,7 +50,8 @@ int main(int argc, char* argv[]) /* Prepend header comment. */ fprintf(ofp, "/*\n * DO NOT EDIT\n * This file is generated by:\n"); fprintf(ofp, " * %s\n */\n\n", argv[0]); - fprintf(ofp, "#include \n\n"); + fprintf(ofp, "#include \"kwsysPrivate.h\"\n"); + fprintf(ofp, "#include KWSYS_HEADER(Configure.h)\n\n"); fprintf(ofp, "#include \n\n"); /* Split file up in 1024-byte chunks. */ diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index b14c8cff5..62fdae48d 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -15,7 +15,8 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ #define KWSYS_IN_PROCESS_C -#include +#include "kwsysPrivate.h" +#include KWSYS_HEADER(Process.h) /* diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index 5296f2f1d..3ef113c3f 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -15,7 +15,8 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ #define KWSYS_IN_PROCESS_C -#include +#include "kwsysPrivate.h" +#include KWSYS_HEADER(Process.h) /* diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx index ef204a12c..451237c87 100644 --- a/Source/kwsys/RegularExpression.cxx +++ b/Source/kwsys/RegularExpression.cxx @@ -33,7 +33,9 @@ // Updated: DLS 03/22/91 New lite version // -#include // Include class specification +#include "kwsysPrivate.h" +#include KWSYS_HEADER(RegularExpression.hxx) + #include namespace KWSYS_NAMESPACE diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 04009a3ec..c2c67f8b1 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -14,10 +14,11 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#include +#include "kwsysPrivate.h" +#include KWSYS_HEADER(SystemTools.hxx) -#include -#include +#include KWSYS_HEADER(std/iostream) +#include KWSYS_HEADER(std/fstream) #ifdef _MSC_VER # pragma warning (disable: 4786) diff --git a/Source/kwsys/kwsysPrivate.h b/Source/kwsys/kwsysPrivate.h new file mode 100644 index 000000000..94f8b4eb1 --- /dev/null +++ b/Source/kwsys/kwsysPrivate.h @@ -0,0 +1,38 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef KWSYS_NAMESPACE +# error "Do not include kwsysPrivate.h outside of kwsys c and cxx files." +#endif + +#ifndef _kwsysPrivate_h +#define _kwsysPrivate_h + +/* + Define KWSYS_HEADER macro to help the c and cxx files include kwsys + headers from the configured namespace directory. The macro can be + used like this: + + #include KWSYS_HEADER(Directory.hxx) + #include KWSYS_HEADER(std/vector) +*/ +#define KWSYS_HEADER(x) KWSYS_HEADER0(KWSYS_NAMESPACE/x) +#define KWSYS_HEADER0(x) KWSYS_HEADER1(x) +#define KWSYS_HEADER1(x) + +#else +# error "kwsysPrivate.h included multiple times." +#endif