From 036b6ef7c47ccb19f291d2f36df37aaf885b4ba8 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Thu, 17 Dec 2015 15:03:42 -0500
Subject: Port CMake from cmIML to KWIML

KWIML no longer uses a configured prefix.
---
 CMakeLists.txt                |  6 +++---
 CTestCustom.cmake.in          |  2 +-
 Source/cmAlgorithms.h         |  4 ++--
 Source/cmELF.cxx              | 11 ++++-------
 Source/cmFileCommand.cxx      |  4 ++--
 Source/cmFindPackageCommand.h |  2 +-
 Source/cmLocalGenerator.cxx   |  4 ++--
 Source/cmLocalGenerator.h     |  4 ++--
 Source/cmStandardIncludes.h   |  2 +-
 Source/cmVersion.h            |  2 +-
 Source/cm_sha2.c              | 13 ++++++-------
 Source/cm_sha2.h              | 10 +++++-----
 Utilities/cm_kwiml.h          | 18 ++++++++++++++++++
 bootstrap                     | 19 ++-----------------
 14 files changed, 50 insertions(+), 51 deletions(-)
 create mode 100644 Utilities/cm_kwiml.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ebee14b..932d07e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -538,9 +538,9 @@ if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x")
   set(CMAKE_TESTS_CDASH_SERVER "http://open.cdash.org")
 endif()
 
-# Create the KWIML library for CMake.
-set(KWIML cmIML)
-set(KWIML_HEADER_ROOT ${CMake_BINARY_DIR}/Utilities)
+if(BUILD_TESTING)
+  set(KWIML_TEST_ENABLE 1)
+endif()
 add_subdirectory(Utilities/KWIML)
 
 if(NOT CMake_TEST_EXTERNAL_CMAKE)
diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in
index 2adf317..db64559 100644
--- a/CTestCustom.cmake.in
+++ b/CTestCustom.cmake.in
@@ -36,7 +36,7 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
   "LINK : warning LNK4089: all references to.*SHELL32.dll.*discarded by /OPT:REF"
   "LINK : warning LNK4089: all references to.*USER32.dll.*discarded by /OPT:REF"
   "LINK : warning LNK4089: all references to.*ole32.dll.*discarded by /OPT:REF"
-  "Warning.*: .*/Utilities/KWIML/test/test_INT_format.h.* # Redundant preprocessing concatenation"
+  "Warning.*: .*/Utilities/KWIML/test/test_int_format.h.* # Redundant preprocessing concatenation"
   "Warning: library was too large for page size.*"
   "Warning: public.*_archive_.*in module.*archive_*clashes with prior module.*archive_.*"
   "Warning: public.*BZ2_bz.*in module.*bzlib.*clashes with prior module.*bzlib.*"
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index bda933b..ef607d2 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -162,13 +162,13 @@ struct cmRange
   const_iterator end() const { return End; }
   bool empty() const { return std::distance(Begin, End) == 0; }
   difference_type size() const { return std::distance(Begin, End); }
-  cmRange& advance(cmIML_INT_intptr_t amount)
+  cmRange& advance(KWIML_INT_intptr_t amount)
   {
     std::advance(Begin, amount);
     return *this;
   }
 
-  cmRange& retreat(cmIML_INT_intptr_t amount)
+  cmRange& retreat(KWIML_INT_intptr_t amount)
   {
     std::advance(End, -amount);
     return *this;
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index fda6e02..b480cd5 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -15,9 +15,6 @@
 #include <cmsys/auto_ptr.hxx>
 #include <cmsys/FStream.hxx>
 
-// Need the native byte order of the running CPU.
-#include <cmIML/ABI.h>
-
 // Include the ELF format information system header.
 #if defined(__OpenBSD__)
 # include <stdint.h>
@@ -101,9 +98,9 @@ public:
     // In most cases the processor-specific byte order will match that
     // of the target execution environment.  If we choose wrong here
     // it is fixed when the header is read.
-#if cmIML_ABI_ENDIAN_ID == cmIML_ABI_ENDIAN_ID_LITTLE
+#if KWIML_ABI_ENDIAN_ID == KWIML_ABI_ENDIAN_ID_LITTLE
     this->NeedSwap = (this->ByteOrder == ByteOrderMSB);
-#elif cmIML_ABI_ENDIAN_ID == cmIML_ABI_ENDIAN_ID_BIG
+#elif KWIML_ABI_ENDIAN_ID == KWIML_ABI_ENDIAN_ID_BIG
     this->NeedSwap = (this->ByteOrder == ByteOrderLSB);
 #else
     this->NeedSwap = false; // Final decision is at runtime anyway.
@@ -197,7 +194,7 @@ struct cmELFTypes32
   typedef Elf32_Shdr ELF_Shdr;
   typedef Elf32_Dyn  ELF_Dyn;
   typedef Elf32_Half ELF_Half;
-  typedef cmIML_INT_uint32_t tagtype;
+  typedef KWIML_INT_uint32_t tagtype;
   static const char* GetName() { return "32-bit"; }
 };
 
