diff --git a/Base64.h.in b/Base64.h.in index 383f5203a7eb01c139650118f45ba7c52bc6bd29..9a3dbe8f674a2ca57ad7afa679c282bfb441d004 100644 --- a/Base64.h.in +++ b/Base64.h.in @@ -17,11 +17,14 @@ #ifndef @KWSYS_NAMESPACE@_Base64_h #define @KWSYS_NAMESPACE@_Base64_h +#include <@KWSYS_NAMESPACE@/Configure.h> + /* Redefine all public interface symbol names to be in the proper namespace. These macros are used internally to kwsys only, and are not visible to user code. Use kwsysHeaderDump.pl to reproduce these macros after making changes to the interface. */ #define kwsys(x) @KWSYS_NAMESPACE@##x +#define kwsysEXPORT kwsys(_EXPORT) #define kwsysBase64 kwsys(Base64) #define kwsysBase64_Decode kwsys(Base64_Decode) #define kwsysBase64_Decode3 kwsys(Base64_Decode3) @@ -38,17 +41,20 @@ extern "C" /** * Encode 3 bytes into a 4 byte string. */ -void kwsysBase64_Encode3(const unsigned char *src, unsigned char *dest); +kwsysEXPORT void kwsysBase64_Encode3(const unsigned char *src, + unsigned char *dest); /** * Encode 2 bytes into a 4 byte string. */ -void kwsysBase64_Encode2(const unsigned char *src, unsigned char *dest); +kwsysEXPORT void kwsysBase64_Encode2(const unsigned char *src, + unsigned char *dest); /** * Encode 1 bytes into a 4 byte string. */ -void kwsysBase64_Encode1(const unsigned char *src, unsigned char *dest); +kwsysEXPORT void kwsysBase64_Encode1(const unsigned char *src, + unsigned char *dest); /** * Encode 'length' bytes from the input buffer and store the encoded @@ -63,16 +69,17 @@ void kwsysBase64_Encode1(const unsigned char *src, unsigned char *dest); * the extra padding needed to complete the encode 4 bytes will stop * the decoding anyway). */ -unsigned long kwsysBase64_Encode(const unsigned char *input, - unsigned long length, - unsigned char *output, - int mark_end); +kwsysEXPORT unsigned long kwsysBase64_Encode(const unsigned char *input, + unsigned long length, + unsigned char *output, + int mark_end); /** * Decode 4 bytes into a 3 byte string. Returns the number of bytes * actually decoded. */ -int kwsysBase64_Decode3(const unsigned char *src, unsigned char *dest); +kwsysEXPORT int kwsysBase64_Decode3(const unsigned char *src, + unsigned char *dest); /** * Decode bytes from the input buffer and store the decoded stream @@ -86,10 +93,10 @@ int kwsysBase64_Decode3(const unsigned char *src, unsigned char *dest); * much decoded data to expect (of course, the buffer must be large * enough). */ -unsigned long kwsysBase64_Decode(const unsigned char *input, - unsigned long length, - unsigned char *output, - unsigned long max_input_length); +kwsysEXPORT unsigned long kwsysBase64_Decode(const unsigned char *input, + unsigned long length, + unsigned char *output, + unsigned long max_input_length); #if defined(__cplusplus) } /* extern "C" */ @@ -99,6 +106,7 @@ unsigned long kwsysBase64_Decode(const unsigned char *input, undefine them to keep the namespace clean. */ #if !defined(KWSYS_IN_BASE64_C) # undef kwsys +# undef kwsysEXPORT # undef kwsysBase64 # undef kwsysBase64_Decode # undef kwsysBase64_Decode3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d5754ed6c4f1676dfbe50b8b5592aebbb350fbf..db1ec9b62f37bd17a84b699550cc34169a40c1f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,19 @@ SET(KWSYS_NO_STD_NAMESPACE ${CMAKE_NO_STD_NAMESPACE}) SET(KWSYS_NO_ANSI_STREAM_HEADERS ${CMAKE_NO_ANSI_STREAM_HEADERS}) SET(KWSYS_NO_ANSI_STRING_STREAM ${CMAKE_NO_ANSI_STRING_STREAM}) +# Choose default shared/static build if not specified. +IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$") + SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS}) +ENDIF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$") + +IF(KWSYS_BUILD_SHARED) + SET(KWSYS_BUILD_SHARED 1) + SET(KWSYS_LIBRARY_TYPE SHARED) +ELSE(KWSYS_BUILD_SHARED) + SET(KWSYS_BUILD_SHARED 0) + SET(KWSYS_LIBRARY_TYPE STATIC) +ENDIF(KWSYS_BUILD_SHARED) + #----------------------------------------------------------------------------- # Choose a directory for the generated headers. IF(NOT KWSYS_HEADER_ROOT) @@ -192,7 +205,7 @@ ENDFOREACH(header) # Build a list of classes and headers we need to implement the # selected components. Initialize with required components. SET(KWSYS_CLASSES) -SET(KWSYS_H_FILES) +SET(KWSYS_H_FILES Configure) SET(KWSYS_HXX_FILES Configure) # Enforce component dependencies (none currently exists). @@ -283,7 +296,7 @@ ENDFOREACH(h) #----------------------------------------------------------------------------- # Add the library with the configured name and list of sources. -ADD_LIBRARY(${KWSYS_NAMESPACE} ${KWSYS_SRCS}) +ADD_LIBRARY(${KWSYS_NAMESPACE} ${KWSYS_LIBRARY_TYPE} ${KWSYS_SRCS}) # Create an install target for the library. IF(KWSYS_LIBRARY_INSTALL_DIR) diff --git a/Configure.h.in b/Configure.h.in new file mode 100644 index 0000000000000000000000000000000000000000..fadd120347da41a5b7f1f5384dcc01e03c71dc1f --- /dev/null +++ b/Configure.h.in @@ -0,0 +1,30 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: Configure.h.in + 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@_Configure_h +#define @KWSYS_NAMESPACE@_Configure_h + +#if defined(_WIN32) && @KWSYS_BUILD_SHARED@ +# if defined(@KWSYS_NAMESPACE@_EXPORTS) +# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport) +# else +# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport) +# endif +#else +# define @KWSYS_NAMESPACE@_EXPORT +#endif + +#endif diff --git a/Directory.cxx b/Directory.cxx index 4d89ca44eac861977cd927390e46a02047c154cb..8d2d08faba110e8d72ad2ecfa1c60d61a78173b6 100644 --- a/Directory.cxx +++ b/Directory.cxx @@ -16,6 +16,8 @@ =========================================================================*/ #include <Directory.hxx> +#include <Configure.hxx> + #include <std/string> #include <std/vector> diff --git a/Directory.hxx.in b/Directory.hxx.in index 0a843b87e5e52a5abea52034354909d125921760..2cc6884e42229acdc39c0ab4a3355c8e517380c6 100644 --- a/Directory.hxx.in +++ b/Directory.hxx.in @@ -17,7 +17,7 @@ #ifndef @KWSYS_NAMESPACE@_Directory_hxx #define @KWSYS_NAMESPACE@_Directory_hxx -#include <@KWSYS_NAMESPACE@/Configure.hxx> +#include <@KWSYS_NAMESPACE@/Configure.h> namespace @KWSYS_NAMESPACE@ { @@ -32,7 +32,7 @@ class DirectoryInternals; * * Directory currently works with Windows and Unix operating systems. */ -class Directory +class @KWSYS_NAMESPACE@_EXPORT Directory { public: Directory(); diff --git a/EncodeExecutable.c b/EncodeExecutable.c index 34c444e0747dbbb48bf20d7624c951b5aee20a3a..6981e0a68b4073dff583ed639f612c12e9ed67af 100644 --- a/EncodeExecutable.c +++ b/EncodeExecutable.c @@ -50,6 +50,7 @@ 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 <Configure.h>\n\n"); fprintf(ofp, "#include <stdio.h>\n\n"); /* Split file up in 1024-byte chunks. */ @@ -74,8 +75,8 @@ int main(int argc, char* argv[]) fclose(ifp); /* Provide a function to write the data to a file. */ - fprintf(ofp, "extern int %sEncodedWriteArray%s(const char* fname)\n", - argv[3], argv[4]); + fprintf(ofp, "extern %s_EXPORT int %sEncodedWriteArray%s(const char* fname)\n", + argv[3], argv[3], argv[4]); fprintf(ofp, "{\n"); fprintf(ofp, " FILE* ofp = fopen(fname, \"wb\");\n"); fprintf(ofp, " if(!ofp) { return 0; }\n"); diff --git a/Process.h.in b/Process.h.in index 64885ed59dfb374a91384537aca7c0c58fe84a2d..3b14880660369400b5647afe543541bbe274285a 100644 --- a/Process.h.in +++ b/Process.h.in @@ -17,11 +17,14 @@ #ifndef @KWSYS_NAMESPACE@_Process_h #define @KWSYS_NAMESPACE@_Process_h +#include <@KWSYS_NAMESPACE@/Configure.h> + /* Redefine all public interface symbol names to be in the proper namespace. These macros are used internally to kwsys only, and are not visible to user code. Use kwsysHeaderDump.pl to reproduce these macros after making changes to the interface. */ #define kwsys(x) @KWSYS_NAMESPACE@##x +#define kwsysEXPORT kwsys(_EXPORT) #define kwsysProcess kwsys(Process) #define kwsysProcess_s kwsys(Process_s) #define kwsysProcess_New kwsys(Process_New) @@ -70,20 +73,21 @@ typedef struct kwsysProcess_s kwsysProcess; /** * Create a new Process instance. */ -kwsysProcess* kwsysProcess_New(); +kwsysEXPORT kwsysProcess* kwsysProcess_New(); /** * Delete an existing Process instance. If the instance is currently * executing a process, this blocks until the process terminates. */ -void kwsysProcess_Delete(kwsysProcess* cp); +kwsysEXPORT void kwsysProcess_Delete(kwsysProcess* cp); /** * Set the command line to be executed. Argument is an array of * pointers to the command and each argument. Ths array must end with * a NULL pointer. */ -void kwsysProcess_SetCommand(kwsysProcess* cp, char const* const* command); +kwsysEXPORT void kwsysProcess_SetCommand(kwsysProcess* cp, + char const* const* command); /** * Set the timeout for the child process. The timeout period begins @@ -91,7 +95,7 @@ void kwsysProcess_SetCommand(kwsysProcess* cp, char const* const* command); * the timeout expires, it will be killed. A non-positive (<= 0) * value will disable the timeout. */ -void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout); +kwsysEXPORT void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout); /** * Get the current state of the Process instance. Possible states are: @@ -104,7 +108,7 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout); * kwsysProcess_State_Expired = Child process's timeout expired. * kwsysProcess_State_Killed = Child process terminated by Kill method. */ -int kwsysProcess_GetState(kwsysProcess* cp); +kwsysEXPORT int kwsysProcess_GetState(kwsysProcess* cp); enum kwsysProcess_State_e { kwsysProcess_State_Starting, @@ -128,7 +132,7 @@ enum kwsysProcess_State_e * kwsysProcess_Exception_Numerical = Child crashed with a numerical exception. * kwsysProcess_Exception_Other = Child terminated for another reason. */ -int kwsysProcess_GetExitException(kwsysProcess* cp); +kwsysEXPORT int kwsysProcess_GetExitException(kwsysProcess* cp); enum kwsysProcess_Exception_e { kwsysProcess_Exception_None, @@ -149,25 +153,25 @@ enum kwsysProcess_Exception_e * If GetState returns "Exited", use GetExitValue to get the * platform-independent child return value. */ -int kwsysProcess_GetExitCode(kwsysProcess* cp); +kwsysEXPORT int kwsysProcess_GetExitCode(kwsysProcess* cp); /** * When GetState returns "Exited", this method returns the child's * platform-independent exit code (such as the value returned by the * child's main). */ -int kwsysProcess_GetExitValue(kwsysProcess* cp); +kwsysEXPORT int kwsysProcess_GetExitValue(kwsysProcess* cp); /** * When GetState returns "Error", this method returns a string * describing the problem. Otherwise, it returns NULL. */ -const char* kwsysProcess_GetErrorString(kwsysProcess* cp); +kwsysEXPORT const char* kwsysProcess_GetErrorString(kwsysProcess* cp); /** * Start executing the child process. */ -void kwsysProcess_Execute(kwsysProcess* cp); +kwsysEXPORT void kwsysProcess_Execute(kwsysProcess* cp); /** * Block until data are available on a requested pipe, a timeout @@ -198,8 +202,9 @@ void kwsysProcess_Execute(kwsysProcess* cp); * call. Time elapsed has been subtracted from timeout * argument. */ -int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, char** data, - int* length, double* timeout); +kwsysEXPORT int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, + char** data, int* length, + double* timeout); enum kwsysProcess_Pipes_e { kwsysProcess_Pipe_STDOUT=1, @@ -225,14 +230,14 @@ enum kwsysProcess_Pipes_e * argument. * 1 = Child has terminated or was not running. */ -int kwsysProcess_WaitForExit(kwsysProcess* cp, double* timeout); +kwsysEXPORT int kwsysProcess_WaitForExit(kwsysProcess* cp, double* timeout); /** * Forcefully terminate the child process that is currently running. * The caller should call WaitForExit after this returns to wait for * the child to terminate. */ -void kwsysProcess_Kill(kwsysProcess* cp); +kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp); #if defined(__cplusplus) } /* extern "C" */ @@ -242,6 +247,7 @@ void kwsysProcess_Kill(kwsysProcess* cp); Otherwise, undefine them to keep the namespace clean. */ #if !defined(KWSYS_IN_PROCESS_C) # undef kwsys +# undef kwsysEXPORT # undef kwsysProcess # undef kwsysProcess_s # undef kwsysProcess_New diff --git a/ProcessWin32.c b/ProcessWin32.c index 309a3f5f7f433b9f3be226c870adbebaea082002..c684e0bb497aba9dc59612ccc9f576200807b323 100644 --- a/ProcessWin32.c +++ b/ProcessWin32.c @@ -51,7 +51,7 @@ Q190351 and Q150956. /* The maximum amount to read from a pipe at a time. */ #define CMPE_PIPE_BUFFER_SIZE 1024 -#define kwsysEncodedWriteArrayProcessFwd kwsys(EncodedWriteArrayProcessFwd) +#define kwsysEncodedWriteArrayProcessFwd9x kwsys(EncodedWriteArrayProcessFwd9x) typedef LARGE_INTEGER kwsysProcessTime; @@ -72,7 +72,7 @@ static kwsysProcessTime kwsysProcessTimeFromDouble(double d); static int kwsysProcessTimeLess(kwsysProcessTime in1, kwsysProcessTime in2); static kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1, kwsysProcessTime in2); static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1, kwsysProcessTime in2); -extern int kwsysEncodedWriteArrayProcessFwd9x(const char* fname); +extern kwsysEXPORT int kwsysEncodedWriteArrayProcessFwd9x(const char* fname); /*--------------------------------------------------------------------------*/ /* A structure containing data for each pipe's thread. */ diff --git a/RegularExpression.cxx b/RegularExpression.cxx index 33c20106ffc6456c7d52a57fadd329cb6d2da4bd..6c0a626f2d4362621a9f3bc3a6461a03a10bf458 100644 --- a/RegularExpression.cxx +++ b/RegularExpression.cxx @@ -413,7 +413,7 @@ static char* reg (int paren, int *flagp) { // Make an OPEN node, if parenthesized. if (paren) { - if (regnpar >= RegularExpressionNSUBEXP) { + if (regnpar >= RegularExpression::NSUBEXP) { //RAISE Error, SYM(RegularExpression), SYM(Too_Many_Parens), printf ("RegularExpression::compile(): Too many parentheses.\n"); return 0; @@ -925,7 +925,7 @@ static int regtry (const char* string, const char* *start, sp1 = start; ep = end; - for (i = RegularExpressionNSUBEXP; i > 0; i--) { + for (i = RegularExpression::NSUBEXP; i > 0; i--) { *sp1++ = 0; *ep++ = 0; } diff --git a/RegularExpression.hxx.in b/RegularExpression.hxx.in index 5f7fc726b1aa739a79cd72b58f34bc7b6feac30c..6fb1eccc9900ae3ac6234351c83b262421c0a04a 100644 --- a/RegularExpression.hxx.in +++ b/RegularExpression.hxx.in @@ -35,6 +35,7 @@ #ifndef @KWSYS_NAMESPACE@_RegularExpression_hxx #define @KWSYS_NAMESPACE@_RegularExpression_hxx +#include <@KWSYS_NAMESPACE@/Configure.h> #include <@KWSYS_NAMESPACE@/Configure.hxx> #include <@KWSYS_NAMESPACE@/std/string> @@ -47,8 +48,6 @@ namespace @KWSYS_NAMESPACE@ { -const int RegularExpressionNSUBEXP = 10; - /** \class RegularExpression * \brief Implements pattern matching with regular expressions. * @@ -186,7 +185,7 @@ const int RegularExpressionNSUBEXP = 10; * the line. It would match "drepa qrepb" in "rep drepa qrepb". * */ -class RegularExpression +class @KWSYS_NAMESPACE@_EXPORT RegularExpression { public: /** @@ -273,9 +272,10 @@ public: kwsys_std::string::size_type end(int n) const; kwsys_std::string match(int n) const; + enum { NSUBEXP = 10 }; private: - const char* startp[RegularExpressionNSUBEXP]; - const char* endp[RegularExpressionNSUBEXP]; + const char* startp[NSUBEXP]; + const char* endp[NSUBEXP]; char regstart; // Internal use only char reganch; // Internal use only const char* regmust; // Internal use only diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index 77fa78eb6c9b063b9e6354d280a5edf5ca9f9675..0b8ef8d229a33b62161359aae2d8a5cc4e63f781 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -21,6 +21,8 @@ #include <@KWSYS_NAMESPACE@/std/string> #include <@KWSYS_NAMESPACE@/std/vector> +#include <@KWSYS_NAMESPACE@/Configure.h> + /* Define this macro temporarily to keep the code readable. */ #if !defined (KWSYS_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_NAME_IS_KWSYS) # define kwsys_std @KWSYS_NAMESPACE@_std @@ -32,7 +34,7 @@ namespace @KWSYS_NAMESPACE@ /** \class SystemTools * \brief A collection of useful platform-independent system functions. */ -class SystemTools +class @KWSYS_NAMESPACE@_EXPORT SystemTools { public: /**