diff options
author | Brad King <brad.king@kitware.com> | 2006-10-19 19:00:10 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-10-19 19:00:10 (GMT) |
commit | f91b3c1daaeacd79b36644ce9a2610b31e9d964c (patch) | |
tree | f4d1fb12d71e40359e425cb29fffa783146e45c2 | |
parent | de007ef199190c84c0f53ac106c282fc190f5df1 (diff) | |
download | CMake-f91b3c1daaeacd79b36644ce9a2610b31e9d964c.zip CMake-f91b3c1daaeacd79b36644ce9a2610b31e9d964c.tar.gz CMake-f91b3c1daaeacd79b36644ce9a2610b31e9d964c.tar.bz2 |
ENH: Add options to build with system utility libraries. Organize inclusion of third party libraries into a single header per library. This addresses bug#3653.
-rw-r--r-- | CMakeLists.txt | 155 | ||||
-rw-r--r-- | Source/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Source/CPack/cmCPackTGZGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 17 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 2 | ||||
-rw-r--r-- | Source/cmGeneratedFileStream.cxx | 10 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 10 | ||||
-rw-r--r-- | Source/cmXMLParser.cxx | 2 | ||||
-rw-r--r-- | Utilities/cmThirdParty.h.in | 26 | ||||
-rw-r--r-- | Utilities/cm_curl.h | 28 | ||||
-rw-r--r-- | Utilities/cm_expat.h | 28 | ||||
-rw-r--r-- | Utilities/cm_xmlrpc.h | 30 | ||||
-rw-r--r-- | Utilities/cm_zlib.h | 28 | ||||
-rw-r--r-- | Utilities/cmtar/CMakeLists.txt | 11 | ||||
-rw-r--r-- | Utilities/cmtar/config.h.in | 5 | ||||
-rw-r--r-- | Utilities/cmtar/libtar.c | 21 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc.h | 4 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_expat.c | 2 |
18 files changed, 322 insertions, 73 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e0496c..627233d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,27 +71,116 @@ SET(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source) SUBDIRS(Source/kwsys) #----------------------------------------------------------------------------- -# Build zlib library for Curl, CMake, and CTest. -SUBDIRS(Utilities/cmzlib) -SET(CMAKE_ZLIB_INCLUDES - "${CMAKE_CURRENT_BINARY_DIR}/Utilities" +# Setup third-party libraries. + +# Everything in the tree should be able to include files from the +# Utilities directory. +INCLUDE_DIRECTORIES( + ${CMake_SOURCE_DIR}/Utilities + ${CMake_BINARY_DIR}/Utilities ) -SET(CMAKE_ZLIB_LIBRARIES "cmzlib") -SET(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES}) -SET(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES}) -SET(CURL_SPECIAL_ZLIB_H "cmzlib/zlib.h") + +# Third party libraries must be something that can be found. +IF(EXISTS ${CMAKE_ROOT}/Modules/FindXMLRPC.cmake) + SET(CMAKE_ALLOW_SYSTEM_LIBRARIES 1) +ELSE(EXISTS ${CMAKE_ROOT}/Modules/FindXMLRPC.cmake) + SET(CMAKE_ALLOW_SYSTEM_LIBRARIES 0) +ENDIF(EXISTS ${CMAKE_ROOT}/Modules/FindXMLRPC.cmake) + +IF(CMAKE_ALLOW_SYSTEM_LIBRARIES) + # Options have dependencies. + INCLUDE(CMakeDependentOption) + + # Allow the user to enable/disable all system utility library options + # by setting CMAKE_USE_SYSTEM_LIBRARIES on the command line. + IF(DEFINED CMAKE_USE_SYSTEM_LIBRARIES) + SET(CMAKE_USE_SYSTEM_LIBRARIES_USER 1) + ENDIF(DEFINED CMAKE_USE_SYSTEM_LIBRARIES) + IF(CMAKE_USE_SYSTEM_LIBRARIES) + SET(CMAKE_USE_SYSTEM_LIBRARIES ON) + ELSE(CMAKE_USE_SYSTEM_LIBRARIES) + SET(CMAKE_USE_SYSTEM_LIBRARIES OFF) + ENDIF(CMAKE_USE_SYSTEM_LIBRARIES) + IF(CMAKE_USE_SYSTEM_LIBRARIES_USER) + SET(CMAKE_USE_SYSTEM_CURL "${CMAKE_USE_SYSTEM_LIBRARIES}" CACHE BOOL "Use system-installed curl" FORCE) + SET(CMAKE_USE_SYSTEM_EXPAT "${CMAKE_USE_SYSTEM_LIBRARIES}" CACHE BOOL "Use system-installed expat" FORCE) + SET(CMAKE_USE_SYSTEM_XMLRPC "${CMAKE_USE_SYSTEM_LIBRARIES}" CACHE BOOL "Use system-installed xmlrpc" FORCE) + SET(CMAKE_USE_SYSTEM_ZLIB "${CMAKE_USE_SYSTEM_LIBRARIES}" CACHE BOOL "Use system-installed zlib" FORCE) + ENDIF(CMAKE_USE_SYSTEM_LIBRARIES_USER) + + # Optionally use system utility libraries. + OPTION(CMAKE_USE_SYSTEM_CURL "Use system-installed curl" ${CMAKE_USE_SYSTEM_LIBRARIES}) + OPTION(CMAKE_USE_SYSTEM_XMLRPC "Use system-installed xmlrpc" ${CMAKE_USE_SYSTEM_LIBRARIES}) + CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_EXPAT "Use system-installed expat" + ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CMAKE_USE_SYSTEM_XMLRPC" ON) + CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_ZLIB "Use system-installed zlib" + ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CMAKE_USE_SYSTEM_CURL" ON) + + # There is currently no option for system tar because the upstream + # libtar does not have our modifications to allow reentrant + # object-oriented use of the library. + # OPTION(CMAKE_USE_SYSTEM_TAR "Use system-installed tar" OFF) +ELSE(CMAKE_ALLOW_SYSTEM_LIBRARIES) + SET(CMAKE_USE_SYSTEM_CURL 0) + SET(CMAKE_USE_SYSTEM_EXPAT 0) + SET(CMAKE_USE_SYSTEM_XMLRPC 0) + SET(CMAKE_USE_SYSTEM_ZLIB 0) +ENDIF(CMAKE_ALLOW_SYSTEM_LIBRARIES) + +# Inform utility library header wrappers whether to use system versions. +CONFIGURE_FILE(${CMake_SOURCE_DIR}/Utilities/cmThirdParty.h.in + ${CMake_BINARY_DIR}/Utilities/cmThirdParty.h + @ONLY IMMEDIATE) + +# Mention to the user what system libraries are being used. +FOREACH(util CURL EXPAT XMLRPC ZLIB) + IF(CMAKE_USE_SYSTEM_${util}) + MESSAGE(STATUS "Using system-installed ${util}") + ENDIF(CMAKE_USE_SYSTEM_${util}) +ENDFOREACH(util) + +#----------------------------------------------------------------------------- +# Build zlib library for Curl, CMake, and CTest. +SET(CMAKE_ZLIB_HEADER "cm_zlib.h") +IF(CMAKE_USE_SYSTEM_ZLIB) + FIND_PACKAGE(ZLIB) + IF(NOT ZLIB_FOUND) + MESSAGE(FATAL_ERROR "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!") + ENDIF(NOT ZLIB_FOUND) + SET(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR}) + SET(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) +ELSE(CMAKE_USE_SYSTEM_ZLIB) + SUBDIRS(Utilities/cmzlib) + SET(CMAKE_ZLIB_INCLUDES) + SET(CMAKE_ZLIB_LIBRARIES cmzlib) +ENDIF(CMAKE_USE_SYSTEM_ZLIB) #----------------------------------------------------------------------------- # Build Curl library for CTest. -SUBDIRS(Utilities/cmcurl) -SET(CMAKE_CURL_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/Utilities") -SET(CMAKE_CURL_LIBRARIES "cmcurl") +IF(CMAKE_USE_SYSTEM_CURL) + FIND_PACKAGE(CURL) + IF(NOT CURL_FOUND) + MESSAGE(FATAL_ERROR "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!") + ENDIF(NOT CURL_FOUND) + SET(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS}) + SET(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES}) +ELSE(CMAKE_USE_SYSTEM_CURL) + SET(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER}) + SET(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES}) + SET(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES}) + SUBDIRS(Utilities/cmcurl) + SET(CMAKE_CURL_INCLUDES) + SET(CMAKE_CURL_LIBRARIES cmcurl) +ENDIF(CMAKE_USE_SYSTEM_CURL) #----------------------------------------------------------------------------- # Build Tar library for CTest. +SET(CMTAR_ZLIB_HEADER ${CMAKE_ZLIB_HEADER}) +SET(CMTAR_ZLIB_LIBRARIES ${CMAKE_ZLIB_LIBRARIES}) +SET(CMTAR_ZLIB_INCLUDE_DIRS ${CMAKE_ZLIB_INCLUDES}) SUBDIRS(Utilities/cmtar) -SET(CMAKE_TAR_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmtar") -SET(CMAKE_TAR_LIBRARIES "cmtar") +SET(CMAKE_TAR_INCLUDES ${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmtar) +SET(CMAKE_TAR_LIBRARIES cmtar) #----------------------------------------------------------------------------- # Build Compress library for CTest. @@ -101,19 +190,33 @@ SET(CMAKE_COMPRESS_LIBRARIES "cmcompress") #----------------------------------------------------------------------------- # Build expat library for CMake and CTest. -SUBDIRS(Utilities/cmexpat) -SET(CMAKE_EXPAT_INCLUDES - "${CMAKE_CURRENT_BINARY_DIR}/Utilities" - "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmexpat" - ) -SET(CMAKE_EXPAT_LIBRARIES "cmexpat") - -SUBDIRS(Utilities/cmxmlrpc) -SET(CMAKE_XMLRPC_INCLUDES - "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmxmlrpc" - "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmxmlrpc" - ) -SET(CMAKE_XMLRPC_LIBRARIES "cmXMLRPC") +IF(CMAKE_USE_SYSTEM_EXPAT) + FIND_PACKAGE(EXPAT) + IF(NOT EXPAT_FOUND) + MESSAGE(FATAL_ERROR + "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!") + ENDIF(NOT EXPAT_FOUND) + SET(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS}) + SET(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES}) +ELSE(CMAKE_USE_SYSTEM_EXPAT) + SUBDIRS(Utilities/cmexpat) + SET(CMAKE_EXPAT_INCLUDES) + SET(CMAKE_EXPAT_LIBRARIES cmexpat) +ENDIF(CMAKE_USE_SYSTEM_EXPAT) + +IF(CMAKE_USE_SYSTEM_XMLRPC) + FIND_PACKAGE(XMLRPC QUIET REQUIRED libwww-client) + IF(NOT XMLRPC_FOUND) + MESSAGE(FATAL_ERROR + "CMAKE_USE_SYSTEM_XMLRPC is ON but a xmlrpc is not found!") + ENDIF(NOT XMLRPC_FOUND) + SET(CMAKE_XMLRPC_INCLUDES ${XMLRPC_INCLUDE_DIRS}) + SET(CMAKE_XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES}) +ELSE(CMAKE_USE_SYSTEM_XMLRPC) + SUBDIRS(Utilities/cmxmlrpc) + SET(CMAKE_XMLRPC_INCLUDES) + SET(CMAKE_XMLRPC_LIBRARIES cmXMLRPC) +ENDIF(CMAKE_USE_SYSTEM_XMLRPC) IF (UNIX) FIND_PACKAGE(Curses QUIET) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 17aa18d..8bd39a1 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -352,6 +352,13 @@ IF(BUILD_TESTING) SET(CMAKE_TEST_DIFFERENT_GENERATOR TRUE) ENDIF(NOT CMAKE_TEST_GENERATOR) + SET(CMAKE_TEST_SYSTEM_LIBRARIES 0) + FOREACH(util CURL EXPAT XMLRPC ZLIB) + IF(CMAKE_USE_SYSTEM_${util}) + SET(CMAKE_TEST_SYSTEM_LIBRARIES 1) + ENDIF(CMAKE_USE_SYSTEM_${util}) + ENDFOREACH(util) + # This variable is set by cmake, however to # test cmake we want to make sure that # the ctest from this cmake is used for testing @@ -602,6 +609,7 @@ IF(BUILD_TESTING) --build-exe-dir "${CMake_BINARY_DIR}/Tests/Complex/bin" --build-options -DCMAKE_TEST_DIFFERENT_GENERATOR:BOOL=${CMAKE_TEST_DIFFERENT_GENERATOR} + -DCMAKE_TEST_SYSTEM_LIBRARIES:BOOL=${CMAKE_TEST_SYSTEM_LIBRARIES} --test-command complex ) @@ -615,6 +623,7 @@ IF(BUILD_TESTING) --build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexOneConfig/bin" --build-options -DCMAKE_TEST_DIFFERENT_GENERATOR:BOOL=${CMAKE_TEST_DIFFERENT_GENERATOR} + -DCMAKE_TEST_SYSTEM_LIBRARIES:BOOL=${CMAKE_TEST_SYSTEM_LIBRARIES} --test-command complex) # ADD_TEST(complexRelativePaths ${CMAKE_CTEST_COMMAND} diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx index d4663db..133fe0a 100644 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ b/Source/CPack/cmCPackTGZGenerator.cxx @@ -26,7 +26,7 @@ #include "cmCPackLog.h" #include <cmsys/SystemTools.hxx> -#include <cmzlib/zutil.h> +#include <cm_zlib.h> #include <libtar/libtar.h> #include <memory> // auto_ptr #include <fcntl.h> @@ -94,7 +94,7 @@ int cmCPackTGZ_Data_Open(void *client_data, const char* pathname, mydata->ZLibStream.opaque = Z_NULL; int strategy = Z_DEFAULT_STRATEGY; if ( deflateInit2(&mydata->ZLibStream, mydata->CompressionLevel, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy) != Z_OK ) + Z_DEFLATED, -MAX_WBITS, 8, strategy) != Z_OK ) { return -1; } @@ -281,7 +281,8 @@ int cmCPackTGZGenerator::GenerateHeader(std::ostream* os) const int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ char header[11]; sprintf(header, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], - Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); + Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, + 3 /* zlib os code for UNIX, not really used anyway */); os->write(header, 10); } return 1; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index b20388c..6fd24de 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -25,11 +25,10 @@ PURPOSE. See the above copyright notices for more information. #include <cmsys/Base64.h> // For XML-RPC submission -#include "xmlrpc.h" -#include "xmlrpc_client.h" +#include "cm_xmlrpc.h" // For curl submission -#include "cmcurl/curl/curl.h" +#include "cm_curl.h" #include <sys/stat.h> @@ -644,12 +643,14 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, const cmStdString& url) { xmlrpc_env env; - std::string ctestVersion = cmVersion::GetCMakeVersion(); + char ctestString[] = "CTest"; + std::string ctestVersionString = cmVersion::GetCMakeVersion(); + char* ctestVersion = const_cast<char*>(ctestVersionString.c_str()); cmStdString realURL = url + "/" + remoteprefix + "/Command/"; /* Start up our XML-RPC client library. */ - xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, "CTest", ctestVersion.c_str()); + xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, ctestString, ctestVersion); /* Initialize our error-handling environment. */ xmlrpc_env_init(&env); @@ -697,9 +698,9 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, } fclose(fp); - std::string remoteCommand = "Submit.put"; - result = xmlrpc_client_call(&env, realURL.c_str(), - remoteCommand.c_str(), + char remoteCommand[] = "Submit.put"; + char* pRealURL = const_cast<char*>(realURL.c_str()); + result = xmlrpc_client_call(&env, pRealURL, remoteCommand, "(6)", fileBuffer, (xmlrpc_int32)fileSize ); delete [] fileBuffer; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 8d05762..653fc12 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -14,7 +14,7 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#include "cmcurl/curl/curl.h" +#include "cm_curl.h" #include "cmCTest.h" #include "cmake.h" diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index e8be5fd..82ac2b7 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -27,7 +27,7 @@ #endif #if defined(CMAKE_BUILD_WITH_CMAKE) -# include <cmzlib/zlib.h> +# include <cm_zlib.h> #endif //---------------------------------------------------------------------------- @@ -213,7 +213,7 @@ void cmGeneratedFileStreamBase::Close() int cmGeneratedFileStreamBase::CompressFile(const char* oldname, const char* newname) { - gzFile gf = cm_zlib_gzopen(newname, "w"); + gzFile gf = gzopen(newname, "w"); if ( !gf ) { return 0; @@ -228,15 +228,15 @@ int cmGeneratedFileStreamBase::CompressFile(const char* oldname, char buffer[BUFFER_SIZE]; while ( (res = fread(buffer, 1, BUFFER_SIZE, ifs)) > 0 ) { - if ( !cm_zlib_gzwrite(gf, buffer, res) ) + if ( !gzwrite(gf, buffer, res) ) { fclose(ifs); - cm_zlib_gzclose(gf); + gzclose(gf); return 0; } } fclose(ifs); - cm_zlib_gzclose(gf); + gzclose(gf); return 1; } #else diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 4d257b2..8746c7a 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -48,7 +48,7 @@ # include <libtar/libtar.h> # include <memory> // auto_ptr # include <fcntl.h> -# include <cmzlib/zlib.h> +# include <cm_zlib.h> #endif #if defined(__sgi) && !defined(__GNUC__) @@ -1439,7 +1439,7 @@ int cmSystemToolsGZStructOpen(void* call_data, const char *pathname, } #endif - gzf->GZFile = cm_zlib_gzdopen(fd, gzoflags); + gzf->GZFile = gzdopen(fd, gzoflags); if (!gzf->GZFile) { errno = ENOMEM; @@ -1452,20 +1452,20 @@ int cmSystemToolsGZStructOpen(void* call_data, const char *pathname, int cmSystemToolsGZStructClose(void* call_data) { cmSystemToolsGZStruct* gzf = static_cast<cmSystemToolsGZStruct*>(call_data); - return cm_zlib_gzclose(gzf->GZFile); + return gzclose(gzf->GZFile); } ssize_t cmSystemToolsGZStructRead(void* call_data, void* buf, size_t count) { cmSystemToolsGZStruct* gzf = static_cast<cmSystemToolsGZStruct*>(call_data); - return cm_zlib_gzread(gzf->GZFile, buf, count); + return gzread(gzf->GZFile, buf, count); } ssize_t cmSystemToolsGZStructWrite(void* call_data, const void* buf, size_t count) { cmSystemToolsGZStruct* gzf = static_cast<cmSystemToolsGZStruct*>(call_data); - return cm_zlib_gzwrite(gzf->GZFile, (void*)buf, count); + return gzwrite(gzf->GZFile, (void*)buf, count); } #endif diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx index 58f3656..2894090 100644 --- a/Source/cmXMLParser.cxx +++ b/Source/cmXMLParser.cxx @@ -16,7 +16,7 @@ =========================================================================*/ #include "cmXMLParser.h" -#include <cmexpat/expat.h> +#include <cm_expat.h> #include <ctype.h> //---------------------------------------------------------------------------- diff --git a/Utilities/cmThirdParty.h.in b/Utilities/cmThirdParty.h.in new file mode 100644 index 0000000..845a1bd --- /dev/null +++ b/Utilities/cmThirdParty.h.in @@ -0,0 +1,26 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or 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 __cmThirdParty_h +#define __cmThirdParty_h + +/* Whether CMake is using its own utility libraries. */ +#cmakedefine CMAKE_USE_SYSTEM_CURL +#cmakedefine CMAKE_USE_SYSTEM_EXPAT +#cmakedefine CMAKE_USE_SYSTEM_XMLRPC +#cmakedefine CMAKE_USE_SYSTEM_ZLIB + +#endif diff --git a/Utilities/cm_curl.h b/Utilities/cm_curl.h new file mode 100644 index 0000000..0fcb5c5 --- /dev/null +++ b/Utilities/cm_curl.h @@ -0,0 +1,28 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or 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 __cm_curl_h +#define __cm_curl_h + +/* Use the curl library configured for CMake. */ +#include "cmThirdParty.h" +#ifdef CMAKE_USE_SYSTEM_CURL +# include <curl/curl.h> +#else +# include <cmcurl/curl/curl.h> +#endif + +#endif diff --git a/Utilities/cm_expat.h b/Utilities/cm_expat.h new file mode 100644 index 0000000..f152abb --- /dev/null +++ b/Utilities/cm_expat.h @@ -0,0 +1,28 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or 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 __cm_expat_h +#define __cm_expat_h + +/* Use the expat library configured for CMake. */ +#include "cmThirdParty.h" +#ifdef CMAKE_USE_SYSTEM_EXPAT +# include <expat.h> +#else +# include <cmexpat/expat.h> +#endif + +#endif diff --git a/Utilities/cm_xmlrpc.h b/Utilities/cm_xmlrpc.h new file mode 100644 index 0000000..95655bf --- /dev/null +++ b/Utilities/cm_xmlrpc.h @@ -0,0 +1,30 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or 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 __cm_xmlrpc_h +#define __cm_xmlrpc_h + +/* Use the xmlrpc library configured for CMake. */ +#include "cmThirdParty.h" +#ifdef CMAKE_USE_SYSTEM_XMLRPC +# include <xmlrpc.h> +# include <xmlrpc_client.h> +#else +# include <cmxmlrpc/xmlrpc.h> +# include <cmxmlrpc/xmlrpc_client.h> +#endif + +#endif diff --git a/Utilities/cm_zlib.h b/Utilities/cm_zlib.h new file mode 100644 index 0000000..a5bb52a --- /dev/null +++ b/Utilities/cm_zlib.h @@ -0,0 +1,28 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or 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 __cm_zlib_h +#define __cm_zlib_h + +/* Use the zlib library configured for CMake. */ +#include "cmThirdParty.h" +#ifdef CMAKE_USE_SYSTEM_ZLIB +# include <zlib.h> +#else +# include <cmzlib/zlib.h> +#endif + +#endif diff --git a/Utilities/cmtar/CMakeLists.txt b/Utilities/cmtar/CMakeLists.txt index a54e629..4b4ce40 100644 --- a/Utilities/cmtar/CMakeLists.txt +++ b/Utilities/cmtar/CMakeLists.txt @@ -367,11 +367,18 @@ ENDIF(NOT HAVE_FNMATCH) #SET(NEED_GLOB 1) #ENDIF(NOT HAVE_GLOB) +# Setup zlib. +IF(NOT CMTAR_ZLIB_LIBRARIES) + MESSAGE(FATAL_ERROR "Parent project must set CMTAR_ZLIB_LIBRARIES.") +ENDIF(NOT CMTAR_ZLIB_LIBRARIES) +IF(NOT CMTAR_ZLIB_HEADER) + MESSAGE(FATAL_ERROR "Parent project must set CMTAR_ZLIB_HEADER.") +ENDIF(NOT CMTAR_ZLIB_HEADER) +INCLUDE_DIRECTORIES(${CMTAR_ZLIB_INCLUDE_DIRS}) CONFIGURE_FILE(${LIBTAR_SOURCE_DIR}/config.h.in ${LIBTAR_BINARY_DIR}/libtar/config.h) ADD_LIBRARY(cmtar STATIC ${libtar_SRC}) ADD_EXECUTABLE(tartest libtar.c) -TARGET_LINK_LIBRARIES(tartest cmtar ${CMAKE_ZLIB_LIBRARIES}) - +TARGET_LINK_LIBRARIES(tartest cmtar ${CMTAR_ZLIB_LIBRARIES}) diff --git a/Utilities/cmtar/config.h.in b/Utilities/cmtar/config.h.in index 1ab4362..b3b7f5c 100644 --- a/Utilities/cmtar/config.h.in +++ b/Utilities/cmtar/config.h.in @@ -42,9 +42,6 @@ /* Define to 1 if you have the `z' library (-lz). */ #cmakedefine HAVE_LIBZ @HAVE_LIBZ@ -/* Define to 1 if you have the VTK's `z' library */ -#cmakedefine HAVE_VTK_LIBZ @HAVE_VTK_LIBZ@ - /* Define to 1 if the system has the type `major_t'. */ #cmakedefine HAVE_MAJOR_T @HAVE_MAJOR_T@ @@ -209,3 +206,5 @@ /* Define to `long long' if not defined in system header files. */ #cmakedefine uint64_t @uint64_t@ + +#define CMTAR_ZLIB_HEADER "@CMTAR_ZLIB_HEADER@" diff --git a/Utilities/cmtar/libtar.c b/Utilities/cmtar/libtar.c index c918e24..362c105 100644 --- a/Utilities/cmtar/libtar.c +++ b/Utilities/cmtar/libtar.c @@ -35,18 +35,7 @@ # include <signal.h> #endif -#ifdef HAVE_LIBZ -#ifdef HAVE_VTK_LIBZ -# include <vtkzlib/zlib.h> -# define cm_zlib_gzdopen gzdopen -# define cm_zlib_gzclose gzclose -# define cm_zlib_gzread gzread -# define cm_zlib_gzwrite gzwrite - -#else -# include <cmzlib/zlib.h> -#endif -#endif +#include CMTAR_ZLIB_HEADER #include <libtar/compat.h> @@ -117,7 +106,7 @@ static int libtar_gzopen(void* call_data, const char *pathname, } #endif - gzf->GZFile = cm_zlib_gzdopen(fd, gzoflags); + gzf->GZFile = gzdopen(fd, gzoflags); if (!gzf->GZFile) { errno = ENOMEM; @@ -130,19 +119,19 @@ static int libtar_gzopen(void* call_data, const char *pathname, static int libtar_gzclose(void* call_data) { struct gzStruct* gzf = (struct gzStruct*)call_data; - return cm_zlib_gzclose(gzf->GZFile); + return gzclose(gzf->GZFile); } static ssize_t libtar_gzread(void* call_data, void* buf, size_t count) { struct gzStruct* gzf = (struct gzStruct*)call_data; - return cm_zlib_gzread(gzf->GZFile, buf, count); + return gzread(gzf->GZFile, buf, count); } static ssize_t libtar_gzwrite(void* call_data, const void* buf, size_t count) { struct gzStruct* gzf = (struct gzStruct*)call_data; - return cm_zlib_gzwrite(gzf->GZFile, (void*)buf, count); + return gzwrite(gzf->GZFile, (void*)buf, count); } tartype_t gztype = { diff --git a/Utilities/cmxmlrpc/xmlrpc.h b/Utilities/cmxmlrpc/xmlrpc.h index 69160a2..30b8384 100644 --- a/Utilities/cmxmlrpc/xmlrpc.h +++ b/Utilities/cmxmlrpc/xmlrpc.h @@ -29,7 +29,7 @@ #include <stddef.h> #include <stdarg.h> -#include <xmlrpc_config.h> +#include <cmxmlrpc/xmlrpc_config.h> #ifdef HAVE_UNICODE_WCHAR #include <wchar.h> @@ -778,7 +778,7 @@ char *xmlrpc_authcookie(void); in here. For backward compatibility, we need to include it here, even though it really isn't logical to do so. */ -#include <xmlrpc_server.h> +#include <cmxmlrpc/xmlrpc_server.h> #endif diff --git a/Utilities/cmxmlrpc/xmlrpc_expat.c b/Utilities/cmxmlrpc/xmlrpc_expat.c index cb467d1..d7b6e19 100644 --- a/Utilities/cmxmlrpc/xmlrpc_expat.c +++ b/Utilities/cmxmlrpc/xmlrpc_expat.c @@ -28,7 +28,7 @@ #include <stddef.h> #include <stdlib.h> #include <string.h> -#include <expat.h> +#include <cm_expat.h> #include "xmlrpc.h" #include "xmlrpc_int.h" |