@@ -208,7 +205,7 @@ struct cmELFTypes64
   typedef Elf64_Shdr ELF_Shdr;
   typedef Elf64_Dyn  ELF_Dyn;
   typedef Elf64_Half ELF_Half;
-  typedef cmIML_INT_uint64_t tagtype;
+  typedef KWIML_INT_uint64_t tagtype;
   static const char* GetName() { return "64-bit"; }
 };
 
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index df95d9d..b3557f9 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2811,8 +2811,8 @@ namespace {
       case CURLINFO_SSL_DATA_OUT:
         {
         char buf[128];
-        int n = sprintf(buf, "[%" cmIML_INT_PRIu64 " bytes data]\n",
-                        static_cast<cmIML_INT_uint64_t>(size));
+        int n = sprintf(buf, "[%" KWIML_INT_PRIu64 " bytes data]\n",
+                        static_cast<KWIML_INT_uint64_t>(size));
         if (n > 0)
           {
           vec->insert(vec->end(), buf, buf + n);
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 3eee404..8bfd405 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -130,7 +130,7 @@ private:
   unsigned int VersionFoundPatch;
   unsigned int VersionFoundTweak;
   unsigned int VersionFoundCount;
-  cmIML_INT_uint64_t RequiredCMakeVersion;
+  KWIML_INT_uint64_t RequiredCMakeVersion;
   bool Quiet;
   bool Required;
   bool UseConfigFiles;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 6a57374..1d17032 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2980,7 +2980,7 @@ cmLocalGenerator::GetTargetDirectory(const cmGeneratorTarget*) const
 }
 
 //----------------------------------------------------------------------------
-cmIML_INT_uint64_t cmLocalGenerator::GetBackwardsCompatibility()
+KWIML_INT_uint64_t cmLocalGenerator::GetBackwardsCompatibility()
 {
   // The computed version may change until the project is fully
   // configured.
@@ -3033,7 +3033,7 @@ bool cmLocalGenerator::NeedBackwardsCompatibility_2_4()
 
   // Compatibility is needed if CMAKE_BACKWARDS_COMPATIBILITY is set
   // equal to or lower than the given version.
-  cmIML_INT_uint64_t actual_compat = this->GetBackwardsCompatibility();
+  KWIML_INT_uint64_t actual_compat = this->GetBackwardsCompatibility();
   return (actual_compat &&
           actual_compat <= CMake_VERSION_ENCODE(2, 4, 255));
 }
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index e2f5519..68e7667 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -267,7 +267,7 @@ public:
    *
    * and is monotonically increasing with the CMake version.
    */
-  cmIML_INT_uint64_t GetBackwardsCompatibility();
+  KWIML_INT_uint64_t GetBackwardsCompatibility();
 
   /**
    * Test whether compatibility is set to a given version or lower.
@@ -390,7 +390,7 @@ protected:
   // committed.
   std::string TargetImplib;
 
-  cmIML_INT_uint64_t BackwardsCompatibility;
+  KWIML_INT_uint64_t BackwardsCompatibility;
   bool BackwardsCompatibilityFinal;
 private:
   void AddSharedFlags(std::string& flags, const std::string& lang,
diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h
index aed2e74..272c136 100644
--- a/Source/cmStandardIncludes.h
+++ b/Source/cmStandardIncludes.h
@@ -31,7 +31,7 @@
 #endif
 
 // Provide fixed-size integer types.
-#include <cmIML/INT.h>
+#include <cm_kwiml.h>
 
 #include <fstream>
 #include <iostream>
diff --git a/Source/cmVersion.h b/Source/cmVersion.h
index 0ab6390..84f750f 100644
--- a/Source/cmVersion.h
+++ b/Source/cmVersion.h
@@ -34,7 +34,7 @@ public:
 
 /* Encode with room for up to 1000 minor releases between major releases
    and to encode dates until the year 10000 in the patch level.  */
-#define CMake_VERSION_ENCODE__BASE cmIML_INT_UINT64_C(100000000)
+#define CMake_VERSION_ENCODE__BASE KWIML_INT_UINT64_C(100000000)
 #define CMake_VERSION_ENCODE(major, minor, patch) \
   ((((major) * 1000u) * CMake_VERSION_ENCODE__BASE) + \
    (((minor) % 1000u) * CMake_VERSION_ENCODE__BASE) + \
diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c
index b90e060..649c39a 100644
--- a/Source/cm_sha2.c
+++ b/Source/cm_sha2.c
@@ -87,22 +87,21 @@
  * made).
  */
 #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
-/* CMake modification: use byte order from cmIML.  */
-# include "cmIML/ABI.h"
+/* CMake modification: use byte order from KWIML.  */
 # undef BYTE_ORDER
 # undef BIG_ENDIAN
 # undef LITTLE_ENDIAN
-# define BYTE_ORDER    cmIML_ABI_ENDIAN_ID
-# define BIG_ENDIAN    cmIML_ABI_ENDIAN_ID_BIG
-# define LITTLE_ENDIAN cmIML_ABI_ENDIAN_ID_LITTLE
+# define BYTE_ORDER    KWIML_ABI_ENDIAN_ID
+# define BIG_ENDIAN    KWIML_ABI_ENDIAN_ID_BIG
+# define LITTLE_ENDIAN KWIML_ABI_ENDIAN_ID_LITTLE
 #endif
 
 /* CMake modification: use types computed in header.  */
 typedef cm_sha2_uint8_t  sha_byte;	/* Exactly 1 byte */
 typedef cm_sha2_uint32_t sha_word32;	/* Exactly 4 bytes */
 typedef cm_sha2_uint64_t sha_word64;	/* Exactly 8 bytes */
-#define SHA_UINT32_C(x) cmIML_INT_UINT32_C(x)
-#define SHA_UINT64_C(x) cmIML_INT_UINT64_C(x)
+#define SHA_UINT32_C(x) KWIML_INT_UINT32_C(x)
+#define SHA_UINT64_C(x) KWIML_INT_UINT64_C(x)
 #if defined(__clang__)
 # pragma clang diagnostic ignored "-Wcast-align"
 #endif
diff --git a/Source/cm_sha2.h b/Source/cm_sha2.h
index 71395f0..f151031 100644
--- a/Source/cm_sha2.h
+++ b/Source/cm_sha2.h
@@ -38,11 +38,11 @@
 
 #include "cm_sha2_mangle.h"
 
-/* CMake modification: use integer types from cmIML.  */
-#include "cmIML/INT.h"
-typedef cmIML_INT_uint8_t cm_sha2_uint8_t;
-typedef cmIML_INT_uint32_t cm_sha2_uint32_t;
-typedef cmIML_INT_uint64_t cm_sha2_uint64_t;
+/* CMake modification: use integer types from KWIML.  */
+#include <cm_kwiml.h>
+typedef KWIML_INT_uint8_t cm_sha2_uint8_t;
+typedef KWIML_INT_uint32_t cm_sha2_uint32_t;
+typedef KWIML_INT_uint64_t cm_sha2_uint64_t;
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/Utilities/cm_kwiml.h b/Utilities/cm_kwiml.h
new file mode 100644
index 0000000..2e1a108
--- /dev/null
+++ b/Utilities/cm_kwiml.h
@@ -0,0 +1,18 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2000-2015 Kitware, Inc., Insight Software Consortium
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+#ifndef cm_kwiml_h
+#define cm_kwiml_h
+
+#include "KWIML/include/kwiml/abi.h"
+#include "KWIML/include/kwiml/int.h"
+
+#endif
diff --git a/bootstrap b/bootstrap
index b2421a1..860b5e4 100755
--- a/bootstrap
+++ b/bootstrap
@@ -373,11 +373,6 @@ KWSYS_FILES="\
   SystemTools.hxx \
   Terminal.h"
 
-KWIML_FILES='
-  ABI.h
-  INT.h
-'
-
 # Display CMake bootstrap usage
 cmake_usage()
 {
@@ -702,11 +697,6 @@ if [ ! -d "cmsys" ]; then
   cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
 fi
 
-[ -d "cmIML" ] || mkdir "cmIML"
-if [ ! -d "cmIML" ]; then
-  cmake_error 12 "Cannot create directory ${cmake_bootstrap_dir}/cmIML"
-fi
-
 # Delete all the bootstrap files
 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
 rm -f "${cmake_bootstrap_dir}/cmConfigure.h${_tmp}"
@@ -1280,11 +1270,6 @@ for a in ${KWSYS_FILES}; do
      "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
 done
 
-for a in ${KWIML_FILES}; do
-  cmake_replace_string "${cmake_source_dir}/Utilities/KWIML/${a}.in" \
-     "${cmake_bootstrap_dir}/cmIML/${a}" KWIML cmIML
-done
-
 # Generate Makefile
 dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
 objs=""
@@ -1326,9 +1311,9 @@ cmake_cxx_flags_SystemTools="
   -DKWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES}
 "
 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
-  -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
+  -I`cmake_escape \"${cmake_source_dir}/Utilities\"`"
 cmake_cxx_flags="${cmake_cxx_flags} -I`cmake_escape \"${cmake_bootstrap_dir}\"` -I`cmake_escape \"${cmake_source_dir}/Source\"` \
-  -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
+  -I`cmake_escape \"${cmake_source_dir}/Utilities\"`"
 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
 echo "	${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
 for a in ${CMAKE_CXX_SOURCES}; do
-- 
cgit v0.12