From 831badeca25a8eca9e92dbbb181ea69b58112b2c Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 27 Jun 2011 13:58:32 -0400 Subject: KWIML: The Kitware Information Macro Library Provides header files that use preprocessor tests to detect and provide information about the compiler and its target architecture. The headers contain no configuration-time test results and thus may be installed into an architecture-independent include directory. This makes them suitable for use in the public interface of any package. --- ABI.h.in | 461 +++++++++++++++++++++++++++++ CMakeLists.txt | 79 +++++ Copyright.txt | 30 ++ INT.h.in | 735 ++++++++++++++++++++++++++++++++++++++++++++++ README.txt | 29 ++ test/CMakeLists.txt | 51 ++++ test/test.c | 35 +++ test/test.cxx | 12 + test/test.h | 35 +++ test/test_ABI_C.c | 22 ++ test/test_ABI_CXX.cxx | 22 ++ test/test_ABI_endian.h.in | 47 +++ test/test_INT_C.c | 22 ++ test/test_INT_CXX.cxx | 22 ++ test/test_INT_format.h.in | 188 ++++++++++++ 15 files changed, 1790 insertions(+) create mode 100644 ABI.h.in create mode 100644 CMakeLists.txt create mode 100644 Copyright.txt create mode 100644 INT.h.in create mode 100644 README.txt create mode 100644 test/CMakeLists.txt create mode 100644 test/test.c create mode 100644 test/test.cxx create mode 100644 test/test.h create mode 100644 test/test_ABI_C.c create mode 100644 test/test_ABI_CXX.cxx create mode 100644 test/test_ABI_endian.h.in create mode 100644 test/test_INT_C.c create mode 100644 test/test_INT_CXX.cxx create mode 100644 test/test_INT_format.h.in diff --git a/ABI.h.in b/ABI.h.in new file mode 100644 index 0000000..c4121ff --- /dev/null +++ b/ABI.h.in @@ -0,0 +1,461 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of Kitware, Inc. nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +============================================================================*/ +#ifndef @KWIML@_ABI_H +#define @KWIML@_ABI_H +/* +This header defines macros with information about the C ABI. +Only information that can be determined using the preprocessor at +compilation time is available. No try-compile results may be added +here. Instead we memorize results on platforms of interest. + +An includer may optionally define the following macros to suppress errors: + + @KWIML@_ABI_NO_VERIFY = skip verification declarations + @KWIML@_ABI_NO_ERROR_CHAR_SIGN = signedness of 'char' may be unknown + @KWIML@_ABI_NO_ERROR_LONG_LONG = existence of 'long long' may be unknown + @KWIML@_ABI_NO_ERROR_ENDIAN = byte order of CPU may be unknown + +An includer may test the following macros after inclusion: + + @KWIML@_ABI_SIZEOF_DATA_PTR = sizeof(void*) + @KWIML@_ABI_SIZEOF_CODE_PTR = sizeof(void(*)(void)) + @KWIML@_ABI_SIZEOF_FLOAT = sizeof(float) + @KWIML@_ABI_SIZEOF_DOUBLE = sizeof(double) + @KWIML@_ABI_SIZEOF_CHAR = sizeof(char) + @KWIML@_ABI_SIZEOF_SHORT = sizeof(short) + @KWIML@_ABI_SIZEOF_INT = sizeof(int) + @KWIML@_ABI_SIZEOF_LONG = sizeof(long) + + @KWIML@_ABI_SIZEOF_LONG_LONG = sizeof(long long) or 0 if not a type + Undefined if existence is unknown and error suppression macro + @KWIML@_ABI_NO_ERROR_LONG_LONG was defined. + + @KWIML@_ABI_SIZEOF___INT64 = 8 if '__int64' exists or 0 if not + Undefined if existence is unknown. + + @KWIML@_ABI___INT64_IS_LONG = 1 if '__int64' is 'long' (same type) + Undefined otherwise. + @KWIML@_ABI___INT64_IS_LONG_LONG = 1 if '__int64' is 'long long' (same type) + Undefined otherwise. + @KWIML@_ABI___INT64_IS_UNIQUE = 1 if '__int64' is a distinct type + Undefined otherwise. + + @KWIML@_ABI_CHAR_IS_UNSIGNED = 1 if 'char' is unsigned, else undefined + @KWIML@_ABI_CHAR_IS_SIGNED = 1 if 'char' is signed, else undefined + One of these is defined unless signedness of 'char' is unknown and + error suppression macro @KWIML@_ABI_NO_ERROR_CHAR_SIGN was defined. + + @KWIML@_ABI_ENDIAN_ID_BIG = id for big-endian (always defined) + @KWIML@_ABI_ENDIAN_ID_LITTLE = id for little-endian (always defined) + @KWIML@_ABI_ENDIAN_ID = id of byte order of target CPU + Defined to @KWIML@_ABI_ENDIAN_ID_BIG or @KWIML@_ABI_ENDIAN_ID_LITTLE + unless byte order is unknown and error suppression macro + @KWIML@_ABI_NO_ERROR_ENDIAN was defined. + +We verify most results using dummy "extern" declarations that are +invalid if the macros are wrong. Verification is disabled if +suppression macro @KWIML@_ABI_NO_VERIFY was defined. +*/ + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_DATA_PTR) +# if defined(__SIZEOF_POINTER__) +# define @KWIML@_ABI_SIZEOF_DATA_PTR __SIZEOF_POINTER__ +# elif defined(_SIZE_PTR) +# define @KWIML@_ABI_SIZEOF_DATA_PTR (_SIZE_PTR >> 3) +# elif defined(_LP64) || defined(__LP64__) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(_ILP32) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 4 +# elif defined(__64BIT__) /* IBM XL */ +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(_M_X64) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(__ia64) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(__sparcv9) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(__x86_64) || defined(__x86_64__) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(__amd64) || defined(__amd64__) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(__i386) || defined(__i386__) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 4 +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_DATA_PTR) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 4 +#endif +#if !defined(@KWIML@_ABI_SIZEOF_CODE_PTR) +# define @KWIML@_ABI_SIZEOF_CODE_PTR @KWIML@_ABI_SIZEOF_DATA_PTR +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_CHAR) +# define @KWIML@_ABI_SIZEOF_CHAR 1 +#endif + +#if !defined(@KWIML@_ABI_CHAR_IS_UNSIGNED) && !defined(@KWIML@_ABI_CHAR_IS_SIGNED) +# if defined(__CHAR_UNSIGNED__) /* GNU, some IBM XL, others? */ +# define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 +# elif defined(_CHAR_UNSIGNED) /* Intel, IBM XL, MSVC, Borland, others? */ +# define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 +# elif defined(_CHAR_SIGNED) /* IBM XL, others? */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(__CHAR_SIGNED__) /* IBM XL, Watcom, others? */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(__SIGNED_CHARS__) /* EDG, Intel, SGI MIPSpro */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(_CHAR_IS_SIGNED) /* Some SunPro, others? */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(_CHAR_IS_UNSIGNED) /* SunPro, others? */ +# define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 +# elif defined(__GNUC__) /* GNU default */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* SunPro default */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(__HP_cc) || defined(__HP_aCC) /* HP default (unless +uc) */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(_SGI_COMPILER_VERSION) /* SGI MIPSpro default */ +# define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 +# elif defined(_MSC_VER) /* MSVC default */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(__WATCOMC__) /* Watcom default */ +# define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 +# elif defined(__BORLANDC__) /* Borland default */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# endif +#endif +#if !defined(@KWIML@_ABI_CHAR_IS_UNSIGNED) && !defined(@KWIML@_ABI_CHAR_IS_SIGNED) \ + && !defined(@KWIML@_ABI_NO_ERROR_CHAR_SIGN) +# error "Signedness of 'char' unknown." +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_SHORT) +# if defined(__SIZEOF_SHORT__) +# define @KWIML@_ABI_SIZEOF_SHORT __SIZEOF_SHORT__ +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_SHORT) +# define @KWIML@_ABI_SIZEOF_SHORT 2 +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_INT) +# if defined(__SIZEOF_INT__) +# define @KWIML@_ABI_SIZEOF_INT __SIZEOF_INT__ +# elif defined(_SIZE_INT) +# define @KWIML@_ABI_SIZEOF_INT (_SIZE_INT >> 3) +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_INT) +# define @KWIML@_ABI_SIZEOF_INT 4 +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_LONG) +# if defined(__SIZEOF_LONG__) +# define @KWIML@_ABI_SIZEOF_LONG __SIZEOF_LONG__ +# elif defined(_SIZE_LONG) +# define @KWIML@_ABI_SIZEOF_LONG (_SIZE_LONG >> 3) +# elif defined(__LONG_MAX__) +# if __LONG_MAX__ == 0x7fffffff +# define @KWIML@_ABI_SIZEOF_LONG 4 +# elif __LONG_MAX__>>32 == 0x7fffffff +# define @KWIML@_ABI_SIZEOF_LONG 8 +# endif +# elif defined(_MSC_VER) /* MSVC and Intel on Windows */ +# define @KWIML@_ABI_SIZEOF_LONG 4 +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_LONG) +# define @KWIML@_ABI_SIZEOF_LONG @KWIML@_ABI_SIZEOF_DATA_PTR +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_LONG_LONG) +# if defined(__SIZEOF_LONG_LONG__) +# define @KWIML@_ABI_SIZEOF_LONG_LONG __SIZEOF_LONG_LONG__ +# elif defined(__LONG_LONG_MAX__) +# if __LONG_LONG_MAX__ == 0x7fffffff +# define @KWIML@_ABI_SIZEOF_LONG_LONG 4 +# elif __LONG_LONG_MAX__>>32 == 0x7fffffff +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# endif +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_LONG_LONG) +# if defined(_LONGLONG) /* SGI, some GNU, perhaps others. */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(_LONG_LONG) /* IBM XL, perhaps others. */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__NO_LONG_LONG) /* EDG */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 0 +# elif defined(__cplusplus) && __cplusplus > 199711L /* C++0x */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* SunPro */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__HP_cc) || defined(__HP_aCC) /* HP */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__WATCOMC__) /* Watcom */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__INTEL_COMPILER) /* Intel */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__BORLANDC__) /* Borland */ +# if __BORLANDC__ >= 0x0560 +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# else +# define @KWIML@_ABI_SIZEOF_LONG_LONG 0 +# endif +# elif defined(_MSC_VER) /* Microsoft */ +# if _MSC_VER >= 1310 +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# else +# define @KWIML@_ABI_SIZEOF_LONG_LONG 0 +# endif +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && !defined(@KWIML@_ABI_NO_ERROR_LONG_LONG) +# error "Existence of 'long long' unknown." +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF___INT64) +# if defined(__INTEL_COMPILER) +# define @KWIML@_ABI_SIZEOF___INT64 8 +# elif defined(_MSC_VER) +# define @KWIML@_ABI_SIZEOF___INT64 8 +# elif defined(__BORLANDC__) +# define @KWIML@_ABI_SIZEOF___INT64 8 +# else +# define @KWIML@_ABI_SIZEOF___INT64 0 +# endif +#endif + +#if defined(@KWIML@_ABI_SIZEOF___INT64) && @KWIML@_ABI_SIZEOF___INT64 > 0 +# if @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_ABI___INT64_IS_LONG 1 +# elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# define @KWIML@_ABI___INT64_IS_LONG_LONG 1 +# else +# define @KWIML@_ABI___INT64_IS_UNIQUE 1 +# endif +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_FLOAT) +# if defined(__SIZEOF_FLOAT__) +# define @KWIML@_ABI_SIZEOF_FLOAT __SIZEOF_FLOAT__ +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_FLOAT) +# define @KWIML@_ABI_SIZEOF_FLOAT 4 +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_DOUBLE) +# if defined(__SIZEOF_DOUBLE__) +# define @KWIML@_ABI_SIZEOF_DOUBLE __SIZEOF_DOUBLE__ +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_DOUBLE) +# define @KWIML@_ABI_SIZEOF_DOUBLE 8 +#endif + +/*--------------------------------------------------------------------------*/ +/* Identify possible endian cases. The macro @KWIML@_ABI_ENDIAN_ID will be + defined to one of these, or undefined if unknown. */ +#if !defined(@KWIML@_ABI_ENDIAN_ID_BIG) +# define @KWIML@_ABI_ENDIAN_ID_BIG 4321 +#endif +#if !defined(@KWIML@_ABI_ENDIAN_ID_LITTLE) +# define @KWIML@_ABI_ENDIAN_ID_LITTLE 1234 +#endif +#if @KWIML@_ABI_ENDIAN_ID_BIG == @KWIML@_ABI_ENDIAN_ID_LITTLE +# error "@KWIML@_ABI_ENDIAN_ID_BIG == @KWIML@_ABI_ENDIAN_ID_LITTLE" +#endif + +#if defined(@KWIML@_ABI_ENDIAN_ID) /* Skip #elif cases if already defined. */ + +/* Use dedicated symbols if the compiler defines them. Do this first + because some architectures allow runtime byte order selection by + the operating system (values for such architectures below are + guesses for compilers that do not define a dedicated symbol). + Ensure that only one is defined in case the platform or a header + defines both as possible values for some third symbol. */ +#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +#elif defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +#elif defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE + +/* Alpha */ +#elif defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE + +/* Arm */ +#elif defined(__arm__) +# if !defined(__ARMEB__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +# else +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +# endif + +/* Intel x86 */ +#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +#elif defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +#elif defined(__MWERKS__) && defined(__INTEL__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE + +/* Intel x86-64 */ +#elif defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +#elif defined(__amd64) || defined(__amd64__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE + +/* Intel Architecture-64 (Itanium) */ +#elif defined(__ia64) || defined(__ia64__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +#elif defined(_IA64) || defined(__IA64__) || defined(_M_IA64) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE + +/* PowerPC */ +#elif defined(__powerpc) || defined(__powerpc__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +#elif defined(__ppc) || defined(__ppc__) || defined(__POWERPC__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* SPARC */ +#elif defined(__sparc) || defined(__sparc__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* HP/PA RISC */ +#elif defined(__hppa) || defined(__hppa__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* Motorola 68k */ +#elif defined(__m68k__) || defined(M68000) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* MIPS */ +#elif defined(__mips) || defined(__mips__) || defined(__MIPS__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* RS/6000 */ +#elif defined(__THW_RS600) || defined(_IBMR2) || defined(_POWER) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +#elif defined(_ARCH_PWR) || defined(_ARCH_PWR2) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* System/370 */ +#elif defined(__370__) || defined(__THW_370__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* System/390 */ +#elif defined(__s390__) || defined(__s390x__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* z/Architecture */ +#elif defined(__SYSC_ZARCH__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* Unknown CPU */ +#elif !defined(@KWIML@_ABI_NO_ERROR_ENDIAN) +# error "Byte order of target CPU unknown." +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_NO_VERIFY) +#define @KWIML@_ABI__VERIFY(n, x, y) extern int (*n)[x]; extern int (*n)[y] +#define @KWIML@_ABI__VERIFY2(n, x, y) extern int (*n)(x*); extern int (*n)(y*) +#if defined(__cplusplus) +# define @KWIML@_ABI__VERIFY3(n, x, y) extern int* n(x*); extern char* n(y*) +#else +# define @KWIML@_ABI__VERIFY3(n, x, y) extern int* n(x*) /* TODO: possible? */ +#endif +#define @KWIML@_ABI__VERIFY_BOOL(m, b) @KWIML@_ABI__VERIFY(m##__VERIFY__, 2, (b)?2:3) +#define @KWIML@_ABI__VERIFY_SIZE(m, t) @KWIML@_ABI__VERIFY(m##__VERIFY__, m, sizeof(t)) +#define @KWIML@_ABI__VERIFY_SAME(m, x, y) @KWIML@_ABI__VERIFY2(m##__VERIFY__, x, y) +#define @KWIML@_ABI__VERIFY_DIFF(m, x, y) @KWIML@_ABI__VERIFY3(m##__VERIFY__, x, y) + +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_DATA_PTR, int*); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_CODE_PTR, int(*)(int)); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_CHAR, char); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_SHORT, short); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_INT, int); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_LONG, long); +#if defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG > 0 +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_LONG_LONG, long long); +#endif +#if defined(@KWIML@_ABI_SIZEOF___INT64) && @KWIML@_ABI_SIZEOF___INT64 > 0 +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF___INT64, __int64); +#endif +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_FLOAT, float); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_DOUBLE, double); + +#if defined(@KWIML@_ABI___INT64_IS_LONG) +@KWIML@_ABI__VERIFY_SAME(@KWIML@_ABI___INT64_IS_LONG, __int64, long); +#elif defined(@KWIML@_ABI___INT64_IS_LONG_LONG) +@KWIML@_ABI__VERIFY_SAME(@KWIML@_ABI___INT64_IS_LONG_LONG, __int64, long long); +#elif defined(@KWIML@_ABI_SIZEOF___INT64) && @KWIML@_ABI_SIZEOF___INT64 > 0 +@KWIML@_ABI__VERIFY_DIFF(@KWIML@_ABI___INT64_NOT_LONG, __int64, long); +# if defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG > 0 +@KWIML@_ABI__VERIFY_DIFF(@KWIML@_ABI___INT64_NOT_LONG_LONG, __int64, long long); +# endif +#endif + +#if defined(@KWIML@_ABI_CHAR_IS_UNSIGNED) +@KWIML@_ABI__VERIFY_BOOL(@KWIML@_ABI_CHAR_IS_UNSIGNED, (char)0x80 > 0); +#elif defined(@KWIML@_ABI_CHAR_IS_SIGNED) +@KWIML@_ABI__VERIFY_BOOL(@KWIML@_ABI_CHAR_IS_SIGNED, (char)0x80 < 0); +#endif + +#undef @KWIML@_ABI__VERIFY_DIFF +#undef @KWIML@_ABI__VERIFY_SAME +#undef @KWIML@_ABI__VERIFY_SIZE +#undef @KWIML@_ABI__VERIFY_BOOL +#undef @KWIML@_ABI__VERIFY3 +#undef @KWIML@_ABI__VERIFY2 +#undef @KWIML@_ABI__VERIFY + +#endif + +#endif diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6a8641a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,79 @@ +#============================================================================= +# Kitware Information Macro Library +# Copyright 2010-2011 Kitware, Inc. +# +# 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. +#============================================================================= + +# Import the KWIML directory tree into a subdirectory under a parent +# project and configure the library as follows: +# +# SET(KWIML myIML) +# SUBDIRS(KWIML) +# +# Optional settings are as follows: +# +# KWIML_HEADER_ROOT = build tree directory to hold KWIML headers. +# Headers will go in a directory called "${KWIML}" under this root. +# For example: +# +# SET(KWIML_HEADER_ROOT ${PROJECT_BINARY_DIR}) +# INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) +# +# KWIML_INSTALL_INCLUDE_DIR = install KWIML with "make install" +# Specify a value relative to the install prefix and do NOT start with '/'. +# KWIML_INSTALL_INCLUDE_OPTIONS = extra header installation options +# Specify options for the install(FILES) command. +# +# KWIML_LABELS_TEST = list of labels for KWIML tests + +cmake_minimum_required(VERSION 2.6.3 FATAL_ERROR) + +#----------------------------------------------------------------------------- +if(NOT DEFINED KWIML) + if(NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") + message(FATAL_ERROR "Set KWIML namespace in parent directory!") + endif() + set(KWIML KWIML) + set(KWIML_STANDALONE 1) + project(KWIML) + include(CTest) + mark_as_advanced(BUILD_TESTING) +endif() + +#----------------------------------------------------------------------------- +get_property(KWIML_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) +foreach(lang ${KWIML_LANGUAGES}) + set(KWIML_LANGUAGE_${lang} 1) +endforeach() +if(NOT KWIML_LANGUAGE_C AND NOT KWIML_LANGUAGE_CXX) + set(BUILD_TESTING OFF) +endif() + +#----------------------------------------------------------------------------- +if(NOT KWIML_HEADER_ROOT) + set(KWIML_HEADER_ROOT "${PROJECT_BINARY_DIR}") +endif() +set(KWIML_HEADER_DIR "${KWIML_HEADER_ROOT}/${KWIML}") +include_directories(${KWIML_HEADER_ROOT}) + +#----------------------------------------------------------------------------- +foreach(h ABI INT) + set(header ${KWIML_HEADER_DIR}/${h}.h) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${h}.h.in ${header} @ONLY) + if(KWIML_INSTALL_INCLUDE_DIR) + install(FILES ${header} + DESTINATION ${KWIML_INSTALL_INCLUDE_DIR}/${KWIML} + ${KWIML_INSTALL_INCLUDE_OPTIONS}) + endif() +endforeach() + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(test) +endif() diff --git a/Copyright.txt b/Copyright.txt new file mode 100644 index 0000000..c1e5ebc --- /dev/null +++ b/Copyright.txt @@ -0,0 +1,30 @@ +Kitware Information Macro Library +Copyright 2010-2011 Kitware, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name of Kitware, Inc. nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/INT.h.in b/INT.h.in new file mode 100644 index 0000000..4a6298a --- /dev/null +++ b/INT.h.in @@ -0,0 +1,735 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of Kitware, Inc. nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +============================================================================*/ +#ifndef @KWIML@_INT_H +#define @KWIML@_INT_H +/* +This header defines macros with information about sized integer types. +Only information that can be determined using the preprocessor at +compilation time is available. No try-compile results may be added +here. Instead we memorize results on platforms of interest. + +An includer may optionally define the following macros to suppress errors: + +Input: + @KWIML@_INT_NO_VERIFY = skip verification declarations + @KWIML@_INT_NO_ERROR_INT64_T = type '@KWIML@_INT_int64_t' is optional (*) + @KWIML@_INT_NO_ERROR_UINT64_T = type '@KWIML@_INT_uint64_t' is optional (*) + @KWIML@_INT_NO_ERROR_INTPTR_T = type '@KWIML@_INT_intptr_t' is optional (*) + @KWIML@_INT_NO_ERROR_UINTPTR_T = type '@KWIML@_INT_uintptr_t' is optional (*) + +An includer may optionally define the following macros to override defaults. +Either way, an includer may test these macros after inclusion: + + @KWIML@_INT_HAVE_STDINT_H = include + @KWIML@_INT_NO_STDINT_H = do not include + @KWIML@_INT_HAVE_INTTYPES_H = include + @KWIML@_INT_NO_INTTYPES_H = do not include + +An includer may test the following macros after inclusion: + + @KWIML@_INT_HAVE_INT#_T = type 'int#_t' is available + @KWIML@_INT_HAVE_UINT#_T = type 'uint#_t' is available + # = 8, 16, 32, 64, PTR + + @KWIML@_INT_int#_t = signed integer type exactly # bits wide + @KWIML@_INT_uint#_t = unsigned integer type exactly # bits wide + # = 8, 16, 32, 64 (*), ptr (*) + + @KWIML@_INT_NO_INT64_T = type '@KWIML@_INT_int64_t' not available + @KWIML@_INT_NO_UINT64_T = type '@KWIML@_INT_uint64_t' not available + @KWIML@_INT_NO_INTPTR_T = type '@KWIML@_INT_intptr_t' not available + @KWIML@_INT_NO_UINTPTR_T = type '@KWIML@_INT_uintptr_t' not available + + @KWIML@_INT_INT#_C(c) = signed integer constant at least # bits wide + @KWIML@_INT_UINT#_C(c) = unsigned integer constant at least # bits wide + # = 8, 16, 32, 64 (*) + + @KWIML@_INT_# = print or scan format, in table below + # = 8, 16, 32, 64, PTR (*) + + signed unsigned + ----------- ------------------------------ + | decimal | decimal octal hexadecimal | + print | PRId PRIi | PRIu PRIo PRIx PRIX | + scan | SCNd SCNi | SCNu SCNo SCNx | + ----------- ------------------------------ + + The SCN*8 and SCN*64 format macros will not be defined on systems + with scanf implementations known not to support them. + + @KWIML@_INT_BROKEN_INT64_C = macro INT64_C is incorrect if defined + @KWIML@_INT_BROKEN_UINT64_C = macro UINT64_C is incorrect if defined + Some compilers define integer constant macros incorrectly and + cannot handle literals as large as the integer type. + + @KWIML@_INT_BROKEN_INT8_T = type 'int8_t' is available but incorrect + Some compilers have a flag to make 'char' (un)signed but do not account + for it while defining int8_t in the non-default case. + + The broken cases do not affect correctness of the macros documented above. +*/ + +#include "ABI.h" + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_STDINT_H) /* Already defined. */ +#elif defined(@KWIML@_INT_NO_STDINT_H) /* Already defined. */ +#elif defined(HAVE_STDINT_H) /* Optionally provided by includer. */ +# define @KWIML@_INT_HAVE_STDINT_H 1 +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# define @KWIML@_INT_HAVE_STDINT_H 1 +#elif defined(_MSC_VER) /* MSVC */ +# if _MSC_VER >= 1600 +# define @KWIML@_INT_HAVE_STDINT_H 1 +# else +# define @KWIML@_INT_NO_STDINT_H 1 +# endif +#elif defined(__BORLANDC__) /* Borland */ +# if __BORLANDC__ >= 0x560 +# define @KWIML@_INT_HAVE_STDINT_H 1 +# else +# define @KWIML@_INT_NO_STDINT_H 1 +# endif +#elif defined(__WATCOMC__) /* Watcom */ +# define @KWIML@_INT_NO_STDINT_H 1 +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INTTYPES_H) /* Already defined. */ +#elif defined(@KWIML@_INT_NO_INTTYPES_H) /* Already defined. */ +#elif defined(HAVE_INTTYPES_H) /* Optionally provided by includer. */ +# define @KWIML@_INT_HAVE_INTTYPES_H 1 +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# define @KWIML@_INT_HAVE_INTTYPES_H 1 +#elif defined(_MSC_VER) /* MSVC */ +# define @KWIML@_INT_NO_INTTYPES_H 1 +#elif defined(__BORLANDC__) /* Borland */ +# define @KWIML@_INT_NO_INTTYPES_H 1 +#elif defined(__WATCOMC__) /* Watcom */ +# define @KWIML@_INT_NO_INTTYPES_H 1 +#else /* Assume it exists. */ +# define @KWIML@_INT_HAVE_INTTYPES_H 1 +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_STDINT_H) && defined(@KWIML@_INT_NO_STDINT_H) +# error "Both @KWIML@_INT_HAVE_STDINT_H and @KWIML@_INT_NO_STDINT_H defined!" +#endif +#if defined(@KWIML@_INT_HAVE_INTTYPES_H) && defined(@KWIML@_INT_NO_INTTYPES_H) +# error "Both @KWIML@_INT_HAVE_INTTYPES_H and @KWIML@_INT_NO_INTTYPES_H defined!" +#endif + +#if defined(@KWIML@_INT_HAVE_STDINT_H) +# include +#endif +#if defined(@KWIML@_INT_HAVE_INTTYPES_H) +# if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) +# define __STDC_FORMAT_MACROS +# endif +# include +#endif + +#if defined(@KWIML@_INT_HAVE_STDINT_H) || defined(@KWIML@_INT_HAVE_INTTYPES_H) +#define @KWIML@_INT_HAVE_INT8_T 1 +#define @KWIML@_INT_HAVE_UINT8_T 1 +#define @KWIML@_INT_HAVE_INT16_T 1 +#define @KWIML@_INT_HAVE_UINT16_T 1 +#define @KWIML@_INT_HAVE_INT32_T 1 +#define @KWIML@_INT_HAVE_UINT32_T 1 +#define @KWIML@_INT_HAVE_INT64_T 1 +#define @KWIML@_INT_HAVE_UINT64_T 1 +#define @KWIML@_INT_HAVE_INTPTR_T 1 +#define @KWIML@_INT_HAVE_UINTPTR_T 1 +#endif + +#if (defined(__SUNPRO_C)||defined(__SUNPRO_CC)) && defined(_CHAR_IS_UNSIGNED) +# define @KWIML@_INT_BROKEN_INT8_T /* system type defined incorrectly */ +#elif defined(__BORLANDC__) && defined(_CHAR_UNSIGNED) +# define @KWIML@_INT_BROKEN_INT8_T /* system type defined incorrectly */ +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INT8_T) && !defined(@KWIML@_INT_BROKEN_INT8_T) +# define @KWIML@_INT_int8_t int8_t +#else +# define @KWIML@_INT_int8_t signed char +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) +# define @KWIML@_INT_uint8_t uint8_t +#else +# define @KWIML@_INT_uint8_t unsigned char +#endif + +#if defined(__INTEL_COMPILER) +#elif defined(__SUNPRO_C) && __SUNPRO_C < 0x570 +# define @KWIML@_INT__NO_SCN8 +#elif defined(__SUNPRO_CC) && __SUNPRO_CC < 0x570 +# define @KWIML@_INT__NO_SCN8 +#elif defined(__HP_cc) || defined(__HP_aCC) +# define @KWIML@_INT__NO_SCN8 +#elif defined(__BORLANDC__) +# define @KWIML@_INT__NO_SCN8 +# define @KWIML@_INT__NO_SCN64 +#elif defined(_MSC_VER) +# define @KWIML@_INT__NO_SCN8 +#elif defined(__WATCOMC__) +# define @KWIML@_INT__NO_SCN8 +#endif + +/* 8-bit d, i */ +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(PRId8) +# define @KWIML@_INT_PRId8 PRId8 +#else +# define @KWIML@_INT_PRId8 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(SCNd8) +# define @KWIML@_INT_SCNd8 SCNd8 +#elif !defined(@KWIML@_INT__NO_SCN8) +# define @KWIML@_INT_SCNd8 "hhd" +#endif +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(PRIi8) +# define @KWIML@_INT_PRIi8 PRIi8 +#else +# define @KWIML@_INT_PRIi8 "i" +#endif +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(SCNi8) +# define @KWIML@_INT_SCNi8 SCNi8 +#elif !defined(@KWIML@_INT__NO_SCN8) +# define @KWIML@_INT_SCNi8 "hhi" +#endif + +/* 8-bit o, u, x, X */ +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIo8) +# define @KWIML@_INT_PRIo8 PRIo8 +#else +# define @KWIML@_INT_PRIo8 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNo8) +# define @KWIML@_INT_SCNo8 SCNo8 +#elif !defined(@KWIML@_INT__NO_SCN8) +# define @KWIML@_INT_SCNo8 "hho" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIu8) +# define @KWIML@_INT_PRIu8 PRIu8 +#else +# define @KWIML@_INT_PRIu8 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNu8) +# define @KWIML@_INT_SCNu8 SCNu8 +#elif !defined(@KWIML@_INT__NO_SCN8) +# define @KWIML@_INT_SCNu8 "hhu" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIx8) +# define @KWIML@_INT_PRIx8 PRIx8 +#else +# define @KWIML@_INT_PRIx8 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNx8) +# define @KWIML@_INT_SCNx8 SCNx8 +#elif !defined(@KWIML@_INT__NO_SCN8) +# define @KWIML@_INT_SCNx8 "hhx" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIX8) +# define @KWIML@_INT_PRIX8 PRIX8 +#else +# define @KWIML@_INT_PRIX8 "X" +#endif + +/* 8-bit constants */ +#if defined(INT8_C) +# define @KWIML@_INT_INT8_C(c) INT8_C(c) +#else +# define @KWIML@_INT_INT8_C(c) c +#endif +#if defined(UINT8_C) +# define @KWIML@_INT_UINT8_C(c) UINT8_C(c) +#else +# define @KWIML@_INT_UINT8_C(c) c ## u +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INT16_T) +# define @KWIML@_INT_int16_t int16_t +#else +# define @KWIML@_INT_int16_t signed short +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) +# define @KWIML@_INT_uint16_t uint16_t +#else +# define @KWIML@_INT_uint16_t unsigned short +#endif + +/* 16-bit d, i */ +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(PRId16) +# define @KWIML@_INT_PRId16 PRId16 +#else +# define @KWIML@_INT_PRId16 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(SCNd16) +# define @KWIML@_INT_SCNd16 SCNd16 +#else +# define @KWIML@_INT_SCNd16 "hd" +#endif +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(PRIi16) +# define @KWIML@_INT_PRIi16 PRIi16 +#else +# define @KWIML@_INT_PRIi16 "i" +#endif +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(SCNi16) +# define @KWIML@_INT_SCNi16 SCNi16 +#else +# define @KWIML@_INT_SCNi16 "hi" +#endif + +/* 16-bit o, u, x, X */ +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIo16) +# define @KWIML@_INT_PRIo16 PRIo16 +#else +# define @KWIML@_INT_PRIo16 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNo16) +# define @KWIML@_INT_SCNo16 SCNo16 +#else +# define @KWIML@_INT_SCNo16 "ho" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIu16) +# define @KWIML@_INT_PRIu16 PRIu16 +#else +# define @KWIML@_INT_PRIu16 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNu16) +# define @KWIML@_INT_SCNu16 SCNu16 +#else +# define @KWIML@_INT_SCNu16 "hu" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIx16) +# define @KWIML@_INT_PRIx16 PRIx16 +#else +# define @KWIML@_INT_PRIx16 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNx16) +# define @KWIML@_INT_SCNx16 SCNx16 +#else +# define @KWIML@_INT_SCNx16 "hx" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIX16) +# define @KWIML@_INT_PRIX16 PRIX16 +#else +# define @KWIML@_INT_PRIX16 "X" +#endif + +/* 16-bit constants */ +#if defined(INT16_C) +# define @KWIML@_INT_INT16_C(c) INT16_C(c) +#else +# define @KWIML@_INT_INT16_C(c) c +#endif +#if defined(UINT16_C) +# define @KWIML@_INT_UINT16_C(c) UINT16_C(c) +#else +# define @KWIML@_INT_UINT16_C(c) c ## u +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INT32_T) +# define @KWIML@_INT_int32_t int32_t +#else +# define @KWIML@_INT_int32_t signed int +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) +# define @KWIML@_INT_uint32_t uint32_t +#else +# define @KWIML@_INT_uint32_t unsigned int +#endif + +/* 32-bit d, i */ +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(PRId32) +# define @KWIML@_INT_PRId32 PRId32 +#else +# define @KWIML@_INT_PRId32 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(SCNd32) +# define @KWIML@_INT_SCNd32 SCNd32 +#else +# define @KWIML@_INT_SCNd32 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(PRIi32) +# define @KWIML@_INT_PRIi32 PRIi32 +#else +# define @KWIML@_INT_PRIi32 "i" +#endif +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(SCNi32) +# define @KWIML@_INT_SCNi32 SCNi32 +#else +# define @KWIML@_INT_SCNi32 "i" +#endif + +/* 32-bit o, u, x, X */ +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIo32) +# define @KWIML@_INT_PRIo32 PRIo32 +#else +# define @KWIML@_INT_PRIo32 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNo32) +# define @KWIML@_INT_SCNo32 SCNo32 +#else +# define @KWIML@_INT_SCNo32 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIu32) +# define @KWIML@_INT_PRIu32 PRIu32 +#else +# define @KWIML@_INT_PRIu32 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNu32) +# define @KWIML@_INT_SCNu32 SCNu32 +#else +# define @KWIML@_INT_SCNu32 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIx32) +# define @KWIML@_INT_PRIx32 PRIx32 +#else +# define @KWIML@_INT_PRIx32 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNx32) +# define @KWIML@_INT_SCNx32 SCNx32 +#else +# define @KWIML@_INT_SCNx32 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIX32) +# define @KWIML@_INT_PRIX32 PRIX32 +#else +# define @KWIML@_INT_PRIX32 "X" +#endif + +/* 32-bit constants */ +#if defined(INT32_C) +# define @KWIML@_INT_INT32_C(c) INT32_C(c) +#else +# define @KWIML@_INT_INT32_C(c) c +#endif +#if defined(UINT32_C) +# define @KWIML@_INT_UINT32_C(c) UINT32_C(c) +#else +# define @KWIML@_INT_UINT32_C(c) c ## u +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INT64_T) +# define @KWIML@_INT_int64_t int64_t +#elif @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_INT_int64_t signed long +#elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# define @KWIML@_INT_int64_t signed long long +#elif defined(@KWIML@_ABI_SIZEOF___INT64) +# define @KWIML@_INT_int64_t signed __int64 +#elif defined(@KWIML@_INT_NO_ERROR_INT64_T) +# define @KWIML@_INT_NO_INT64_T +#else +# error "No type known for 'int64_t'." +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) +# define @KWIML@_INT_uint64_t uint64_t +#elif @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_INT_uint64_t unsigned long +#elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# define @KWIML@_INT_uint64_t unsigned long long +#elif defined(@KWIML@_ABI_SIZEOF___INT64) +# define @KWIML@_INT_uint64_t unsigned __int64 +#elif defined(@KWIML@_INT_NO_ERROR_UINT64_T) +# define @KWIML@_INT_NO_UINT64_T +#else +# error "No type known for 'uint64_t'." +#endif + +#if defined(__INTEL_COMPILER) +#elif defined(__BORLANDC__) +# define @KWIML@_INT__NO_FMTLL /* type 'long long' but not 'll' format */ +# define @KWIML@_INT_BROKEN_INT64_C /* system macro defined incorrectly */ +# define @KWIML@_INT_BROKEN_UINT64_C /* system macro defined incorrectly */ +#elif defined(_MSC_VER) && _MSC_VER < 1400 +# define @KWIML@_INT__NO_FMTLL /* type 'long long' but not 'll' format */ +#endif + +#if @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_INT__FMT64 "l" +#elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# if !defined(@KWIML@_INT__NO_FMTLL) +# define @KWIML@_INT__FMT64 "ll" +# else +# define @KWIML@_INT__FMT64 "I64" +# endif +#elif defined(@KWIML@_ABI_SIZEOF___INT64) +# if defined(__BORLANDC__) +# define @KWIML@_INT__FMT64 "L" +# else +# define @KWIML@_INT__FMT64 "I64" +# endif +#endif + +/* 64-bit d, i */ +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(PRId64) +# define @KWIML@_INT_PRId64 PRId64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRId64 @KWIML@_INT__FMT64 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(SCNd64) +# define @KWIML@_INT_SCNd64 SCNd64 +#elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) +# define @KWIML@_INT_SCNd64 @KWIML@_INT__FMT64 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(PRIi64) +# define @KWIML@_INT_PRIi64 PRIi64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRIi64 @KWIML@_INT__FMT64 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(SCNi64) +# define @KWIML@_INT_SCNi64 SCNi64 +#elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) +# define @KWIML@_INT_SCNi64 @KWIML@_INT__FMT64 "d" +#endif + +/* 64-bit o, u, x, X */ +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIo64) +# define @KWIML@_INT_PRIo64 PRIo64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRIo64 @KWIML@_INT__FMT64 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNo64) +# define @KWIML@_INT_SCNo64 SCNo64 +#elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) +# define @KWIML@_INT_SCNo64 @KWIML@_INT__FMT64 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIu64) +# define @KWIML@_INT_PRIu64 PRIu64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRIu64 @KWIML@_INT__FMT64 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNu64) +# define @KWIML@_INT_SCNu64 SCNu64 +#elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) +# define @KWIML@_INT_SCNu64 @KWIML@_INT__FMT64 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIx64) +# define @KWIML@_INT_PRIx64 PRIx64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRIx64 @KWIML@_INT__FMT64 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNx64) +# define @KWIML@_INT_SCNx64 SCNx64 +#elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) +# define @KWIML@_INT_SCNx64 @KWIML@_INT__FMT64 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIX64) +# define @KWIML@_INT_PRIX64 PRIX64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRIX64 @KWIML@_INT__FMT64 "X" +#endif + +/* 64-bit constants */ +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(INT64_C) \ + && !defined(@KWIML@_INT_BROKEN_INT64_C) +# define @KWIML@_INT_INT64_C(c) INT64_C(c) +#elif @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_INT_INT64_C(c) c ## l +#elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# define @KWIML@_INT_INT64_C(c) c ## ll +#elif defined(@KWIML@_ABI_SIZEOF___INT64) +# define @KWIML@_INT_INT64_C(c) c ## i64 +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(UINT64_C) \ + && !defined(@KWIML@_INT_BROKEN_UINT64_C) +# define @KWIML@_INT_UINT64_C(c) UINT64_C(c) +#elif @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_INT_UINT64_C(c) c ## ul +#elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# define @KWIML@_INT_UINT64_C(c) c ## ull +#elif defined(@KWIML@_ABI_SIZEOF___INT64) +# define @KWIML@_INT_UINT64_C(c) c ## ui64 +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INTPTR_T) +# define @KWIML@_INT_intptr_t intptr_t +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_intptr_t @KWIML@_INT_int32_t +#elif !defined(@KWIML@_INT_NO_INT64_T) +# define @KWIML@_INT_intptr_t @KWIML@_INT_int64_t +#elif defined(@KWIML@_INT_NO_ERROR_INTPTR_T) +# define @KWIML@_INT_NO_INTPTR_T +#else +# error "No type known for 'intptr_t'." +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) +# define @KWIML@_INT_uintptr_t uintptr_t +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_uintptr_t @KWIML@_INT_uint32_t +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_uintptr_t @KWIML@_INT_uint64_t +#elif defined(@KWIML@_INT_NO_ERROR_UINTPTR_T) +# define @KWIML@_INT_NO_UINTPTR_T +#else +# error "No type known for 'uintptr_t'." +#endif + +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(PRIdPTR) +# define @KWIML@_INT_PRIdPTR PRIdPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIdPTR @KWIML@_INT_PRId32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIdPTR @KWIML@_INT_PRId64 +#endif +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(SCNdPTR) +# define @KWIML@_INT_SCNdPTR SCNdPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_SCNdPTR @KWIML@_INT_SCNd32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_SCNdPTR @KWIML@_INT_SCNd64 +#endif +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(PRIiPTR) +# define @KWIML@_INT_PRIiPTR PRIiPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIiPTR @KWIML@_INT_PRIi32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIiPTR @KWIML@_INT_PRIi64 +#endif +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(SCNiPTR) +# define @KWIML@_INT_SCNiPTR SCNiPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_SCNiPTR @KWIML@_INT_SCNi32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_SCNiPTR @KWIML@_INT_SCNi64 +#endif + +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIoPTR) +# define @KWIML@_INT_PRIoPTR PRIoPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIoPTR @KWIML@_INT_PRIo32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIoPTR @KWIML@_INT_PRIo64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNoPTR) +# define @KWIML@_INT_SCNoPTR SCNoPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_SCNoPTR @KWIML@_INT_SCNo32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_SCNoPTR @KWIML@_INT_SCNo64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIuPTR) +# define @KWIML@_INT_PRIuPTR PRIuPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIuPTR @KWIML@_INT_PRIu32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIuPTR @KWIML@_INT_PRIu64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNuPTR) +# define @KWIML@_INT_SCNuPTR SCNuPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_SCNuPTR @KWIML@_INT_SCNu32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_SCNuPTR @KWIML@_INT_SCNu64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIxPTR) +# define @KWIML@_INT_PRIxPTR PRIxPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIxPTR @KWIML@_INT_PRIx32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIxPTR @KWIML@_INT_PRIx64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNxPTR) +# define @KWIML@_INT_SCNxPTR SCNxPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_SCNxPTR @KWIML@_INT_SCNx32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_SCNxPTR @KWIML@_INT_SCNx64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIXPTR) +# define @KWIML@_INT_PRIXPTR PRIXPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIXPTR @KWIML@_INT_PRIX32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIXPTR @KWIML@_INT_PRIX64 +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_INT_NO_VERIFY) +#define @KWIML@_INT__VERIFY(n, x, y) extern int (*n)[x]; extern int (*n)[y] +#define @KWIML@_INT__VERIFY_BOOL(m, b) @KWIML@_INT__VERIFY(m##__VERIFY__, 2, (b)?2:3) +#define @KWIML@_INT__VERIFY_TYPE(t, s) @KWIML@_INT__VERIFY(t##__VERIFY__, s, sizeof(t)) +#define @KWIML@_INT__VERIFY_SIGN(t, u, o) @KWIML@_INT__VERIFY_BOOL(t##__SIGN, (t)((u)1 << ((sizeof(t)<<3)-1)) o 0) + +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int8_t, 1); +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint8_t, 1); +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int16_t, 2); +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint16_t, 2); +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int32_t, 4); +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint32_t, 4); +#if !defined(@KWIML@_INT_NO_INT64_T) +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int64_t, 8); +#endif +#if !defined(@KWIML@_INT_NO_UINT64_T) +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint64_t, 8); +#endif +#if !defined(@KWIML@_INT_NO_INTPTR_T) +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_intptr_t, sizeof(void*)); +#endif +#if !defined(@KWIML@_INT_NO_UINTPTR_T) +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uintptr_t, sizeof(void*)); +#endif + +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int8_t, @KWIML@_INT_uint8_t, <); +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint8_t, @KWIML@_INT_uint8_t, >); +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int16_t, @KWIML@_INT_uint16_t, <); +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint16_t, @KWIML@_INT_uint16_t, >); +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int32_t, @KWIML@_INT_uint32_t, <); +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint32_t, @KWIML@_INT_uint32_t, >); +#if !defined(@KWIML@_INT_NO_INT64_T) +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int64_t, @KWIML@_INT_uint64_t, <); +#endif +#if !defined(@KWIML@_INT_NO_UINT64_T) +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint64_t, @KWIML@_INT_uint64_t, >); +#endif +#if !defined(@KWIML@_INT_NO_INTPTR_T) +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_intptr_t, @KWIML@_INT_uintptr_t, <); +#endif +#if !defined(@KWIML@_INT_NO_UINTPTR_T) +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uintptr_t, @KWIML@_INT_uintptr_t, >); +#endif + +#undef @KWIML@_INT__VERIFY_SIGN +#undef @KWIML@_INT__VERIFY_TYPE +#undef @KWIML@_INT__VERIFY_BOOL +#undef @KWIML@_INT__VERIFY + +#endif + +#endif diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..6bdf859 --- /dev/null +++ b/README.txt @@ -0,0 +1,29 @@ +KWIML - The Kitware Information Macro Library + +KWIML provides header files that use preprocessor tests to detect and +provide information about the compiler and its target architecture. The +headers contain no configuration-time test results and thus may be +installed into an architecture-independent include directory. This +makes them suitable for use in the public interface of any package. + +This source tree is intended for distribution inside the source trees of +other packages. In order to avoid name collisions among multiple +packages the KWIML headers are configured with a per-package prefix on +both the header locations and the macros they define. See comments in +CMakeLists.txt for instructions to include KWIML inside another project. + +The entire KWIML source tree is distributed under the OSI-approved +3-clause BSD License. Files used only for build and test purposes +contain a copyright notice and reference Copyright.txt for details. +Headers meant for installation and distribution outside the source tree +come with full inlined copies of the copyright notice and license text. +This makes them suitable for distribution with any package under +compatible license terms. + +The following components are provided. See header comments for details: + + ABI.h = Fundamental type size and representation + INT.h = Fixed-size integer types and format specifiers + +The "test" subdirectory builds tests that verify correctness of the +information provided by each header. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..aaff9e9 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,51 @@ +#============================================================================= +# Kitware Information Macro Library +# Copyright 2010-2011 Kitware, Inc. +# +# 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. +#============================================================================= + +set(test_defs KWIML_NAMESPACE=${KWIML}) + +# Tell CMake how to follow dependencies of sources in this directory. +set_property(DIRECTORY + PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM + "KWIML_HEADER(%)=<${KWIML}/%>" + ) + +if(KWIML_LANGUAGE_C) + set(test_srcs test.c) +else() + set(test_srcs test.cxx) +endif() +if(KWIML_LANGUAGE_C) + list(APPEND test_defs KWIML_LANGUAGE_C) + list(APPEND test_srcs + test_ABI_C.c + test_INT_C.c + ) +endif() +if(KWIML_LANGUAGE_CXX) + list(APPEND test_defs KWIML_LANGUAGE_CXX) + list(APPEND test_srcs + test_ABI_CXX.cxx + test_INT_CXX.cxx + ) +endif() + +foreach(th test_ABI_endian test_INT_format) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${th}.h.in + ${CMAKE_CURRENT_BINARY_DIR}/${th}.h @ONLY) +endforeach() +include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) +add_executable(${KWIML}_test ${test_srcs}) +set_property(TARGET ${KWIML}_test PROPERTY COMPILE_DEFINITIONS ${test_defs}) +set_property(TARGET ${KWIML}_test PROPERTY + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +add_test(${KWIML}.test ${CMAKE_CURRENT_BINARY_DIR}/${KWIML}_test) +set_property(TEST ${KWIML}.test PROPERTY LABELS ${KWIML_LABELS_TEST}) diff --git a/test/test.c b/test/test.c new file mode 100644 index 0000000..d71a284 --- /dev/null +++ b/test/test.c @@ -0,0 +1,35 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + 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. +============================================================================*/ +#ifdef __cplusplus +extern "C" { +#endif +extern int test_ABI_C(void); +extern int test_INT_C(void); +extern int test_ABI_CXX(void); +extern int test_INT_CXX(void); +#ifdef __cplusplus +} // extern "C" +#endif + +int main(void) +{ + int result = 1; +#ifdef KWIML_LANGUAGE_C + result = test_ABI_C() && result; + result = test_INT_C() && result; +#endif +#ifdef KWIML_LANGUAGE_CXX + result = test_ABI_CXX() && result; + result = test_INT_CXX() && result; +#endif + return result? 0 : 1; +} diff --git a/test/test.cxx b/test/test.cxx new file mode 100644 index 0000000..bf61421 --- /dev/null +++ b/test/test.cxx @@ -0,0 +1,12 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + 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. +============================================================================*/ +#include "test.c" diff --git a/test/test.h b/test/test.h new file mode 100644 index 0000000..8abb195 --- /dev/null +++ b/test/test.h @@ -0,0 +1,35 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + 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 KWIML_NAMESPACE +# error "Do not include test.h outside of KWIML test files." +#endif + +#ifndef KWIML_TEST_H +#define KWIML_TEST_H + +/* + Define KWIML_HEADER macro to help the test files include kwiml + headers from the configured namespace directory. The macro can be + used like this: + + #include KWIML_HEADER(ABI.h) +*/ +#define KWIML_HEADER(x) KWIML_HEADER0(KWIML_NAMESPACE/x) +#define KWIML_HEADER0(x) KWIML_HEADER1(x) +#define KWIML_HEADER1(x) + +/* Quiet MS standard library deprecation warnings. */ +#define _CRT_SECURE_NO_DEPRECATE + +#else +# error "test.h included multiple times." +#endif diff --git a/test/test_ABI_C.c b/test/test_ABI_C.c new file mode 100644 index 0000000..3ca4ad3 --- /dev/null +++ b/test/test_ABI_C.c @@ -0,0 +1,22 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + 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. +============================================================================*/ +#include "test.h" +#include KWIML_HEADER(ABI.h) +#include "test_ABI_endian.h" +int test_ABI_C(void) +{ + if(!test_ABI_endian()) + { + return 0; + } + return 1; +} diff --git a/test/test_ABI_CXX.cxx b/test/test_ABI_CXX.cxx new file mode 100644 index 0000000..7ede20e --- /dev/null +++ b/test/test_ABI_CXX.cxx @@ -0,0 +1,22 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + 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. +============================================================================*/ +#include "test.h" +#include KWIML_HEADER(ABI.h) +#include "test_ABI_endian.h" +extern "C" int test_ABI_CXX(void) +{ + if(!test_ABI_endian()) + { + return 0; + } + return 1; +} diff --git a/test/test_ABI_endian.h.in b/test/test_ABI_endian.h.in new file mode 100644 index 0000000..992baea --- /dev/null +++ b/test/test_ABI_endian.h.in @@ -0,0 +1,47 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + 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. +============================================================================*/ +#include + +#ifdef __cplusplus +# define LANG "C++ " +#else +# define LANG "C " +#endif + +static int test_ABI_endian(void) +{ + int result = 1; + { +#if defined(@KWIML@_ABI_ENDIAN_ID) + int expect; + union { short s; unsigned char c[sizeof(short)]; } x; + x.s = 1; + expect = (x.c[0] == 1 ? + @KWIML@_ABI_ENDIAN_ID_LITTLE : @KWIML@_ABI_ENDIAN_ID_BIG); + printf(LANG "@KWIML@_ABI_ENDIAN_ID: expected [%d], got [%d]", + expect, @KWIML@_ABI_ENDIAN_ID); + if(@KWIML@_ABI_ENDIAN_ID == expect) + { + printf(", PASSED\n"); + } + else + { + printf(", FAILED\n"); + result = 0; + } +#else + printf(LANG "@KWIML@_ABI_ENDIAN_ID: unknown, FAILED\n"); + result = 0; +#endif + } + return result; +} diff --git a/test/test_INT_C.c b/test/test_INT_C.c new file mode 100644 index 0000000..5513a0b --- /dev/null +++ b/test/test_INT_C.c @@ -0,0 +1,22 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + 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. +============================================================================*/ +#include "test.h" +#include KWIML_HEADER(INT.h) +#include "test_INT_format.h" +int test_INT_C(void) +{ + if(!test_INT_format()) + { + return 0; + } + return 1; +} diff --git a/test/test_INT_CXX.cxx b/test/test_INT_CXX.cxx new file mode 100644 index 0000000..9f74e96 --- /dev/null +++ b/test/test_INT_CXX.cxx @@ -0,0 +1,22 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + 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. +============================================================================*/ +#include "test.h" +#include KWIML_HEADER(INT.h) +#include "test_INT_format.h" +extern "C" int test_INT_CXX(void) +{ + if(!test_INT_format()) + { + return 0; + } + return 1; +} diff --git a/test/test_INT_format.h.in b/test/test_INT_format.h.in new file mode 100644 index 0000000..72a62f2 --- /dev/null +++ b/test/test_INT_format.h.in @@ -0,0 +1,188 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + 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. +============================================================================*/ +#include +#include + +#ifdef __cplusplus +# define LANG "C++ " +#else +# define LANG "C " +#endif + +#define VALUE(T, U) \ + (@KWIML@_INT_##T)((@KWIML@_INT_##U)0xab << \ + ((sizeof(@KWIML@_INT_##T)-1)<<3)) \ + +#define TEST_C(C, V, PRI, T, U) \ + { \ + @KWIML@_INT_##T const x = VALUE(T, U); \ + @KWIML@_INT_##T y = @KWIML@_INT_##C(V); \ + printf(LANG "@KWIML@_INT_" #C ":" \ + " expression [%"@KWIML@_INT_PRI##PRI"]," \ + " literal [%"@KWIML@_INT_PRI##PRI"]", x, y); \ + if(x == y) \ + { \ + printf(", PASSED\n"); \ + } \ + else \ + { \ + printf(", FAILED\n"); \ + result = 0; \ + } \ + } + +#define TEST_PRI(PRI, T, U, STR) \ + { \ + @KWIML@_INT_##T const x = VALUE(T, U); \ + char const* str = STR; \ + sprintf(buf, "%"@KWIML@_INT_PRI##PRI, x); \ + printf(LANG "@KWIML@_INT_PRI" #PRI ":" \ + " expected [%s], got [%s]", str, buf); \ + if(strcmp(str, buf) == 0) \ + { \ + printf(", PASSED\n"); \ + } \ + else \ + { \ + printf(", FAILED\n"); \ + result = 0; \ + } \ + } + +#define TEST_SCN(SCN, T, U, STR) TEST_SCN2(SCN, SCN, T, U, STR) +#define TEST_SCN2(PRI, SCN, T, U, STR) \ + { \ + @KWIML@_INT_##T const x = VALUE(T, U); \ + @KWIML@_INT_##T y; \ + char const* str = STR; \ + if(sscanf(str, "%"@KWIML@_INT_SCN##SCN, &y) != 1) \ + { \ + y = 0; \ + } \ + printf(LANG "@KWIML@_INT_SCN" #SCN ":" \ + " expected [%"@KWIML@_INT_PRI##PRI"]," \ + " got [%"@KWIML@_INT_PRI##PRI"]", x, y); \ + if(x == y) \ + { \ + printf(", PASSED\n"); \ + } \ + else \ + { \ + printf(", FAILED\n"); \ + result = 0; \ + } \ + } + +#define TEST(FMT, T, U, STR) TEST2(FMT, FMT, T, U, STR) +#define TEST2(PRI, SCN, T, U, STR) \ + TEST_PRI(PRI, T, U, STR) \ + TEST_SCN2(PRI, SCN, T, U, STR) + +static int test_INT_format(void) +{ + int result = 1; + char buf[256]; + TEST_PRI(i8, int8_t, uint8_t, "-85") +#if defined(@KWIML@_INT_SCNi8) + TEST_SCN(i8, int8_t, uint8_t, "-85") +#endif + TEST_PRI(d8, int8_t, uint8_t, "-85") +#if defined(@KWIML@_INT_SCNd8) + TEST_SCN(d8, int8_t, uint8_t, "-85") +#endif + TEST_PRI(o8, uint8_t, uint8_t, "253") +#if defined(@KWIML@_INT_SCNo8) + TEST_SCN(o8, uint8_t, uint8_t, "253") +#endif + TEST_PRI(u8, uint8_t, uint8_t, "171") +#if defined(@KWIML@_INT_SCNu8) + TEST_SCN(u8, uint8_t, uint8_t, "171") +#endif + TEST_PRI(x8, uint8_t, uint8_t, "ab") + TEST_PRI(X8, uint8_t, uint8_t, "AB") +#if defined(@KWIML@_INT_SCNx8) + TEST_SCN(x8, uint8_t, uint8_t, "ab") + TEST_SCN2(X8, x8, uint8_t, uint8_t, "AB") +#endif + + TEST(i16, int16_t, uint16_t, "-21760") + TEST(d16, int16_t, uint16_t, "-21760") + TEST(o16, uint16_t, uint16_t, "125400") + TEST(u16, uint16_t, uint16_t, "43776") + TEST(x16, uint16_t, uint16_t, "ab00") + TEST2(X16, x16, uint16_t, uint16_t, "AB00") + + TEST(i32, int32_t, uint32_t, "-1426063360") + TEST(d32, int32_t, uint32_t, "-1426063360") + TEST(o32, uint32_t, uint32_t, "25300000000") + TEST(u32, uint32_t, uint32_t, "2868903936") + TEST(x32, uint32_t, uint32_t, "ab000000") + TEST2(X32, x32, uint32_t, uint32_t, "AB000000") + + TEST_PRI(i64, int64_t, uint64_t, "-6124895493223874560") +#if defined(@KWIML@_INT_SCNi64) + TEST_SCN(i64, int64_t, uint64_t, "-6124895493223874560") +#endif + TEST_PRI(d64, int64_t, uint64_t, "-6124895493223874560") +#if defined(@KWIML@_INT_SCNd64) + TEST_SCN(d64, int64_t, uint64_t, "-6124895493223874560") +#endif + TEST_PRI(o64, uint64_t, uint64_t, "1254000000000000000000") +#if defined(@KWIML@_INT_SCNo64) + TEST_SCN(o64, uint64_t, uint64_t, "1254000000000000000000") +#endif + TEST_PRI(u64, uint64_t, uint64_t, "12321848580485677056") +#if defined(@KWIML@_INT_SCNu64) + TEST_SCN(u64, uint64_t, uint64_t, "12321848580485677056") +#endif + TEST_PRI(x64, uint64_t, uint64_t, "ab00000000000000") + TEST_PRI(X64, uint64_t, uint64_t, "AB00000000000000") +#if defined(@KWIML@_INT_SCNx64) + TEST_SCN(x64, uint64_t, uint64_t, "ab00000000000000") + TEST_SCN2(X64, x64, uint64_t, uint64_t, "AB00000000000000") +#endif + +#if !defined(@KWIML@_INT_NO_INTPTR_T) +# if @KWIML@_ABI_SIZEOF_DATA_PTR == 4 + TEST(iPTR, intptr_t, uint32_t, "-1426063360") + TEST(dPTR, intptr_t, uint32_t, "-1426063360") +# else + TEST(iPTR, intptr_t, uint64_t, "-6124895493223874560") + TEST(dPTR, intptr_t, uint64_t, "-6124895493223874560") +# endif +#endif + +#if !defined(@KWIML@_INT_NO_UINTPTR_T) +# if @KWIML@_ABI_SIZEOF_DATA_PTR == 4 + TEST(oPTR, uintptr_t, uintptr_t, "25300000000") + TEST(uPTR, uintptr_t, uintptr_t, "2868903936") + TEST(xPTR, uintptr_t, uintptr_t, "ab000000") + TEST2(XPTR, xPTR, uintptr_t, uintptr_t, "AB000000") +# else + TEST(oPTR, uintptr_t, uintptr_t, "1254000000000000000000") + TEST(uPTR, uintptr_t, uintptr_t, "12321848580485677056") + TEST(xPTR, uintptr_t, uintptr_t, "ab00000000000000") + TEST2(XPTR, xPTR, uintptr_t, uintptr_t, "AB00000000000000") +# endif +#endif + + TEST_C(INT8_C, -0x55, i8, int8_t, uint8_t) + TEST_C(UINT8_C, 0xAB, u8, uint8_t, uint8_t) + TEST_C(INT16_C, -0x5500, i16, int16_t, uint16_t) + TEST_C(UINT16_C, 0xAB00, u16, uint16_t, uint16_t) + TEST_C(INT32_C, -0x55000000, i32, int32_t, uint32_t) + TEST_C(UINT32_C, 0xAB000000, u32, uint32_t, uint32_t) + TEST_C(INT64_C, -0x5500000000000000, i64, int64_t, uint64_t) + TEST_C(UINT64_C, 0xAB00000000000000, u64, uint64_t, uint64_t) + + return result; +} -- cgit v0.12 From 93cebcaf23118425c1ac51fcd07073c376be4e34 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 27 Jun 2011 14:15:37 -0400 Subject: Configure KWIML inside CMake as cmIML --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93822ef..09fd7d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,6 +214,12 @@ ENDMACRO(CMAKE_SET_TARGET_FOLDER) #----------------------------------------------------------------------- MACRO (CMAKE_BUILD_UTILITIES) #--------------------------------------------------------------------- + # Create the KWIML library for CMake. + SET(KWIML cmIML) + SET(KWIML_HEADER_ROOT ${CMake_BINARY_DIR}/Utilities) + ADD_SUBDIRECTORY(Utilities/KWIML) + + #--------------------------------------------------------------------- # Create the kwsys library for CMake. SET(KWSYS_NAMESPACE cmsys) SET(KWSYS_USE_SystemTools 1) -- cgit v0.12 From 9912c41c176105bf0dad953e242aacc2717e9e6f Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 27 Jun 2011 14:27:23 -0400 Subject: Import sha2 implementation 1.0 from Aaron D. Gifford Copy cm_sha2.[hc] from sha2.[hc] in "sha2-1.0.tar.gz" downloaded today from http://www.aarongifford.com/computers/sha.html with trivial whitespace cleanup. Also fix #include to account for rename. --- Source/.gitattributes | 2 + Source/cm_sha2.c | 1064 +++++++++++++++++++++++++++++++++++++++++++++++++ Source/cm_sha2.h | 196 +++++++++ 3 files changed, 1262 insertions(+) create mode 100644 Source/.gitattributes create mode 100644 Source/cm_sha2.c create mode 100644 Source/cm_sha2.h diff --git a/Source/.gitattributes b/Source/.gitattributes new file mode 100644 index 0000000..cf4dabd --- /dev/null +++ b/Source/.gitattributes @@ -0,0 +1,2 @@ +# Preserve upstream indentation style. +cm_sha2.* whitespace=indent-with-non-tab diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c new file mode 100644 index 0000000..15f0f20 --- /dev/null +++ b/Source/cm_sha2.c @@ -0,0 +1,1064 @@ +/* + * FILE: sha2.c + * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ + * + * Copyright (c) 2000-2001, Aaron D. Gifford + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $ + */ + +#include /* memcpy()/memset() or bcopy()/bzero() */ +#include /* assert() */ +#include "cm_sha2.h" /* "sha2.h" -> "cm_sha2.h" renamed for CMake */ + +/* + * ASSERT NOTE: + * Some sanity checking code is included using assert(). On my FreeBSD + * system, this additional code can be removed by compiling with NDEBUG + * defined. Check your own systems manpage on assert() to see how to + * compile WITHOUT the sanity checking code on your system. + * + * UNROLLED TRANSFORM LOOP NOTE: + * You can define SHA2_UNROLL_TRANSFORM to use the unrolled transform + * loop version for the hash transform rounds (defined using macros + * later in this file). Either define on the command line, for example: + * + * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c + * + * or define below: + * + * #define SHA2_UNROLL_TRANSFORM + * + */ + + +/*** SHA-256/384/512 Machine Architecture Definitions *****************/ +/* + * BYTE_ORDER NOTE: + * + * Please make sure that your system defines BYTE_ORDER. If your + * architecture is little-endian, make sure it also defines + * LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are + * equivilent. + * + * If your system does not define the above, then you can do so by + * hand like this: + * + * #define LITTLE_ENDIAN 1234 + * #define BIG_ENDIAN 4321 + * + * And for little-endian machines, add: + * + * #define BYTE_ORDER LITTLE_ENDIAN + * + * Or for big-endian machines: + * + * #define BYTE_ORDER BIG_ENDIAN + * + * The FreeBSD machine this was written on defines BYTE_ORDER + * appropriately by including (which in turn includes + * where the appropriate definitions are actually + * made). + */ +#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) +#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN +#endif + +/* + * Define the followingsha2_* types to types of the correct length on + * the native archtecture. Most BSD systems and Linux define u_intXX_t + * types. Machines with very recent ANSI C headers, can use the + * uintXX_t definintions from inttypes.h by defining SHA2_USE_INTTYPES_H + * during compile or in the sha.h header file. + * + * Machines that support neither u_intXX_t nor inttypes.h's uintXX_t + * will need to define these three typedefs below (and the appropriate + * ones in sha.h too) by hand according to their system architecture. + * + * Thank you, Jun-ichiro itojun Hagino, for suggesting using u_intXX_t + * types and pointing out recent ANSI C support for uintXX_t in inttypes.h. + */ +#ifdef SHA2_USE_INTTYPES_H + +typedef uint8_t sha2_byte; /* Exactly 1 byte */ +typedef uint32_t sha2_word32; /* Exactly 4 bytes */ +typedef uint64_t sha2_word64; /* Exactly 8 bytes */ + +#else /* SHA2_USE_INTTYPES_H */ + +typedef u_int8_t sha2_byte; /* Exactly 1 byte */ +typedef u_int32_t sha2_word32; /* Exactly 4 bytes */ +typedef u_int64_t sha2_word64; /* Exactly 8 bytes */ + +#endif /* SHA2_USE_INTTYPES_H */ + + +/*** SHA-256/384/512 Various Length Definitions ***********************/ +/* NOTE: Most of these are in sha2.h */ +#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8) +#define SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16) +#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16) + + +/*** ENDIAN REVERSAL MACROS *******************************************/ +#if BYTE_ORDER == LITTLE_ENDIAN +#define REVERSE32(w,x) { \ + sha2_word32 tmp = (w); \ + tmp = (tmp >> 16) | (tmp << 16); \ + (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \ +} +#define REVERSE64(w,x) { \ + sha2_word64 tmp = (w); \ + tmp = (tmp >> 32) | (tmp << 32); \ + tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | \ + ((tmp & 0x00ff00ff00ff00ffULL) << 8); \ + (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \ + ((tmp & 0x0000ffff0000ffffULL) << 16); \ +} +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +/* + * Macro for incrementally adding the unsigned 64-bit integer n to the + * unsigned 128-bit integer (represented using a two-element array of + * 64-bit words): + */ +#define ADDINC128(w,n) { \ + (w)[0] += (sha2_word64)(n); \ + if ((w)[0] < (n)) { \ + (w)[1]++; \ + } \ +} + +/* + * Macros for copying blocks of memory and for zeroing out ranges + * of memory. Using these macros makes it easy to switch from + * using memset()/memcpy() and using bzero()/bcopy(). + * + * Please define either SHA2_USE_MEMSET_MEMCPY or define + * SHA2_USE_BZERO_BCOPY depending on which function set you + * choose to use: + */ +#if !defined(SHA2_USE_MEMSET_MEMCPY) && !defined(SHA2_USE_BZERO_BCOPY) +/* Default to memset()/memcpy() if no option is specified */ +#define SHA2_USE_MEMSET_MEMCPY 1 +#endif +#if defined(SHA2_USE_MEMSET_MEMCPY) && defined(SHA2_USE_BZERO_BCOPY) +/* Abort with an error if BOTH options are defined */ +#error Define either SHA2_USE_MEMSET_MEMCPY or SHA2_USE_BZERO_BCOPY, not both! +#endif + +#ifdef SHA2_USE_MEMSET_MEMCPY +#define MEMSET_BZERO(p,l) memset((p), 0, (l)) +#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l)) +#endif +#ifdef SHA2_USE_BZERO_BCOPY +#define MEMSET_BZERO(p,l) bzero((p), (l)) +#define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l)) +#endif + + +/*** THE SIX LOGICAL FUNCTIONS ****************************************/ +/* + * Bit shifting and rotation (used by the six SHA-XYZ logical functions: + * + * NOTE: The naming of R and S appears backwards here (R is a SHIFT and + * S is a ROTATION) because the SHA-256/384/512 description document + * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this + * same "backwards" definition. + */ +/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ +#define R(b,x) ((x) >> (b)) +/* 32-bit Rotate-right (used in SHA-256): */ +#define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) +/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */ +#define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b)))) + +/* Two of six logical functions used in SHA-256, SHA-384, and SHA-512: */ +#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) +#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) + +/* Four of six logical functions used in SHA-256: */ +#define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) +#define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) +#define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x))) +#define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x))) + +/* Four of six logical functions used in SHA-384 and SHA-512: */ +#define Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x))) +#define Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x))) +#define sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x))) +#define sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x))) + +/*** INTERNAL FUNCTION PROTOTYPES *************************************/ +/* NOTE: These should not be accessed directly from outside this + * library -- they are intended for private internal visibility/use + * only. + */ +void SHA512_Last(SHA512_CTX*); +void SHA256_Transform(SHA256_CTX*, const sha2_word32*); +void SHA512_Transform(SHA512_CTX*, const sha2_word64*); + + +/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ +/* Hash constant words K for SHA-256: */ +const static sha2_word32 K256[64] = { + 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, + 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, + 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, + 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, + 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, + 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, + 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, + 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, + 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, + 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, + 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, + 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, + 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, + 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, + 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, + 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL +}; + +/* Initial hash value H for SHA-256: */ +const static sha2_word32 sha256_initial_hash_value[8] = { + 0x6a09e667UL, + 0xbb67ae85UL, + 0x3c6ef372UL, + 0xa54ff53aUL, + 0x510e527fUL, + 0x9b05688cUL, + 0x1f83d9abUL, + 0x5be0cd19UL +}; + +/* Hash constant words K for SHA-384 and SHA-512: */ +const static sha2_word64 K512[80] = { + 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, + 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, + 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, + 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, + 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, + 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, + 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, + 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, + 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, + 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, + 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, + 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, + 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, + 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, + 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, + 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, + 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, + 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, + 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, + 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, + 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, + 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, + 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, + 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, + 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, + 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, + 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, + 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, + 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, + 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, + 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, + 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, + 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, + 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, + 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, + 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, + 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, + 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, + 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, + 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL +}; + +/* Initial hash value H for SHA-384 */ +const static sha2_word64 sha384_initial_hash_value[8] = { + 0xcbbb9d5dc1059ed8ULL, + 0x629a292a367cd507ULL, + 0x9159015a3070dd17ULL, + 0x152fecd8f70e5939ULL, + 0x67332667ffc00b31ULL, + 0x8eb44a8768581511ULL, + 0xdb0c2e0d64f98fa7ULL, + 0x47b5481dbefa4fa4ULL +}; + +/* Initial hash value H for SHA-512 */ +const static sha2_word64 sha512_initial_hash_value[8] = { + 0x6a09e667f3bcc908ULL, + 0xbb67ae8584caa73bULL, + 0x3c6ef372fe94f82bULL, + 0xa54ff53a5f1d36f1ULL, + 0x510e527fade682d1ULL, + 0x9b05688c2b3e6c1fULL, + 0x1f83d9abfb41bd6bULL, + 0x5be0cd19137e2179ULL +}; + +/* + * Constant used by SHA256/384/512_End() functions for converting the + * digest to a readable hexadecimal character string: + */ +static const char *sha2_hex_digits = "0123456789abcdef"; + + +/*** SHA-256: *********************************************************/ +void SHA256_Init(SHA256_CTX* context) { + if (context == (SHA256_CTX*)0) { + return; + } + MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LENGTH); + MEMSET_BZERO(context->buffer, SHA256_BLOCK_LENGTH); + context->bitcount = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-256 round macros: */ + +#if BYTE_ORDER == LITTLE_ENDIAN + +#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ + REVERSE32(*data++, W256[j]); \ + T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ + K256[j] + W256[j]; \ + (d) += T1; \ + (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ + j++ + + +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ + T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ + K256[j] + (W256[j] = *data++); \ + (d) += T1; \ + (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ + j++ + +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND256(a,b,c,d,e,f,g,h) \ + s0 = W256[(j+1)&0x0f]; \ + s0 = sigma0_256(s0); \ + s1 = W256[(j+14)&0x0f]; \ + s1 = sigma1_256(s1); \ + T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \ + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ + j++ + +void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { + sha2_word32 a, b, c, d, e, f, g, h, s0, s1; + sha2_word32 T1, *W256; + int j; + + W256 = (sha2_word32*)context->buffer; + + /* Initialize registers with the prev. intermediate value */ + a = context->state[0]; + b = context->state[1]; + c = context->state[2]; + d = context->state[3]; + e = context->state[4]; + f = context->state[5]; + g = context->state[6]; + h = context->state[7]; + + j = 0; + do { + /* Rounds 0 to 15 (unrolled): */ + ROUND256_0_TO_15(a,b,c,d,e,f,g,h); + ROUND256_0_TO_15(h,a,b,c,d,e,f,g); + ROUND256_0_TO_15(g,h,a,b,c,d,e,f); + ROUND256_0_TO_15(f,g,h,a,b,c,d,e); + ROUND256_0_TO_15(e,f,g,h,a,b,c,d); + ROUND256_0_TO_15(d,e,f,g,h,a,b,c); + ROUND256_0_TO_15(c,d,e,f,g,h,a,b); + ROUND256_0_TO_15(b,c,d,e,f,g,h,a); + } while (j < 16); + + /* Now for the remaining rounds to 64: */ + do { + ROUND256(a,b,c,d,e,f,g,h); + ROUND256(h,a,b,c,d,e,f,g); + ROUND256(g,h,a,b,c,d,e,f); + ROUND256(f,g,h,a,b,c,d,e); + ROUND256(e,f,g,h,a,b,c,d); + ROUND256(d,e,f,g,h,a,b,c); + ROUND256(c,d,e,f,g,h,a,b); + ROUND256(b,c,d,e,f,g,h,a); + } while (j < 64); + + /* Compute the current intermediate hash value */ + context->state[0] += a; + context->state[1] += b; + context->state[2] += c; + context->state[3] += d; + context->state[4] += e; + context->state[5] += f; + context->state[6] += g; + context->state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { + sha2_word32 a, b, c, d, e, f, g, h, s0, s1; + sha2_word32 T1, T2, *W256; + int j; + + W256 = (sha2_word32*)context->buffer; + + /* Initialize registers with the prev. intermediate value */ + a = context->state[0]; + b = context->state[1]; + c = context->state[2]; + d = context->state[3]; + e = context->state[4]; + f = context->state[5]; + g = context->state[6]; + h = context->state[7]; + + j = 0; + do { +#if BYTE_ORDER == LITTLE_ENDIAN + /* Copy data while converting to host byte order */ + REVERSE32(*data++,W256[j]); + /* Apply the SHA-256 compression function to update a..h */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j]; +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + /* Apply the SHA-256 compression function to update a..h with copy */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++); +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + T2 = Sigma0_256(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 16); + + do { + /* Part of the message block expansion: */ + s0 = W256[(j+1)&0x0f]; + s0 = sigma0_256(s0); + s1 = W256[(j+14)&0x0f]; + s1 = sigma1_256(s1); + + /* Apply the SHA-256 compression function to update a..h */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); + T2 = Sigma0_256(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 64); + + /* Compute the current intermediate hash value */ + context->state[0] += a; + context->state[1] += b; + context->state[2] += c; + context->state[3] += d; + context->state[4] += e; + context->state[5] += f; + context->state[6] += g; + context->state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = T2 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) { + unsigned int freespace, usedspace; + + if (len == 0) { + /* Calling with no data is valid - we do nothing */ + return; + } + + /* Sanity check: */ + assert(context != (SHA256_CTX*)0 && data != (sha2_byte*)0); + + usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = SHA256_BLOCK_LENGTH - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace); + context->bitcount += freespace << 3; + len -= freespace; + data += freespace; + SHA256_Transform(context, (sha2_word32*)context->buffer); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(&context->buffer[usedspace], data, len); + context->bitcount += len << 3; + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= SHA256_BLOCK_LENGTH) { + /* Process as many complete blocks as we can */ + SHA256_Transform(context, (sha2_word32*)data); + context->bitcount += SHA256_BLOCK_LENGTH << 3; + len -= SHA256_BLOCK_LENGTH; + data += SHA256_BLOCK_LENGTH; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->buffer, data, len); + context->bitcount += len << 3; + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { + sha2_word32 *d = (sha2_word32*)digest; + unsigned int usedspace; + + /* Sanity check: */ + assert(context != (SHA256_CTX*)0); + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha2_byte*)0) { + usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + REVERSE64(context->bitcount,context->bitcount); +#endif + if (usedspace > 0) { + /* Begin padding with a 1 bit: */ + context->buffer[usedspace++] = 0x80; + + if (usedspace <= SHA256_SHORT_BLOCK_LENGTH) { + /* Set-up for the last transform: */ + MEMSET_BZERO(&context->buffer[usedspace], SHA256_SHORT_BLOCK_LENGTH - usedspace); + } else { + if (usedspace < SHA256_BLOCK_LENGTH) { + MEMSET_BZERO(&context->buffer[usedspace], SHA256_BLOCK_LENGTH - usedspace); + } + /* Do second-to-last transform: */ + SHA256_Transform(context, (sha2_word32*)context->buffer); + + /* And set-up for the last transform: */ + MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH); + } + } else { + /* Set-up for the last transform: */ + MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH); + + /* Begin padding with a 1 bit: */ + *context->buffer = 0x80; + } + /* Set the bit count: */ + *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; + + /* Final transform: */ + SHA256_Transform(context, (sha2_word32*)context->buffer); + +#if BYTE_ORDER == LITTLE_ENDIAN + { + /* Convert TO host byte order */ + int j; + for (j = 0; j < 8; j++) { + REVERSE32(context->state[j],context->state[j]); + *d++ = context->state[j]; + } + } +#else + MEMCPY_BCOPY(d, context->state, SHA256_DIGEST_LENGTH); +#endif + } + + /* Clean up state data: */ + MEMSET_BZERO(context, sizeof(context)); + usedspace = 0; +} + +char *SHA256_End(SHA256_CTX* context, char buffer[]) { + sha2_byte digest[SHA256_DIGEST_LENGTH], *d = digest; + int i; + + /* Sanity check: */ + assert(context != (SHA256_CTX*)0); + + if (buffer != (char*)0) { + SHA256_Final(digest, context); + + for (i = 0; i < SHA256_DIGEST_LENGTH; i++) { + *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha2_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + MEMSET_BZERO(context, sizeof(context)); + } + MEMSET_BZERO(digest, SHA256_DIGEST_LENGTH); + return buffer; +} + +char* SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) { + SHA256_CTX context; + + SHA256_Init(&context); + SHA256_Update(&context, data, len); + return SHA256_End(&context, digest); +} + + +/*** SHA-512: *********************************************************/ +void SHA512_Init(SHA512_CTX* context) { + if (context == (SHA512_CTX*)0) { + return; + } + MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH); + MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH); + context->bitcount[0] = context->bitcount[1] = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-512 round macros: */ +#if BYTE_ORDER == LITTLE_ENDIAN + +#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ + REVERSE64(*data++, W512[j]); \ + T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ + K512[j] + W512[j]; \ + (d) += T1, \ + (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), \ + j++ + + +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ + T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ + K512[j] + (W512[j] = *data++); \ + (d) += T1; \ + (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ + j++ + +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND512(a,b,c,d,e,f,g,h) \ + s0 = W512[(j+1)&0x0f]; \ + s0 = sigma0_512(s0); \ + s1 = W512[(j+14)&0x0f]; \ + s1 = sigma1_512(s1); \ + T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \ + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ + j++ + +void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { + sha2_word64 a, b, c, d, e, f, g, h, s0, s1; + sha2_word64 T1, *W512 = (sha2_word64*)context->buffer; + int j; + + /* Initialize registers with the prev. intermediate value */ + a = context->state[0]; + b = context->state[1]; + c = context->state[2]; + d = context->state[3]; + e = context->state[4]; + f = context->state[5]; + g = context->state[6]; + h = context->state[7]; + + j = 0; + do { + ROUND512_0_TO_15(a,b,c,d,e,f,g,h); + ROUND512_0_TO_15(h,a,b,c,d,e,f,g); + ROUND512_0_TO_15(g,h,a,b,c,d,e,f); + ROUND512_0_TO_15(f,g,h,a,b,c,d,e); + ROUND512_0_TO_15(e,f,g,h,a,b,c,d); + ROUND512_0_TO_15(d,e,f,g,h,a,b,c); + ROUND512_0_TO_15(c,d,e,f,g,h,a,b); + ROUND512_0_TO_15(b,c,d,e,f,g,h,a); + } while (j < 16); + + /* Now for the remaining rounds up to 79: */ + do { + ROUND512(a,b,c,d,e,f,g,h); + ROUND512(h,a,b,c,d,e,f,g); + ROUND512(g,h,a,b,c,d,e,f); + ROUND512(f,g,h,a,b,c,d,e); + ROUND512(e,f,g,h,a,b,c,d); + ROUND512(d,e,f,g,h,a,b,c); + ROUND512(c,d,e,f,g,h,a,b); + ROUND512(b,c,d,e,f,g,h,a); + } while (j < 80); + + /* Compute the current intermediate hash value */ + context->state[0] += a; + context->state[1] += b; + context->state[2] += c; + context->state[3] += d; + context->state[4] += e; + context->state[5] += f; + context->state[6] += g; + context->state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { + sha2_word64 a, b, c, d, e, f, g, h, s0, s1; + sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer; + int j; + + /* Initialize registers with the prev. intermediate value */ + a = context->state[0]; + b = context->state[1]; + c = context->state[2]; + d = context->state[3]; + e = context->state[4]; + f = context->state[5]; + g = context->state[6]; + h = context->state[7]; + + j = 0; + do { +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + REVERSE64(*data++, W512[j]); + /* Apply the SHA-512 compression function to update a..h */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j]; +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + /* Apply the SHA-512 compression function to update a..h with copy */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++); +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + T2 = Sigma0_512(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 16); + + do { + /* Part of the message block expansion: */ + s0 = W512[(j+1)&0x0f]; + s0 = sigma0_512(s0); + s1 = W512[(j+14)&0x0f]; + s1 = sigma1_512(s1); + + /* Apply the SHA-512 compression function to update a..h */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); + T2 = Sigma0_512(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 80); + + /* Compute the current intermediate hash value */ + context->state[0] += a; + context->state[1] += b; + context->state[2] += c; + context->state[3] += d; + context->state[4] += e; + context->state[5] += f; + context->state[6] += g; + context->state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = T2 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) { + unsigned int freespace, usedspace; + + if (len == 0) { + /* Calling with no data is valid - we do nothing */ + return; + } + + /* Sanity check: */ + assert(context != (SHA512_CTX*)0 && data != (sha2_byte*)0); + + usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = SHA512_BLOCK_LENGTH - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace); + ADDINC128(context->bitcount, freespace << 3); + len -= freespace; + data += freespace; + SHA512_Transform(context, (sha2_word64*)context->buffer); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(&context->buffer[usedspace], data, len); + ADDINC128(context->bitcount, len << 3); + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= SHA512_BLOCK_LENGTH) { + /* Process as many complete blocks as we can */ + SHA512_Transform(context, (sha2_word64*)data); + ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3); + len -= SHA512_BLOCK_LENGTH; + data += SHA512_BLOCK_LENGTH; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->buffer, data, len); + ADDINC128(context->bitcount, len << 3); + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void SHA512_Last(SHA512_CTX* context) { + unsigned int usedspace; + + usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + REVERSE64(context->bitcount[0],context->bitcount[0]); + REVERSE64(context->bitcount[1],context->bitcount[1]); +#endif + if (usedspace > 0) { + /* Begin padding with a 1 bit: */ + context->buffer[usedspace++] = 0x80; + + if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) { + /* Set-up for the last transform: */ + MEMSET_BZERO(&context->buffer[usedspace], SHA512_SHORT_BLOCK_LENGTH - usedspace); + } else { + if (usedspace < SHA512_BLOCK_LENGTH) { + MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace); + } + /* Do second-to-last transform: */ + SHA512_Transform(context, (sha2_word64*)context->buffer); + + /* And set-up for the last transform: */ + MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2); + } + } else { + /* Prepare for final transform: */ + MEMSET_BZERO(context->buffer, SHA512_SHORT_BLOCK_LENGTH); + + /* Begin padding with a 1 bit: */ + *context->buffer = 0x80; + } + /* Store the length of input data (in bits): */ + *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; + *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; + + /* Final transform: */ + SHA512_Transform(context, (sha2_word64*)context->buffer); +} + +void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { + sha2_word64 *d = (sha2_word64*)digest; + + /* Sanity check: */ + assert(context != (SHA512_CTX*)0); + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha2_byte*)0) { + SHA512_Last(context); + + /* Save the hash data for output: */ +#if BYTE_ORDER == LITTLE_ENDIAN + { + /* Convert TO host byte order */ + int j; + for (j = 0; j < 8; j++) { + REVERSE64(context->state[j],context->state[j]); + *d++ = context->state[j]; + } + } +#else + MEMCPY_BCOPY(d, context->state, SHA512_DIGEST_LENGTH); +#endif + } + + /* Zero out state data */ + MEMSET_BZERO(context, sizeof(context)); +} + +char *SHA512_End(SHA512_CTX* context, char buffer[]) { + sha2_byte digest[SHA512_DIGEST_LENGTH], *d = digest; + int i; + + /* Sanity check: */ + assert(context != (SHA512_CTX*)0); + + if (buffer != (char*)0) { + SHA512_Final(digest, context); + + for (i = 0; i < SHA512_DIGEST_LENGTH; i++) { + *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha2_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + MEMSET_BZERO(context, sizeof(context)); + } + MEMSET_BZERO(digest, SHA512_DIGEST_LENGTH); + return buffer; +} + +char* SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) { + SHA512_CTX context; + + SHA512_Init(&context); + SHA512_Update(&context, data, len); + return SHA512_End(&context, digest); +} + + +/*** SHA-384: *********************************************************/ +void SHA384_Init(SHA384_CTX* context) { + if (context == (SHA384_CTX*)0) { + return; + } + MEMCPY_BCOPY(context->state, sha384_initial_hash_value, SHA512_DIGEST_LENGTH); + MEMSET_BZERO(context->buffer, SHA384_BLOCK_LENGTH); + context->bitcount[0] = context->bitcount[1] = 0; +} + +void SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) { + SHA512_Update((SHA512_CTX*)context, data, len); +} + +void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) { + sha2_word64 *d = (sha2_word64*)digest; + + /* Sanity check: */ + assert(context != (SHA384_CTX*)0); + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha2_byte*)0) { + SHA512_Last((SHA512_CTX*)context); + + /* Save the hash data for output: */ +#if BYTE_ORDER == LITTLE_ENDIAN + { + /* Convert TO host byte order */ + int j; + for (j = 0; j < 6; j++) { + REVERSE64(context->state[j],context->state[j]); + *d++ = context->state[j]; + } + } +#else + MEMCPY_BCOPY(d, context->state, SHA384_DIGEST_LENGTH); +#endif + } + + /* Zero out state data */ + MEMSET_BZERO(context, sizeof(context)); +} + +char *SHA384_End(SHA384_CTX* context, char buffer[]) { + sha2_byte digest[SHA384_DIGEST_LENGTH], *d = digest; + int i; + + /* Sanity check: */ + assert(context != (SHA384_CTX*)0); + + if (buffer != (char*)0) { + SHA384_Final(digest, context); + + for (i = 0; i < SHA384_DIGEST_LENGTH; i++) { + *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha2_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + MEMSET_BZERO(context, sizeof(context)); + } + MEMSET_BZERO(digest, SHA384_DIGEST_LENGTH); + return buffer; +} + +char* SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) { + SHA384_CTX context; + + SHA384_Init(&context); + SHA384_Update(&context, data, len); + return SHA384_End(&context, digest); +} diff --git a/Source/cm_sha2.h b/Source/cm_sha2.h new file mode 100644 index 0000000..3a55b33 --- /dev/null +++ b/Source/cm_sha2.h @@ -0,0 +1,196 @@ +/* + * FILE: sha2.h + * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ + * + * Copyright (c) 2000-2001, Aaron D. Gifford + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $ + */ + +#ifndef __SHA2_H__ +#define __SHA2_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Import u_intXX_t size_t type definitions from system headers. You + * may need to change this, or define these things yourself in this + * file. + */ +#include + +#ifdef SHA2_USE_INTTYPES_H + +#include + +#endif /* SHA2_USE_INTTYPES_H */ + + +/*** SHA-256/384/512 Various Length Definitions ***********************/ +#define SHA256_BLOCK_LENGTH 64 +#define SHA256_DIGEST_LENGTH 32 +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#define SHA384_BLOCK_LENGTH 128 +#define SHA384_DIGEST_LENGTH 48 +#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) +#define SHA512_BLOCK_LENGTH 128 +#define SHA512_DIGEST_LENGTH 64 +#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) + + +/*** SHA-256/384/512 Context Structures *******************************/ +/* NOTE: If your architecture does not define either u_intXX_t types or + * uintXX_t (from inttypes.h), you may need to define things by hand + * for your system: + */ +#if 0 +typedef unsigned char u_int8_t; /* 1-byte (8-bits) */ +typedef unsigned int u_int32_t; /* 4-bytes (32-bits) */ +typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */ +#endif +/* + * Most BSD systems already define u_intXX_t types, as does Linux. + * Some systems, however, like Compaq's Tru64 Unix instead can use + * uintXX_t types defined by very recent ANSI C standards and included + * in the file: + * + * #include + * + * If you choose to use then please define: + * + * #define SHA2_USE_INTTYPES_H + * + * Or on the command line during compile: + * + * cc -DSHA2_USE_INTTYPES_H ... + */ +#ifdef SHA2_USE_INTTYPES_H + +typedef struct _SHA256_CTX { + uint32_t state[8]; + uint64_t bitcount; + uint8_t buffer[SHA256_BLOCK_LENGTH]; +} SHA256_CTX; +typedef struct _SHA512_CTX { + uint64_t state[8]; + uint64_t bitcount[2]; + uint8_t buffer[SHA512_BLOCK_LENGTH]; +} SHA512_CTX; + +#else /* SHA2_USE_INTTYPES_H */ + +typedef struct _SHA256_CTX { + u_int32_t state[8]; + u_int64_t bitcount; + u_int8_t buffer[SHA256_BLOCK_LENGTH]; +} SHA256_CTX; +typedef struct _SHA512_CTX { + u_int64_t state[8]; + u_int64_t bitcount[2]; + u_int8_t buffer[SHA512_BLOCK_LENGTH]; +} SHA512_CTX; + +#endif /* SHA2_USE_INTTYPES_H */ + +typedef SHA512_CTX SHA384_CTX; + + +/*** SHA-256/384/512 Function Prototypes ******************************/ +#ifndef NOPROTO +#ifdef SHA2_USE_INTTYPES_H + +void SHA256_Init(SHA256_CTX *); +void SHA256_Update(SHA256_CTX*, const uint8_t*, size_t); +void SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*); +char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); +char* SHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); + +void SHA384_Init(SHA384_CTX*); +void SHA384_Update(SHA384_CTX*, const uint8_t*, size_t); +void SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*); +char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); +char* SHA384_Data(const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); + +void SHA512_Init(SHA512_CTX*); +void SHA512_Update(SHA512_CTX*, const uint8_t*, size_t); +void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); +char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); +char* SHA512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); + +#else /* SHA2_USE_INTTYPES_H */ + +void SHA256_Init(SHA256_CTX *); +void SHA256_Update(SHA256_CTX*, const u_int8_t*, size_t); +void SHA256_Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*); +char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); +char* SHA256_Data(const u_int8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); + +void SHA384_Init(SHA384_CTX*); +void SHA384_Update(SHA384_CTX*, const u_int8_t*, size_t); +void SHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*); +char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); +char* SHA384_Data(const u_int8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); + +void SHA512_Init(SHA512_CTX*); +void SHA512_Update(SHA512_CTX*, const u_int8_t*, size_t); +void SHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); +char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); +char* SHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); + +#endif /* SHA2_USE_INTTYPES_H */ + +#else /* NOPROTO */ + +void SHA256_Init(); +void SHA256_Update(); +void SHA256_Final(); +char* SHA256_End(); +char* SHA256_Data(); + +void SHA384_Init(); +void SHA384_Update(); +void SHA384_Final(); +char* SHA384_End(); +char* SHA384_Data(); + +void SHA512_Init(); +void SHA512_Update(); +void SHA512_Final(); +char* SHA512_End(); +char* SHA512_Data(); + +#endif /* NOPROTO */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __SHA2_H__ */ -- cgit v0.12 From 8251b20d4bba026b920c018e7cfb6ce2ce101110 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 27 Jun 2011 14:35:09 -0400 Subject: Import sha2 implementation 1.1 from Aaron D. Gifford Update cm_sha2.[hc] from sha2.[hc] in "sha2-1.1-ALPHA.tgz" downloaded today from http://www.aarongifford.com/computers/sha.html with trivial whitespace cleanup. This adds SHA-224 support. --- Source/cm_sha2.c | 1103 ++++++++++++++++++++++++++++++++++++++++-------------- Source/cm_sha2.h | 192 ++++++---- 2 files changed, 949 insertions(+), 346 deletions(-) diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c index 15f0f20..855a5bb 100644 --- a/Source/cm_sha2.c +++ b/Source/cm_sha2.c @@ -1,8 +1,9 @@ /* * FILE: sha2.c - * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ + * AUTHOR: Aaron D. Gifford + * http://www.aarongifford.com/computers/sha.html * - * Copyright (c) 2000-2001, Aaron D. Gifford + * Copyright (c) 2000-2003, Aaron D. Gifford * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $ + * $Id: sha2.c,v 1.4 2004/01/07 22:58:18 adg Exp $ */ #include /* memcpy()/memset() or bcopy()/bzero() */ @@ -57,7 +58,7 @@ */ -/*** SHA-256/384/512 Machine Architecture Definitions *****************/ +/*** SHA-224/256/384/512 Machine Architecture Definitions *************/ /* * BYTE_ORDER NOTE: * @@ -90,7 +91,7 @@ #endif /* - * Define the followingsha2_* types to types of the correct length on + * Define the following sha_* types to types of the correct length on * the native archtecture. Most BSD systems and Linux define u_intXX_t * types. Machines with very recent ANSI C headers, can use the * uintXX_t definintions from inttypes.h by defining SHA2_USE_INTTYPES_H @@ -105,35 +106,28 @@ */ #ifdef SHA2_USE_INTTYPES_H -typedef uint8_t sha2_byte; /* Exactly 1 byte */ -typedef uint32_t sha2_word32; /* Exactly 4 bytes */ -typedef uint64_t sha2_word64; /* Exactly 8 bytes */ +typedef uint8_t sha_byte; /* Exactly 1 byte */ +typedef uint32_t sha_word32; /* Exactly 4 bytes */ +typedef uint64_t sha_word64; /* Exactly 8 bytes */ #else /* SHA2_USE_INTTYPES_H */ -typedef u_int8_t sha2_byte; /* Exactly 1 byte */ -typedef u_int32_t sha2_word32; /* Exactly 4 bytes */ -typedef u_int64_t sha2_word64; /* Exactly 8 bytes */ +typedef u_int8_t sha_byte; /* Exactly 1 byte */ +typedef u_int32_t sha_word32; /* Exactly 4 bytes */ +typedef u_int64_t sha_word64; /* Exactly 8 bytes */ #endif /* SHA2_USE_INTTYPES_H */ -/*** SHA-256/384/512 Various Length Definitions ***********************/ -/* NOTE: Most of these are in sha2.h */ -#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8) -#define SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16) -#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16) - - /*** ENDIAN REVERSAL MACROS *******************************************/ #if BYTE_ORDER == LITTLE_ENDIAN #define REVERSE32(w,x) { \ - sha2_word32 tmp = (w); \ + sha_word32 tmp = (w); \ tmp = (tmp >> 16) | (tmp << 16); \ (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \ } #define REVERSE64(w,x) { \ - sha2_word64 tmp = (w); \ + sha_word64 tmp = (w); \ tmp = (tmp >> 32) | (tmp << 32); \ tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | \ ((tmp & 0x00ff00ff00ff00ffULL) << 8); \ @@ -148,7 +142,7 @@ typedef u_int64_t sha2_word64; /* Exactly 8 bytes */ * 64-bit words): */ #define ADDINC128(w,n) { \ - (w)[0] += (sha2_word64)(n); \ + (w)[0] += (sha_word64)(n); \ if ((w)[0] < (n)) { \ (w)[1]++; \ } \ @@ -186,47 +180,81 @@ typedef u_int64_t sha2_word64; /* Exactly 8 bytes */ /* * Bit shifting and rotation (used by the six SHA-XYZ logical functions: * - * NOTE: The naming of R and S appears backwards here (R is a SHIFT and - * S is a ROTATION) because the SHA-256/384/512 description document - * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this - * same "backwards" definition. + * NOTE: In the original SHA-256/384/512 document, the shift-right + * function was named R and the rotate-right function was called S. + * (See: http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf on the + * web.) + * + * The newer NIST FIPS 180-2 document uses a much clearer naming + * scheme, SHR for shift-right, ROTR for rotate-right, and ROTL for + * rotate-left. (See: + * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf + * on the web.) + * + * WARNING: These macros must be used cautiously, since they reference + * supplied parameters sometimes more than once, and thus could have + * unexpected side-effects if used without taking this into account. */ /* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ -#define R(b,x) ((x) >> (b)) +#define SHR(b,x) ((x) >> (b)) /* 32-bit Rotate-right (used in SHA-256): */ -#define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) +#define ROTR32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) /* 64-bit Rotate-right (used in SHA-384 and SHA-512): */ -#define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b)))) +#define ROTR64(b,x) (((x) >> (b)) | ((x) << (64 - (b)))) +/* 32-bit Rotate-left (used in SHA-1): */ +#define ROTL32(b,x) (((x) << (b)) | ((x) >> (32 - (b)))) -/* Two of six logical functions used in SHA-256, SHA-384, and SHA-512: */ +/* Two logical functions used in SHA-1, SHA-254, SHA-256, SHA-384, and SHA-512: */ #define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) #define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) -/* Four of six logical functions used in SHA-256: */ -#define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) -#define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) -#define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x))) -#define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x))) +/* Function used in SHA-1: */ +#define Parity(x,y,z) ((x) ^ (y) ^ (z)) + +/* Four logical functions used in SHA-256: */ +#define Sigma0_256(x) (ROTR32(2, (x)) ^ ROTR32(13, (x)) ^ ROTR32(22, (x))) +#define Sigma1_256(x) (ROTR32(6, (x)) ^ ROTR32(11, (x)) ^ ROTR32(25, (x))) +#define sigma0_256(x) (ROTR32(7, (x)) ^ ROTR32(18, (x)) ^ SHR( 3 , (x))) +#define sigma1_256(x) (ROTR32(17, (x)) ^ ROTR32(19, (x)) ^ SHR( 10, (x))) /* Four of six logical functions used in SHA-384 and SHA-512: */ -#define Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x))) -#define Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x))) -#define sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x))) -#define sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x))) +#define Sigma0_512(x) (ROTR64(28, (x)) ^ ROTR64(34, (x)) ^ ROTR64(39, (x))) +#define Sigma1_512(x) (ROTR64(14, (x)) ^ ROTR64(18, (x)) ^ ROTR64(41, (x))) +#define sigma0_512(x) (ROTR64( 1, (x)) ^ ROTR64( 8, (x)) ^ SHR( 7, (x))) +#define sigma1_512(x) (ROTR64(19, (x)) ^ ROTR64(61, (x)) ^ SHR( 6, (x))) /*** INTERNAL FUNCTION PROTOTYPES *************************************/ -/* NOTE: These should not be accessed directly from outside this - * library -- they are intended for private internal visibility/use - * only. - */ -void SHA512_Last(SHA512_CTX*); -void SHA256_Transform(SHA256_CTX*, const sha2_word32*); -void SHA512_Transform(SHA512_CTX*, const sha2_word64*); +/* SHA-224 and SHA-256: */ +void SHA256_Internal_Init(SHA_CTX*, const sha_word32*); +void SHA256_Internal_Last(SHA_CTX*); +void SHA256_Internal_Transform(SHA_CTX*, const sha_word32*); + +/* SHA-384 and SHA-512: */ +void SHA512_Internal_Init(SHA_CTX*, const sha_word64*); +void SHA512_Internal_Last(SHA_CTX*); +void SHA512_Internal_Transform(SHA_CTX*, const sha_word64*); + + +/*** SHA2 INITIAL HASH VALUES AND CONSTANTS ***************************/ -/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ -/* Hash constant words K for SHA-256: */ -const static sha2_word32 K256[64] = { +/* Hash constant words K for SHA-1: */ +#define K1_0_TO_19 0x5a827999UL +#define K1_20_TO_39 0x6ed9eba1UL +#define K1_40_TO_59 0x8f1bbcdcUL +#define K1_60_TO_79 0xca62c1d6UL + +/* Initial hash value H for SHA-1: */ +const static sha_word32 sha1_initial_hash_value[5] = { + 0x67452301UL, + 0xefcdab89UL, + 0x98badcfeUL, + 0x10325476UL, + 0xc3d2e1f0UL +}; + +/* Hash constant words K for SHA-224 and SHA-256: */ +const static sha_word32 K256[64] = { 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, @@ -245,8 +273,20 @@ const static sha2_word32 K256[64] = { 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL }; +/* Initial hash value H for SHA-224: */ +const static sha_word32 sha224_initial_hash_value[8] = { + 0xc1059ed8UL, + 0x367cd507UL, + 0x3070dd17UL, + 0xf70e5939UL, + 0xffc00b31UL, + 0x68581511UL, + 0x64f98fa7UL, + 0xbefa4fa4UL +}; + /* Initial hash value H for SHA-256: */ -const static sha2_word32 sha256_initial_hash_value[8] = { +const static sha_word32 sha256_initial_hash_value[8] = { 0x6a09e667UL, 0xbb67ae85UL, 0x3c6ef372UL, @@ -258,7 +298,7 @@ const static sha2_word32 sha256_initial_hash_value[8] = { }; /* Hash constant words K for SHA-384 and SHA-512: */ -const static sha2_word64 K512[80] = { +const static sha_word64 K512[80] = { 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, @@ -302,7 +342,7 @@ const static sha2_word64 K512[80] = { }; /* Initial hash value H for SHA-384 */ -const static sha2_word64 sha384_initial_hash_value[8] = { +const static sha_word64 sha384_initial_hash_value[8] = { 0xcbbb9d5dc1059ed8ULL, 0x629a292a367cd507ULL, 0x9159015a3070dd17ULL, @@ -314,7 +354,7 @@ const static sha2_word64 sha384_initial_hash_value[8] = { }; /* Initial hash value H for SHA-512 */ -const static sha2_word64 sha512_initial_hash_value[8] = { +const static sha_word64 sha512_initial_hash_value[8] = { 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL, @@ -326,20 +366,439 @@ const static sha2_word64 sha512_initial_hash_value[8] = { }; /* - * Constant used by SHA256/384/512_End() functions for converting the + * Constant used by SHA224/256/384/512_End() functions for converting the * digest to a readable hexadecimal character string: */ -static const char *sha2_hex_digits = "0123456789abcdef"; +static const char *sha_hex_digits = "0123456789abcdef"; -/*** SHA-256: *********************************************************/ -void SHA256_Init(SHA256_CTX* context) { - if (context == (SHA256_CTX*)0) { +/*** SHA-1: ***********************************************************/ +void SHA1_Init(SHA_CTX* context) { + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + MEMCPY_BCOPY(context->s1.state, sha1_initial_hash_value, sizeof(sha_word32) * 5); + MEMSET_BZERO(context->s1.buffer, 64); + context->s1.bitcount = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-1 round macros: */ + +#if BYTE_ORDER == LITTLE_ENDIAN + +#define ROUND1_0_TO_15(a,b,c,d,e) \ + REVERSE32(*data++, W1[j]); \ + (e) = ROTL32(5, (a)) + Ch((b), (c), (d)) + (e) + \ + K1_0_TO_19 + W1[j]; \ + (b) = ROTL32(30, (b)); \ + j++; + +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND1_0_TO_15(a,b,c,d,e) \ + (e) = ROTL32(5, (a)) + Ch((b), (c), (d)) + (e) + \ + K1_0_TO_19 + ( W1[j] = *data++ ); \ + (b) = ROTL32(30, (b)); \ + j++; + +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND1_16_TO_19(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Ch(b,c,d) + e + K1_0_TO_19 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_20_TO_39(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Parity(b,c,d) + e + K1_20_TO_39 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_40_TO_59(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Maj(b,c,d) + e + K1_40_TO_59 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_60_TO_79(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Parity(b,c,d) + e + K1_60_TO_79 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +void SHA1_Internal_Transform(SHA_CTX* context, const sha_word32* data) { + sha_word32 a, b, c, d, e; + sha_word32 T1, *W1; + int j; + + W1 = (sha_word32*)context->s1.buffer; + + /* Initialize registers with the prev. intermediate value */ + a = context->s1.state[0]; + b = context->s1.state[1]; + c = context->s1.state[2]; + d = context->s1.state[3]; + e = context->s1.state[4]; + + j = 0; + + /* Rounds 0 to 15 unrolled: */ + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + + /* Rounds 16 to 19 unrolled: */ + ROUND1_16_TO_19(e,a,b,c,d); + ROUND1_16_TO_19(d,e,a,b,c); + ROUND1_16_TO_19(c,d,e,a,b); + ROUND1_16_TO_19(b,c,d,e,a); + + /* Rounds 20 to 39 unrolled: */ + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + + /* Rounds 40 to 59 unrolled: */ + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + + /* Rounds 60 to 79 unrolled: */ + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + + /* Compute the current intermediate hash value */ + context->s1.state[0] += a; + context->s1.state[1] += b; + context->s1.state[2] += c; + context->s1.state[3] += d; + context->s1.state[4] += e; + + /* Clean up */ + a = b = c = d = e = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void SHA1_Internal_Transform(SHA_CTX* context, const sha_word32* data) { + sha_word32 a, b, c, d, e; + sha_word32 T1, *W1; + int j; + + W1 = (sha_word32*)context->s1.buffer; + + /* Initialize registers with the prev. intermediate value */ + a = context->s1.state[0]; + b = context->s1.state[1]; + c = context->s1.state[2]; + d = context->s1.state[3]; + e = context->s1.state[4]; + j = 0; + do { +#if BYTE_ORDER == LITTLE_ENDIAN + T1 = data[j]; + /* Copy data while converting to host byte order */ + REVERSE32(*data++, W1[j]); + T1 = ROTL32(5, a) + Ch(b, c, d) + e + K1_0_TO_19 + W1[j]; +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + T1 = ROTL32(5, a) + Ch(b, c, d) + e + K1_0_TO_19 + (W1[j] = *data++); +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 16); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Ch(b,c,d) + e + K1_0_TO_19 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 20); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Parity(b,c,d) + e + K1_20_TO_39 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 40); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Maj(b,c,d) + e + K1_40_TO_59 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 60); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Parity(b,c,d) + e + K1_60_TO_79 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 80); + + + /* Compute the current intermediate hash value */ + context->s1.state[0] += a; + context->s1.state[1] += b; + context->s1.state[2] += c; + context->s1.state[3] += d; + context->s1.state[4] += e; + + /* Clean up */ + a = b = c = d = e = T1 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void SHA1_Update(SHA_CTX* context, const sha_byte *data, size_t len) { + unsigned int freespace, usedspace; + if (len == 0) { + /* Calling with no data is valid - we do nothing */ return; } - MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LENGTH); - MEMSET_BZERO(context->buffer, SHA256_BLOCK_LENGTH); - context->bitcount = 0; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); + + usedspace = (context->s1.bitcount >> 3) % 64; + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = 64 - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(&context->s1.buffer[usedspace], data, freespace); + context->s1.bitcount += freespace << 3; + len -= freespace; + data += freespace; + SHA1_Internal_Transform(context, (sha_word32*)context->s1.buffer); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(&context->s1.buffer[usedspace], data, len); + context->s1.bitcount += len << 3; + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= 64) { + /* Process as many complete blocks as we can */ + SHA1_Internal_Transform(context, (sha_word32*)data); + context->s1.bitcount += 512; + len -= 64; + data += 64; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->s1.buffer, data, len); + context->s1.bitcount += len << 3; + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void SHA1_Final(sha_byte digest[], SHA_CTX* context) { + sha_word32 *d = (sha_word32*)digest; + unsigned int usedspace; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + if (digest == (sha_byte*)0) { + /* + * No digest buffer, so we can do nothing + * except clean up and go home + */ + MEMSET_BZERO(context, sizeof(context)); + return; + } + + usedspace = (context->s1.bitcount >> 3) % 64; + if (usedspace == 0) { + /* Set-up for the last transform: */ + MEMSET_BZERO(context->s1.buffer, 56); + + /* Begin padding with a 1 bit: */ + *context->s1.buffer = 0x80; + } else { + /* Begin padding with a 1 bit: */ + context->s1.buffer[usedspace++] = 0x80; + + if (usedspace <= 56) { + /* Set-up for the last transform: */ + MEMSET_BZERO(&context->s1.buffer[usedspace], 56 - usedspace); + } else { + if (usedspace < 64) { + MEMSET_BZERO(&context->s1.buffer[usedspace], 64 - usedspace); + } + /* Do second-to-last transform: */ + SHA1_Internal_Transform(context, (sha_word32*)context->s1.buffer); + + /* And set-up for the last transform: */ + MEMSET_BZERO(context->s1.buffer, 56); + } + /* Clean up: */ + usedspace = 0; + } + /* Set the bit count: */ +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + REVERSE64(context->s1.bitcount,context->s1.bitcount); +#endif + *(sha_word64*)&context->s1.buffer[56] = context->s1.bitcount; + + /* Final transform: */ + SHA1_Internal_Transform(context, (sha_word32*)context->s1.buffer); + + /* Save the hash data for output: */ +#if BYTE_ORDER == LITTLE_ENDIAN + { + /* Convert TO host byte order */ + int j; + for (j = 0; j < (SHA1_DIGEST_LENGTH >> 2); j++) { + REVERSE32(context->s1.state[j],context->s1.state[j]); + *d++ = context->s1.state[j]; + } + } +#else + MEMCPY_BCOPY(d, context->s1.state, SHA1_DIGEST_LENGTH); +#endif + + /* Clean up: */ + MEMSET_BZERO(context, sizeof(context)); +} + +char *SHA1_End(SHA_CTX* context, char buffer[]) { + sha_byte digest[SHA1_DIGEST_LENGTH], *d = digest; + int i; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + if (buffer != (char*)0) { + SHA1_Final(digest, context); + + for (i = 0; i < SHA1_DIGEST_LENGTH; i++) { + *buffer++ = sha_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + MEMSET_BZERO(context, sizeof(context)); + } + MEMSET_BZERO(digest, SHA1_DIGEST_LENGTH); + return buffer; +} + +char* SHA1_Data(const sha_byte* data, size_t len, char digest[SHA1_DIGEST_STRING_LENGTH]) { + SHA_CTX context; + + SHA1_Init(&context); + SHA1_Update(&context, data, len); + return SHA1_End(&context, digest); +} + + +/*** SHA-256: *********************************************************/ +void SHA256_Internal_Init(SHA_CTX* context, const sha_word32* ihv) { + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + MEMCPY_BCOPY(context->s256.state, ihv, sizeof(sha_word32) * 8); + MEMSET_BZERO(context->s256.buffer, 64); + context->s256.bitcount = 0; +} + +void SHA256_Init(SHA_CTX* context) { + SHA256_Internal_Init(context, sha256_initial_hash_value); } #ifdef SHA2_UNROLL_TRANSFORM @@ -379,22 +838,22 @@ void SHA256_Init(SHA256_CTX* context) { (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ j++ -void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { - sha2_word32 a, b, c, d, e, f, g, h, s0, s1; - sha2_word32 T1, *W256; +void SHA256_Internal_Transform(SHA_CTX* context, const sha_word32* data) { + sha_word32 a, b, c, d, e, f, g, h, s0, s1; + sha_word32 T1, *W256; int j; - W256 = (sha2_word32*)context->buffer; + W256 = (sha_word32*)context->s256.buffer; /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; + a = context->s256.state[0]; + b = context->s256.state[1]; + c = context->s256.state[2]; + d = context->s256.state[3]; + e = context->s256.state[4]; + f = context->s256.state[5]; + g = context->s256.state[6]; + h = context->s256.state[7]; j = 0; do { @@ -422,14 +881,14 @@ void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { } while (j < 64); /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; + context->s256.state[0] += a; + context->s256.state[1] += b; + context->s256.state[2] += c; + context->s256.state[3] += d; + context->s256.state[4] += e; + context->s256.state[5] += f; + context->s256.state[6] += g; + context->s256.state[7] += h; /* Clean up */ a = b = c = d = e = f = g = h = T1 = 0; @@ -437,22 +896,22 @@ void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { #else /* SHA2_UNROLL_TRANSFORM */ -void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { - sha2_word32 a, b, c, d, e, f, g, h, s0, s1; - sha2_word32 T1, T2, *W256; +void SHA256_Internal_Transform(SHA_CTX* context, const sha_word32* data) { + sha_word32 a, b, c, d, e, f, g, h, s0, s1; + sha_word32 T1, T2, *W256; int j; - W256 = (sha2_word32*)context->buffer; + W256 = (sha_word32*)context->s256.buffer; /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; + a = context->s256.state[0]; + b = context->s256.state[1]; + c = context->s256.state[2]; + d = context->s256.state[3]; + e = context->s256.state[4]; + f = context->s256.state[5]; + g = context->s256.state[6]; + h = context->s256.state[7]; j = 0; do { @@ -502,14 +961,14 @@ void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { } while (j < 64); /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; + context->s256.state[0] += a; + context->s256.state[1] += b; + context->s256.state[2] += c; + context->s256.state[3] += d; + context->s256.state[4] += e; + context->s256.state[5] += f; + context->s256.state[6] += g; + context->s256.state[7] += h; /* Clean up */ a = b = c = d = e = f = g = h = T1 = T2 = 0; @@ -517,7 +976,7 @@ void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { #endif /* SHA2_UNROLL_TRANSFORM */ -void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) { +void SHA256_Update(SHA_CTX* context, const sha_byte *data, size_t len) { unsigned int freespace, usedspace; if (len == 0) { @@ -526,121 +985,128 @@ void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) { } /* Sanity check: */ - assert(context != (SHA256_CTX*)0 && data != (sha2_byte*)0); + assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); - usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; + usedspace = (context->s256.bitcount >> 3) % 64; if (usedspace > 0) { /* Calculate how much free space is available in the buffer */ - freespace = SHA256_BLOCK_LENGTH - usedspace; + freespace = 64 - usedspace; if (len >= freespace) { /* Fill the buffer completely and process it */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace); - context->bitcount += freespace << 3; + MEMCPY_BCOPY(&context->s256.buffer[usedspace], data, freespace); + context->s256.bitcount += freespace << 3; len -= freespace; data += freespace; - SHA256_Transform(context, (sha2_word32*)context->buffer); + SHA256_Internal_Transform(context, (sha_word32*)context->s256.buffer); } else { /* The buffer is not yet full */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, len); - context->bitcount += len << 3; + MEMCPY_BCOPY(&context->s256.buffer[usedspace], data, len); + context->s256.bitcount += len << 3; /* Clean up: */ usedspace = freespace = 0; return; } } - while (len >= SHA256_BLOCK_LENGTH) { + while (len >= 64) { /* Process as many complete blocks as we can */ - SHA256_Transform(context, (sha2_word32*)data); - context->bitcount += SHA256_BLOCK_LENGTH << 3; - len -= SHA256_BLOCK_LENGTH; - data += SHA256_BLOCK_LENGTH; + SHA256_Internal_Transform(context, (sha_word32*)data); + context->s256.bitcount += 512; + len -= 64; + data += 64; } if (len > 0) { /* There's left-overs, so save 'em */ - MEMCPY_BCOPY(context->buffer, data, len); - context->bitcount += len << 3; + MEMCPY_BCOPY(context->s256.buffer, data, len); + context->s256.bitcount += len << 3; } /* Clean up: */ usedspace = freespace = 0; } -void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { - sha2_word32 *d = (sha2_word32*)digest; +void SHA256_Internal_Last(SHA_CTX* context) { unsigned int usedspace; - /* Sanity check: */ - assert(context != (SHA256_CTX*)0); - - /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != (sha2_byte*)0) { - usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; + usedspace = (context->s256.bitcount >> 3) % 64; #if BYTE_ORDER == LITTLE_ENDIAN - /* Convert FROM host byte order */ - REVERSE64(context->bitcount,context->bitcount); + /* Convert FROM host byte order */ + REVERSE64(context->s256.bitcount,context->s256.bitcount); #endif - if (usedspace > 0) { - /* Begin padding with a 1 bit: */ - context->buffer[usedspace++] = 0x80; - - if (usedspace <= SHA256_SHORT_BLOCK_LENGTH) { - /* Set-up for the last transform: */ - MEMSET_BZERO(&context->buffer[usedspace], SHA256_SHORT_BLOCK_LENGTH - usedspace); - } else { - if (usedspace < SHA256_BLOCK_LENGTH) { - MEMSET_BZERO(&context->buffer[usedspace], SHA256_BLOCK_LENGTH - usedspace); - } - /* Do second-to-last transform: */ - SHA256_Transform(context, (sha2_word32*)context->buffer); - - /* And set-up for the last transform: */ - MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH); - } - } else { + if (usedspace > 0) { + /* Begin padding with a 1 bit: */ + context->s256.buffer[usedspace++] = 0x80; + + if (usedspace <= 56) { /* Set-up for the last transform: */ - MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH); + MEMSET_BZERO(&context->s256.buffer[usedspace], 56 - usedspace); + } else { + if (usedspace < 64) { + MEMSET_BZERO(&context->s256.buffer[usedspace], 64 - usedspace); + } + /* Do second-to-last transform: */ + SHA256_Internal_Transform(context, (sha_word32*)context->s256.buffer); - /* Begin padding with a 1 bit: */ - *context->buffer = 0x80; + /* And set-up for the last transform: */ + MEMSET_BZERO(context->s256.buffer, 56); } - /* Set the bit count: */ - *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; + /* Clean up: */ + usedspace = 0; + } else { + /* Set-up for the last transform: */ + MEMSET_BZERO(context->s256.buffer, 56); - /* Final transform: */ - SHA256_Transform(context, (sha2_word32*)context->buffer); + /* Begin padding with a 1 bit: */ + *context->s256.buffer = 0x80; + } + /* Set the bit count: */ + *(sha_word64*)&context->s256.buffer[56] = context->s256.bitcount; + + /* Final transform: */ + SHA256_Internal_Transform(context, (sha_word32*)context->s256.buffer); +} + +void SHA256_Final(sha_byte digest[], SHA_CTX* context) { + sha_word32 *d = (sha_word32*)digest; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha_byte*)0) { + SHA256_Internal_Last(context); + + /* Save the hash data for output: */ #if BYTE_ORDER == LITTLE_ENDIAN { /* Convert TO host byte order */ int j; - for (j = 0; j < 8; j++) { - REVERSE32(context->state[j],context->state[j]); - *d++ = context->state[j]; + for (j = 0; j < (SHA256_DIGEST_LENGTH >> 2); j++) { + REVERSE32(context->s256.state[j],context->s256.state[j]); + *d++ = context->s256.state[j]; } } #else - MEMCPY_BCOPY(d, context->state, SHA256_DIGEST_LENGTH); + MEMCPY_BCOPY(d, context->s256.state, SHA256_DIGEST_LENGTH); #endif } /* Clean up state data: */ MEMSET_BZERO(context, sizeof(context)); - usedspace = 0; } -char *SHA256_End(SHA256_CTX* context, char buffer[]) { - sha2_byte digest[SHA256_DIGEST_LENGTH], *d = digest; +char *SHA256_End(SHA_CTX* context, char buffer[]) { + sha_byte digest[SHA256_DIGEST_LENGTH], *d = digest; int i; /* Sanity check: */ - assert(context != (SHA256_CTX*)0); + assert(context != (SHA_CTX*)0); if (buffer != (char*)0) { SHA256_Final(digest, context); for (i = 0; i < SHA256_DIGEST_LENGTH; i++) { - *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; - *buffer++ = sha2_hex_digits[*d & 0x0f]; + *buffer++ = sha_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha_hex_digits[*d & 0x0f]; d++; } *buffer = (char)0; @@ -651,8 +1117,8 @@ char *SHA256_End(SHA256_CTX* context, char buffer[]) { return buffer; } -char* SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) { - SHA256_CTX context; +char* SHA256_Data(const sha_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) { + SHA_CTX context; SHA256_Init(&context); SHA256_Update(&context, data, len); @@ -660,14 +1126,92 @@ char* SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_S } -/*** SHA-512: *********************************************************/ -void SHA512_Init(SHA512_CTX* context) { - if (context == (SHA512_CTX*)0) { - return; +/*** SHA-224: *********************************************************/ +void SHA224_Init(SHA_CTX* context) { + SHA256_Internal_Init(context, sha224_initial_hash_value); +} + +void SHA224_Internal_Transform(SHA_CTX* context, const sha_word32* data) { + SHA256_Internal_Transform(context, data); +} + +void SHA224_Update(SHA_CTX* context, const sha_byte *data, size_t len) { + SHA256_Update(context, data, len); +} + +void SHA224_Final(sha_byte digest[], SHA_CTX* context) { + sha_word32 *d = (sha_word32*)digest; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha_byte*)0) { + SHA256_Internal_Last(context); + + /* Save the hash data for output: */ +#if BYTE_ORDER == LITTLE_ENDIAN + { + /* Convert TO host byte order */ + int j; + for (j = 0; j < (SHA224_DIGEST_LENGTH >> 2); j++) { + REVERSE32(context->s256.state[j],context->s256.state[j]); + *d++ = context->s256.state[j]; + } + } +#else + MEMCPY_BCOPY(d, context->s256.state, SHA224_DIGEST_LENGTH); +#endif + } + + /* Clean up state data: */ + MEMSET_BZERO(context, sizeof(context)); +} + +char *SHA224_End(SHA_CTX* context, char buffer[]) { + sha_byte digest[SHA224_DIGEST_LENGTH], *d = digest; + int i; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + if (buffer != (char*)0) { + SHA224_Final(digest, context); + + for (i = 0; i < SHA224_DIGEST_LENGTH; i++) { + *buffer++ = sha_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + MEMSET_BZERO(context, sizeof(context)); } - MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH); - MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH); - context->bitcount[0] = context->bitcount[1] = 0; + MEMSET_BZERO(digest, SHA224_DIGEST_LENGTH); + return buffer; +} + +char* SHA224_Data(const sha_byte* data, size_t len, char digest[SHA224_DIGEST_STRING_LENGTH]) { + SHA_CTX context; + + SHA224_Init(&context); + SHA224_Update(&context, data, len); + return SHA224_End(&context, digest); +} + + +/*** SHA-512: *********************************************************/ +void SHA512_Internal_Init(SHA_CTX* context, const sha_word64* ihv) { + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + MEMCPY_BCOPY(context->s512.state, ihv, sizeof(sha_word64) * 8); + MEMSET_BZERO(context->s512.buffer, 128); + context->s512.bitcount[0] = context->s512.bitcount[1] = 0; +} + +void SHA512_Init(SHA_CTX* context) { + SHA512_Internal_Init(context, sha512_initial_hash_value); } #ifdef SHA2_UNROLL_TRANSFORM @@ -706,20 +1250,20 @@ void SHA512_Init(SHA512_CTX* context) { (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ j++ -void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { - sha2_word64 a, b, c, d, e, f, g, h, s0, s1; - sha2_word64 T1, *W512 = (sha2_word64*)context->buffer; +void SHA512_Internal_Transform(SHA_CTX* context, const sha_word64* data) { + sha_word64 a, b, c, d, e, f, g, h, s0, s1; + sha_word64 T1, *W512 = (sha_word64*)context->s512.buffer; int j; /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; + a = context->s512.state[0]; + b = context->s512.state[1]; + c = context->s512.state[2]; + d = context->s512.state[3]; + e = context->s512.state[4]; + f = context->s512.state[5]; + g = context->s512.state[6]; + h = context->s512.state[7]; j = 0; do { @@ -746,14 +1290,14 @@ void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { } while (j < 80); /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; + context->s512.state[0] += a; + context->s512.state[1] += b; + context->s512.state[2] += c; + context->s512.state[3] += d; + context->s512.state[4] += e; + context->s512.state[5] += f; + context->s512.state[6] += g; + context->s512.state[7] += h; /* Clean up */ a = b = c = d = e = f = g = h = T1 = 0; @@ -761,20 +1305,20 @@ void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { #else /* SHA2_UNROLL_TRANSFORM */ -void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { - sha2_word64 a, b, c, d, e, f, g, h, s0, s1; - sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer; +void SHA512_Internal_Transform(SHA_CTX* context, const sha_word64* data) { + sha_word64 a, b, c, d, e, f, g, h, s0, s1; + sha_word64 T1, T2, *W512 = (sha_word64*)context->s512.buffer; int j; /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; + a = context->s512.state[0]; + b = context->s512.state[1]; + c = context->s512.state[2]; + d = context->s512.state[3]; + e = context->s512.state[4]; + f = context->s512.state[5]; + g = context->s512.state[6]; + h = context->s512.state[7]; j = 0; do { @@ -824,14 +1368,14 @@ void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { } while (j < 80); /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; + context->s512.state[0] += a; + context->s512.state[1] += b; + context->s512.state[2] += c; + context->s512.state[3] += d; + context->s512.state[4] += e; + context->s512.state[5] += f; + context->s512.state[6] += g; + context->s512.state[7] += h; /* Clean up */ a = b = c = d = e = f = g = h = T1 = T2 = 0; @@ -839,7 +1383,7 @@ void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { #endif /* SHA2_UNROLL_TRANSFORM */ -void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) { +void SHA512_Update(SHA_CTX* context, const sha_byte *data, size_t len) { unsigned int freespace, usedspace; if (len == 0) { @@ -848,108 +1392,110 @@ void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) { } /* Sanity check: */ - assert(context != (SHA512_CTX*)0 && data != (sha2_byte*)0); + assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); - usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; + usedspace = (context->s512.bitcount[0] >> 3) % 128; if (usedspace > 0) { /* Calculate how much free space is available in the buffer */ - freespace = SHA512_BLOCK_LENGTH - usedspace; + freespace = 128 - usedspace; if (len >= freespace) { /* Fill the buffer completely and process it */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace); - ADDINC128(context->bitcount, freespace << 3); + MEMCPY_BCOPY(&context->s512.buffer[usedspace], data, freespace); + ADDINC128(context->s512.bitcount, freespace << 3); len -= freespace; data += freespace; - SHA512_Transform(context, (sha2_word64*)context->buffer); + SHA512_Internal_Transform(context, (sha_word64*)context->s512.buffer); } else { /* The buffer is not yet full */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, len); - ADDINC128(context->bitcount, len << 3); + MEMCPY_BCOPY(&context->s512.buffer[usedspace], data, len); + ADDINC128(context->s512.bitcount, len << 3); /* Clean up: */ usedspace = freespace = 0; return; } } - while (len >= SHA512_BLOCK_LENGTH) { + while (len >= 128) { /* Process as many complete blocks as we can */ - SHA512_Transform(context, (sha2_word64*)data); - ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3); - len -= SHA512_BLOCK_LENGTH; - data += SHA512_BLOCK_LENGTH; + SHA512_Internal_Transform(context, (sha_word64*)data); + ADDINC128(context->s512.bitcount, 1024); + len -= 128; + data += 128; } if (len > 0) { /* There's left-overs, so save 'em */ - MEMCPY_BCOPY(context->buffer, data, len); - ADDINC128(context->bitcount, len << 3); + MEMCPY_BCOPY(context->s512.buffer, data, len); + ADDINC128(context->s512.bitcount, len << 3); } /* Clean up: */ usedspace = freespace = 0; } -void SHA512_Last(SHA512_CTX* context) { +void SHA512_Internal_Last(SHA_CTX* context) { unsigned int usedspace; - usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; + usedspace = (context->s512.bitcount[0] >> 3) % 128; #if BYTE_ORDER == LITTLE_ENDIAN /* Convert FROM host byte order */ - REVERSE64(context->bitcount[0],context->bitcount[0]); - REVERSE64(context->bitcount[1],context->bitcount[1]); + REVERSE64(context->s512.bitcount[0],context->s512.bitcount[0]); + REVERSE64(context->s512.bitcount[1],context->s512.bitcount[1]); #endif if (usedspace > 0) { /* Begin padding with a 1 bit: */ - context->buffer[usedspace++] = 0x80; + context->s512.buffer[usedspace++] = 0x80; - if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) { + if (usedspace <= 112) { /* Set-up for the last transform: */ - MEMSET_BZERO(&context->buffer[usedspace], SHA512_SHORT_BLOCK_LENGTH - usedspace); + MEMSET_BZERO(&context->s512.buffer[usedspace], 112 - usedspace); } else { - if (usedspace < SHA512_BLOCK_LENGTH) { - MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace); + if (usedspace < 128) { + MEMSET_BZERO(&context->s512.buffer[usedspace], 128 - usedspace); } /* Do second-to-last transform: */ - SHA512_Transform(context, (sha2_word64*)context->buffer); + SHA512_Internal_Transform(context, (sha_word64*)context->s512.buffer); /* And set-up for the last transform: */ - MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2); + MEMSET_BZERO(context->s512.buffer, 112); } + /* Clean up: */ + usedspace = 0; } else { /* Prepare for final transform: */ - MEMSET_BZERO(context->buffer, SHA512_SHORT_BLOCK_LENGTH); + MEMSET_BZERO(context->s512.buffer, 112); /* Begin padding with a 1 bit: */ - *context->buffer = 0x80; + *context->s512.buffer = 0x80; } /* Store the length of input data (in bits): */ - *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; - *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; + *(sha_word64*)&context->s512.buffer[112] = context->s512.bitcount[1]; + *(sha_word64*)&context->s512.buffer[120] = context->s512.bitcount[0]; /* Final transform: */ - SHA512_Transform(context, (sha2_word64*)context->buffer); + SHA512_Internal_Transform(context, (sha_word64*)context->s512.buffer); } -void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { - sha2_word64 *d = (sha2_word64*)digest; +void SHA512_Final(sha_byte digest[], SHA_CTX* context) { + sha_word64 *d = (sha_word64*)digest; /* Sanity check: */ - assert(context != (SHA512_CTX*)0); + assert(context != (SHA_CTX*)0); /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != (sha2_byte*)0) { - SHA512_Last(context); + if (digest != (sha_byte*)0) { + SHA512_Internal_Last(context); /* Save the hash data for output: */ #if BYTE_ORDER == LITTLE_ENDIAN { /* Convert TO host byte order */ int j; - for (j = 0; j < 8; j++) { - REVERSE64(context->state[j],context->state[j]); - *d++ = context->state[j]; + for (j = 0; j < (SHA512_DIGEST_LENGTH >> 3); j++) { + REVERSE64(context->s512.state[j],context->s512.state[j]); + *d++ = context->s512.state[j]; } } #else - MEMCPY_BCOPY(d, context->state, SHA512_DIGEST_LENGTH); + MEMCPY_BCOPY(d, context->s512.state, SHA512_DIGEST_LENGTH); #endif } @@ -957,19 +1503,19 @@ void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { MEMSET_BZERO(context, sizeof(context)); } -char *SHA512_End(SHA512_CTX* context, char buffer[]) { - sha2_byte digest[SHA512_DIGEST_LENGTH], *d = digest; +char *SHA512_End(SHA_CTX* context, char buffer[]) { + sha_byte digest[SHA512_DIGEST_LENGTH], *d = digest; int i; /* Sanity check: */ - assert(context != (SHA512_CTX*)0); + assert(context != (SHA_CTX*)0); if (buffer != (char*)0) { SHA512_Final(digest, context); for (i = 0; i < SHA512_DIGEST_LENGTH; i++) { - *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; - *buffer++ = sha2_hex_digits[*d & 0x0f]; + *buffer++ = sha_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha_hex_digits[*d & 0x0f]; d++; } *buffer = (char)0; @@ -980,8 +1526,8 @@ char *SHA512_End(SHA512_CTX* context, char buffer[]) { return buffer; } -char* SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) { - SHA512_CTX context; +char* SHA512_Data(const sha_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) { + SHA_CTX context; SHA512_Init(&context); SHA512_Update(&context, data, len); @@ -990,41 +1536,36 @@ char* SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_S /*** SHA-384: *********************************************************/ -void SHA384_Init(SHA384_CTX* context) { - if (context == (SHA384_CTX*)0) { - return; - } - MEMCPY_BCOPY(context->state, sha384_initial_hash_value, SHA512_DIGEST_LENGTH); - MEMSET_BZERO(context->buffer, SHA384_BLOCK_LENGTH); - context->bitcount[0] = context->bitcount[1] = 0; +void SHA384_Init(SHA_CTX* context) { + SHA512_Internal_Init(context, sha384_initial_hash_value); } -void SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) { - SHA512_Update((SHA512_CTX*)context, data, len); +void SHA384_Update(SHA_CTX* context, const sha_byte* data, size_t len) { + SHA512_Update(context, data, len); } -void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) { - sha2_word64 *d = (sha2_word64*)digest; +void SHA384_Final(sha_byte digest[], SHA_CTX* context) { + sha_word64 *d = (sha_word64*)digest; /* Sanity check: */ - assert(context != (SHA384_CTX*)0); + assert(context != (SHA_CTX*)0); /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != (sha2_byte*)0) { - SHA512_Last((SHA512_CTX*)context); + if (digest != (sha_byte*)0) { + SHA512_Internal_Last(context); /* Save the hash data for output: */ #if BYTE_ORDER == LITTLE_ENDIAN { /* Convert TO host byte order */ int j; - for (j = 0; j < 6; j++) { - REVERSE64(context->state[j],context->state[j]); - *d++ = context->state[j]; + for (j = 0; j < (SHA384_DIGEST_LENGTH >> 3); j++) { + REVERSE64(context->s512.state[j],context->s512.state[j]); + *d++ = context->s512.state[j]; } } #else - MEMCPY_BCOPY(d, context->state, SHA384_DIGEST_LENGTH); + MEMCPY_BCOPY(d, context->s512.state, SHA384_DIGEST_LENGTH); #endif } @@ -1032,19 +1573,19 @@ void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) { MEMSET_BZERO(context, sizeof(context)); } -char *SHA384_End(SHA384_CTX* context, char buffer[]) { - sha2_byte digest[SHA384_DIGEST_LENGTH], *d = digest; +char *SHA384_End(SHA_CTX* context, char buffer[]) { + sha_byte digest[SHA384_DIGEST_LENGTH], *d = digest; int i; /* Sanity check: */ - assert(context != (SHA384_CTX*)0); + assert(context != (SHA_CTX*)0); if (buffer != (char*)0) { SHA384_Final(digest, context); for (i = 0; i < SHA384_DIGEST_LENGTH; i++) { - *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; - *buffer++ = sha2_hex_digits[*d & 0x0f]; + *buffer++ = sha_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha_hex_digits[*d & 0x0f]; d++; } *buffer = (char)0; @@ -1055,8 +1596,8 @@ char *SHA384_End(SHA384_CTX* context, char buffer[]) { return buffer; } -char* SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) { - SHA384_CTX context; +char* SHA384_Data(const sha_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) { + SHA_CTX context; SHA384_Init(&context); SHA384_Update(&context, data, len); diff --git a/Source/cm_sha2.h b/Source/cm_sha2.h index 3a55b33..9459f75 100644 --- a/Source/cm_sha2.h +++ b/Source/cm_sha2.h @@ -1,8 +1,9 @@ /* - * FILE: sha2.h - * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ + * FILE: sha2.h + * AUTHOR: Aaron D. Gifford + * http://www.aarongifford.com/computers/sha.html * - * Copyright (c) 2000-2001, Aaron D. Gifford + * Copyright (c) 2000-2003, Aaron D. Gifford * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $ + * $Id: sha2.h,v 1.4 2004/01/07 19:06:18 adg Exp $ */ #ifndef __SHA2_H__ @@ -54,27 +55,30 @@ extern "C" { #endif /* SHA2_USE_INTTYPES_H */ -/*** SHA-256/384/512 Various Length Definitions ***********************/ -#define SHA256_BLOCK_LENGTH 64 -#define SHA256_DIGEST_LENGTH 32 -#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) -#define SHA384_BLOCK_LENGTH 128 -#define SHA384_DIGEST_LENGTH 48 -#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) -#define SHA512_BLOCK_LENGTH 128 -#define SHA512_DIGEST_LENGTH 64 -#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) +/*** SHA-224/256/384/512 Various Length Definitions *******************/ +/* Digest lengths for SHA-1/224/256/384/512 */ +#define SHA1_DIGEST_LENGTH 20 +#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1) +#define SHA224_DIGEST_LENGTH 28 +#define SHA224_DIGEST_STRING_LENGTH (SHA224_DIGEST_LENGTH * 2 + 1) +#define SHA256_DIGEST_LENGTH 32 +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#define SHA384_DIGEST_LENGTH 48 +#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) +#define SHA512_DIGEST_LENGTH 64 +#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) -/*** SHA-256/384/512 Context Structures *******************************/ + +/*** SHA-224/256/384/512 Context Structures ***************************/ /* NOTE: If your architecture does not define either u_intXX_t types or * uintXX_t (from inttypes.h), you may need to define things by hand * for your system: */ #if 0 -typedef unsigned char u_int8_t; /* 1-byte (8-bits) */ -typedef unsigned int u_int32_t; /* 4-bytes (32-bits) */ -typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */ +typedef unsigned char u_int8_t; /* 1-byte (8-bits) */ +typedef unsigned int u_int32_t; /* 4-bytes (32-bits) */ +typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */ #endif /* * Most BSD systems already define u_intXX_t types, as does Linux. @@ -94,81 +98,139 @@ typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */ */ #ifdef SHA2_USE_INTTYPES_H -typedef struct _SHA256_CTX { - uint32_t state[8]; - uint64_t bitcount; - uint8_t buffer[SHA256_BLOCK_LENGTH]; -} SHA256_CTX; -typedef struct _SHA512_CTX { - uint64_t state[8]; - uint64_t bitcount[2]; - uint8_t buffer[SHA512_BLOCK_LENGTH]; -} SHA512_CTX; +typedef union _SHA_CTX { + /* SHA-1 uses this part of the union: */ + struct { + uint32_t state[5]; + uint64_t bitcount; + uint8_t buffer[64]; + } s1; + + /* SHA-224 and SHA-256 use this part of the union: */ + struct { + uint32_t state[8]; + uint64_t bitcount; + uint8_t buffer[64]; + } s256; + + /* SHA-384 and SHA-512 use this part of the union: */ + struct { + uint64_t state[8]; + uint64_t bitcount[2]; + uint8_t buffer[128]; + } s512; +} SHA_CTX; #else /* SHA2_USE_INTTYPES_H */ -typedef struct _SHA256_CTX { - u_int32_t state[8]; - u_int64_t bitcount; - u_int8_t buffer[SHA256_BLOCK_LENGTH]; -} SHA256_CTX; -typedef struct _SHA512_CTX { - u_int64_t state[8]; - u_int64_t bitcount[2]; - u_int8_t buffer[SHA512_BLOCK_LENGTH]; -} SHA512_CTX; +typedef union _SHA_CTX { + /* SHA-1 uses this part of the union: */ + struct { + u_int32_t state[5]; + u_int64_t bitcount; + u_int8_t buffer[64]; + } s1; + + /* SHA-224 and SHA-256 use this part of the union: */ + struct { + u_int32_t state[8]; + u_int64_t bitcount; + u_int8_t buffer[64]; + } s256; + + /* SHA-384 and SHA-512 use this part of the union: */ + struct { + u_int64_t state[8]; + u_int64_t bitcount[2]; + u_int8_t buffer[128]; + } s512; +} SHA_CTX; #endif /* SHA2_USE_INTTYPES_H */ -typedef SHA512_CTX SHA384_CTX; - /*** SHA-256/384/512 Function Prototypes ******************************/ #ifndef NOPROTO #ifdef SHA2_USE_INTTYPES_H -void SHA256_Init(SHA256_CTX *); -void SHA256_Update(SHA256_CTX*, const uint8_t*, size_t); -void SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*); -char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); +void SHA1_Init(SHA_CTX*); +void SHA1_Update(SHA_CTX*, const uint8_t*, size_t); +void SHA1_Final(uint8_t[SHA1_DIGEST_LENGTH], SHA_CTX*); +char* SHA1_End(SHA_CTX*, char[SHA1_DIGEST_STRING_LENGTH]); +char* SHA1_Data(const uint8_t*, size_t, char[SHA1_DIGEST_STRING_LENGTH]); + +void SHA224_Init(SHA_CTX*); +void SHA224_Update(SHA_CTX*, const uint8_t*, size_t); +void SHA224_Final(uint8_t[SHA224_DIGEST_LENGTH], SHA_CTX*); +char* SHA224_End(SHA_CTX*, char[SHA224_DIGEST_STRING_LENGTH]); +char* SHA224_Data(const uint8_t*, size_t, char[SHA224_DIGEST_STRING_LENGTH]); + +void SHA256_Init(SHA_CTX*); +void SHA256_Update(SHA_CTX*, const uint8_t*, size_t); +void SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA_CTX*); +char* SHA256_End(SHA_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); char* SHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); -void SHA384_Init(SHA384_CTX*); -void SHA384_Update(SHA384_CTX*, const uint8_t*, size_t); -void SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*); -char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); +void SHA384_Init(SHA_CTX*); +void SHA384_Update(SHA_CTX*, const uint8_t*, size_t); +void SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA_CTX*); +char* SHA384_End(SHA_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); char* SHA384_Data(const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); -void SHA512_Init(SHA512_CTX*); -void SHA512_Update(SHA512_CTX*, const uint8_t*, size_t); -void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); -char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); +void SHA512_Init(SHA_CTX*); +void SHA512_Update(SHA_CTX*, const uint8_t*, size_t); +void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA_CTX*); +char* SHA512_End(SHA_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); char* SHA512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); #else /* SHA2_USE_INTTYPES_H */ -void SHA256_Init(SHA256_CTX *); -void SHA256_Update(SHA256_CTX*, const u_int8_t*, size_t); -void SHA256_Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*); -char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); +void SHA1_Init(SHA_CTX*); +void SHA1_Update(SHA_CTX*, const u_int8_t*, size_t); +void SHA1_Final(u_int8_t[SHA1_DIGEST_LENGTH], SHA_CTX*); +char* SHA1_End(SHA_CTX*, char[SHA1_DIGEST_STRING_LENGTH]); +char* SHA1_Data(const u_int8_t*, size_t, char[SHA1_DIGEST_STRING_LENGTH]); + +void SHA224_Init(SHA_CTX*); +void SHA224_Update(SHA_CTX*, const u_int8_t*, size_t); +void SHA224_Final(u_int8_t[SHA224_DIGEST_LENGTH], SHA_CTX*); +char* SHA224_End(SHA_CTX*, char[SHA224_DIGEST_STRING_LENGTH]); +char* SHA224_Data(const u_int8_t*, size_t, char[SHA224_DIGEST_STRING_LENGTH]); + +void SHA256_Init(SHA_CTX*); +void SHA256_Update(SHA_CTX*, const u_int8_t*, size_t); +void SHA256_Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA_CTX*); +char* SHA256_End(SHA_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); char* SHA256_Data(const u_int8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); -void SHA384_Init(SHA384_CTX*); -void SHA384_Update(SHA384_CTX*, const u_int8_t*, size_t); -void SHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*); -char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); +void SHA384_Init(SHA_CTX*); +void SHA384_Update(SHA_CTX*, const u_int8_t*, size_t); +void SHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA_CTX*); +char* SHA384_End(SHA_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); char* SHA384_Data(const u_int8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); -void SHA512_Init(SHA512_CTX*); -void SHA512_Update(SHA512_CTX*, const u_int8_t*, size_t); -void SHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); -char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); +void SHA512_Init(SHA_CTX*); +void SHA512_Update(SHA_CTX*, const u_int8_t*, size_t); +void SHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA_CTX*); +char* SHA512_End(SHA_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); char* SHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); #endif /* SHA2_USE_INTTYPES_H */ #else /* NOPROTO */ +void SHA1_Init(); +void SHA1_Update(); +void SHA1_Final(); +char* SHA1_End(); +char* SHA1_Data(); + +void SHA224_Init(); +void SHA224_Update(); +void SHA224_Final(); +char* SHA224_End(); +char* SHA224_Data(); + void SHA256_Init(); void SHA256_Update(); void SHA256_Final(); @@ -189,7 +251,7 @@ char* SHA512_Data(); #endif /* NOPROTO */ -#ifdef __cplusplus +#ifdef __cplusplus } #endif /* __cplusplus */ -- cgit v0.12 From 8c8305f286dab4e374bb8142ee991e00c57e418b Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 31 Oct 2011 22:07:12 +0100 Subject: don't crash in automoc with empty COMPILE_DEFINITIONS property Reported by Laszlo Papp: http://www.cmake.org/pipermail/cmake/2011-October/047089.html Alex --- Source/cmQtAutomoc.cxx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index a839489..fdc19e4 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -124,21 +124,22 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) } } - std::string _moc_incs = makefile->GetProperty("INCLUDE_DIRECTORIES"); - std::string _moc_defs = makefile->GetProperty("DEFINITIONS"); - std::string _moc_compile_defs = makefile->GetProperty("COMPILE_DEFINITIONS"); + const char* _moc_incs = makefile->GetProperty("INCLUDE_DIRECTORIES"); + const char* _moc_defs = makefile->GetProperty("DEFINITIONS"); + const char* _moc_compile_defs = makefile->GetProperty("COMPILE_DEFINITIONS"); // forget the variables added here afterwards again: cmMakefile::ScopePushPop varScope(makefile); static_cast(varScope); makefile->AddDefinition("_moc_target_name", automocTargetName.c_str()); - makefile->AddDefinition("_moc_incs", _moc_incs.c_str()); - makefile->AddDefinition("_moc_defs", _moc_defs.c_str()); - makefile->AddDefinition("_moc_compile_defs", _moc_compile_defs.c_str()); + makefile->AddDefinition("_moc_incs", _moc_incs!=0 ? _moc_incs : ""); + makefile->AddDefinition("_moc_defs", _moc_defs!=0 ? _moc_defs : ""); + makefile->AddDefinition("_moc_compile_defs", + _moc_compile_defs!=0 ? _moc_compile_defs : ""); makefile->AddDefinition("_moc_files", _moc_files.c_str()); makefile->AddDefinition("_moc_headers", _moc_headers.c_str()); - const char* cmakeRoot = makefile->GetDefinition("CMAKE_ROOT"); + const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT"); std::string inputFile = cmakeRoot; inputFile += "/Modules/AutomocInfo.cmake.in"; std::string outputFile = targetDir; -- cgit v0.12 From 057633151a527fc614b56f4ca3fd73f63928ebff Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 31 Oct 2011 23:37:01 +0100 Subject: Eclipse: make targets work from any directory Set the working directory for make targets which are associated to virtual folders, otherwise Eclipse simply runs make from the current working directory (where Eclipse has been started), and where probably not the correct makefile is located. Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 785e85a..eab149e 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -998,7 +998,11 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const std::string virtDir = "[Targets]/"; virtDir += prefix; virtDir += ti->first; - this->AppendTarget(fout, "Build", make, makeArgs, virtDir, "", + std::string buildArgs = "-C "; + buildArgs += makefile->GetHomeOutputDirectory(); + buildArgs += " "; + buildArgs += makeArgs; + this->AppendTarget(fout, "Build", make, buildArgs, virtDir, "", ti->first.c_str()); std::string cleanArgs = "-E chdir \""; -- cgit v0.12 From 1ecc55aa7b95a487996654e81d6493e7b72961c0 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 1 Nov 2011 13:59:14 +0100 Subject: Automoc: fix the fix, need to use std::string, not just char* pointer We need to take a copy of the property values, since the returned char* pointer is reused by the following GetProperty() calls Alex --- Source/cmQtAutomoc.cxx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index fdc19e4..e9cc9d1 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -124,18 +124,21 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) } } - const char* _moc_incs = makefile->GetProperty("INCLUDE_DIRECTORIES"); - const char* _moc_defs = makefile->GetProperty("DEFINITIONS"); - const char* _moc_compile_defs = makefile->GetProperty("COMPILE_DEFINITIONS"); + const char* tmp = makefile->GetProperty("INCLUDE_DIRECTORIES"); + std::string _moc_incs = (tmp!=0 ? tmp : ""); + tmp = makefile->GetProperty("DEFINITIONS"); + std::string _moc_defs = (tmp!=0 ? tmp : ""); + tmp = makefile->GetProperty("COMPILE_DEFINITIONS"); + std::string _moc_compile_defs = (tmp!=0 ? tmp : ""); + // forget the variables added here afterwards again: cmMakefile::ScopePushPop varScope(makefile); static_cast(varScope); makefile->AddDefinition("_moc_target_name", automocTargetName.c_str()); - makefile->AddDefinition("_moc_incs", _moc_incs!=0 ? _moc_incs : ""); - makefile->AddDefinition("_moc_defs", _moc_defs!=0 ? _moc_defs : ""); - makefile->AddDefinition("_moc_compile_defs", - _moc_compile_defs!=0 ? _moc_compile_defs : ""); + makefile->AddDefinition("_moc_incs", _moc_incs.c_str()); + makefile->AddDefinition("_moc_defs", _moc_defs.c_str()); + makefile->AddDefinition("_moc_compile_defs", _moc_compile_defs.c_str()); makefile->AddDefinition("_moc_files", _moc_files.c_str()); makefile->AddDefinition("_moc_headers", _moc_headers.c_str()); -- cgit v0.12 From 52719a1d66db0bbdb17019bcb2ea5ab0a1258e22 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 1 Nov 2011 14:33:11 +0100 Subject: automoc: fix #12541, support moc options This commit adds a new target property AUTOMOC_MOC_OPTIONS, which can be set to add extra options for the moc invocations done via automoc. This is equivalent to the OPTIONS parameter in the qt4_wrap_cpp() macro. Alex --- Modules/AutomocInfo.cmake.in | 1 + Source/cmQtAutomoc.cxx | 12 ++++++++++++ Source/cmQtAutomoc.h | 2 ++ Source/cmTarget.cxx | 1 + 4 files changed, 16 insertions(+) diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutomocInfo.cmake.in index 2dc3aa2..9c71952 100644 --- a/Modules/AutomocInfo.cmake.in +++ b/Modules/AutomocInfo.cmake.in @@ -3,6 +3,7 @@ set(AM_HEADERS "@_moc_headers@" ) set(AM_MOC_COMPILE_DEFINITIONS "@_moc_compile_defs@") set(AM_MOC_DEFINITIONS "@_moc_defs@") set(AM_MOC_INCLUDES "@_moc_incs@") +set(AM_MOC_OPTIONS "@_moc_options@") set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@") set(AM_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@/") set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/") diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index e9cc9d1..eb89c90 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -130,6 +130,8 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) std::string _moc_defs = (tmp!=0 ? tmp : ""); tmp = makefile->GetProperty("COMPILE_DEFINITIONS"); std::string _moc_compile_defs = (tmp!=0 ? tmp : ""); + tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); + std::string _moc_options = (tmp!=0 ? tmp : ""); // forget the variables added here afterwards again: cmMakefile::ScopePushPop varScope(makefile); @@ -139,6 +141,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) makefile->AddDefinition("_moc_incs", _moc_incs.c_str()); makefile->AddDefinition("_moc_defs", _moc_defs.c_str()); makefile->AddDefinition("_moc_compile_defs", _moc_compile_defs.c_str()); + makefile->AddDefinition("_moc_options", _moc_options.c_str()); makefile->AddDefinition("_moc_files", _moc_files.c_str()); makefile->AddDefinition("_moc_headers", _moc_headers.c_str()); @@ -230,6 +233,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, "AM_MOC_COMPILE_DEFINITIONS"); this->MocDefinitionsStr = makefile->GetSafeDefinition("AM_MOC_DEFINITIONS"); this->MocIncludesStr = makefile->GetSafeDefinition("AM_MOC_INCLUDES"); + this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS"); this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR"); this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME"); @@ -306,6 +310,8 @@ void cmQtAutomoc::Init() } } + cmSystemTools::ExpandListArgument(this->MocOptionsStr, this->MocOptions); + std::vector incPaths; cmSystemTools::ExpandListArgument(this->MocIncludesStr, incPaths); @@ -715,6 +721,12 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, { command.push_back(*it); } + for(std::vector::const_iterator it=this->MocOptions.begin(); + it != this->MocOptions.end(); + ++it) + { + command.push_back(*it); + } #ifdef _WIN32 command.push_back("-DWIN32"); #endif diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index c3550a4..db53b21 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -62,6 +62,7 @@ private: std::string MocCompileDefinitionsStr; std::string MocDefinitionsStr; std::string MocIncludesStr; + std::string MocOptionsStr; std::string ProjectBinaryDir; std::string ProjectSourceDir; std::string TargetName; @@ -71,6 +72,7 @@ private: std::string OutMocCppFilename; std::list MocIncludes; std::list MocDefinitions; + std::vector MocOptions; bool Verbose; bool ColorOutput; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f7d3ba9..e8064d0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1179,6 +1179,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); this->SetPropertyDefault("OSX_ARCHITECTURES", 0); this->SetPropertyDefault("AUTOMOC", 0); + this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0); this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); // Collect the set of configuration types. -- cgit v0.12 From c208ab8d5ca0c8ee3819c8e318290f829275c228 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 1 Nov 2011 14:48:45 +0100 Subject: Also run moc automatically with Qt5. The method of running moc hasn't changed in Qt5. --- Source/cmQtAutomoc.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index a839489..fea2e79 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -51,7 +51,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) const char* targetName = target->GetName(); // don't do anything if there is no Qt4: std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); - if (qtMajorVersion != "4") + if (qtMajorVersion != "4" && qtMajorVersion != "5") { return; } @@ -170,7 +170,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory) this->Init(); - if (this->QtMajorVersion == "4") + if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") { this->RunAutomocQt4(); } -- cgit v0.12 From 36b0c432cf5804ec45367066e34f4c38165d5c09 Mon Sep 17 00:00:00 2001 From: David Cole Date: Mon, 24 Oct 2011 16:55:52 -0400 Subject: Tests: Add the MFC test (#11213) Build a simple, do-nothing VS 7.1 MFC wizard generated app with CMake. Build it two different ways via ExternalProject, one with CMAKE_MFC_FLAG set to 1 for linking to MFC statically, and one with CMAKE_MFC_FLAG set to 2 for linking to the shared MFC dlls. Validate that the install tree of the static build has only one *.exe file in it and nothing else. Also validate that the install tree of the shared library build has multiple files in it (no less than 3) and that they are only of the expected types *.exe, *.dll and *.manifest. This commit does not address the issue reported in #11213, it merely adds a test that may be used to show that the bug report is valid. After this commit, the MFC test should fail on any dashboard machines that have MSVC defined, but cannot build an MFC app. We can then analyze that failure data as input to solving the issue. --- Tests/CMakeLists.txt | 21 +++ Tests/MFC/CMakeLists.txt | 50 +++++ Tests/MFC/CMakeLists.txt.in | 50 +++++ Tests/MFC/ValidateBuild.cmake.in | 60 ++++++ Tests/MFC/mfc1/.gitattributes | 6 + Tests/MFC/mfc1/ChildFrm.cpp | 59 ++++++ Tests/MFC/mfc1/ChildFrm.h | 34 ++++ Tests/MFC/mfc1/MainFrm.cpp | 98 ++++++++++ Tests/MFC/mfc1/MainFrm.h | 38 ++++ Tests/MFC/mfc1/ReadMe.txt | 135 ++++++++++++++ Tests/MFC/mfc1/Resource.h | 20 ++ Tests/MFC/mfc1/mfc1.cpp | 144 +++++++++++++++ Tests/MFC/mfc1/mfc1.h | 31 ++++ Tests/MFC/mfc1/mfc1.rc | 387 +++++++++++++++++++++++++++++++++++++++ Tests/MFC/mfc1/mfc1.reg | 13 ++ Tests/MFC/mfc1/mfc1.sln | 21 +++ Tests/MFC/mfc1/mfc1.vcproj | 216 ++++++++++++++++++++++ Tests/MFC/mfc1/mfc1Doc.cpp | 78 ++++++++ Tests/MFC/mfc1/mfc1Doc.h | 37 ++++ Tests/MFC/mfc1/mfc1View.cpp | 99 ++++++++++ Tests/MFC/mfc1/mfc1View.h | 48 +++++ Tests/MFC/mfc1/res/Toolbar.bmp | Bin 0 -> 1078 bytes Tests/MFC/mfc1/res/mfc1.ico | Bin 0 -> 21630 bytes Tests/MFC/mfc1/res/mfc1.manifest | 22 +++ Tests/MFC/mfc1/res/mfc1.rc2 | 13 ++ Tests/MFC/mfc1/res/mfc1Doc.ico | Bin 0 -> 1078 bytes Tests/MFC/mfc1/stdafx.cpp | 5 + Tests/MFC/mfc1/stdafx.h | 41 +++++ 28 files changed, 1726 insertions(+) create mode 100644 Tests/MFC/CMakeLists.txt create mode 100644 Tests/MFC/CMakeLists.txt.in create mode 100644 Tests/MFC/ValidateBuild.cmake.in create mode 100644 Tests/MFC/mfc1/.gitattributes create mode 100644 Tests/MFC/mfc1/ChildFrm.cpp create mode 100644 Tests/MFC/mfc1/ChildFrm.h create mode 100644 Tests/MFC/mfc1/MainFrm.cpp create mode 100644 Tests/MFC/mfc1/MainFrm.h create mode 100644 Tests/MFC/mfc1/ReadMe.txt create mode 100644 Tests/MFC/mfc1/Resource.h create mode 100644 Tests/MFC/mfc1/mfc1.cpp create mode 100644 Tests/MFC/mfc1/mfc1.h create mode 100644 Tests/MFC/mfc1/mfc1.rc create mode 100644 Tests/MFC/mfc1/mfc1.reg create mode 100644 Tests/MFC/mfc1/mfc1.sln create mode 100644 Tests/MFC/mfc1/mfc1.vcproj create mode 100644 Tests/MFC/mfc1/mfc1Doc.cpp create mode 100644 Tests/MFC/mfc1/mfc1Doc.h create mode 100644 Tests/MFC/mfc1/mfc1View.cpp create mode 100644 Tests/MFC/mfc1/mfc1View.h create mode 100644 Tests/MFC/mfc1/res/Toolbar.bmp create mode 100644 Tests/MFC/mfc1/res/mfc1.ico create mode 100644 Tests/MFC/mfc1/res/mfc1.manifest create mode 100644 Tests/MFC/mfc1/res/mfc1.rc2 create mode 100644 Tests/MFC/mfc1/res/mfc1Doc.ico create mode 100644 Tests/MFC/mfc1/stdafx.cpp create mode 100644 Tests/MFC/mfc1/stdafx.h diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 78db39d..f400f6d 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1206,6 +1206,27 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MakeClean") ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile") + if(NOT DEFINED CTEST_RUN_MFC) + set(CTEST_RUN_MFC OFF) + if(MSVC) + set(CTEST_RUN_MFC ON) + endif() + endif() + + if(CTEST_RUN_MFC) + add_test(MFC ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/MFC" + "${CMake_BINARY_DIR}/Tests/MFC" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project mfc_driver + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command ${CMAKE_CTEST_COMMAND} + -C \${CTEST_CONFIGURATION_TYPE} -VV) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC") + endif() + IF(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio") ADD_TEST(VSExternalInclude ${CMAKE_CTEST_COMMAND} --build-and-test diff --git a/Tests/MFC/CMakeLists.txt b/Tests/MFC/CMakeLists.txt new file mode 100644 index 0000000..ea5c41d --- /dev/null +++ b/Tests/MFC/CMakeLists.txt @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 2.8) +project(mfc_driver) + +include(CTest) +include(ExternalProject) + + +set(CMAKE_MFC_FLAG_VALUE "2") +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.SharedMfcDll.txt + @ONLY + ) + +ExternalProject_Add(mfcShared + URL ${CMAKE_CURRENT_SOURCE_DIR}/mfc1 + PATCH_COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.SharedMfcDll.txt + /CMakeLists.txt + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= + ) + + +set(CMAKE_MFC_FLAG_VALUE "1") +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.StaticMfcLib.txt + @ONLY + ) + +ExternalProject_Add(mfcStatic + URL ${CMAKE_CURRENT_SOURCE_DIR}/mfc1 + PATCH_COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.StaticMfcLib.txt + /CMakeLists.txt + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= + ) + + +set(binary_dir "${CMAKE_CURRENT_BINARY_DIR}") +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/ValidateBuild.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/ValidateBuild.cmake + @ONLY + ) +add_test( + NAME validate + COMMAND ${CMAKE_COMMAND} + -P "${CMAKE_CURRENT_BINARY_DIR}/ValidateBuild.cmake" + ) diff --git a/Tests/MFC/CMakeLists.txt.in b/Tests/MFC/CMakeLists.txt.in new file mode 100644 index 0000000..06ba8b3 --- /dev/null +++ b/Tests/MFC/CMakeLists.txt.in @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 2.8) +project(mfc1) + +macro(replace_flags var these those) + if("${${var}}" MATCHES "${these}") + string(REGEX REPLACE "${these}" "${those}" ${var} "${${var}}") + #message(STATUS "info: ${var} changed to '${${var}}'") + endif() +endmacro() + +macro(msvc_link_to_static_crt) + if(MSVC) + foreach(lang C CXX) + foreach(suffix "" _DEBUG _MINSIZEREL _RELEASE _RELWITHDEBINFO) + replace_flags("CMAKE_${lang}_FLAGS${suffix}" "/MD" "/MT") + endforeach() + endforeach() + endif() +endmacro() + +set(files + ChildFrm.cpp + ChildFrm.h + MainFrm.cpp + MainFrm.h + mfc1.cpp + mfc1.h + mfc1.rc + mfc1Doc.cpp + mfc1Doc.h + mfc1View.cpp + mfc1View.h + Resource.h + stdafx.cpp + stdafx.h +) + +set(CMAKE_MFC_FLAG "@CMAKE_MFC_FLAG_VALUE@") + +if("${CMAKE_MFC_FLAG}" STREQUAL "1") + msvc_link_to_static_crt() +endif() + +add_executable(mfc1 WIN32 ${files}) +install(TARGETS mfc1 DESTINATION bin) + +if("${CMAKE_MFC_FLAG}" STREQUAL "2") + set(CMAKE_INSTALL_MFC_LIBRARIES ON) + include(InstallRequiredSystemLibraries) +endif() diff --git a/Tests/MFC/ValidateBuild.cmake.in b/Tests/MFC/ValidateBuild.cmake.in new file mode 100644 index 0000000..68de549 --- /dev/null +++ b/Tests/MFC/ValidateBuild.cmake.in @@ -0,0 +1,60 @@ +# +# This code validates that the install trees of the shared and static builds +# of "mfc1" have the expected contents: +# +set(binary_dir "@binary_dir@") +message("binary_dir='${binary_dir}'") + +# There should be exactly one file in the static install tree "bin" directory +# and it should be named "mfc1.exe" +# +message(STATUS "===== mfcStatic install tree =====") +file(GLOB_RECURSE files "${binary_dir}/mfcStatic-prefix/bin/*.*") +message(STATUS "mfcStatic files='${files}'") +list(LENGTH files len) +if(NOT len EQUAL 1) + message(FATAL_ERROR + "len='${len}' is not '1' (count of static 'bin' files)") +endif() +get_filename_component(name "${files}" NAME) +string(TOLOWER "${name}" name) +if(NOT "${name}" STREQUAL "mfc1.exe") + message(FATAL_ERROR "unexpected mfcStatic file name '${name}'") +endif() + +# There should be at least 3 files in the shared install tree "bin" +# directory: mfc1.exe, the main MFC dll and the C runtime dll. With more +# recent versions of VS, there will also be an MFC language dll and a +# manifest file. +# +message(STATUS "===== mfcShared install tree =====") +file(GLOB_RECURSE files "${binary_dir}/mfcShared-prefix/bin/*.*") +message(STATUS "mfcShared files='${files}'") +list(LENGTH files len) +if(len LESS 3) + message(FATAL_ERROR + "len='${len}' is less than '3' (count of shared 'bin' files)") +endif() +foreach(f ${files}) + message(STATUS "file '${f}'") + get_filename_component(ext "${f}" EXT) + string(TOLOWER "${ext}" ext) + + if("${ext}" MATCHES "\\.exe$") + message(STATUS " exe file") + get_filename_component(name "${f}" NAME) + string(TOLOWER "${name}" name) + if(NOT "${name}" STREQUAL "mfc1.exe") + message(FATAL_ERROR "unexpected mfcShared .exe file name '${name}'") + endif() + elseif("${ext}" MATCHES "\\.dll$") + message(STATUS " dll file") + elseif("${ext}" MATCHES "\\.manifest$") + message(STATUS " manifest file") + else() + message(STATUS " unknown file") + message(FATAL_ERROR "unexpected mfcShared ${ext} file name '${f}'") + endif() +endforeach() + +message(STATUS "All mfc1 build validation tests pass.") diff --git a/Tests/MFC/mfc1/.gitattributes b/Tests/MFC/mfc1/.gitattributes new file mode 100644 index 0000000..59be5dc --- /dev/null +++ b/Tests/MFC/mfc1/.gitattributes @@ -0,0 +1,6 @@ +.gitattributes export-ignore + +*.sln -crlf +*.vcproj -crlf + +* -whitespace diff --git a/Tests/MFC/mfc1/ChildFrm.cpp b/Tests/MFC/mfc1/ChildFrm.cpp new file mode 100644 index 0000000..b04c4f2 --- /dev/null +++ b/Tests/MFC/mfc1/ChildFrm.cpp @@ -0,0 +1,59 @@ +// ChildFrm.cpp : implementation of the CChildFrame class +// +#include "stdafx.h" +#include "mfc1.h" + +#include "ChildFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CChildFrame + +IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd) + +BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd) +END_MESSAGE_MAP() + + +// CChildFrame construction/destruction + +CChildFrame::CChildFrame() +{ + // TODO: add member initialization code here +} + +CChildFrame::~CChildFrame() +{ +} + + +BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs + if( !CMDIChildWnd::PreCreateWindow(cs) ) + return FALSE; + + return TRUE; +} + + +// CChildFrame diagnostics + +#ifdef _DEBUG +void CChildFrame::AssertValid() const +{ + CMDIChildWnd::AssertValid(); +} + +void CChildFrame::Dump(CDumpContext& dc) const +{ + CMDIChildWnd::Dump(dc); +} + +#endif //_DEBUG + + +// CChildFrame message handlers diff --git a/Tests/MFC/mfc1/ChildFrm.h b/Tests/MFC/mfc1/ChildFrm.h new file mode 100644 index 0000000..34b80f1 --- /dev/null +++ b/Tests/MFC/mfc1/ChildFrm.h @@ -0,0 +1,34 @@ +// ChildFrm.h : interface of the CChildFrame class +// + + +#pragma once + + +class CChildFrame : public CMDIChildWnd +{ + DECLARE_DYNCREATE(CChildFrame) +public: + CChildFrame(); + +// Attributes +public: + +// Operations +public: + +// Overrides + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + +// Implementation +public: + virtual ~CChildFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +// Generated message map functions +protected: + DECLARE_MESSAGE_MAP() +}; diff --git a/Tests/MFC/mfc1/MainFrm.cpp b/Tests/MFC/mfc1/MainFrm.cpp new file mode 100644 index 0000000..44554bf --- /dev/null +++ b/Tests/MFC/mfc1/MainFrm.cpp @@ -0,0 +1,98 @@ +// MainFrm.cpp : implementation of the CMainFrame class +// + +#include "stdafx.h" +#include "mfc1.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CMainFrame + +IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) + ON_WM_CREATE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // status line indicator + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + + +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ + // TODO: add member initialization code here +} + +CMainFrame::~CMainFrame() +{ +} + + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP + | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) + { + TRACE0("Failed to create toolbar\n"); + return -1; // fail to create + } + + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators)/sizeof(UINT))) + { + TRACE0("Failed to create status bar\n"); + return -1; // fail to create + } + // TODO: Delete these three lines if you don't want the toolbar to be dockable + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndToolBar); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CMDIFrameWnd::PreCreateWindow(cs) ) + return FALSE; + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return TRUE; +} + + +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CMDIFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CMDIFrameWnd::Dump(dc); +} + +#endif //_DEBUG + + +// CMainFrame message handlers diff --git a/Tests/MFC/mfc1/MainFrm.h b/Tests/MFC/mfc1/MainFrm.h new file mode 100644 index 0000000..1039ac5 --- /dev/null +++ b/Tests/MFC/mfc1/MainFrm.h @@ -0,0 +1,38 @@ +// MainFrm.h : interface of the CMainFrame class +// + + +#pragma once +class CMainFrame : public CMDIFrameWnd +{ + DECLARE_DYNAMIC(CMainFrame) +public: + CMainFrame(); + +// Attributes +public: + +// Operations +public: + +// Overrides +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + +// Implementation +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // control bar embedded members + CStatusBar m_wndStatusBar; + CToolBar m_wndToolBar; + +// Generated message map functions +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + DECLARE_MESSAGE_MAP() +}; diff --git a/Tests/MFC/mfc1/ReadMe.txt b/Tests/MFC/mfc1/ReadMe.txt new file mode 100644 index 0000000..d84608e --- /dev/null +++ b/Tests/MFC/mfc1/ReadMe.txt @@ -0,0 +1,135 @@ +================================================================================ + MICROSOFT FOUNDATION CLASS LIBRARY : mfc1 Project Overview +=============================================================================== + +The application wizard has created this mfc1 application for +you. This application not only demonstrates the basics of using the Microsoft +Foundation Classes but is also a starting point for writing your application. + +This file contains a summary of what you will find in each of the files that +make up your mfc1 application. + +mfc1.vcproj + This is the main project file for VC++ projects generated using an application wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + application wizard. + +mfc1.h + This is the main header file for the application. It includes other + project specific headers (including Resource.h) and declares the + Cmfc1App application class. + +mfc1.cpp + This is the main application source file that contains the application + class Cmfc1App. + +mfc1.rc + This is a listing of all of the Microsoft Windows resources that the + program uses. It includes the icons, bitmaps, and cursors that are stored + in the RES subdirectory. This file can be directly edited in Microsoft + Visual C++. Your project resources are in 1033. + +res\mfc1.ico + This is an icon file, which is used as the application's icon. This + icon is included by the main resource file mfc1.rc. + +res\mfc1.rc2 + This file contains resources that are not edited by Microsoft + Visual C++. You should place all resources not editable by + the resource editor in this file. +mfc1.reg + This is an example .reg file that shows you the kind of registration + settings the framework will set for you. You can use this as a .reg + file to go along with your application or just delete it and rely + on the default RegisterShellFileTypes registration. +///////////////////////////////////////////////////////////////////////////// + +For the main frame window: + The project includes a standard MFC interface. +MainFrm.h, MainFrm.cpp + These files contain the frame class CMainFrame, which is derived from + CMDIFrameWnd and controls all MDI frame features. +res\Toolbar.bmp + This bitmap file is used to create tiled images for the toolbar. + The initial toolbar and status bar are constructed in the CMainFrame + class. Edit this toolbar bitmap using the resource editor, and + update the IDR_MAINFRAME TOOLBAR array in mfc1.rc to add + toolbar buttons. +///////////////////////////////////////////////////////////////////////////// + +For the child frame window: + +ChildFrm.h, ChildFrm.cpp + These files define and implement the CChildFrame class, which + supports the child windows in an MDI application. + +///////////////////////////////////////////////////////////////////////////// + +The application wizard creates one document type and one view: + +mfc1Doc.h, mfc1Doc.cpp - the document + These files contain your Cmfc1Doc class. Edit these files to + add your special document data and to implement file saving and loading + (via Cmfc1Doc::Serialize). + The Document will have the following strings: + File extension: mf1 + File type ID: mfc1.Document + Main frame caption: mfc1 + Doc type name: mfc1 + Filter name: mfc1 Files (*.mf1) + File new short name: mfc1 + File type long name: mfc1.Document +mfc1View.h, mfc1View.cpp - the view of the document + These files contain your Cmfc1View class. + Cmfc1View objects are used to view Cmfc1Doc objects. +res\mfc1Doc.ico + This is an icon file, which is used as the icon for MDI child windows + for the Cmfc1Doc class. This icon is included by the main + resource file mfc1.rc. +///////////////////////////////////////////////////////////////////////////// + +Other Features: + +ActiveX Controls + The application includes support to use ActiveX controls. + +Printing and Print Preview support + The application wizard has generated code to handle the print, print setup, and print preview + commands by calling member functions in the CView class from the MFC library. +///////////////////////////////////////////////////////////////////////////// + +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named mfc1.pch and a precompiled types file named StdAfx.obj. + +Resource.h + This is the standard header file, which defines new resource IDs. + Microsoft Visual C++ reads and updates this file. + +mfc1.manifest + Application manifest files are used by Windows XP to describe an applications + dependency on specific versions of Side-by-Side assemblies. The loader uses this + information to load the appropriate assembly from the assembly cache or private + from the application. The Application manifest maybe included for redistribution + as an external .manifest file that is installed in the same folder as the application + executable or it may be included in the executable in the form of a resource. +///////////////////////////////////////////////////////////////////////////// + +Other notes: + +The application wizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +If your application uses MFC in a shared DLL, and your application is in a +language other than the operating system's current language, you will need +to copy the corresponding localized resources MFC70XXX.DLL from the Microsoft +Visual C++ CD-ROM under the Win\System directory to your computer's system or +system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the +language abbreviation. For example, MFC70DEU.DLL contains resources +translated to German.) If you don't do this, some of the UI elements of +your application will remain in the language of the operating system. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Tests/MFC/mfc1/Resource.h b/Tests/MFC/mfc1/Resource.h new file mode 100644 index 0000000..0a9c13f --- /dev/null +++ b/Tests/MFC/mfc1/Resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by mfc1.rc +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_MAINFRAME 128 +#define IDR_mfc1TYPE 129 +#define IDR_MANIFEST CREATEPROCESS_MANIFEST_RESOURCE_ID + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 32771 +#endif +#endif diff --git a/Tests/MFC/mfc1/mfc1.cpp b/Tests/MFC/mfc1/mfc1.cpp new file mode 100644 index 0000000..9530cd2 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.cpp @@ -0,0 +1,144 @@ +// mfc1.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "mfc1.h" +#include "MainFrm.h" + +#include "ChildFrm.h" +#include "mfc1Doc.h" +#include "mfc1View.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cmfc1App + +BEGIN_MESSAGE_MAP(Cmfc1App, CWinApp) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + // Standard file based document commands + ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) + // Standard print setup command + ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// Cmfc1App construction + +Cmfc1App::Cmfc1App() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + + +// The one and only Cmfc1App object + +Cmfc1App theApp; + +// Cmfc1App initialization + +BOOL Cmfc1App::InitInstance() +{ + // InitCommonControls() is required on Windows XP if an application + // manifest specifies use of ComCtl32.dll version 6 or later to enable + // visual styles. Otherwise, any window creation will fail. + InitCommonControls(); + + CWinApp::InitInstance(); + + // Initialize OLE libraries + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + AfxEnableControlContainer(); + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need + // Change the registry key under which our settings are stored + // TODO: You should modify this string to be something appropriate + // such as the name of your company or organization + SetRegistryKey(_T("Local AppWizard-Generated Applications")); + LoadStdProfileSettings(4); // Load standard INI file options (including MRU) + // Register the application's document templates. Document templates + // serve as the connection between documents, frame windows and views + CMultiDocTemplate* pDocTemplate; + pDocTemplate = new CMultiDocTemplate(IDR_mfc1TYPE, + RUNTIME_CLASS(Cmfc1Doc), + RUNTIME_CLASS(CChildFrame), // custom MDI child frame + RUNTIME_CLASS(Cmfc1View)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + // create main MDI Frame window + CMainFrame* pMainFrame = new CMainFrame; + if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) + return FALSE; + m_pMainWnd = pMainFrame; + // call DragAcceptFiles only if there's a suffix + // In an MDI app, this should occur immediately after setting m_pMainWnd + // Enable drag/drop open + m_pMainWnd->DragAcceptFiles(); + // Enable DDE Execute open + EnableShellOpen(); + RegisterShellFileTypes(TRUE); + // Parse command line for standard shell commands, DDE, file open + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + // Dispatch commands specified on the command line. Will return FALSE if + // app was launched with /RegServer, /Register, /Unregserver or /Unregister. + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + // The main window has been initialized, so show and update it + pMainFrame->ShowWindow(m_nCmdShow); + pMainFrame->UpdateWindow(); + return TRUE; +} + + + +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + enum { IDD = IDD_ABOUTBOX }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + +// Implementation +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) +END_MESSAGE_MAP() + +// App command to run the dialog +void Cmfc1App::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + + +// Cmfc1App message handlers diff --git a/Tests/MFC/mfc1/mfc1.h b/Tests/MFC/mfc1/mfc1.h new file mode 100644 index 0000000..c273601 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.h @@ -0,0 +1,31 @@ +// mfc1.h : main header file for the mfc1 application +// +#pragma once + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + + +// Cmfc1App: +// See mfc1.cpp for the implementation of this class +// + +class Cmfc1App : public CWinApp +{ +public: + Cmfc1App(); + + +// Overrides +public: + virtual BOOL InitInstance(); + +// Implementation + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern Cmfc1App theApp; diff --git a/Tests/MFC/mfc1/mfc1.rc b/Tests/MFC/mfc1/mfc1.rc new file mode 100644 index 0000000..c960302 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.rc @@ -0,0 +1,387 @@ +//Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// + +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +#ifdef APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#include ""res\\mfc1.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#include ""afxprint.rc"" // printing/print preview resources\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) +IDR_MAINFRAME ICON "res\\mfc1.ico" +IDR_mfc1TYPE ICON "res\\mfc1Doc.ico" +#endif +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR 16, 15 +BEGIN + BUTTON ID_FILE_NEW + BUTTON ID_FILE_OPEN + BUTTON ID_FILE_SAVE + SEPARATOR + BUTTON ID_EDIT_CUT + BUTTON ID_EDIT_COPY + BUTTON ID_EDIT_PASTE + SEPARATOR + BUTTON ID_FILE_PRINT + BUTTON ID_APP_ABOUT +END + + + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New\tCtrl+N", ID_FILE_NEW + MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN + MENUITEM SEPARATOR + MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP + MENUITEM SEPARATOR + MENUITEM "Recent File", ID_FILE_MRU_FILE1,GRAYED + MENUITEM SEPARATOR + MENUITEM "&Close", ID_FILE_CLOSE + MENUITEM "E&xit", ID_APP_EXIT + END + POPUP "&View" + BEGIN + MENUITEM "&Toolbar", ID_VIEW_TOOLBAR + MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR + END + POPUP "&Help" + BEGIN + MENUITEM "&About mfc1...", ID_APP_ABOUT + END +END +IDR_mfc1TYPE MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New\tCtrl+N", ID_FILE_NEW + MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN + MENUITEM "&Close", ID_FILE_CLOSE + MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE + MENUITEM "Save &As...", ID_FILE_SAVE_AS + MENUITEM SEPARATOR + MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT + MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW + MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP + MENUITEM SEPARATOR + MENUITEM "Recent File", ID_FILE_MRU_FILE1,GRAYED + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_APP_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO + MENUITEM SEPARATOR + MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT + MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY + MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE + END + POPUP "&View" + BEGIN + MENUITEM "&Toolbar", ID_VIEW_TOOLBAR + MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR + END + POPUP "&Window" + BEGIN + MENUITEM "&New Window", ID_WINDOW_NEW + MENUITEM "&Cascade", ID_WINDOW_CASCADE + MENUITEM "&Tile", ID_WINDOW_TILE_HORZ + MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE + END + POPUP "&Help" + BEGIN + MENUITEM "&About mfc1...", ID_APP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS +BEGIN + "N", ID_FILE_NEW, VIRTKEY,CONTROL + "O", ID_FILE_OPEN, VIRTKEY,CONTROL + "S", ID_FILE_SAVE, VIRTKEY,CONTROL + "P", ID_FILE_PRINT, VIRTKEY,CONTROL + "Z", ID_EDIT_UNDO, VIRTKEY,CONTROL + "X", ID_EDIT_CUT, VIRTKEY,CONTROL + "C", ID_EDIT_COPY, VIRTKEY,CONTROL + "V", ID_EDIT_PASTE, VIRTKEY,CONTROL + VK_BACK, ID_EDIT_UNDO, VIRTKEY,ALT + VK_DELETE, ID_EDIT_CUT, VIRTKEY,SHIFT + VK_INSERT, ID_EDIT_COPY, VIRTKEY,CONTROL + VK_INSERT, ID_EDIT_PASTE, VIRTKEY,SHIFT + VK_F6, ID_NEXT_PANE, VIRTKEY + VK_F6, ID_PREV_PANE, VIRTKEY,SHIFT +END + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 +CAPTION "About mfc1" +STYLE DS_MODALFRAME | DS_SHELLFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU +FONT 8, "MS Shell Dlg" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT "mfc1 Version 1.0",IDC_STATIC,40,10,119,8, + SS_NOPREFIX + LTEXT "Copyright (C) 2011",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,16,WS_GROUP +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "TODO: " + VALUE "FileDescription", "TODO: " + VALUE "FileVersion", "1.0.0.1" + VALUE "InternalName", "mfc1.exe" + VALUE "LegalCopyright", "TODO: (c) . All rights reserved." + VALUE "OriginalFilename","mfc1.exe" + VALUE "ProductName", "TODO: " + VALUE "ProductVersion", "1.0.0.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 228 + TOPMARGIN, 7 + BOTTOMMARGIN, 48 + END +END +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN +// Non-mac-targeting apps remove the two extra substrings + IDR_MAINFRAME "mfc1" + // has a file suffix - shell file type too + IDR_mfc1TYPE "\nmfc1\nmfc1\nmfc1 Files (*.mf1)\n.mf1\nmfc1.Document\nmfc1.Document" +END +STRINGTABLE +BEGIN + AFX_IDS_APP_TITLE "mfc1" + AFX_IDS_IDLEMESSAGE "Ready" +END +STRINGTABLE +BEGIN + ID_INDICATOR_EXT "EXT" + ID_INDICATOR_CAPS "CAP" + ID_INDICATOR_NUM "NUM" + ID_INDICATOR_SCRL "SCRL" + ID_INDICATOR_OVR "OVR" + ID_INDICATOR_REC "REC" +END +STRINGTABLE +BEGIN + ID_FILE_NEW "Create a new document\nNew" + ID_FILE_OPEN "Open an existing document\nOpen" + ID_FILE_CLOSE "Close the active document\nClose" + ID_FILE_SAVE "Save the active document\nSave" + ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" + ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" + ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" + ID_FILE_PRINT "Print the active document\nPrint" + ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" + ID_APP_ABOUT "Display program information, version number and copyright\nAbout" + ID_APP_EXIT "Quit the application; prompts to save documents\nExit" + ID_FILE_MRU_FILE1 "Open this document" + ID_FILE_MRU_FILE2 "Open this document" + ID_FILE_MRU_FILE3 "Open this document" + ID_FILE_MRU_FILE4 "Open this document" + ID_FILE_MRU_FILE5 "Open this document" + ID_FILE_MRU_FILE6 "Open this document" + ID_FILE_MRU_FILE7 "Open this document" + ID_FILE_MRU_FILE8 "Open this document" + ID_FILE_MRU_FILE9 "Open this document" + ID_FILE_MRU_FILE10 "Open this document" + ID_FILE_MRU_FILE11 "Open this document" + ID_FILE_MRU_FILE12 "Open this document" + ID_FILE_MRU_FILE13 "Open this document" + ID_FILE_MRU_FILE14 "Open this document" + ID_FILE_MRU_FILE15 "Open this document" + ID_FILE_MRU_FILE16 "Open this document" + ID_NEXT_PANE "Switch to the next window pane\nNext Pane" + ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" + ID_WINDOW_NEW "Open another window for the active document\nNew Window" + ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" + ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" + ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" + ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" + ID_WINDOW_SPLIT "Split the active window into panes\nSplit" + ID_EDIT_CLEAR "Erase the selection\nErase" + ID_EDIT_CLEAR_ALL "Erase everything\nErase All" + ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" + ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" + ID_EDIT_FIND "Find the specified text\nFind" + ID_EDIT_PASTE "Insert Clipboard contents\nPaste" + ID_EDIT_REPEAT "Repeat the last action\nRepeat" + ID_EDIT_REPLACE "Replace specific text with different text\nReplace" + ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" + ID_EDIT_UNDO "Undo the last action\nUndo" + ID_EDIT_REDO "Redo the previously undone action\nRedo" + ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" + ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" +END + +STRINGTABLE +BEGIN + AFX_IDS_SCSIZE "Change the window size" + AFX_IDS_SCMOVE "Change the window position" + AFX_IDS_SCMINIMIZE "Reduce the window to an icon" + AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" + AFX_IDS_SCNEXTWINDOW "Switch to the next document window" + AFX_IDS_SCPREVWINDOW "Switch to the previous document window" + AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" + AFX_IDS_SCRESTORE "Restore the window to normal size" + AFX_IDS_SCTASKLIST "Activate Task List" + AFX_IDS_MDICHILD "Activate this window" + AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" +END + +#endif + +#ifdef _UNICODE +IDR_MANIFEST RT_MANIFEST "res\\mfc1.manifest" +#endif + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) +#include "res\\mfc1.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#include "afxprint.rc" // printing/print preview resources +#endif +#endif // not APSTUDIO_INVOKED diff --git a/Tests/MFC/mfc1/mfc1.reg b/Tests/MFC/mfc1/mfc1.reg new file mode 100644 index 0000000..9f3a86f --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.reg @@ -0,0 +1,13 @@ +REGEDIT +; This .REG file may be used by your SETUP program. +; If a SETUP program is not available, the entries below will be +; registered in your InitInstance automatically with a call to +; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll. + +HKEY_CLASSES_ROOT\.mf1 = mfc1.Document +HKEY_CLASSES_ROOT\mfc1.Document\shell\open\command = mfc1.EXE %1 +HKEY_CLASSES_ROOT\mfc1.Document\shell\open\ddeexec = [open("%1")] +HKEY_CLASSES_ROOT\mfc1.Document\shell\open\ddeexec\application = mfc1 + ; note: the application is optional + ; (it defaults to the app name in "command") +HKEY_CLASSES_ROOT\mfc1.Document = mfc1.Document diff --git a/Tests/MFC/mfc1/mfc1.sln b/Tests/MFC/mfc1/mfc1.sln new file mode 100644 index 0000000..78bbe56 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mfc1", "mfc1.vcproj", "{06C08100-1145-4104-AEC3-6BC8C608B819}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {06C08100-1145-4104-AEC3-6BC8C608B819}.Debug.ActiveCfg = Debug|Win32 + {06C08100-1145-4104-AEC3-6BC8C608B819}.Debug.Build.0 = Debug|Win32 + {06C08100-1145-4104-AEC3-6BC8C608B819}.Release.ActiveCfg = Release|Win32 + {06C08100-1145-4104-AEC3-6BC8C608B819}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Tests/MFC/mfc1/mfc1.vcproj b/Tests/MFC/mfc1/mfc1.vcproj new file mode 100644 index 0000000..6df86e5 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.vcproj @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/MFC/mfc1/mfc1Doc.cpp b/Tests/MFC/mfc1/mfc1Doc.cpp new file mode 100644 index 0000000..8767052 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1Doc.cpp @@ -0,0 +1,78 @@ +// mfc1Doc.cpp : implementation of the Cmfc1Doc class +// + +#include "stdafx.h" +#include "mfc1.h" + +#include "mfc1Doc.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cmfc1Doc + +IMPLEMENT_DYNCREATE(Cmfc1Doc, CDocument) + +BEGIN_MESSAGE_MAP(Cmfc1Doc, CDocument) +END_MESSAGE_MAP() + + +// Cmfc1Doc construction/destruction + +Cmfc1Doc::Cmfc1Doc() +{ + // TODO: add one-time construction code here + +} + +Cmfc1Doc::~Cmfc1Doc() +{ +} + +BOOL Cmfc1Doc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: add reinitialization code here + // (SDI documents will reuse this document) + + return TRUE; +} + + + + +// Cmfc1Doc serialization + +void Cmfc1Doc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: add storing code here + } + else + { + // TODO: add loading code here + } +} + + +// Cmfc1Doc diagnostics + +#ifdef _DEBUG +void Cmfc1Doc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void Cmfc1Doc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// Cmfc1Doc commands diff --git a/Tests/MFC/mfc1/mfc1Doc.h b/Tests/MFC/mfc1/mfc1Doc.h new file mode 100644 index 0000000..92d8e35 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1Doc.h @@ -0,0 +1,37 @@ +// mfc1Doc.h : interface of the Cmfc1Doc class +// + + +#pragma once + +class Cmfc1Doc : public CDocument +{ +protected: // create from serialization only + Cmfc1Doc(); + DECLARE_DYNCREATE(Cmfc1Doc) + +// Attributes +public: + +// Operations +public: + +// Overrides + public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); + +// Implementation +public: + virtual ~Cmfc1Doc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + DECLARE_MESSAGE_MAP() +}; diff --git a/Tests/MFC/mfc1/mfc1View.cpp b/Tests/MFC/mfc1/mfc1View.cpp new file mode 100644 index 0000000..06c7652 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1View.cpp @@ -0,0 +1,99 @@ +// mfc1View.cpp : implementation of the Cmfc1View class +// + +#include "stdafx.h" +#include "mfc1.h" + +#include "mfc1Doc.h" +#include "mfc1View.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cmfc1View + +IMPLEMENT_DYNCREATE(Cmfc1View, CView) + +BEGIN_MESSAGE_MAP(Cmfc1View, CView) + // Standard printing commands + ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) +END_MESSAGE_MAP() + +// Cmfc1View construction/destruction + +Cmfc1View::Cmfc1View() +{ + // TODO: add construction code here + +} + +Cmfc1View::~Cmfc1View() +{ +} + +BOOL Cmfc1View::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return CView::PreCreateWindow(cs); +} + +// Cmfc1View drawing + +void Cmfc1View::OnDraw(CDC* /*pDC*/) +{ + Cmfc1Doc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + + // TODO: add draw code for native data here +} + + +// Cmfc1View printing + +BOOL Cmfc1View::OnPreparePrinting(CPrintInfo* pInfo) +{ + // default preparation + return DoPreparePrinting(pInfo); +} + +void Cmfc1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: add extra initialization before printing +} + +void Cmfc1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: add cleanup after printing +} + + +// Cmfc1View diagnostics + +#ifdef _DEBUG +void Cmfc1View::AssertValid() const +{ + CView::AssertValid(); +} + +void Cmfc1View::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +Cmfc1Doc* Cmfc1View::GetDocument() const // non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(Cmfc1Doc))); + return (Cmfc1Doc*)m_pDocument; +} +#endif //_DEBUG + + +// Cmfc1View message handlers diff --git a/Tests/MFC/mfc1/mfc1View.h b/Tests/MFC/mfc1/mfc1View.h new file mode 100644 index 0000000..4244653 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1View.h @@ -0,0 +1,48 @@ +// mfc1View.h : interface of the Cmfc1View class +// + + +#pragma once + + +class Cmfc1View : public CView +{ +protected: // create from serialization only + Cmfc1View(); + DECLARE_DYNCREATE(Cmfc1View) + +// Attributes +public: + Cmfc1Doc* GetDocument() const; + +// Operations +public: + +// Overrides + public: + virtual void OnDraw(CDC* pDC); // overridden to draw this view +virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// Implementation +public: + virtual ~Cmfc1View(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // debug version in mfc1View.cpp +inline Cmfc1Doc* Cmfc1View::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif diff --git a/Tests/MFC/mfc1/res/Toolbar.bmp b/Tests/MFC/mfc1/res/Toolbar.bmp new file mode 100644 index 0000000..d501723 Binary files /dev/null and b/Tests/MFC/mfc1/res/Toolbar.bmp differ diff --git a/Tests/MFC/mfc1/res/mfc1.ico b/Tests/MFC/mfc1/res/mfc1.ico new file mode 100644 index 0000000..8a84ca3 Binary files /dev/null and b/Tests/MFC/mfc1/res/mfc1.ico differ diff --git a/Tests/MFC/mfc1/res/mfc1.manifest b/Tests/MFC/mfc1/res/mfc1.manifest new file mode 100644 index 0000000..b15d2f2 --- /dev/null +++ b/Tests/MFC/mfc1/res/mfc1.manifest @@ -0,0 +1,22 @@ + + + +Your app description here + + + + + + diff --git a/Tests/MFC/mfc1/res/mfc1.rc2 b/Tests/MFC/mfc1/res/mfc1.rc2 new file mode 100644 index 0000000..62a3ab0 --- /dev/null +++ b/Tests/MFC/mfc1/res/mfc1.rc2 @@ -0,0 +1,13 @@ +// +// mfc1.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/Tests/MFC/mfc1/res/mfc1Doc.ico b/Tests/MFC/mfc1/res/mfc1Doc.ico new file mode 100644 index 0000000..2a1f1ae Binary files /dev/null and b/Tests/MFC/mfc1/res/mfc1Doc.ico differ diff --git a/Tests/MFC/mfc1/stdafx.cpp b/Tests/MFC/mfc1/stdafx.cpp new file mode 100644 index 0000000..67fd1b5 --- /dev/null +++ b/Tests/MFC/mfc1/stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// mfc1.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/Tests/MFC/mfc1/stdafx.h b/Tests/MFC/mfc1/stdafx.h new file mode 100644 index 0000000..fb9dfb3 --- /dev/null +++ b/Tests/MFC/mfc1/stdafx.h @@ -0,0 +1,41 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#endif + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. +#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. +#endif + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. +#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. +#endif + +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. +#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. +#endif + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit + +// turns off MFC's hiding of some common and often safely ignored warning messages +#define _AFX_ALL_WARNINGS + +#include // MFC core and standard components +#include // MFC extensions +#include // MFC Automation classes + +#include // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT -- cgit v0.12 From b0f0b3e4405cb663fd5757441f556ee6cd3fac8c Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Mon, 31 Oct 2011 19:04:08 -0500 Subject: VS: Add VS_SCC_AUXPATH target property (#12549) Maps to SccAuxPath tag in VCPROJ files. --- Source/cmLocalVisualStudio7Generator.cxx | 7 +++++++ Source/cmSetTargetPropertiesCommand.h | 3 ++- Source/cmTarget.cxx | 7 ++++++- Source/cmVisualStudio10TargetGenerator.cxx | 10 +++++++++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index d9b2772..ae70759 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1811,11 +1811,18 @@ void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout, const char* vsProjectname = target.GetProperty("VS_SCC_PROJECTNAME"); const char* vsLocalpath = target.GetProperty("VS_SCC_LOCALPATH"); const char* vsProvider = target.GetProperty("VS_SCC_PROVIDER"); + if(vsProvider && vsLocalpath && vsProjectname) { fout << "\tSccProjectName=\"" << vsProjectname << "\"\n" << "\tSccLocalPath=\"" << vsLocalpath << "\"\n" << "\tSccProvider=\"" << vsProvider << "\"\n"; + + const char* vsAuxPath = target.GetProperty("VS_SCC_AUXPATH"); + if(vsAuxPath) + { + fout << "\tSccAuxPath=\"" << vsAuxPath << "\"\n"; + } } } diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index 320378d..f001a11 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -140,7 +140,8 @@ public: "the target in an IDE like visual studio. VS_KEYWORD can be set " "to change the visual studio keyword, for example QT integration " "works better if this is set to Qt4VSv1.0.\n" - "VS_SCC_PROJECTNAME, VS_SCC_LOCALPATH, VS_SCC_PROVIDER can be set " + "VS_SCC_PROJECTNAME, VS_SCC_LOCALPATH, VS_SCC_PROVIDER and " + "VS_SCC_AUXPATH can be set " "to add support for source control bindings in a Visual Studio " "project file.\n" "VS_GLOBAL_ can be set to add a Visual Studio " diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f7d3ba9..6bf7ec9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1011,7 +1011,7 @@ void cmTarget::DefineProperties(cmake *cm) "provider property."); cm->DefineProperty ("VS_SCC_LOCALPATH", cmProperty::TARGET, - "Visual Studio Source Code Control Provider.", + "Visual Studio Source Code Control Local Path.", "Can be set to change the visual studio source code control " "local path property."); cm->DefineProperty @@ -1020,6 +1020,11 @@ void cmTarget::DefineProperties(cmake *cm) "Can be set to change the visual studio source code control " "project name property."); cm->DefineProperty + ("VS_SCC_AUXPATH", cmProperty::TARGET, + "Visual Studio Source Code Control Aux Path.", + "Can be set to change the visual studio source code control " + "auxpath property."); + cm->DefineProperty ("VS_GLOBAL_", cmProperty::TARGET, "Visual Studio project-specific global variable.", "Tell the Visual Studio generator to set the global variable " diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 551b0ad..45a79c8 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -182,7 +182,7 @@ void cmVisualStudio10TargetGenerator::Generate() const char* vsLocalPath = this->Target->GetProperty("VS_SCC_LOCALPATH"); const char* vsProvider = this->Target->GetProperty("VS_SCC_PROVIDER"); - if ( vsProjectName && vsLocalPath && vsProvider) + if( vsProjectName && vsLocalPath && vsProvider ) { this->WriteString("", 2); (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectName) << @@ -193,6 +193,14 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("", 2); (*this->BuildFileStream) << cmVS10EscapeXML(vsProvider) << "\n"; + + const char* vsAuxPath = this->Target->GetProperty("VS_SCC_AUXPATH"); + if( vsAuxPath ) + { + this->WriteString("", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsAuxPath) << + "\n"; + } } this->WriteString("Win32Proj\n", 2); -- cgit v0.12 From 2c648ab7e204540a8a669b597cc7d3510c84647e Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 1 Nov 2011 19:54:04 +0100 Subject: add documentation for the AUTOMOC_MOC_OPTIONS property Alex --- Source/cmDocumentVariables.cxx | 9 +++++++++ Source/cmTarget.cxx | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index f4d4e7c..a759a82 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1103,6 +1103,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables that Control the Build"); cm->DefineProperty + ("CMAKE_AUTOMOC_MOC_OPTIONS", cmProperty::VARIABLE, + "Additional options for moc when using automoc (see CMAKE_AUTOMOC).", + "This variable is used to initialize the " + "AUTOMOC_MOC_OPTIONS property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + + cm->DefineProperty ("CMAKE_DEBUG_POSTFIX", cmProperty::VARIABLE, "See variable CMAKE__POSTFIX.", "This variable is a special case of the more-general " diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8064d0..d669a5b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -157,7 +157,20 @@ void cmTarget::DefineProperties(cmake *cm) "files are included in a generated _automoc.cpp file, " "which is compiled as part of the target." "This property is initialized by the value of the variable " - "CMAKE_AUTOMOC if it is set when a target is created."); + "CMAKE_AUTOMOC if it is set when a target is created.\n" + "Additional command line options for moc can be set via the " + "AUTOMOC_MOC_OPTIONS property." + ); + + cm->DefineProperty + ("AUTOMOC_MOC_OPTIONS", cmProperty::TARGET, + "Additional options for moc when using automoc (see the AUTOMOC property)", + "This property is only used if the AUTOMOC property is set to TRUE for " + "this target. In this case, it holds additional command line options " + "which will be used when moc is executed during the build, i.e. it is " + "equivalent to the optional OPTIONS argument of the qt4_wrap_cpp() " + "macro.\n" + "By default it is empty."); cm->DefineProperty ("BUILD_WITH_INSTALL_RPATH", cmProperty::TARGET, -- cgit v0.12 From 4b930220be0c0b2391a33336a37525154f6b402d Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 1 Nov 2011 10:41:23 +0100 Subject: Eclipse: warn if CMAKE_BINARY_DIR is subdir of CMAKE_SOURCE_DIR Eclipse doesn't handle this case well. When doing out-of-source builds we create a linked resource which points to CMAKE_SOURCE_DIR, so the user can browse the source dir in Eclipse. This is not possible when the build dir is a subdir of the source dir. Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 785e85a..0667da7 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -87,6 +87,16 @@ void cmExtraEclipseCDT4Generator::Generate() this->GenerateSourceProject = (this->IsOutOfSourceBuild && mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT")); + if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), + this->HomeDirectory.c_str())) + { + mf->IssueMessage(cmake::WARNING, "The build directory is a subdirectory " + "of the source directory.\n" + "This is not supported well by Eclipse. It is strongly " + "recommended to use a build directory which is a " + "sibling of the source directory."); + } + // NOTE: This is not good, since it pollutes the source tree. However, // Eclipse doesn't allow CVS/SVN to work when the .project is not in // the cvs/svn root directory. Hence, this is provided as an option. -- cgit v0.12 From d31b1aca3fcf5d8c0e7ab5cbb37045ad87dead79 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 1 Nov 2011 21:23:52 +0100 Subject: Eclipse: quote the build dir (to make it work with spaces) When creating the targets for Eclipse, quote the directory in which make should change. Otherwise it will fail if the path contains with spaces. Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index eab149e..a338031 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -998,9 +998,9 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const std::string virtDir = "[Targets]/"; virtDir += prefix; virtDir += ti->first; - std::string buildArgs = "-C "; + std::string buildArgs = "-C \""; buildArgs += makefile->GetHomeOutputDirectory(); - buildArgs += " "; + buildArgs += "\" "; buildArgs += makeArgs; this->AppendTarget(fout, "Build", make, buildArgs, virtDir, "", ti->first.c_str()); -- cgit v0.12 From 54595e6d89a6280dfbc9580500ce50283ce71d3f Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 1 Nov 2011 16:27:24 -0400 Subject: Tests: Avoid MFC test automatically for VCExpress builds (#11213) --- Tests/CMakeLists.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index f400f6d..27018d1 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1210,6 +1210,30 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ set(CTEST_RUN_MFC OFF) if(MSVC) set(CTEST_RUN_MFC ON) + + # Look for evidence that this is a VCExpress build. If so, avoid + # the MFC test by default. + string(TOLOWER "${CMAKE_TEST_MAKEPROGRAM}" mkprog) + if(mkprog MATCHES "vcexpress") + message(STATUS + "CMAKE_TEST_MAKEPROGRAM indicates vcexpress, avoiding MFC test") + set(CTEST_RUN_MFC OFF) + endif() + + # Since MSBuild might also be the "makeprogram" for a VCExpress + # build tree, use one more heuristic, too. The string representing + # the .vcproj file type contains "VCExpress" on machines where an + # express edition of VS was installed last: + if(CTEST_RUN_MFC) + execute_process(COMMAND cmd /c assoc .vcproj + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE ov) + if(ov MATCHES "VCExpress") + message(STATUS + ".vcproj file association indicates VCExpress, avoiding MFC test") + set(CTEST_RUN_MFC OFF) + endif() + endif() endif() endif() -- cgit v0.12 From b297da615aa2331a558a1c9aa8864e4db3e1f39a Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 2 Nov 2011 08:03:12 -0400 Subject: Tests: Fix MFC test w/ Make-based generators (#11213) An explicit add_definitions of _AFXDLL is required for shared library builds with non-Visual Studio generators. --- Tests/MFC/CMakeLists.txt.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Tests/MFC/CMakeLists.txt.in b/Tests/MFC/CMakeLists.txt.in index 06ba8b3..e6bfabd 100644 --- a/Tests/MFC/CMakeLists.txt.in +++ b/Tests/MFC/CMakeLists.txt.in @@ -6,15 +6,23 @@ macro(replace_flags var these those) string(REGEX REPLACE "${these}" "${those}" ${var} "${${var}}") #message(STATUS "info: ${var} changed to '${${var}}'") endif() + message(STATUS "info: ${var}='${${var}}'") endmacro() macro(msvc_link_to_static_crt) if(MSVC) + set(has_correct_flag 0) foreach(lang C CXX) foreach(suffix "" _DEBUG _MINSIZEREL _RELEASE _RELWITHDEBINFO) replace_flags("CMAKE_${lang}_FLAGS${suffix}" "/MD" "/MT") + if(CMAKE_${lang}_FLAGS${suffix} MATCHES "/MT") + set(has_correct_flag 1) + endif() endforeach() endforeach() + if(NOT has_correct_flag) + message(FATAL_ERROR "no CMAKE_*_FLAGS var contains /MT") + endif() endif() endmacro() @@ -39,6 +47,10 @@ set(CMAKE_MFC_FLAG "@CMAKE_MFC_FLAG_VALUE@") if("${CMAKE_MFC_FLAG}" STREQUAL "1") msvc_link_to_static_crt() +else() + # VS generators add this automatically based on the CMAKE_MFC_FLAG value, + # but generators matching "Make" require: + add_definitions(-D_AFXDLL) endif() add_executable(mfc1 WIN32 ${files}) -- cgit v0.12 From e74f3744ae25b5be2bf6e4c33a0420d836a2f37d Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 2 Nov 2011 08:58:41 -0400 Subject: Fix linking to OS X Frameworks named with spaces (#12550) Teach cmComputeLinkInformation to generate the "-framework" option as a separate link item preceding the actual framework name. Then escape the framework name to pass as an argument through a shell. This fixes the link line for frameworks with spaces in the name. The build system generators that call cli.GetItems() and generate the final list of items on the link line already handle escaping correctly for items that are paths. However, for raw link items like "-lfoo" they just pass through to the command line verbatim. This is incorrect. The generators should escape these items too. Unfortunately we cannot fix that without introducing a new CMake Policy because projects may already be passing raw link flags with their own escapes to work around this bug. Therefore we punt on this bug for now and go with the above fix. --- Source/cmComputeLinkInformation.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c87b64d..f8ab686 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1318,8 +1318,9 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item) this->AddFrameworkPath(this->SplitFramework.match(1)); // Add the item using the -framework option. - std::string fw = "-framework "; - fw += this->SplitFramework.match(2); + this->Items.push_back(Item("-framework", false)); + std::string fw = this->SplitFramework.match(2); + fw = this->LocalGenerator->EscapeForShell(fw.c_str()); this->Items.push_back(Item(fw, false)); } -- cgit v0.12 From a42e3f2bf915c510b43fd0f8c90f4716aab41541 Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 3 Nov 2011 08:37:23 -0400 Subject: Tests: Fix MFC test for old vs6 dashboards (#11213) The MFC test's mfc1 directory was a "VS-MFC-wizard-generated" starter MFC app, using VS 7.1 as the generator. There's one define used in the generated rc file that was not available back in the VS6 days... Put a conditional define in here based on _MSC_VER to enable the test app to build on VS6 dashboards. --- Tests/MFC/mfc1/mfc1.rc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Tests/MFC/mfc1/mfc1.rc b/Tests/MFC/mfc1/mfc1.rc index c960302..346c5fb 100644 --- a/Tests/MFC/mfc1/mfc1.rc +++ b/Tests/MFC/mfc1/mfc1.rc @@ -198,9 +198,15 @@ END // Dialog // +#if _MSC_VER < 1300 +#define DS_SHELLFONT_FLAG 0 +#else +#define DS_SHELLFONT_FLAG DS_SHELLFONT +#endif + IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 CAPTION "About mfc1" -STYLE DS_MODALFRAME | DS_SHELLFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU +STYLE DS_MODALFRAME | DS_SHELLFONT_FLAG | WS_POPUP | WS_CAPTION | WS_SYSMENU FONT 8, "MS Shell Dlg" BEGIN ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 -- cgit v0.12 From 23381d83d8d8399eea372e3f2407beac39e55b98 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Nov 2011 08:59:50 -0400 Subject: Watcom: Use shortpath to CMake if full path has parens (#12548) The Watcom WMake tool has trouble running commands in paths that have parentheses. We already convert most commands to a shortpath for Watcom if the path contains a space, but the use of $(CMAKE_COMMAND) hides the true path from that conversion. Factor the shortpath conversion code out into a new ConvertShellCommand method. Teach it to convert paths that contain parentheses as well as spaces. Use the new method to convert the value of $(CMAKE_COMMAND) and other helper variables. --- Source/cmLocalUnixMakefileGenerator3.cxx | 42 +++++++++++++++++++------------- Source/cmLocalUnixMakefileGenerator3.h | 1 + 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index da6a1c6..c8a06aa 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -608,6 +608,27 @@ cmLocalUnixMakefileGenerator3 } //---------------------------------------------------------------------------- +std::string +cmLocalUnixMakefileGenerator3 +::ConvertShellCommand(std::string const& cmd, RelativeRoot root) +{ + if(this->WatcomWMake && + cmSystemTools::FileIsFullPath(cmd.c_str()) && + cmd.find_first_of("( )") != cmd.npos) + { + // On Watcom WMake use the windows short path for the command + // name. This is needed to avoid funny quoting problems on + // lines with shell redirection operators. + std::string scmd; + if(cmSystemTools::GetShortPath(cmd.c_str(), scmd)) + { + return this->Convert(scmd.c_str(), NONE, SHELL); + } + } + return this->Convert(cmd.c_str(), root, SHELL); +} + +//---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 ::WriteMakeVariables(std::ostream& makefileStream) @@ -646,13 +667,13 @@ cmLocalUnixMakefileGenerator3 makefileStream << "# The CMake executable.\n" << "CMAKE_COMMAND = " - << this->Convert(cmakecommand.c_str(), FULL, SHELL).c_str() + << this->ConvertShellCommand(cmakecommand, FULL) << "\n" << "\n"; makefileStream << "# The command to remove a file.\n" << "RM = " - << this->Convert(cmakecommand.c_str(),FULL,SHELL).c_str() + << this->ConvertShellCommand(cmakecommand, FULL) << " -E remove -f\n" << "\n"; @@ -662,7 +683,7 @@ cmLocalUnixMakefileGenerator3 makefileStream << "# The program to use to edit the cache.\n" << "CMAKE_EDIT_COMMAND = " - << this->Convert(edit_cmd,FULL,SHELL) << "\n" + << this->ConvertShellCommand(edit_cmd, FULL) << "\n" << "\n"; } @@ -1019,22 +1040,9 @@ cmLocalUnixMakefileGenerator3 // without the current directory being in the search path. cmd = "./" + cmd; } - if(this->WatcomWMake && - cmSystemTools::FileIsFullPath(cmd.c_str()) && - cmd.find(" ") != cmd.npos) - { - // On Watcom WMake use the windows short path for the command - // name. This is needed to avoid funny quoting problems on - // lines with shell redirection operators. - std::string scmd; - if(cmSystemTools::GetShortPath(cmd.c_str(), scmd)) - { - cmd = scmd; - } - } std::string launcher = this->MakeLauncher(cc, target, workingDir? NONE : START_OUTPUT); - cmd = launcher + this->Convert(cmd.c_str(),NONE,SHELL); + cmd = launcher + this->ConvertShellCommand(cmd, NONE); ccg.AppendArguments(c, cmd); if(content) diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index fab98da..45ac21d 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -340,6 +340,7 @@ protected: void CheckMultipleOutputs(bool verbose); private: + std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root); std::string MakeLauncher(const cmCustomCommand& cc, cmTarget* target, RelativeRoot relative); -- cgit v0.12 From c71f7ab7db843234cab7e6b75ab2636a0d7e8d67 Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 3 Nov 2011 13:21:06 -0400 Subject: Tests: Avoid MFC test automatically for Watcom WMake builds (#11213) --- Tests/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 27018d1..cfc59be 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1208,6 +1208,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ if(NOT DEFINED CTEST_RUN_MFC) set(CTEST_RUN_MFC OFF) + if(MSVC) set(CTEST_RUN_MFC ON) @@ -1234,6 +1235,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ set(CTEST_RUN_MFC OFF) endif() endif() + + # For the Watcom WMake generator, avoid the MFC test by default. + if(CTEST_RUN_MFC) + if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake") + message(STATUS + "using the Watcom WMake generator, avoiding MFC test") + set(CTEST_RUN_MFC OFF) + endif() + endif() endif() endif() -- cgit v0.12 From 83d02ee52b60e541d2f52feff0c0858e7e7595e8 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 3 Nov 2011 22:55:42 +0100 Subject: make automoc work when using ccmake via PATH (#12551) In ccmake, cmake::GetCMakeCommand() returns "/cmake" when ccmake was started from the PATH, i.e. by simply running "ccmake" Alex --- Source/cmQtAutomoc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index a839489..8750b64 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -67,7 +67,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) targetDir += ".dir/"; cmCustomCommandLine currentLine; - currentLine.push_back(makefile->GetCMakeInstance()->GetCMakeCommand()); + currentLine.push_back(makefile->GetSafeDefinition("CMAKE_COMMAND")); currentLine.push_back("-E"); currentLine.push_back("cmake_automoc"); currentLine.push_back(targetDir); -- cgit v0.12 From a2e6d2482e4eb007c8012f2aee3b2381cc95a001 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 4 Nov 2011 13:07:38 -0400 Subject: Tests: Fix MFC test to work with VS 10 and later (#11213) The mfc app in the test was generated by the VS 7.1 wizard, and due to changes in VS since then, the values used for WINVER and _WIN32_WINNT caused compile errors when built with VS 10 or later. Change them to values appropriate for targeting Windows XP or later when building with VS 10 or later. See http://msdn.microsoft.com/en-us/library/6sehtctf.aspx for more info. --- Tests/MFC/mfc1/stdafx.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Tests/MFC/mfc1/stdafx.h b/Tests/MFC/mfc1/stdafx.h index fb9dfb3..35a678d 100644 --- a/Tests/MFC/mfc1/stdafx.h +++ b/Tests/MFC/mfc1/stdafx.h @@ -8,23 +8,38 @@ #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif +// See http://msdn.microsoft.com/en-us/library/6sehtctf.aspx for more info +// on WINVER and _WIN32_WINNT + // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. #ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. +#if _MSC_VER < 1600 #define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. +#else +#define WINVER 0x0501 // Target Windows XP and later with VS 10 and later +#endif #endif #ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. +#if _MSC_VER < 1600 #define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. +#else +#define _WIN32_WINNT 0x0501 // Target Windows XP and later with VS 10 and later +#endif #endif #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. +#if _MSC_VER < 1600 #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. #endif +#endif #ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. +#if _MSC_VER < 1600 #define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. #endif +#endif #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit -- cgit v0.12 From 011694c269a1193ec8f7fe8dce8d4a86bcafa8e4 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 4 Nov 2011 13:29:41 -0400 Subject: VS10: Use expected values for UseOfMfc (#11213) Use expected values for the UseOfMfc xml element in VS 10 .vcxproj files. CMAKE_MFC_FLAG=1 maps to "Static" CMAKE_MFC_FLAG=2 maps to "Dynamic" all other values map to "false" Thanks to Randy Schott and McBen for their patches which served as inspiration and motivation for getting this done. See also http://public.kitware.com/Bug/view.php?id=11224 --- Source/cmVisualStudio10TargetGenerator.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 551b0ad..c51254a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -290,16 +290,24 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() } configType += "\n"; this->WriteString(configType.c_str(), 2); + const char* mfcFlag = this->Target->GetMakefile()->GetDefinition("CMAKE_MFC_FLAG"); - if(mfcFlag) + std::string mfcFlagValue = mfcFlag ? mfcFlag : "0"; + + std::string useOfMfcValue = "false"; + if(mfcFlagValue == "1") { - this->WriteString("true\n", 2); + useOfMfcValue = "Static"; } - else + else if(mfcFlagValue == "2") { - this->WriteString("false\n", 2); + useOfMfcValue = "Dynamic"; } + std::string mfcLine = ""; + mfcLine += useOfMfcValue + "\n"; + this->WriteString(mfcLine.c_str(), 2); + if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY && this->ClOptions[*i]->UsingUnicode()) { -- cgit v0.12 From 6d51f5fa3c34d3c8f5b188b3ab9e5d385d1f02a4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Nov 2011 19:49:40 +0100 Subject: Fix typo. --- Source/cmLocalUnixMakefileGenerator3.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index da6a1c6..64d8e7d 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -697,7 +697,7 @@ cmLocalUnixMakefileGenerator3 // This should be the first target except for the default_target in // the interface Makefile. this->WriteMakeRule( - makefileStream, "Disable implicit rules so canoncical targets will work.", + makefileStream, "Disable implicit rules so canonical targets will work.", ".SUFFIXES", no_depends, no_commands, false); if(!this->NMake && !this->WatcomWMake && !this->BorlandMakeCurlyHack) -- cgit v0.12 From 9066886f9b88744e49721c8ac9cf0a8bf50e72fe Mon Sep 17 00:00:00 2001 From: Eric NOULARD Date: Sat, 5 Nov 2011 11:40:47 +0100 Subject: CPackRPM fix #12556 and enhance documentation Inspired-By: Chip Christian --- Modules/CPackRPM.cmake | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 36b86cf..bb1021b 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -7,7 +7,9 @@ # the specifics CPACK_RPM_XXX variables. CPackRPM is a component aware # generator so when CPACK_RPM_COMPONENT_INSTALL is ON some more # CPACK_RPM__XXXX variables may be used in order -# to have component specific values. +# to have component specific values. Note however that +# refers to the **grouping name**. This may be either a component name +# or a component GROUP name. # Usually those vars correspond to RPM spec file entities, one may find # information about spec files here http://www.rpm.org/wiki/Docs. # You'll find a detailed usage of CPackRPM on the wiki: @@ -101,9 +103,11 @@ # If CPACK_SET_DESTDIR is set then you will get a warning message # but if there is file installed with absolute path you'll get # unexpected behavior. -# CPACK_RPM_SPEC_INSTALL_POST +# CPACK_RPM_SPEC_INSTALL_POST [deprecated] # Mandatory : NO # Default : - +# This way of specifying post-install script is deprecated use +# CPACK_RPM_POST_INSTALL_SCRIPT_FILE # May be used to set an RPM post-install command inside the spec file. # For example setting it to "/bin/true" may be used to prevent # rpmbuild to strip binaries. @@ -161,7 +165,7 @@ # Mandatory : NO # Default : - # May be used to embed a changelog in the spec file. -# The refered file will be read and directly put after the %changelog +# The refered file will be read and directly put after the %changelog # section. #============================================================================= @@ -462,20 +466,31 @@ else(CPACK_RPM_PACKAGE_COMPONENT) set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) endif(CPACK_RPM_PACKAGE_COMPONENT) + +# Handle post-install file if it has been specified if(CPACK_RPM_POST_INSTALL_READ_FILE) if(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) file(READ ${CPACK_RPM_POST_INSTALL_READ_FILE} CPACK_RPM_SPEC_POSTINSTALL) else(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_READ_FILE}> does not exists - ignoring") endif(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) +else(CPACK_RPM_POST_INSTALL_READ_FILE) + # reset SPEC var value if no post install file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_POSTINSTALL "") endif(CPACK_RPM_POST_INSTALL_READ_FILE) +# Handle post-uninstall file if it has been specified if(CPACK_RPM_POST_UNINSTALL_READ_FILE) if(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) file(READ ${CPACK_RPM_POST_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_POSTUNINSTALL) else(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_READ_FILE}> does not exists - ignoring") endif(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) +else(CPACK_RPM_POST_UNINSTALL_READ_FILE) + # reset SPEC var value if no post uninstall file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_POSTUNINSTALL "") endif(CPACK_RPM_POST_UNINSTALL_READ_FILE) # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM__PRE_INSTALL_SCRIPT_FILE) @@ -498,20 +513,31 @@ else(CPACK_RPM_PACKAGE_COMPONENT) set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) endif(CPACK_RPM_PACKAGE_COMPONENT) + +# Handle pre-install file if it has been specified if(CPACK_RPM_PRE_INSTALL_READ_FILE) if(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) file(READ ${CPACK_RPM_PRE_INSTALL_READ_FILE} CPACK_RPM_SPEC_PREINSTALL) else(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_READ_FILE}> does not exists - ignoring") endif(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) +else(CPACK_RPM_PRE_INSTALL_READ_FILE) + # reset SPEC var value if no pre-install file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_PREINSTALL "") endif(CPACK_RPM_PRE_INSTALL_READ_FILE) +# Handle pre-uninstall file if it has been specified if(CPACK_RPM_PRE_UNINSTALL_READ_FILE) if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) file(READ ${CPACK_RPM_PRE_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_PREUNINSTALL) else(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_READ_FILE}> does not exists - ignoring") endif(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) +else(CPACK_RPM_PRE_UNINSTALL_READ_FILE) + # reset SPEC var value if no pre-uninstall file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_PREUNINSTALL "") endif(CPACK_RPM_PRE_UNINSTALL_READ_FILE) # CPACK_RPM_CHANGELOG_FILE -- cgit v0.12 From 3de9669e1bda83e9960d224aa466d476e58b2ba7 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 7 Nov 2011 00:01:06 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index b4e55d4..7d3eeb4 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 06) +SET(KWSYS_DATE_STAMP_DAY 07) -- cgit v0.12 From 7fe3484f20652169b57b131d6c51a0a0e7eb0a8c Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 8 Nov 2011 00:01:13 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 7d3eeb4..38b9719 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 07) +SET(KWSYS_DATE_STAMP_DAY 08) -- cgit v0.12 From d85ab7a41212c7d42305dd1e33d8f5a0ac9fdf68 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 8 Nov 2011 15:11:31 -0500 Subject: Tests: Add environment logging to the MFC test (#11213) Simply to ease analyzing still-occurring dashboard failures. --- Tests/MFC/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Tests/MFC/CMakeLists.txt b/Tests/MFC/CMakeLists.txt index ea5c41d..df3149a 100644 --- a/Tests/MFC/CMakeLists.txt +++ b/Tests/MFC/CMakeLists.txt @@ -48,3 +48,14 @@ add_test( COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ValidateBuild.cmake" ) + + +add_test( + NAME environment + COMMAND ${CMAKE_COMMAND} -E environment + ) + + +message(STATUS "===== environment =====") +execute_process(COMMAND ${CMAKE_COMMAND} -E environment) +message(STATUS "===== /environment =====") -- cgit v0.12 From 51f442e6034a151e797f678e479073285b433d71 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 8 Nov 2011 15:22:40 -0500 Subject: VS11: Update InstallRequiredSystemLibraries.cmake for VS11 (#11213) Should fix the newly added MFC test on VS11 dashboards. --- Modules/InstallRequiredSystemLibraries.cmake | 96 +++++++++++++++++----------- 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index b6735c1..65d254a 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -141,36 +141,46 @@ IF(MSVC) ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) ENDIF(MSVC90) - IF(MSVC10) + MACRO(MSVCRT_FILES_FOR_VERSION version) + SET(v "${version}") + # Find the runtime library redistribution directory. GET_FILENAME_COMPONENT(msvc_install_dir - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]" ABSOLUTE) - FIND_PATH(MSVC10_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\${v}.0;InstallDir]" ABSOLUTE) + FIND_PATH(MSVC${v}_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT PATHS "${msvc_install_dir}/../../VC/redist" "${base_dir}/VC/redist" - "$ENV{ProgramFiles}/Microsoft Visual Studio 10.0/VC/redist" - "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio 10.0/VC/redist" + "$ENV{ProgramFiles}/Microsoft Visual Studio ${v}.0/VC/redist" + "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio ${v}.0/VC/redist" ) - MARK_AS_ADVANCED(MSVC10_REDIST_DIR) - SET(MSVC10_CRT_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT") + MARK_AS_ADVANCED(MSVC${v}_REDIST_DIR) + SET(MSVC${v}_CRT_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT") IF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) SET(__install__libs - "${MSVC10_CRT_DIR}/msvcp100.dll" - "${MSVC10_CRT_DIR}/msvcr100.dll" + "${MSVC${v}_CRT_DIR}/msvcp${v}0.dll" + "${MSVC${v}_CRT_DIR}/msvcr${v}0.dll" ) ENDIF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) IF(CMAKE_INSTALL_DEBUG_LIBRARIES) - SET(MSVC10_CRT_DIR - "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC100.DebugCRT") + SET(MSVC${v}_CRT_DIR + "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugCRT") SET(__install__libs ${__install__libs} - "${MSVC10_CRT_DIR}/msvcp100d.dll" - "${MSVC10_CRT_DIR}/msvcr100d.dll" + "${MSVC${v}_CRT_DIR}/msvcp${v}0d.dll" + "${MSVC${v}_CRT_DIR}/msvcr${v}0d.dll" ) ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) - ENDIF(MSVC10) + ENDMACRO() + + IF(MSVC10) + MSVCRT_FILES_FOR_VERSION(10) + ENDIF() + + IF(MSVC11) + MSVCRT_FILES_FOR_VERSION(11) + ENDIF() IF(CMAKE_INSTALL_MFC_LIBRARIES) IF(MSVC70) @@ -273,42 +283,52 @@ IF(MSVC) ) ENDIF(MSVC90) - IF(MSVC10) + MACRO(MFC_FILES_FOR_VERSION version) + SET(v "${version}") + IF(CMAKE_INSTALL_DEBUG_LIBRARIES) - SET(MSVC10_MFC_DIR - "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC100.DebugMFC") + SET(MSVC${v}_MFC_DIR + "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugMFC") SET(__install__libs ${__install__libs} - "${MSVC10_MFC_DIR}/mfc100d.dll" - "${MSVC10_MFC_DIR}/mfc100ud.dll" - "${MSVC10_MFC_DIR}/mfcm100d.dll" - "${MSVC10_MFC_DIR}/mfcm100ud.dll" + "${MSVC${v}_MFC_DIR}/mfc${v}0d.dll" + "${MSVC${v}_MFC_DIR}/mfc${v}0ud.dll" + "${MSVC${v}_MFC_DIR}/mfcm${v}0d.dll" + "${MSVC${v}_MFC_DIR}/mfcm${v}0ud.dll" ) ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) - SET(MSVC10_MFC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFC") + SET(MSVC${v}_MFC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFC") IF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) SET(__install__libs ${__install__libs} - "${MSVC10_MFC_DIR}/mfc100.dll" - "${MSVC10_MFC_DIR}/mfc100u.dll" - "${MSVC10_MFC_DIR}/mfcm100.dll" - "${MSVC10_MFC_DIR}/mfcm100u.dll" + "${MSVC${v}_MFC_DIR}/mfc${v}0.dll" + "${MSVC${v}_MFC_DIR}/mfc${v}0u.dll" + "${MSVC${v}_MFC_DIR}/mfcm${v}0.dll" + "${MSVC${v}_MFC_DIR}/mfcm${v}0u.dll" ) ENDIF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) - # include the language dll's for vs10 as well as the actuall dll's - SET(MSVC10_MFCLOC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFCLOC") + # include the language dll's as well as the actuall dll's + SET(MSVC${v}_MFCLOC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFCLOC") SET(__install__libs ${__install__libs} - "${MSVC10_MFCLOC_DIR}/mfc100chs.dll" - "${MSVC10_MFCLOC_DIR}/mfc100cht.dll" - "${MSVC10_MFCLOC_DIR}/mfc100enu.dll" - "${MSVC10_MFCLOC_DIR}/mfc100esp.dll" - "${MSVC10_MFCLOC_DIR}/mfc100deu.dll" - "${MSVC10_MFCLOC_DIR}/mfc100fra.dll" - "${MSVC10_MFCLOC_DIR}/mfc100ita.dll" - "${MSVC10_MFCLOC_DIR}/mfc100jpn.dll" - "${MSVC10_MFCLOC_DIR}/mfc100kor.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0chs.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0cht.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0enu.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0esp.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0deu.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0fra.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0ita.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0jpn.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0kor.dll" ) - ENDIF(MSVC10) + ENDMACRO() + + IF(MSVC10) + MFC_FILES_FOR_VERSION(10) + ENDIF() + + IF(MSVC11) + MFC_FILES_FOR_VERSION(11) + ENDIF() ENDIF(CMAKE_INSTALL_MFC_LIBRARIES) FOREACH(lib -- cgit v0.12 From 5675ec5e493e01e10d9ad8d8b60eac62033f31c2 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 9 Nov 2011 00:01:05 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 38b9719..c032d82 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 08) +SET(KWSYS_DATE_STAMP_DAY 09) -- cgit v0.12 From 0e721e512941c7f7aa51116c3291dfa198b5fccb Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Wed, 9 Nov 2011 06:22:32 -0500 Subject: Modules: Add XRes to FindX11.cmake --- Modules/FindX11.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index 9df3f01..04646c0 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -108,6 +108,7 @@ IF (UNIX) FIND_PATH(X11_XShm_INCLUDE_PATH X11/extensions/XShm.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xrandr_INCLUDE_PATH X11/extensions/Xrandr.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xrender_INCLUDE_PATH X11/extensions/Xrender.h ${X11_INC_SEARCH_PATH}) + FIND_PATH(X11_XRes_INCLUDE_PATH X11/extensions/XRes.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xscreensaver_INCLUDE_PATH X11/extensions/scrnsaver.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xshape_INCLUDE_PATH X11/extensions/shape.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xutil_INCLUDE_PATH X11/Xutil.h ${X11_INC_SEARCH_PATH}) @@ -136,6 +137,7 @@ IF (UNIX) FIND_LIBRARY(X11_Xpm_LIB Xpm ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xrandr_LIB Xrandr ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xrender_LIB Xrender ${X11_LIB_SEARCH_PATH}) + FIND_LIBRARY(X11_XRes_LIB XRes ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xscreensaver_LIB Xss ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xt_LIB Xt ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_XTest_LIB Xtst ${X11_LIB_SEARCH_PATH}) @@ -250,6 +252,11 @@ IF (UNIX) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xrender_INCLUDE_PATH}) ENDIF (X11_Xrender_INCLUDE_PATH AND X11_Xrender_LIB) + IF (X11_XRes_INCLUDE_PATH AND X11_XRes_LIB) + SET(X11_XRes_FOUND TRUE) + SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XRes_INCLUDE_PATH}) + ENDIF (X11_XRes_INCLUDE_PATH AND X11_XRes_LIB) + IF (X11_Xrandr_INCLUDE_PATH AND X11_Xrandr_LIB) SET(X11_Xrandr_FOUND TRUE) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xrandr_INCLUDE_PATH}) @@ -424,6 +431,8 @@ IF (UNIX) X11_Xdamage_INCLUDE_PATH X11_Xrender_LIB X11_Xrender_INCLUDE_PATH + X11_XRes_LIB + X11_XRes_INCLUDE_PATH X11_Xxf86misc_LIB X11_xf86misc_INCLUDE_PATH X11_xf86vmode_INCLUDE_PATH -- cgit v0.12 From 537020f9581d36c436d18e30f98d58f0ef5924cc Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 9 Nov 2011 13:31:05 -0500 Subject: Tests: Nudge MFC test to pass on VS 6 dashboards (#11213) InstallRequiredSystemLibraries does not install any dlls when used with VS 6 dashboards. Modify the ValidateBuild script to expect only 1 file when building with VS 6. Using "-DCMAKE_INSTALL_PREFIX=" does not work when evaluates to a long enough string. However, using "-DCMAKE_INSTALL_PREFIX:PATH=" does work, even with the longer strings. So: make sure to include the ":PATH" when using this construct with ExternalProject calls so that they may install to the proper location on VS 6 builds. All existing calls that match "CMAKE_INSTALL_PREFIX.*INSTALL_DIR" include the ":PATH" after this commit. By the way: https://twitter.com/DLRdave/status/134339505397309440 --- Tests/ExternalProject/Example/CMakeLists.txt | 2 +- Tests/MFC/CMakeLists.txt | 4 ++-- Tests/MFC/ValidateBuild.cmake.in | 12 ++++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Tests/ExternalProject/Example/CMakeLists.txt b/Tests/ExternalProject/Example/CMakeLists.txt index 2cadd7d..69ebaaf 100644 --- a/Tests/ExternalProject/Example/CMakeLists.txt +++ b/Tests/ExternalProject/Example/CMakeLists.txt @@ -6,6 +6,6 @@ include(ExternalProject) ExternalProject_Add( cmake281 URL http://www.cmake.org/files/v2.8/cmake-2.8.1.tar.gz - CMAKE_ARGS -D CMAKE_INSTALL_PREFIX= + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= BUILD_COMMAND "" ) diff --git a/Tests/MFC/CMakeLists.txt b/Tests/MFC/CMakeLists.txt index df3149a..62ff749 100644 --- a/Tests/MFC/CMakeLists.txt +++ b/Tests/MFC/CMakeLists.txt @@ -17,7 +17,7 @@ ExternalProject_Add(mfcShared PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.SharedMfcDll.txt /CMakeLists.txt - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= ) @@ -33,7 +33,7 @@ ExternalProject_Add(mfcStatic PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.StaticMfcLib.txt /CMakeLists.txt - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= ) diff --git a/Tests/MFC/ValidateBuild.cmake.in b/Tests/MFC/ValidateBuild.cmake.in index 68de549..ed923f5 100644 --- a/Tests/MFC/ValidateBuild.cmake.in +++ b/Tests/MFC/ValidateBuild.cmake.in @@ -31,9 +31,17 @@ message(STATUS "===== mfcShared install tree =====") file(GLOB_RECURSE files "${binary_dir}/mfcShared-prefix/bin/*.*") message(STATUS "mfcShared files='${files}'") list(LENGTH files len) -if(len LESS 3) + +set(msvc6 "@MSVC60@") +if("${msvc6}" STREQUAL "1") + set(expected_minimum_file_count 1) +else() + set(expected_minimum_file_count 3) +endif() + +if(len LESS ${expected_minimum_file_count}) message(FATAL_ERROR - "len='${len}' is less than '3' (count of shared 'bin' files)") + "len='${len}' is less than '${expected_minimum_file_count}' (count of shared 'bin' files)") endif() foreach(f ${files}) message(STATUS "file '${f}'") -- cgit v0.12 From 812dab067e5ea053ca36db6089507db7a5de437e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 9 Nov 2011 23:17:20 +0100 Subject: Don't assume the existence of QT_MAJOR_VERSION. Also handle Qt5SrcTools_MAJOR_VERSION. --- Modules/AutomocInfo.cmake.in | 1 + Source/cmQtAutomoc.cxx | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutomocInfo.cmake.in index 2dc3aa2..5d440fb 100644 --- a/Modules/AutomocInfo.cmake.in +++ b/Modules/AutomocInfo.cmake.in @@ -10,4 +10,5 @@ set(AM_QT_MOC_EXECUTABLE "@QT_MOC_EXECUTABLE@") set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/") set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/") set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" ) +set(AM_Qt5SrcTools_VERSION_MAJOR "@Qt5SrcTools_VERSION_MAJOR@" ) set(AM_TARGET_NAME "@_moc_target_name@") diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index fea2e79..045b439 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -51,6 +51,10 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) const char* targetName = target->GetName(); // don't do anything if there is no Qt4: std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); + if (qtMajorVersion == "") + { + qtMajorVersion = makefile->GetSafeDefinition("Qt5SrcTools_VERSION_MAJOR"); + } if (qtMajorVersion != "4" && qtMajorVersion != "5") { return; @@ -215,6 +219,10 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, } this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR"); + if (this->QtMajorVersion == "") + { + this->QtMajorVersion = makefile->GetSafeDefinition("AM_Qt5SrcTools_VERSION_MAJOR"); + } this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); this->IncludeProjectDirsBefore = makefile->IsOn( -- cgit v0.12 From 74b9392eb9311639612d175bdc1c811560495659 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 9 Nov 2011 23:26:09 +0100 Subject: Update comments and method names to not be Qt4 specific. --- Source/cmQtAutomoc.cxx | 6 +++--- Source/cmQtAutomoc.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 045b439..861e5bb 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -49,7 +49,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) { cmMakefile* makefile = target->GetMakefile(); const char* targetName = target->GetName(); - // don't do anything if there is no Qt4: + // don't do anything if there is no Qt4 or Qt5SrcTools (which contains moc): std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); if (qtMajorVersion == "") { @@ -176,7 +176,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory) if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") { - this->RunAutomocQt4(); + this->RunAutomoc(); } this->WriteOldMocDefinitionsFile(targetDirectory); @@ -380,7 +380,7 @@ void cmQtAutomoc::Init() } -bool cmQtAutomoc::RunAutomocQt4() +bool cmQtAutomoc::RunAutomoc() { if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str()) || (this->OldMocDefinitionsStr != this->Join(this->MocDefinitions, ' '))) diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index c3550a4..59eaac7 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -35,7 +35,7 @@ private: const char* targetDirectory); void WriteOldMocDefinitionsFile(const char* targetDirectory); - bool RunAutomocQt4(); + bool RunAutomoc(); bool GenerateMoc(const std::string& sourceFile, const std::string& mocFileName); void ParseCppFile(const std::string& absFilename, -- cgit v0.12 From bafe5cc6e90ebb510dfe992c8a7a1eca55826813 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 10 Nov 2011 00:57:21 +0100 Subject: Fix style. --- Source/cmQtAutomoc.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 861e5bb..72249bc 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -53,7 +53,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); if (qtMajorVersion == "") { - qtMajorVersion = makefile->GetSafeDefinition("Qt5SrcTools_VERSION_MAJOR"); + qtMajorVersion = makefile->GetSafeDefinition("Qt5SrcTools_VERSION_MAJOR"); } if (qtMajorVersion != "4" && qtMajorVersion != "5") { @@ -221,7 +221,8 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR"); if (this->QtMajorVersion == "") { - this->QtMajorVersion = makefile->GetSafeDefinition("AM_Qt5SrcTools_VERSION_MAJOR"); + this->QtMajorVersion = makefile->GetSafeDefinition( + "AM_Qt5SrcTools_VERSION_MAJOR"); } this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); -- cgit v0.12 From 131d0ae4fc4d51fa8175bc3dfd323efccb1cc951 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 10 Nov 2011 00:01:03 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index c032d82..82fa8cd 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 09) +SET(KWSYS_DATE_STAMP_DAY 10) -- cgit v0.12 From ac39e9c765c2b16a42c0f3bb996fd42492b791c4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Nov 2011 07:55:53 -0500 Subject: Update main Copyright.txt year range for 2011 --- Copyright.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Copyright.txt b/Copyright.txt index 35f7e4b..83a2482 100644 --- a/Copyright.txt +++ b/Copyright.txt @@ -1,5 +1,5 @@ CMake - Cross Platform Makefile Generator -Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +Copyright 2000-2011 Kitware, Inc., Insight Software Consortium All rights reserved. Redistribution and use in source and binary forms, with or without -- cgit v0.12 From 1c4ba48e4417c60abb1b0da0e9dd270e06a893d5 Mon Sep 17 00:00:00 2001 From: Mateusz Loskot Date: Thu, 10 Nov 2011 02:04:25 +0000 Subject: FindBoost: Use MSVC11 to find Boost on Windows (#12568) While at it, add recent Boost versions. --- Modules/FindBoost.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 5ccbd6b..ea60354 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -65,7 +65,7 @@ # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0, # 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0, -# 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1 +# 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1, 1.47, 1.47.0, 1.48, 1.48.0 # # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should # add both 1.x and 1.x.0 as shown above. Official Boost include directories @@ -449,7 +449,7 @@ else(Boost_FIND_VERSION_EXACT) # The user has not requested an exact version. Among known # versions, find those that are acceptable to the user request. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} - "1.46.1" + "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1" "1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" @@ -750,10 +750,12 @@ else(_boost_IN_CACHE) else() set (_boost_COMPILER "-il") endif() - elseif (MSVC90) - set(_boost_COMPILER "-vc90") + elseif (MSVC11) + set(_boost_COMPILER "-vc110") elseif (MSVC10) set(_boost_COMPILER "-vc100") + elseif (MSVC90) + set(_boost_COMPILER "-vc90") elseif (MSVC80) set(_boost_COMPILER "-vc80") elseif (MSVC71) -- cgit v0.12 From b90b6969f68950d57e6ba23fa92780c78c804218 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 11 Nov 2011 00:01:04 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 82fa8cd..23d2fee 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 10) +SET(KWSYS_DATE_STAMP_DAY 11) -- cgit v0.12 From f30f9a500c5e5aeb053c41307dab9987735570dd Mon Sep 17 00:00:00 2001 From: Ondrej Balaz Date: Fri, 11 Nov 2011 19:13:55 +0000 Subject: FindBISON: Fix bison++ version parsing to avoid "Offending entry" I've just found out that use of FindBISON.cmake shipped with CMake 2.8 on system where bison++ is default bison executable (e.g. Debian Linux) will result in corrupted CMakeCache.txt file and parse error due to "Offending entry" As FindBISON.cmake logic used to obtain installed bison executable version is tailored to match only the message used in GNU Bison it fails on absolutely different Bison++ version message and whole version message including \n characters is stored into BISON_VERSION which is then dumped into CMakeCache.txt, so everything after first \n character makes "Offending entry". --- Modules/FindBISON.cmake | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index e855a27..25fd51d 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -67,8 +67,17 @@ IF(BISON_EXECUTABLE) IF(NOT ${BISON_version_result} EQUAL 0) MESSAGE(SEND_ERROR "Command \"${BISON_EXECUTABLE} --version\" failed with output:\n${BISON_version_error}") ELSE() - STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1" - BISON_VERSION "${BISON_version_output}") + # Bison++ + IF(${BISON_version_output} MATCHES "^bison\\+\\+") + STRING(REGEX REPLACE "^bison\\+\\+ Version ([^,]+).*" "\\1" + BISON_VERSION "${BISON_version_output}") + # GNU Bison + ELSEIF(${BISON_version_output} MATCHES "^bison[^+]") + STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1" + BISON_VERSION "${BISON_version_output}") + ELSE() + SET(BISON_VERSION "unknown") + ENDIF() ENDIF() # internal macro -- cgit v0.12 From 553acec76b2dc333a418e0218d65dacb76e30a81 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 12 Nov 2011 07:59:53 -0500 Subject: KWIML: Avoid redefining _CRT_SECURE_NO_DEPRECATE in test.h If the including project defines this macro do not re-define it in the test header. --- test/test.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test.h b/test/test.h index 8abb195..b87a0e7 100644 --- a/test/test.h +++ b/test/test.h @@ -28,7 +28,9 @@ #define KWIML_HEADER1(x) /* Quiet MS standard library deprecation warnings. */ -#define _CRT_SECURE_NO_DEPRECATE +#ifndef _CRT_SECURE_NO_DEPRECATE +# define _CRT_SECURE_NO_DEPRECATE +#endif #else # error "test.h included multiple times." -- cgit v0.12 From 6d12ab3f897310354bbaffd7a07b0458f489a7df Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 12 Nov 2011 09:39:40 -0500 Subject: KWIML: Suppress printf/scanf format warnings in test KWIML defines format string macros matching the fixed-sized types. This test checks that they behave as expected and that the arguments match the *sizes* expected by the format strings. --- test/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index aaff9e9..15816cf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,6 +18,13 @@ set_property(DIRECTORY "KWIML_HEADER(%)=<${KWIML}/%>" ) +# Suppress printf/scanf format warnings; we test if the sizes match. +foreach(lang C CXX) + if(KWIML_LANGUAGE_${lang} AND "${CMAKE_${lang}_COMPILER_ID}" STREQUAL GNU) + set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -Wno-format") + endif() +endforeach() + if(KWIML_LANGUAGE_C) set(test_srcs test.c) else() -- cgit v0.12 From bcc06d498ccdc6af80544b415678f4385f99279b Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 12 Nov 2011 10:03:33 -0500 Subject: KWIML: No INT_SCN*8 on SunPro compiler The Sun compiler does not document support for SCN*8 format (%hh*). It works only on platforms that happen to provide a runtime library that supports the format. --- INT.h.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/INT.h.in b/INT.h.in index 4a6298a..5fca08f 100644 --- a/INT.h.in +++ b/INT.h.in @@ -191,9 +191,7 @@ An includer may test the following macros after inclusion: #endif #if defined(__INTEL_COMPILER) -#elif defined(__SUNPRO_C) && __SUNPRO_C < 0x570 -# define @KWIML@_INT__NO_SCN8 -#elif defined(__SUNPRO_CC) && __SUNPRO_CC < 0x570 +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) # define @KWIML@_INT__NO_SCN8 #elif defined(__HP_cc) || defined(__HP_aCC) # define @KWIML@_INT__NO_SCN8 -- cgit v0.12 From 9aa10f8045b2c8cc68107d2dee2b813469848684 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 13 Nov 2011 11:20:53 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 23d2fee..36edd53 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 11) +SET(KWSYS_DATE_STAMP_DAY 13) -- cgit v0.12 From 2f8f7ec56ad50d783e8b09d132263657d3462339 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 13 Nov 2011 12:24:46 -0500 Subject: KWSys: Remove trailing whitespace in SystemTools.cxx --- Source/kwsys/SystemTools.cxx | 256 +++++++++++++++++++++---------------------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 1bf19c0..b6c3fda 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -128,7 +128,7 @@ public: #include #include #define _unlink unlink -#endif +#endif /* The maximum length of a file name. */ #if defined(PATH_MAX) @@ -168,9 +168,9 @@ static inline char *realpath(const char *path, char *resolved_path) snprintf(resolved_path, maxlen, "%s", path); BPath normalized(resolved_path, NULL, true); const char *resolved = normalized.Path(); - if (resolved != NULL) // NULL == No such file. + if (resolved != NULL) // NULL == No such file. { - if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen) + if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen) { return resolved_path; } @@ -179,7 +179,7 @@ static inline char *realpath(const char *path, char *resolved_path) } #endif -#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) +#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) inline int Mkdir(const char* dir) { return _mkdir(dir); @@ -300,7 +300,7 @@ double SystemTools::GetTime(void) #endif } -class SystemToolsTranslationMap : +class SystemToolsTranslationMap : public kwsys_stl::map { }; @@ -392,7 +392,7 @@ kwsysDeletingCharVector::~kwsysDeletingCharVector() #endif } bool SystemTools::PutEnv(const char* value) -{ +{ static kwsysDeletingCharVector localEnvironment; char* envVar = new char[strlen(value)+1]; strcpy(envVar, value); @@ -414,7 +414,7 @@ const char* SystemTools::GetExecutableExtension() return ".exe"; #else return ""; -#endif +#endif } @@ -482,7 +482,7 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, { const char *src = source.c_str(); char *searchPos = const_cast(strstr(src,replace)); - + // get out quick if string is not found if (!searchPos) { @@ -499,7 +499,7 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, char *orig = strdup(src); char *currentPos = orig; searchPos = searchPos - src + orig; - + // initialize the result source.erase(source.begin(),source.end()); do @@ -551,7 +551,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode, #endif // Read a registry value. -// Example : +// Example : // HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath // => will return the data of the "default" value of the key // HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root @@ -580,7 +580,7 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, second = primary.substr(start+1, valuenamepos-start-1); primary = primary.substr(0, start); - + HKEY primaryKey = HKEY_CURRENT_USER; if (primary == "HKEY_CURRENT_USER") { @@ -602,11 +602,11 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, { primaryKey = HKEY_USERS; } - + HKEY hKey; - if(RegOpenKeyEx(primaryKey, - second.c_str(), - 0, + if(RegOpenKeyEx(primaryKey, + second.c_str(), + 0, SystemToolsMakeRegistryMode(KEY_READ, view), &hKey) != ERROR_SUCCESS) { @@ -617,11 +617,11 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, DWORD dwType, dwSize; dwSize = 1023; char data[1024]; - if(RegQueryValueEx(hKey, - (LPTSTR)valuename.c_str(), - NULL, - &dwType, - (BYTE *)data, + if(RegQueryValueEx(hKey, + (LPTSTR)valuename.c_str(), + NULL, + &dwType, + (BYTE *)data, &dwSize) == ERROR_SUCCESS) { if (dwType == REG_SZ) @@ -656,7 +656,7 @@ bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &, // Write a registry value. -// Example : +// Example : // HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath // => will set the data of the "default" value of the key // HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root @@ -669,7 +669,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, kwsys_stl::string primary = key; kwsys_stl::string second; kwsys_stl::string valuename; - + size_t start = primary.find("\\"); if (start == kwsys_stl::string::npos) { @@ -684,7 +684,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, second = primary.substr(start+1, valuenamepos-start-1); primary = primary.substr(0, start); - + HKEY primaryKey = HKEY_CURRENT_USER; if (primary == "HKEY_CURRENT_USER") { @@ -706,13 +706,13 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, { primaryKey = HKEY_USERS; } - + HKEY hKey; DWORD dwDummy; char lpClass[] = ""; - if(RegCreateKeyEx(primaryKey, - second.c_str(), - 0, + if(RegCreateKeyEx(primaryKey, + second.c_str(), + 0, lpClass, REG_OPTION_NON_VOLATILE, SystemToolsMakeRegistryMode(KEY_WRITE, view), @@ -723,11 +723,11 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, return false; } - if(RegSetValueEx(hKey, - (LPTSTR)valuename.c_str(), - 0, - REG_SZ, - (CONST BYTE *)value, + if(RegSetValueEx(hKey, + (LPTSTR)valuename.c_str(), + 0, + REG_SZ, + (CONST BYTE *)value, (DWORD)(strlen(value) + 1)) == ERROR_SUCCESS) { return true; @@ -742,7 +742,7 @@ bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64) #endif // Delete a registry value. -// Example : +// Example : // HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath // => will delete the data of the "default" value of the key // HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root @@ -754,7 +754,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) kwsys_stl::string primary = key; kwsys_stl::string second; kwsys_stl::string valuename; - + size_t start = primary.find("\\"); if (start == kwsys_stl::string::npos) { @@ -769,7 +769,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) second = primary.substr(start+1, valuenamepos-start-1); primary = primary.substr(0, start); - + HKEY primaryKey = HKEY_CURRENT_USER; if (primary == "HKEY_CURRENT_USER") { @@ -791,11 +791,11 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) { primaryKey = HKEY_USERS; } - + HKEY hKey; - if(RegOpenKeyEx(primaryKey, - second.c_str(), - 0, + if(RegOpenKeyEx(primaryKey, + second.c_str(), + 0, SystemToolsMakeRegistryMode(KEY_WRITE, view), &hKey) != ERROR_SUCCESS) { @@ -803,7 +803,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) } else { - if(RegDeleteValue(hKey, + if(RegDeleteValue(hKey, (LPTSTR)valuename.c_str()) == ERROR_SUCCESS) { RegCloseKey(hKey); @@ -824,17 +824,17 @@ bool SystemTools::SameFile(const char* file1, const char* file2) #ifdef _WIN32 HANDLE hFile1, hFile2; - hFile1 = CreateFile( file1, - GENERIC_READ, + hFile1 = CreateFile( file1, + GENERIC_READ, FILE_SHARE_READ , NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL ); - hFile2 = CreateFile( file2, - GENERIC_READ, - FILE_SHARE_READ, + hFile2 = CreateFile( file2, + GENERIC_READ, + FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, @@ -868,10 +868,10 @@ bool SystemTools::SameFile(const char* file1, const char* file2) { // see if the files are the same file // check the device inode and size - if(memcmp(&fileStat2.st_dev, &fileStat1.st_dev, sizeof(fileStat1.st_dev)) == 0 && + if(memcmp(&fileStat2.st_dev, &fileStat1.st_dev, sizeof(fileStat1.st_dev)) == 0 && memcmp(&fileStat2.st_ino, &fileStat1.st_ino, sizeof(fileStat1.st_ino)) == 0 && - fileStat2.st_size == fileStat1.st_size - ) + fileStat2.st_size == fileStat1.st_size + ) { return true; } @@ -1068,11 +1068,11 @@ kwsys_stl::string SystemTools::CapitalizedWords(const kwsys_stl::string& s) #if defined(_MSC_VER) && defined (_MT) && defined (_DEBUG) // MS has an assert that will fail if s[i] < 0; setting // LC_CTYPE using setlocale() does *not* help. Painful. - if ((int)s[i] >= 0 && isalpha(s[i]) && + if ((int)s[i] >= 0 && isalpha(s[i]) && (i == 0 || ((int)s[i - 1] >= 0 && isspace(s[i - 1])))) #else if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1]))) -#endif +#endif { n[i] = static_cast(toupper(s[i])); } @@ -1089,11 +1089,11 @@ kwsys_stl::string SystemTools::UnCapitalizedWords(const kwsys_stl::string& s) #if defined(_MSC_VER) && defined (_MT) && defined (_DEBUG) // MS has an assert that will fail if s[i] < 0; setting // LC_CTYPE using setlocale() does *not* help. Painful. - if ((int)s[i] >= 0 && isalpha(s[i]) && + if ((int)s[i] >= 0 && isalpha(s[i]) && (i == 0 || ((int)s[i - 1] >= 0 && isspace(s[i - 1])))) #else if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1]))) -#endif +#endif { n[i] = static_cast(tolower(s[i])); } @@ -1171,7 +1171,7 @@ char* SystemTools::AppendStrings( return newstr; } -// Return a lower case string +// Return a lower case string kwsys_stl::string SystemTools::LowerCase(const kwsys_stl::string& s) { kwsys_stl::string n; @@ -1183,7 +1183,7 @@ kwsys_stl::string SystemTools::LowerCase(const kwsys_stl::string& s) return n; } -// Return a lower case string +// Return a lower case string kwsys_stl::string SystemTools::UpperCase(const kwsys_stl::string& s) { kwsys_stl::string n; @@ -1313,7 +1313,7 @@ const char* SystemTools::FindLastString(const char* str1, const char* str2) { return NULL; } - + size_t len1 = strlen(str1), len2 = strlen(str2); if (len1 >= len2) { @@ -1341,8 +1341,8 @@ char* SystemTools::DuplicateString(const char* str) return NULL; } -// Return a cropped string -kwsys_stl::string SystemTools::CropString(const kwsys_stl::string& s, +// Return a cropped string +kwsys_stl::string SystemTools::CropString(const kwsys_stl::string& s, size_t max_len) { if (!s.size() || max_len == 0 || max_len >= s.size()) @@ -1386,7 +1386,7 @@ kwsys_stl::vector SystemTools::SplitString(const char* p, char se if(isPath && path[0] == '/') { path.erase(path.begin()); - paths.push_back("/"); + paths.push_back("/"); } kwsys_stl::string::size_type pos1 = 0; kwsys_stl::string::size_type pos2 = path.find(sep, pos1+1); @@ -1395,9 +1395,9 @@ kwsys_stl::vector SystemTools::SplitString(const char* p, char se paths.push_back(path.substr(pos1, pos2-pos1)); pos1 = pos2+1; pos2 = path.find(sep, pos1+1); - } + } paths.push_back(path.substr(pos1, pos2-pos1)); - + return paths; } @@ -1411,11 +1411,11 @@ int SystemTools::EstimateFormatLength(const char *format, va_list ap) // Quick-hack attempt at estimating the length of the string. // Should never under-estimate. - + // Start with the length of the format string itself. size_t length = strlen(format); - + // Increase the length for every argument in the format. const char* cur = format; @@ -1447,7 +1447,7 @@ int SystemTools::EstimateFormatLength(const char *format, va_list ap) { // Assume the argument contributes no more than 64 characters. length += 64; - + // Eat the argument. static_cast(va_arg(ap, double)); } break; @@ -1455,24 +1455,24 @@ int SystemTools::EstimateFormatLength(const char *format, va_list ap) { // Assume the argument contributes no more than 64 characters. length += 64; - + // Eat the argument. static_cast(va_arg(ap, int)); } break; } } - + // Move past the characters just tested. ++cur; } } - + return static_cast(length); } kwsys_stl::string SystemTools::EscapeChars( - const char *str, - const char *chars_to_escape, + const char *str, + const char *chars_to_escape, char escape_char) { kwsys_stl::string n; @@ -1529,7 +1529,7 @@ static void ConvertVMSToUnix(kwsys_stl::string& path) } #endif -// convert windows slashes to unix slashes +// convert windows slashes to unix slashes void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path) { const char* pathCString = path.c_str(); @@ -1596,7 +1596,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path) } } #endif - // remove trailing slash if the path is more than + // remove trailing slash if the path is more than // a single / pathCString = path.c_str(); if(path.size() > 1 && *(pathCString+(path.size()-1)) == '/') @@ -1614,7 +1614,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path) kwsys_stl::string SystemTools::ConvertToUnixOutputPath(const char* path) { kwsys_stl::string ret = path; - + // remove // except at the beginning might be a cygwin drive kwsys_stl::string::size_type pos=1; while((pos = ret.find("//", pos)) != kwsys_stl::string::npos) @@ -1652,7 +1652,7 @@ kwsys_stl::string SystemTools::ConvertToOutputPath(const char* path) // remove double slashes not at the start kwsys_stl::string SystemTools::ConvertToWindowsOutputPath(const char* path) -{ +{ kwsys_stl::string ret; // make it big enough for all of path and double quotes ret.reserve(strlen(path)+3); @@ -1738,13 +1738,13 @@ bool SystemTools::FilesDiffer(const char* source, const char* destination) { struct stat statSource; - if (stat(source, &statSource) != 0) + if (stat(source, &statSource) != 0) { return true; } struct stat statDestination; - if (stat(destination, &statDestination) != 0) + if (stat(destination, &statDestination) != 0) { return true; } @@ -1790,7 +1790,7 @@ bool SystemTools::FilesDiffer(const char* source, { return true; } - + // If this block differs the file differs. if(memcmp(static_cast(source_buf), static_cast(dest_buf), @@ -1849,7 +1849,7 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) // Open files #if defined(_WIN32) || defined(__CYGWIN__) - kwsys_ios::ifstream fin(source, + kwsys_ios::ifstream fin(source, kwsys_ios::ios::binary | kwsys_ios::ios::in); #else kwsys_ios::ifstream fin(source); @@ -1858,7 +1858,7 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) { return false; } - + // try and remove the destination file so that read only destination files // can be written to. // If the remove fails continue so that files in read only directories @@ -1866,17 +1866,17 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) SystemTools::RemoveFile(destination); #if defined(_WIN32) || defined(__CYGWIN__) - kwsys_ios::ofstream fout(destination, + kwsys_ios::ofstream fout(destination, kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc); #else - kwsys_ios::ofstream fout(destination, + kwsys_ios::ofstream fout(destination, kwsys_ios::ios::out | kwsys_ios::ios::trunc); #endif if(!fout) { return false; } - + // This copy loop is very sensitive on certain platforms with // slightly broken stream libraries (like HPUX). Normally, it is // incorrect to not check the error condition on the fin.read() @@ -1890,12 +1890,12 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) fout.write(buffer, fin.gcount()); } } - + // Make sure the operating system has finished writing the file // before closing it. This will ensure the file is finished before // the check below. fout.flush(); - + fin.close(); fout.close(); @@ -1979,7 +1979,7 @@ bool SystemTools::CopyADirectory(const char* source, const char* destination, unsigned long SystemTools::FileLength(const char* filename) { struct stat fs; - if (stat(filename, &fs) != 0) + if (stat(filename, &fs) != 0) { return 0; } @@ -2225,7 +2225,7 @@ kwsys_stl::string SystemTools { // Add the system search path to our path first kwsys_stl::vector path; - if (!no_system_path) + if (!no_system_path) { SystemTools::GetPath(path, "CMAKE_FILE_PATH"); SystemTools::GetPath(path); @@ -2340,7 +2340,7 @@ kwsys_stl::string SystemTools::FindProgram( // first try with extensions if the os supports them if(extensions.size()) { - for(kwsys_stl::vector::iterator i = + for(kwsys_stl::vector::iterator i = extensions.begin(); i != extensions.end(); ++i) { tryPath = name; @@ -2368,7 +2368,7 @@ kwsys_stl::string SystemTools::FindProgram( } // now add the additional paths { - for(kwsys_stl::vector::const_iterator i = + for(kwsys_stl::vector::const_iterator i = userPaths.begin(); i != userPaths.end(); ++i) { path.push_back(*i); @@ -2397,7 +2397,7 @@ kwsys_stl::string SystemTools::FindProgram( // first try with extensions if(extensions.size()) { - for(kwsys_stl::vector::iterator ext + for(kwsys_stl::vector::iterator ext = extensions.begin(); ext != extensions.end(); ++ext) { tryPath = *p; @@ -2962,7 +2962,7 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot } // split up both paths into arrays of strings using / as a separator - kwsys_stl::vector localSplit = SystemTools::SplitString(local, '/', true); + kwsys_stl::vector localSplit = SystemTools::SplitString(local, '/', true); kwsys_stl::vector remoteSplit = SystemTools::SplitString(remote, '/', true); kwsys_stl::vector commonPath; // store shared parts of path in this array kwsys_stl::vector finalPath; // store the final relative path here @@ -3019,7 +3019,7 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot } } kwsys_stl::string relativePath; // result string - // now turn the array of directories into a unix path by puttint / + // now turn the array of directories into a unix path by puttint / // between each entry that does not already have one for(kwsys_stl::vector::iterator vit1 = finalPath.begin(); vit1 != finalPath.end(); ++vit1) @@ -3396,7 +3396,7 @@ kwsys_stl::string SystemTools::GetFilenamePath(const kwsys_stl::string& filename { kwsys_stl::string fn = filename; SystemTools::ConvertToUnixSlashes(fn); - + kwsys_stl::string::size_type slash_pos = fn.rfind("/"); if(slash_pos != kwsys_stl::string::npos) { @@ -3515,7 +3515,7 @@ SystemTools::GetFilenameWithoutLastExtension(const kwsys_stl::string& filename) } bool SystemTools::FileHasSignature(const char *filename, - const char *signature, + const char *signature, long offset) { if (!filename || !signature) @@ -3547,9 +3547,9 @@ bool SystemTools::FileHasSignature(const char *filename, return res; } -SystemTools::FileTypeEnum +SystemTools::FileTypeEnum SystemTools::DetectFileType(const char *filename, - unsigned long length, + unsigned long length, double percent_bin) { if (!filename || percent_bin < 0) @@ -3577,13 +3577,13 @@ SystemTools::DetectFileType(const char *filename, // Loop over contents and count size_t text_count = 0; - + const unsigned char *ptr = buffer; const unsigned char *buffer_end = buffer + read_length; while (ptr != buffer_end) { - if ((*ptr >= 0x20 && *ptr <= 0x7F) || + if ((*ptr >= 0x20 && *ptr <= 0x7F) || *ptr == '\n' || *ptr == '\r' || *ptr == '\t') @@ -3595,7 +3595,7 @@ SystemTools::DetectFileType(const char *filename, delete [] buffer; - double current_percent_bin = + double current_percent_bin = (static_cast(read_length - text_count) / static_cast(read_length)); @@ -3607,8 +3607,8 @@ SystemTools::DetectFileType(const char *filename, return SystemTools::FileTypeText; } -bool SystemTools::LocateFileInDir(const char *filename, - const char *dir, +bool SystemTools::LocateFileInDir(const char *filename, + const char *dir, kwsys_stl::string& filename_found, int try_filename_dirs) { @@ -3621,7 +3621,7 @@ bool SystemTools::LocateFileInDir(const char *filename, kwsys_stl::string filename_base = SystemTools::GetFilenameName(filename); - // Check if 'dir' is really a directory + // Check if 'dir' is really a directory // If win32 and matches something like C:, accept it as a dir kwsys_stl::string real_dir; @@ -3645,7 +3645,7 @@ bool SystemTools::LocateFileInDir(const char *filename, if (filename_base.size() && dir) { size_t dir_len = strlen(dir); - int need_slash = + int need_slash = (dir_len && dir[dir_len - 1] != '/' && dir[dir_len - 1] != '\\'); kwsys_stl::string temp = dir; @@ -3676,7 +3676,7 @@ bool SystemTools::LocateFileInDir(const char *filename, filename_dir = SystemTools::GetFilenamePath(filename_dir); filename_dir_base = SystemTools::GetFilenameName(filename_dir); #if defined( _WIN32 ) - if (!filename_dir_base.size() || + if (!filename_dir_base.size() || filename_dir_base[filename_dir_base.size() - 1] == ':') #else if (!filename_dir_base.size()) @@ -3700,7 +3700,7 @@ bool SystemTools::LocateFileInDir(const char *filename, } while (!res && filename_dir_base.size()); } } - + return res; } @@ -3746,12 +3746,12 @@ bool SystemTools::FileIsFullPath(const char* in_name) bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath) { -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) const int size = int(strlen(path)) +1; // size of return char *buffer = new char[size]; // create a buffer char *tempPath = new char[size]; // create a buffer int ret; - + // if the path passed in has quotes around it, first remove the quotes if (path[0] == '"' && path[strlen(path)-1] == '"') { @@ -3762,7 +3762,7 @@ bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath) { strcpy(tempPath,path); } - + buffer[0] = 0; ret = GetShortPathName(tempPath, buffer, size); @@ -3785,7 +3785,7 @@ bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath) #endif } -void SystemTools::SplitProgramFromArgs(const char* path, +void SystemTools::SplitProgramFromArgs(const char* path, kwsys_stl::string& program, kwsys_stl::string& args) { // see if this is a full path to a program @@ -3797,7 +3797,7 @@ void SystemTools::SplitProgramFromArgs(const char* path, return; } // Try to find the program in the path, note the program - // may have spaces in its name so we have to look for it + // may have spaces in its name so we have to look for it kwsys_stl::vector e; kwsys_stl::string findProg = SystemTools::FindProgram(path, e); if(findProg.size()) @@ -3828,7 +3828,7 @@ void SystemTools::SplitProgramFromArgs(const char* path, args = dir.substr(spacePos, dir.size()-spacePos); return; } - // Now try and find the the program in the path + // Now try and find the the program in the path findProg = SystemTools::FindProgram(tryProg.c_str(), e); if(findProg.size()) { @@ -4203,23 +4203,23 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() if (!bOsVersionInfoEx) { osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (!GetVersionEx((OSVERSIONINFO *)&osvi)) + if (!GetVersionEx((OSVERSIONINFO *)&osvi)) { return 0; } } - + switch (osvi.dwPlatformId) { // Test for the Windows NT product family. case VER_PLATFORM_WIN32_NT: - + // Test for the specific product family. if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) { -#if (_MSC_VER >= 1300) +#if (_MSC_VER >= 1300) if (osvi.wProductType == VER_NT_WORKSTATION) { res += "Microsoft Windows Vista"; @@ -4259,7 +4259,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() { // Test for the workstation type. -#if (_MSC_VER >= 1300) +#if (_MSC_VER >= 1300) if (osvi.wProductType == VER_NT_WORKSTATION) { if (osvi.dwMajorVersion == 4) @@ -4278,7 +4278,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() } } } - + // Test for the server type. else if (osvi.wProductType == VER_NT_SERVER) @@ -4302,7 +4302,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() res += " Standard Edition"; } } - + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) { if (osvi.wSuiteMask & VER_SUITE_DATACENTER) @@ -4319,7 +4319,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() } } - else if (osvi.dwMajorVersion <= 4) // Windows NT 4.0 + else if (osvi.dwMajorVersion <= 4) // Windows NT 4.0 { if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { @@ -4336,7 +4336,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() // Test for specific product on Windows NT 4.0 SP5 and earlier - else + else { HKEY hKey; #define BUFSIZE 80 @@ -4386,7 +4386,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() // Display service pack (if any) and build number. - if (osvi.dwMajorVersion == 4 && + if (osvi.dwMajorVersion == 4 && lstrcmpi(osvi.szCSDVersion, "Service Pack 6") == 0) { HKEY hKey; @@ -4415,7 +4415,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() res += buffer; res += ")"; } - + RegCloseKey(hKey); } else // Windows NT 3.51 and earlier or Windows 2000 and later @@ -4455,11 +4455,11 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) { res += "Microsoft Windows Millennium Edition"; - } + } break; case VER_PLATFORM_WIN32s: - + res += "Microsoft Win32s"; break; } @@ -4469,7 +4469,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() } // ---------------------------------------------------------------------- -bool SystemTools::ParseURLProtocol( const kwsys_stl::string& URL, +bool SystemTools::ParseURLProtocol( const kwsys_stl::string& URL, kwsys_stl::string& protocol, kwsys_stl::string& dataglom ) { @@ -4487,12 +4487,12 @@ bool SystemTools::ParseURLProtocol( const kwsys_stl::string& URL, } // ---------------------------------------------------------------------- -bool SystemTools::ParseURL( const kwsys_stl::string& URL, +bool SystemTools::ParseURL( const kwsys_stl::string& URL, kwsys_stl::string& protocol, - kwsys_stl::string& username, - kwsys_stl::string& password, - kwsys_stl::string& hostname, - kwsys_stl::string& dataport, + kwsys_stl::string& username, + kwsys_stl::string& password, + kwsys_stl::string& hostname, + kwsys_stl::string& dataport, kwsys_stl::string& database ) { kwsys::RegularExpression urlRe( VTK_URL_REGEX ); @@ -4515,7 +4515,7 @@ bool SystemTools::ParseURL( const kwsys_stl::string& URL, hostname = urlRe.match( 6 ); dataport = urlRe.match( 8 ); database = urlRe.match( 9 ); - + return true; } -- cgit v0.12 From 5d6cb1308de39abda8e394531a5027188371df74 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 13 Nov 2011 12:31:11 -0500 Subject: KWSys: Fix wrong spelling of __INTEL_COMPILER Author: Hans Johnson Change-Id: I31a29a8b53e5262b76530b8ea80a1a66cff7b3f7 --- Source/kwsys/SystemTools.cxx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index b6c3fda..ed7f62c 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -371,7 +371,7 @@ bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result) } } -#ifdef INTEL_COMPILER +#ifdef __INTEL_COMPILER #pragma warning disable 444 #endif @@ -403,11 +403,6 @@ bool SystemTools::PutEnv(const char* value) return ret == 0; } -#ifdef INTEL_COMPILER -#pragma warning restore 444 -#endif - - const char* SystemTools::GetExecutableExtension() { #if defined(_WIN32) || defined(__CYGWIN__) || defined(__VMS) -- cgit v0.12 From 33fff24aca46c4eca17997c42c5f62d71666b836 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 13 Nov 2011 15:03:15 -0500 Subject: KWIML: No INT_SCN*8 on Intel for Windows Intel C/C++ for Windows does not support the SCN*8 format (%hh*). The MS runtime does not support it. --- INT.h.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/INT.h.in b/INT.h.in index 5fca08f..3c1f05d 100644 --- a/INT.h.in +++ b/INT.h.in @@ -191,6 +191,9 @@ An includer may test the following macros after inclusion: #endif #if defined(__INTEL_COMPILER) +# if defined(_WIN32) +# define @KWIML@_INT__NO_SCN8 +# endif #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) # define @KWIML@_INT__NO_SCN8 #elif defined(__HP_cc) || defined(__HP_aCC) -- cgit v0.12 From 590c37e2078e91ea4b2820532533a9fa8020ed63 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 14 Nov 2011 00:01:08 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 36edd53..9e6a6d8 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 13) +SET(KWSYS_DATE_STAMP_DAY 14) -- cgit v0.12 From a8f6159f69dbfdacf4d48ff26f21862d83fa7fd8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 14 Nov 2011 07:53:06 -0500 Subject: KWIML: Create test output dir for Xcode Xcode 2.x forgets to create the target output directory before linking the individual architecture pieces of a universal binary for the target KWIML_test. Then it passes the directory to -L and -F options when linking the and warns that the directory does not exist. We work around the problem by using a pre-build rule on the target to create the output directory. --- test/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 15816cf..febc994 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -56,3 +56,13 @@ set_property(TARGET ${KWIML}_test PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) add_test(${KWIML}.test ${CMAKE_CURRENT_BINARY_DIR}/${KWIML}_test) set_property(TEST ${KWIML}.test PROPERTY LABELS ${KWIML_LABELS_TEST}) + +# Xcode 2.x forgets to create the output directory before linking +# the individual architectures. +if(CMAKE_OSX_ARCHITECTURES AND XCODE + AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") + add_custom_command( + TARGET ${KWIML}_test + PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" + ) +endif() -- cgit v0.12 From 1be4b6f4638334970a3d3f19891b5997ddcf5717 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Nov 2011 17:17:41 -0500 Subject: Order VS local generator Version ivar values consistently Move the Version member to the top cmLocalVisualStudioGenerator class and set it consistently for instances created by all the global generator versions. Use an enumeration type with values scaled by a factor of 10 so we can handle VS 7.1 without out-of-order numbers. VS 7.1 support for SuppressStartupBanner was broken by commit 25116a3c (Fix CMAKE_VERBOSE_MAKEFILE for VS10 vcxproj files, 2011-10-11) because it assumed comparison of VS version numbers works. Now it does. --- Source/cmGlobalVisualStudio10Generator.cxx | 3 ++- Source/cmGlobalVisualStudio71Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio7Generator.cxx | 3 ++- Source/cmGlobalVisualStudio8Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio8Win64Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio9Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio9IA64Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio9Win64Generator.cxx | 4 ++-- Source/cmLocalVisualStudio10Generator.cxx | 3 ++- Source/cmLocalVisualStudio10Generator.h | 2 +- Source/cmLocalVisualStudio6Generator.cxx | 3 ++- Source/cmLocalVisualStudio7Generator.cxx | 18 +++++++++--------- Source/cmLocalVisualStudio7Generator.h | 6 +----- Source/cmLocalVisualStudioGenerator.cxx | 3 ++- Source/cmLocalVisualStudioGenerator.h | 18 +++++++++++++++++- Source/cmVisualStudio10TargetGenerator.cxx | 8 ++++---- Source/cmVisualStudioGeneratorOptions.cxx | 26 +++++++++++++------------- Source/cmVisualStudioGeneratorOptions.h | 9 ++++----- 18 files changed, 71 insertions(+), 55 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index ec8f4a5..22ead10 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -43,7 +43,8 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator() { - cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator; + cmLocalVisualStudio10Generator* lg = + new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS10); lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index adb5f2f..a5feaca 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -26,8 +26,8 @@ cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator() ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio71Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; - lg->SetVersion71(); + cmLocalVisualStudio7Generator *lg = + new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS71); lg->SetExtraFlagTable(this->GetExtraFlagTableVS7()); lg->SetGlobalGenerator(this); return lg; diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 84e7f1b..a68e6d8 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -133,7 +133,8 @@ std::string cmGlobalVisualStudio7Generator ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; + cmLocalVisualStudio7Generator *lg = + new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS7); lg->SetExtraFlagTable(this->GetExtraFlagTableVS7()); lg->SetGlobalGenerator(this); return lg; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index ef723b7..a723109 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -28,8 +28,8 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator() ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; - lg->SetVersion8(); + cmLocalVisualStudio7Generator *lg = + new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8); lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); diff --git a/Source/cmGlobalVisualStudio8Win64Generator.cxx b/Source/cmGlobalVisualStudio8Win64Generator.cxx index 3469b17..60e45b8 100644 --- a/Source/cmGlobalVisualStudio8Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio8Win64Generator.cxx @@ -25,8 +25,8 @@ cmGlobalVisualStudio8Win64Generator::cmGlobalVisualStudio8Win64Generator() ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio8Win64Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; - lg->SetVersion8(); + cmLocalVisualStudio7Generator *lg + = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8); lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index f8ceea0..f082675 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -40,8 +40,8 @@ void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout) ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; - lg->SetVersion9(); + cmLocalVisualStudio7Generator *lg + = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9); lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); diff --git a/Source/cmGlobalVisualStudio9IA64Generator.cxx b/Source/cmGlobalVisualStudio9IA64Generator.cxx index d49739b..993340a 100644 --- a/Source/cmGlobalVisualStudio9IA64Generator.cxx +++ b/Source/cmGlobalVisualStudio9IA64Generator.cxx @@ -22,8 +22,8 @@ cmGlobalVisualStudio9IA64Generator::cmGlobalVisualStudio9IA64Generator() ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio9IA64Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; - lg->SetVersion9(); + cmLocalVisualStudio7Generator *lg = + new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9); lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); diff --git a/Source/cmGlobalVisualStudio9Win64Generator.cxx b/Source/cmGlobalVisualStudio9Win64Generator.cxx index ff4fd4f..08f537d 100644 --- a/Source/cmGlobalVisualStudio9Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio9Win64Generator.cxx @@ -22,8 +22,8 @@ cmGlobalVisualStudio9Win64Generator::cmGlobalVisualStudio9Win64Generator() ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio9Win64Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; - lg->SetVersion9(); + cmLocalVisualStudio7Generator *lg = + new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9); lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index ef378f9..8b22705 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -61,7 +61,8 @@ class cmVS10XMLParser : public cmXMLParser //---------------------------------------------------------------------------- -cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator() +cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator(VSVersion v): + cmLocalVisualStudio7Generator(v) { } diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 0fccdb0..699de4c 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -25,7 +25,7 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio10Generator(); + cmLocalVisualStudio10Generator(VSVersion v); virtual ~cmLocalVisualStudio10Generator(); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 095e1a7..1dfcbea 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -21,7 +21,8 @@ #include -cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator() +cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator(): + cmLocalVisualStudioGenerator(VS6) { } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index ae70759..8185b95 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -45,9 +45,9 @@ private: extern cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[]; //---------------------------------------------------------------------------- -cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator() +cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator(VSVersion v): + cmLocalVisualStudioGenerator(v) { - this->Version = 7; this->PlatformName = "Win32"; this->ExtraFlagTable = 0; this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); @@ -719,7 +719,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, t = Options::FortranCompiler; table = cmLocalVisualStudio7GeneratorFortranFlagTable; } - Options targetOptions(this, this->Version, t, + Options targetOptions(this, t, table, this->ExtraFlagTable); targetOptions.FixExceptionHandlingDefault(); @@ -888,7 +888,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, // end of Version >= 8) + if(targetBuilds && this->Version >= VS8) { // Check the filesystem type where the target will be written. if(cmLVS6G_IsFAT(target.GetDirectory(configName).c_str())) @@ -975,7 +975,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, extraLinkOptions += " "; extraLinkOptions += targetLinkFlags; } - Options linkOptions(this, this->Version, Options::Linker, + Options linkOptions(this, Options::Linker, cmLocalVisualStudio7GeneratorLinkFlagTable); linkOptions.Parse(extraLinkOptions.c_str()); if(!this->ModuleDefinitionFile.empty()) @@ -1604,7 +1604,7 @@ void cmLocalVisualStudio7Generator tool = Options::FortranCompiler; table = cmLocalVisualStudio7GeneratorFortranFlagTable; } - Options fileOptions(this, this->Version, tool, table, + Options fileOptions(this, tool, table, this->ExtraFlagTable); fileOptions.Parse(fc.CompileFlags.c_str()); fileOptions.AddDefines(fc.CompileDefs.c_str()); @@ -1920,13 +1920,13 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, fout << "\n" << "Version == 71) + if(this->Version == VS71) { fout << "\tVersion=\"7.10\"\n"; } else { - fout << "\tVersion=\"" << this->Version << ".00\"\n"; + fout << "\tVersion=\"" << (this->Version/10) << ".00\"\n"; } const char* projLabel = target.GetProperty("PROJECT_LABEL"); if(!projLabel) @@ -1941,7 +1941,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, cmGlobalVisualStudio7Generator* gg = static_cast(this->GlobalGenerator); fout << "\tName=\"" << projLabel << "\"\n"; - if(this->Version >= 8) + if(this->Version >= VS8) { fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n"; } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index cdd714e..5b634b8 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -35,7 +35,7 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio7Generator(); + cmLocalVisualStudio7Generator(VSVersion v); virtual ~cmLocalVisualStudio7Generator(); @@ -53,9 +53,6 @@ public: */ void SetBuildType(BuildType,const char *name); - void SetVersion71() {this->Version = 71;} - void SetVersion8() {this->Version = 8;} - void SetVersion9() {this->Version = 9;} void SetPlatformName(const char* n) { this->PlatformName = n;} void GetTargetObjectFileDirectories(cmTarget* target, std::vector& @@ -130,7 +127,6 @@ private: cmVS7FlagTable const* ExtraFlagTable; std::string ModuleDefinitionFile; - int Version; bool FortranProject; std::string PlatformName; // Win32 or x64 cmLocalVisualStudio7GeneratorInternals* Internal; diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 4390a08..4d16409 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -18,10 +18,11 @@ #include "windows.h" //---------------------------------------------------------------------------- -cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator() +cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator(VSVersion v) { this->WindowsShell = true; this->WindowsVSIDE = true; + this->Version = v; } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index a38bc30..9794d59 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -29,7 +29,18 @@ class cmCustomCommand; class cmLocalVisualStudioGenerator : public cmLocalGenerator { public: - cmLocalVisualStudioGenerator(); + /** Known versions of Visual Studio. */ + enum VSVersion + { + VS6 = 60, + VS7 = 70, + VS71 = 71, + VS8 = 80, + VS9 = 90, + VS10 = 100 + }; + + cmLocalVisualStudioGenerator(VSVersion v); virtual ~cmLocalVisualStudioGenerator(); /** Construct a script from the given list of command lines. */ @@ -41,6 +52,9 @@ public: sequence of custom commands. */ const char* GetReportErrorLabel() const; + /** Version of Visual Studio. */ + VSVersion GetVersion() const { return this->Version; } + protected: virtual const char* ReportErrorLabel() const; virtual bool CustomCommandUseLocal() const { return false; } @@ -58,6 +72,8 @@ protected: std::map& count); std::set NeedObjectName; friend class cmVisualStudio10TargetGenerator; + + VSVersion Version; }; #endif diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 45a79c8..2c9ef37 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -905,7 +905,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( hasFlags = true; cmVisualStudioGeneratorOptions clOptions(this->LocalGenerator, - 10, cmVisualStudioGeneratorOptions::Compiler, + cmVisualStudioGeneratorOptions::Compiler, cmVS10CLFlagTable, 0, this); clOptions.Parse(flags.c_str()); clOptions.AddDefines(configDefines.c_str()); @@ -1090,7 +1090,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( // TODO: Integrate code below with cmLocalVisualStudio7Generator. cmsys::auto_ptr pOptions( - new Options(this->LocalGenerator, 10, Options::Compiler, + new Options(this->LocalGenerator, Options::Compiler, cmVS10CLFlagTable)); Options& clOptions = *pOptions; @@ -1245,7 +1245,7 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config) { this->WriteString("\n", 2); cmVisualStudioGeneratorOptions - libOptions(this->LocalGenerator, 10, + libOptions(this->LocalGenerator, cmVisualStudioGeneratorOptions::Linker, cmVS10LibFlagTable, 0, this); libOptions.Parse(libflags?libflags:""); @@ -1325,7 +1325,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& flags += flagsConfig; } cmVisualStudioGeneratorOptions - linkOptions(this->LocalGenerator, 10, + linkOptions(this->LocalGenerator, cmVisualStudioGeneratorOptions::Linker, cmVS10LinkFlagTable, 0, this); if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") ) diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 4edeedc..a3bf0ed 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -25,14 +25,13 @@ inline std::string cmVisualStudioGeneratorOptionsEscapeForXML(const char* s) //---------------------------------------------------------------------------- cmVisualStudioGeneratorOptions -::cmVisualStudioGeneratorOptions(cmLocalGenerator* lg, - int version, +::cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool, cmVS7FlagTable const* table, cmVS7FlagTable const* extraTable, cmVisualStudio10TargetGenerator* g): cmIDEOptions(), - LocalGenerator(lg), Version(version), CurrentTool(tool), + LocalGenerator(lg), Version(lg->GetVersion()), CurrentTool(tool), TargetGenerator(g) { // Store the given flag tables. @@ -61,11 +60,11 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault() // remove the flag we need to override the IDE default of on. switch (this->Version) { - case 7: - case 71: + case cmLocalVisualStudioGenerator::VS7: + case cmLocalVisualStudioGenerator::VS71: this->FlagMap["ExceptionHandling"] = "FALSE"; break; - case 10: + case cmLocalVisualStudioGenerator::VS10: // by default VS puts empty // for a project, to make our projects look the same put a new line // and space over for the closing as the default @@ -93,7 +92,8 @@ void cmVisualStudioGeneratorOptions::SetVerboseMakefile(bool verbose) if(verbose && this->FlagMap.find("SuppressStartupBanner") == this->FlagMap.end()) { - this->FlagMap["SuppressStartupBanner"] = this->Version < 10 ? "FALSE" : ""; + this->FlagMap["SuppressStartupBanner"] = + this->Version < cmLocalVisualStudioGenerator::VS10 ? "FALSE" : ""; } } @@ -211,7 +211,7 @@ cmVisualStudioGeneratorOptions { return; } - if(this->Version == 10) + if(this->Version == cmLocalVisualStudioGenerator::VS10) { // if there are configuration specifc flags, then // use the configuration specific tag for PreprocessorDefinitions @@ -239,7 +239,7 @@ cmVisualStudioGeneratorOptions { // Escape the definition for the compiler. std::string define; - if(this->Version != 10) + if(this->Version != cmLocalVisualStudioGenerator::VS10) { define = this->LocalGenerator->EscapeForShell(di->c_str(), true); @@ -249,7 +249,7 @@ cmVisualStudioGeneratorOptions define = *di; } // Escape this flag for the IDE. - if(this->Version == 10) + if(this->Version == cmLocalVisualStudioGenerator::VS10) { define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str()); @@ -266,7 +266,7 @@ cmVisualStudioGeneratorOptions fout << sep << define; sep = ";"; } - if(this->Version == 10) + if(this->Version == cmLocalVisualStudioGenerator::VS10) { fout << ";%(PreprocessorDefinitions)" << suffix; } @@ -281,7 +281,7 @@ void cmVisualStudioGeneratorOptions ::OutputFlagMap(std::ostream& fout, const char* indent) { - if(this->Version == 10) + if(this->Version == cmLocalVisualStudioGenerator::VS10) { for(std::map::iterator m = this->FlagMap.begin(); m != this->FlagMap.end(); ++m) @@ -326,7 +326,7 @@ cmVisualStudioGeneratorOptions { if(!this->FlagString.empty()) { - if(this->Version == 10) + if(this->Version == cmLocalVisualStudioGenerator::VS10) { fout << prefix; if(this->Configuration.size()) diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index fadc4b5..51a1362 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -12,7 +12,7 @@ #ifndef cmVisualStudioGeneratorOptions_h #define cmVisualStudioGeneratorOptions_h -#include "cmLocalGenerator.h" +#include "cmLocalVisualStudioGenerator.h" #include "cmIDEOptions.h" typedef cmIDEFlagTable cmVS7FlagTable; @@ -30,8 +30,7 @@ public: Linker, FortranCompiler }; - cmVisualStudioGeneratorOptions(cmLocalGenerator* lg, - int version, + cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool, cmVS7FlagTable const* table, cmVS7FlagTable const* extraTable = 0, @@ -62,8 +61,8 @@ public: const char* suffix); void SetConfiguration(const char* config); private: - cmLocalGenerator* LocalGenerator; - int Version; + cmLocalVisualStudioGenerator* LocalGenerator; + cmLocalVisualStudioGenerator::VSVersion Version; std::string Configuration; Tool CurrentTool; -- cgit v0.12 From c92ffece804cd177c3531e58a39c3f0a6487d67d Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 14 Nov 2011 09:42:51 -0500 Subject: Enumerate VS11 version explicitly in local generators Since the parent commit the local generator Version ivar may be compared for ordering. Convert comparisons: "==VS10" becomes ">=VS10" "!=VS10" becomes "< VS10" to support an explicit enumeration value for VS11 with no change in behavior. --- Source/cmGlobalVisualStudio11Generator.cxx | 11 +++++++++++ Source/cmGlobalVisualStudio11Generator.h | 3 +++ Source/cmLocalVisualStudioGenerator.h | 3 ++- Source/cmVisualStudioGeneratorOptions.cxx | 13 +++++++------ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 97308bb..be7fd55 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -10,6 +10,7 @@ See the License for more information. ============================================================================*/ #include "cmGlobalVisualStudio11Generator.h" +#include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" //---------------------------------------------------------------------------- @@ -36,6 +37,16 @@ void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) } //---------------------------------------------------------------------------- +cmLocalGenerator *cmGlobalVisualStudio11Generator::CreateLocalGenerator() +{ + cmLocalVisualStudio10Generator* lg = + new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS11); + lg->SetPlatformName(this->GetPlatformName()); + lg->SetGlobalGenerator(this); + return lg; +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio11Generator ::GetDocumentation(cmDocumentationEntry& entry) const { diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 14019a7..7e8f6aa 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -35,6 +35,9 @@ public: /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; + ///! create the correct local generator + virtual cmLocalGenerator *CreateLocalGenerator(); + /** TODO: VS 11 user macro support. */ virtual std::string GetUserMacrosDirectory() { return ""; } protected: diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 9794d59..fcf1f21 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -37,7 +37,8 @@ public: VS71 = 71, VS8 = 80, VS9 = 90, - VS10 = 100 + VS10 = 100, + VS11 = 110 }; cmLocalVisualStudioGenerator(VSVersion v); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index a3bf0ed..41230e7 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -65,6 +65,7 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault() this->FlagMap["ExceptionHandling"] = "FALSE"; break; case cmLocalVisualStudioGenerator::VS10: + case cmLocalVisualStudioGenerator::VS11: // by default VS puts empty // for a project, to make our projects look the same put a new line // and space over for the closing as the default @@ -211,7 +212,7 @@ cmVisualStudioGeneratorOptions { return; } - if(this->Version == cmLocalVisualStudioGenerator::VS10) + if(this->Version >= cmLocalVisualStudioGenerator::VS10) { // if there are configuration specifc flags, then // use the configuration specific tag for PreprocessorDefinitions @@ -239,7 +240,7 @@ cmVisualStudioGeneratorOptions { // Escape the definition for the compiler. std::string define; - if(this->Version != cmLocalVisualStudioGenerator::VS10) + if(this->Version < cmLocalVisualStudioGenerator::VS10) { define = this->LocalGenerator->EscapeForShell(di->c_str(), true); @@ -249,7 +250,7 @@ cmVisualStudioGeneratorOptions define = *di; } // Escape this flag for the IDE. - if(this->Version == cmLocalVisualStudioGenerator::VS10) + if(this->Version >= cmLocalVisualStudioGenerator::VS10) { define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str()); @@ -266,7 +267,7 @@ cmVisualStudioGeneratorOptions fout << sep << define; sep = ";"; } - if(this->Version == cmLocalVisualStudioGenerator::VS10) + if(this->Version >= cmLocalVisualStudioGenerator::VS10) { fout << ";%(PreprocessorDefinitions)" << suffix; } @@ -281,7 +282,7 @@ void cmVisualStudioGeneratorOptions ::OutputFlagMap(std::ostream& fout, const char* indent) { - if(this->Version == cmLocalVisualStudioGenerator::VS10) + if(this->Version >= cmLocalVisualStudioGenerator::VS10) { for(std::map::iterator m = this->FlagMap.begin(); m != this->FlagMap.end(); ++m) @@ -326,7 +327,7 @@ cmVisualStudioGeneratorOptions { if(!this->FlagString.empty()) { - if(this->Version == cmLocalVisualStudioGenerator::VS10) + if(this->Version >= cmLocalVisualStudioGenerator::VS10) { fout << prefix; if(this->Configuration.size()) -- cgit v0.12 From b688f114c9b3c951c6d4640412d33b70974a1dc6 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 14 Nov 2011 16:34:10 +0000 Subject: Check QtCore without warning. When debug and release versions of QtCore were available it printed a warning. This has been fixed. --- Modules/DeployQt4.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake index 4bf1b6c..5350301 100644 --- a/Modules/DeployQt4.cmake +++ b/Modules/DeployQt4.cmake @@ -250,7 +250,11 @@ function(install_qt4_executable executable) endif() get_filename_component(executable_absolute "${executable}" ABSOLUTE) - gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY}" qtcore_type) + if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}") + gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type) + elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}") + gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type) + endif() if(qtcore_type STREQUAL "system") set(qt_plugins_dir "") endif() -- cgit v0.12 From ecb4459e31a0defec084ca0a02e0450da718afdb Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 15 Nov 2011 18:48:38 +0100 Subject: Strip trailing whitespace Alex --- Modules/FindGettext.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index 0f11234..7c3a261 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -1,5 +1,5 @@ # - Find GNU gettext tools -# This module looks for the GNU gettext tools. This module defines the +# This module looks for the GNU gettext tools. This module defines the # following values: # GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool. # GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool. @@ -7,8 +7,8 @@ # # Additionally it provides the following macros: # GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN ) -# This will create a target "translations" which will convert the -# given input po files into the binary output mo file. If the +# This will create a target "translations" which will convert the +# given input po files into the binary output mo file. If the # ALL option is used, the translations will also be created when # building the default target. # GETTEXT_PROCESS_POT( [ALL] [INSTALL_DESTINATION ] LANGUAGES ... ) -- cgit v0.12 From e48fcfffa36ca34703a4c366cb96593373234faa Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 15 Nov 2011 18:49:47 +0100 Subject: -make GETTEXT_PROCESS_PO_FILES() work with files with multiple dots Patch by Albert Astals Cid. E.g. plasma_package_org.kde.activityswitcher.po will now be installed correctly as plasma_package_org.kde.activityswitcher.mo, and not as plasma_package_org.mo. This is kind-of related to #12282 Alex --- Modules/FindGettext.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index 7c3a261..ffe3f26 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -134,7 +134,8 @@ FUNCTION(GETTEXT_PROCESS_PO_FILES _lang) CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) FOREACH(_current_PO_FILE ${_parsedArguments_PO_FILES}) - GET_FILENAME_COMPONENT(_basename ${_current_PO_FILE} NAME_WE) + GET_FILENAME_COMPONENT(_name ${_current_PO_FILE} NAME) + STRING(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name}) SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo) ADD_CUSTOM_COMMAND(OUTPUT ${_gmoFile} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE} -- cgit v0.12 From cbf453eeb625aef603fddfc0180ec0973d827e32 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 16 Nov 2011 03:25:07 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 9e6a6d8..4458c1d 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 14) +SET(KWSYS_DATE_STAMP_DAY 16) -- cgit v0.12 From ed7cef563445644684af47720c2f7c6fb0a2e440 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Nov 2011 19:37:38 -0500 Subject: Factor Compute(File|String)MD5 into cmCryptoHash helper Define an abstract API around the backend hash algorithm. Expose ifstream errors to HashFile callers. Always try opening the file. Succeed only if the end of file is reached without error. --- Source/CMakeLists.txt | 2 ++ Source/cmCryptoHash.cxx | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ Source/cmCryptoHash.h | 40 +++++++++++++++++++++ Source/cmSystemTools.cxx | 57 ++++-------------------------- 4 files changed, 139 insertions(+), 50 deletions(-) create mode 100644 Source/cmCryptoHash.cxx create mode 100644 Source/cmCryptoHash.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ba41d98..284c84d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -129,6 +129,8 @@ SET(SRCS cmComputeLinkInformation.h cmComputeTargetDepends.h cmComputeTargetDepends.cxx + cmCryptoHash.cxx + cmCryptoHash.h cmCustomCommand.cxx cmCustomCommand.h cmCustomCommandGenerator.cxx diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx new file mode 100644 index 0000000..3a73398 --- /dev/null +++ b/Source/cmCryptoHash.cxx @@ -0,0 +1,90 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 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. +============================================================================*/ +#include "cmCryptoHash.h" + +#include + +//---------------------------------------------------------------------------- +std::string cmCryptoHash::HashString(const char* input) +{ + this->Initialize(); + this->Append(reinterpret_cast(input), + static_cast(strlen(input))); + return this->Finalize(); +} + +//---------------------------------------------------------------------------- +std::string cmCryptoHash::HashFile(const char* file) +{ + std::ifstream fin(file, std::ios::in | cmsys_ios_binary); + if(!fin) + { + return ""; + } + + this->Initialize(); + + // Should be efficient enough on most system: + const int bufferSize = 4096; + char buffer[bufferSize]; + unsigned char const* buffer_uc = + reinterpret_cast(buffer); + // This copy loop is very sensitive on certain platforms with + // slightly broken stream libraries (like HPUX). Normally, it is + // incorrect to not check the error condition on the fin.read() + // before using the data, but the fin.gcount() will be zero if an + // error occurred. Therefore, the loop should be safe everywhere. + while(fin) + { + fin.read(buffer, bufferSize); + if(int gcount = static_cast(fin.gcount())) + { + this->Append(buffer_uc, gcount); + } + } + if(fin.eof()) + { + return this->Finalize(); + } + return ""; +} + +//---------------------------------------------------------------------------- +cmCryptoHashMD5::cmCryptoHashMD5(): MD5(cmsysMD5_New()) +{ +} + +//---------------------------------------------------------------------------- +cmCryptoHashMD5::~cmCryptoHashMD5() +{ + cmsysMD5_Delete(this->MD5); +} + +//---------------------------------------------------------------------------- +void cmCryptoHashMD5::Initialize() +{ + cmsysMD5_Initialize(this->MD5); +} + +//---------------------------------------------------------------------------- +void cmCryptoHashMD5::Append(unsigned char const* buf, int sz) +{ + cmsysMD5_Append(this->MD5, buf, sz); +} + +//---------------------------------------------------------------------------- +std::string cmCryptoHashMD5::Finalize() +{ + char md5out[32]; + cmsysMD5_FinalizeHex(this->MD5, md5out); + return std::string(md5out, 32); +} diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h new file mode 100644 index 0000000..670624c --- /dev/null +++ b/Source/cmCryptoHash.h @@ -0,0 +1,40 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 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 cmCryptoHash_h +#define cmCryptoHash_h + +#include "cmStandardIncludes.h" + +class cmCryptoHash +{ +public: + std::string HashString(const char* input); + std::string HashFile(const char* file); +protected: + virtual void Initialize()=0; + virtual void Append(unsigned char const*, int)=0; + virtual std::string Finalize()=0; +}; + +class cmCryptoHashMD5: public cmCryptoHash +{ + struct cmsysMD5_s* MD5; +public: + cmCryptoHashMD5(); + ~cmCryptoHashMD5(); +protected: + virtual void Initialize(); + virtual void Append(unsigned char const* buf, int sz); + virtual std::string Finalize(); +}; + +#endif diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 03364bd..8eec1e2 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -54,7 +54,7 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) # include // auto_ptr # include -# include +# include "cmCryptoHash.h" #endif #if defined(CMAKE_USE_ELF_PARSER) @@ -1197,48 +1197,10 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) { #if defined(CMAKE_BUILD_WITH_CMAKE) - if(!cmSystemTools::FileExists(source)) - { - return false; - } - - // Open files -#if defined(_WIN32) || defined(__CYGWIN__) - cmsys_ios::ifstream fin(source, cmsys_ios::ios::binary | cmsys_ios::ios::in); -#else - cmsys_ios::ifstream fin(source); -#endif - if(!fin) - { - return false; - } - - cmsysMD5* md5 = cmsysMD5_New(); - cmsysMD5_Initialize(md5); - - // Should be efficient enough on most system: - const int bufferSize = 4096; - char buffer[bufferSize]; - unsigned char const* buffer_uc = - reinterpret_cast(buffer); - // This copy loop is very sensitive on certain platforms with - // slightly broken stream libraries (like HPUX). Normally, it is - // incorrect to not check the error condition on the fin.read() - // before using the data, but the fin.gcount() will be zero if an - // error occurred. Therefore, the loop should be safe everywhere. - while(fin) - { - fin.read(buffer, bufferSize); - if(int gcount = static_cast(fin.gcount())) - { - cmsysMD5_Append(md5, buffer_uc, gcount); - } - } - cmsysMD5_FinalizeHex(md5, md5out); - cmsysMD5_Delete(md5); - - fin.close(); - return true; + cmCryptoHashMD5 md5; + std::string str = md5.HashFile(source); + strncpy(md5out, str.c_str(), 32); + return !str.empty(); #else (void)source; (void)md5out; @@ -1250,13 +1212,8 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) std::string cmSystemTools::ComputeStringMD5(const char* input) { #if defined(CMAKE_BUILD_WITH_CMAKE) - char md5out[32]; - cmsysMD5* md5 = cmsysMD5_New(); - cmsysMD5_Initialize(md5); - cmsysMD5_Append(md5, reinterpret_cast(input), -1); - cmsysMD5_FinalizeHex(md5, md5out); - cmsysMD5_Delete(md5); - return std::string(md5out, 32); + cmCryptoHashMD5 md5; + return md5.HashString(input); #else (void)input; cmSystemTools::Message("md5sum not supported in bootstrapping mode","Error"); -- cgit v0.12 From 042f7965c3a5db7420363fdb76f9ebaa8e93efdc Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Nov 2011 20:39:36 -0500 Subject: Add file(MD5) command to compute cryptographic hash Provide a CMake-language binding to the md5sum function previously available only by "cmake -E md5sum". --- Source/cmFileCommand.cxx | 36 +++++++++++++++++++++++++++++++++ Source/cmFileCommand.h | 4 ++++ Tests/CMakeTests/CheckCMakeTest.cmake | 2 +- Tests/CMakeTests/File-MD5-BadArg1.cmake | 1 + Tests/CMakeTests/File-MD5-BadArg2.cmake | 1 + Tests/CMakeTests/File-MD5-BadArg4.cmake | 1 + Tests/CMakeTests/File-MD5-NoFile.cmake | 1 + Tests/CMakeTests/File-MD5-Works.cmake | 2 ++ Tests/CMakeTests/FileTest.cmake.in | 15 ++++++++++++++ 9 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Tests/CMakeTests/File-MD5-BadArg1.cmake create mode 100644 Tests/CMakeTests/File-MD5-BadArg2.cmake create mode 100644 Tests/CMakeTests/File-MD5-BadArg4.cmake create mode 100644 Tests/CMakeTests/File-MD5-NoFile.cmake create mode 100644 Tests/CMakeTests/File-MD5-Works.cmake diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index f933666..32454f5 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -13,6 +13,7 @@ #include "cmake.h" #include "cmHexFileConverter.h" #include "cmFileTimeComparison.h" +#include "cmCryptoHash.h" #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cm_curl.h" @@ -22,6 +23,7 @@ #include #include +#include #include #include #include @@ -83,6 +85,10 @@ bool cmFileCommand { return this->HandleReadCommand(args); } + else if ( subCommand == "MD5" ) + { + return this->HandleHashCommand(args); + } else if ( subCommand == "STRINGS" ) { return this->HandleStringsCommand(args); @@ -339,6 +345,36 @@ bool cmFileCommand::HandleReadCommand(std::vector const& args) } //---------------------------------------------------------------------------- +bool cmFileCommand::HandleHashCommand(std::vector const& args) +{ + if(args.size() != 3) + { + cmOStringStream e; + e << args[0] << " requires a file name and output variable"; + this->SetError(e.str().c_str()); + return false; + } + + cmsys::auto_ptr hash; + if(args[0] == "MD5") + { hash.reset(new cmCryptoHashMD5); } + if(hash.get()) + { + std::string out = hash->HashFile(args[1].c_str()); + if(!out.empty()) + { + this->Makefile->AddDefinition(args[2].c_str(), out.c_str()); + return true; + } + cmOStringStream e; + e << args[0] << " failed to read file \"" << args[1] << "\": " + << cmSystemTools::GetLastSystemError(); + this->SetError(e.str().c_str()); + } + return false; +} + +//---------------------------------------------------------------------------- bool cmFileCommand::HandleStringsCommand(std::vector const& args) { if(args.size() < 3) diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index 162890a..dce6478 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -65,6 +65,7 @@ public: " file(WRITE filename \"message to write\"... )\n" " file(APPEND filename \"message to write\"... )\n" " file(READ filename variable [LIMIT numBytes] [OFFSET offset] [HEX])\n" + " file(MD5 filename variable)\n" " file(STRINGS filename variable [LIMIT_COUNT num]\n" " [LIMIT_INPUT numBytes] [LIMIT_OUTPUT numBytes]\n" " [LENGTH_MINIMUM numBytes] [LENGTH_MAXIMUM numBytes]\n" @@ -94,6 +95,8 @@ public: "variable. It will start at the given offset and read up to numBytes. " "If the argument HEX is given, the binary data will be converted to " "hexadecimal representation and this will be stored in the variable.\n" + "MD5 " + "will compute a cryptographic hash of the content of a file.\n" "STRINGS will parse a list of ASCII strings from a file and " "store it in a variable. Binary data in the file are ignored. Carriage " "return (CR) characters are ignored. It works also for Intel Hex and " @@ -227,6 +230,7 @@ protected: bool HandleRemove(std::vector const& args, bool recurse); bool HandleWriteCommand(std::vector const& args, bool append); bool HandleReadCommand(std::vector const& args); + bool HandleHashCommand(std::vector const& args); bool HandleStringsCommand(std::vector const& args); bool HandleGlobCommand(std::vector const& args, bool recurse); bool HandleMakeDirectoryCommand(std::vector const& args); diff --git a/Tests/CMakeTests/CheckCMakeTest.cmake b/Tests/CMakeTests/CheckCMakeTest.cmake index 2e4fedd..db92905 100644 --- a/Tests/CMakeTests/CheckCMakeTest.cmake +++ b/Tests/CMakeTests/CheckCMakeTest.cmake @@ -12,7 +12,7 @@ function(check_cmake_test prefix) ) string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}") string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}") - if(NOT "${result}" STREQUAL ${${test}-RESULT}) + if(NOT "${result}" STREQUAL "${${test}-RESULT}") message(FATAL_ERROR "Test ${test} result is [${result}], not [${${test}-RESULT}].\n" "Test ${test} output:\n" diff --git a/Tests/CMakeTests/File-MD5-BadArg1.cmake b/Tests/CMakeTests/File-MD5-BadArg1.cmake new file mode 100644 index 0000000..ac5f67a --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg1.cmake @@ -0,0 +1 @@ +file(MD5) diff --git a/Tests/CMakeTests/File-MD5-BadArg2.cmake b/Tests/CMakeTests/File-MD5-BadArg2.cmake new file mode 100644 index 0000000..68a172f --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg2.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake) diff --git a/Tests/CMakeTests/File-MD5-BadArg4.cmake b/Tests/CMakeTests/File-MD5-BadArg4.cmake new file mode 100644 index 0000000..a11efcb --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg4.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake md5 extra_arg) diff --git a/Tests/CMakeTests/File-MD5-NoFile.cmake b/Tests/CMakeTests/File-MD5-NoFile.cmake new file mode 100644 index 0000000..1b91bc8 --- /dev/null +++ b/Tests/CMakeTests/File-MD5-NoFile.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/DoesNotExist.cmake md5) diff --git a/Tests/CMakeTests/File-MD5-Works.cmake b/Tests/CMakeTests/File-MD5-Works.cmake new file mode 100644 index 0000000..2989e98 --- /dev/null +++ b/Tests/CMakeTests/File-MD5-Works.cmake @@ -0,0 +1,2 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake md5) +message("${md5}") diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index b6dcaa6..3aa88a7 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -12,6 +12,16 @@ set(Copy-NoDest-RESULT 1) set(Copy-NoDest-STDERR "given no DESTINATION") set(Copy-NoFile-RESULT 1) set(Copy-NoFile-STDERR "COPY cannot find.*/does_not_exist\\.txt") +set(MD5-NoFile-RESULT 1) +set(MD5-NoFile-STDERR "file MD5 failed to read file") +set(MD5-BadArg1-RESULT 1) +set(MD5-BadArg1-STDERR "file must be called with at least two arguments") +set(MD5-BadArg2-RESULT 1) +set(MD5-BadArg2-STDERR "file MD5 requires a file name and output variable") +set(MD5-BadArg4-RESULT 1) +set(MD5-BadArg4-STDERR "file MD5 requires a file name and output variable") +set(MD5-Works-RESULT 0) +set(MD5-Works-STDERR "a28a44fb5b58a6acf0cbec46557bc775") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(File @@ -22,6 +32,11 @@ check_cmake_test(File Copy-LateArg Copy-NoDest Copy-NoFile + MD5-NoFile + MD5-BadArg1 + MD5-BadArg2 + MD5-BadArg4 + MD5-Works ) # Also execute each test listed in FileTestScript.cmake: -- cgit v0.12 From c1856a33d46384307884ab6ba6db886a7bca0fd2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Nov 2011 20:18:58 -0500 Subject: sha2: Use KWIML fixed-size integer types and endian-ness These are more portable than those named in the original sha2 code. --- Source/cm_sha2.c | 41 ++++-------- Source/cm_sha2.h | 185 +++++++++---------------------------------------------- 2 files changed, 42 insertions(+), 184 deletions(-) diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c index 855a5bb..0bf62f2 100644 --- a/Source/cm_sha2.c +++ b/Source/cm_sha2.c @@ -87,37 +87,20 @@ * made). */ #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) -#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN +/* CMake modification: use byte order from cmIML. */ +# include "cmIML/ABI.h" +# 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 #endif -/* - * Define the following sha_* types to types of the correct length on - * the native archtecture. Most BSD systems and Linux define u_intXX_t - * types. Machines with very recent ANSI C headers, can use the - * uintXX_t definintions from inttypes.h by defining SHA2_USE_INTTYPES_H - * during compile or in the sha.h header file. - * - * Machines that support neither u_intXX_t nor inttypes.h's uintXX_t - * will need to define these three typedefs below (and the appropriate - * ones in sha.h too) by hand according to their system architecture. - * - * Thank you, Jun-ichiro itojun Hagino, for suggesting using u_intXX_t - * types and pointing out recent ANSI C support for uintXX_t in inttypes.h. - */ -#ifdef SHA2_USE_INTTYPES_H - -typedef uint8_t sha_byte; /* Exactly 1 byte */ -typedef uint32_t sha_word32; /* Exactly 4 bytes */ -typedef uint64_t sha_word64; /* Exactly 8 bytes */ - -#else /* SHA2_USE_INTTYPES_H */ - -typedef u_int8_t sha_byte; /* Exactly 1 byte */ -typedef u_int32_t sha_word32; /* Exactly 4 bytes */ -typedef u_int64_t sha_word64; /* Exactly 8 bytes */ - -#endif /* SHA2_USE_INTTYPES_H */ - +/* 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 */ /*** ENDIAN REVERSAL MACROS *******************************************/ #if BYTE_ORDER == LITTLE_ENDIAN diff --git a/Source/cm_sha2.h b/Source/cm_sha2.h index 9459f75..284ee6a 100644 --- a/Source/cm_sha2.h +++ b/Source/cm_sha2.h @@ -36,6 +36,12 @@ #ifndef __SHA2_H__ #define __SHA2_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; + #ifdef __cplusplus extern "C" { #endif @@ -48,13 +54,6 @@ extern "C" { */ #include -#ifdef SHA2_USE_INTTYPES_H - -#include - -#endif /* SHA2_USE_INTTYPES_H */ - - /*** SHA-224/256/384/512 Various Length Definitions *******************/ /* Digest lengths for SHA-1/224/256/384/512 */ @@ -71,185 +70,61 @@ extern "C" { /*** SHA-224/256/384/512 Context Structures ***************************/ -/* NOTE: If your architecture does not define either u_intXX_t types or - * uintXX_t (from inttypes.h), you may need to define things by hand - * for your system: - */ -#if 0 -typedef unsigned char u_int8_t; /* 1-byte (8-bits) */ -typedef unsigned int u_int32_t; /* 4-bytes (32-bits) */ -typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */ -#endif -/* - * Most BSD systems already define u_intXX_t types, as does Linux. - * Some systems, however, like Compaq's Tru64 Unix instead can use - * uintXX_t types defined by very recent ANSI C standards and included - * in the file: - * - * #include - * - * If you choose to use then please define: - * - * #define SHA2_USE_INTTYPES_H - * - * Or on the command line during compile: - * - * cc -DSHA2_USE_INTTYPES_H ... - */ -#ifdef SHA2_USE_INTTYPES_H typedef union _SHA_CTX { /* SHA-1 uses this part of the union: */ struct { - uint32_t state[5]; - uint64_t bitcount; - uint8_t buffer[64]; + cm_sha2_uint32_t state[5]; + cm_sha2_uint64_t bitcount; + cm_sha2_uint8_t buffer[64]; } s1; /* SHA-224 and SHA-256 use this part of the union: */ struct { - uint32_t state[8]; - uint64_t bitcount; - uint8_t buffer[64]; + cm_sha2_uint32_t state[8]; + cm_sha2_uint64_t bitcount; + cm_sha2_uint8_t buffer[64]; } s256; /* SHA-384 and SHA-512 use this part of the union: */ struct { - uint64_t state[8]; - uint64_t bitcount[2]; - uint8_t buffer[128]; + cm_sha2_uint64_t state[8]; + cm_sha2_uint64_t bitcount[2]; + cm_sha2_uint8_t buffer[128]; } s512; } SHA_CTX; -#else /* SHA2_USE_INTTYPES_H */ - -typedef union _SHA_CTX { - /* SHA-1 uses this part of the union: */ - struct { - u_int32_t state[5]; - u_int64_t bitcount; - u_int8_t buffer[64]; - } s1; - - /* SHA-224 and SHA-256 use this part of the union: */ - struct { - u_int32_t state[8]; - u_int64_t bitcount; - u_int8_t buffer[64]; - } s256; - - /* SHA-384 and SHA-512 use this part of the union: */ - struct { - u_int64_t state[8]; - u_int64_t bitcount[2]; - u_int8_t buffer[128]; - } s512; -} SHA_CTX; - -#endif /* SHA2_USE_INTTYPES_H */ - - /*** SHA-256/384/512 Function Prototypes ******************************/ -#ifndef NOPROTO -#ifdef SHA2_USE_INTTYPES_H void SHA1_Init(SHA_CTX*); -void SHA1_Update(SHA_CTX*, const uint8_t*, size_t); -void SHA1_Final(uint8_t[SHA1_DIGEST_LENGTH], SHA_CTX*); +void SHA1_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); +void SHA1_Final(cm_sha2_uint8_t[SHA1_DIGEST_LENGTH], SHA_CTX*); char* SHA1_End(SHA_CTX*, char[SHA1_DIGEST_STRING_LENGTH]); -char* SHA1_Data(const uint8_t*, size_t, char[SHA1_DIGEST_STRING_LENGTH]); +char* SHA1_Data(const cm_sha2_uint8_t*, size_t, char[SHA1_DIGEST_STRING_LENGTH]); void SHA224_Init(SHA_CTX*); -void SHA224_Update(SHA_CTX*, const uint8_t*, size_t); -void SHA224_Final(uint8_t[SHA224_DIGEST_LENGTH], SHA_CTX*); +void SHA224_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); +void SHA224_Final(cm_sha2_uint8_t[SHA224_DIGEST_LENGTH], SHA_CTX*); char* SHA224_End(SHA_CTX*, char[SHA224_DIGEST_STRING_LENGTH]); -char* SHA224_Data(const uint8_t*, size_t, char[SHA224_DIGEST_STRING_LENGTH]); +char* SHA224_Data(const cm_sha2_uint8_t*, size_t, char[SHA224_DIGEST_STRING_LENGTH]); void SHA256_Init(SHA_CTX*); -void SHA256_Update(SHA_CTX*, const uint8_t*, size_t); -void SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA_CTX*); +void SHA256_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); +void SHA256_Final(cm_sha2_uint8_t[SHA256_DIGEST_LENGTH], SHA_CTX*); char* SHA256_End(SHA_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); -char* SHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); +char* SHA256_Data(const cm_sha2_uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); void SHA384_Init(SHA_CTX*); -void SHA384_Update(SHA_CTX*, const uint8_t*, size_t); -void SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA_CTX*); +void SHA384_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); +void SHA384_Final(cm_sha2_uint8_t[SHA384_DIGEST_LENGTH], SHA_CTX*); char* SHA384_End(SHA_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); -char* SHA384_Data(const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); +char* SHA384_Data(const cm_sha2_uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); void SHA512_Init(SHA_CTX*); -void SHA512_Update(SHA_CTX*, const uint8_t*, size_t); -void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA_CTX*); +void SHA512_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); +void SHA512_Final(cm_sha2_uint8_t[SHA512_DIGEST_LENGTH], SHA_CTX*); char* SHA512_End(SHA_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); -char* SHA512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); - -#else /* SHA2_USE_INTTYPES_H */ - -void SHA1_Init(SHA_CTX*); -void SHA1_Update(SHA_CTX*, const u_int8_t*, size_t); -void SHA1_Final(u_int8_t[SHA1_DIGEST_LENGTH], SHA_CTX*); -char* SHA1_End(SHA_CTX*, char[SHA1_DIGEST_STRING_LENGTH]); -char* SHA1_Data(const u_int8_t*, size_t, char[SHA1_DIGEST_STRING_LENGTH]); - -void SHA224_Init(SHA_CTX*); -void SHA224_Update(SHA_CTX*, const u_int8_t*, size_t); -void SHA224_Final(u_int8_t[SHA224_DIGEST_LENGTH], SHA_CTX*); -char* SHA224_End(SHA_CTX*, char[SHA224_DIGEST_STRING_LENGTH]); -char* SHA224_Data(const u_int8_t*, size_t, char[SHA224_DIGEST_STRING_LENGTH]); - -void SHA256_Init(SHA_CTX*); -void SHA256_Update(SHA_CTX*, const u_int8_t*, size_t); -void SHA256_Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA_CTX*); -char* SHA256_End(SHA_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); -char* SHA256_Data(const u_int8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); - -void SHA384_Init(SHA_CTX*); -void SHA384_Update(SHA_CTX*, const u_int8_t*, size_t); -void SHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA_CTX*); -char* SHA384_End(SHA_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); -char* SHA384_Data(const u_int8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); - -void SHA512_Init(SHA_CTX*); -void SHA512_Update(SHA_CTX*, const u_int8_t*, size_t); -void SHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA_CTX*); -char* SHA512_End(SHA_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); -char* SHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); - -#endif /* SHA2_USE_INTTYPES_H */ - -#else /* NOPROTO */ - -void SHA1_Init(); -void SHA1_Update(); -void SHA1_Final(); -char* SHA1_End(); -char* SHA1_Data(); - -void SHA224_Init(); -void SHA224_Update(); -void SHA224_Final(); -char* SHA224_End(); -char* SHA224_Data(); - -void SHA256_Init(); -void SHA256_Update(); -void SHA256_Final(); -char* SHA256_End(); -char* SHA256_Data(); - -void SHA384_Init(); -void SHA384_Update(); -void SHA384_Final(); -char* SHA384_End(); -char* SHA384_Data(); - -void SHA512_Init(); -void SHA512_Update(); -void SHA512_Final(); -char* SHA512_End(); -char* SHA512_Data(); - -#endif /* NOPROTO */ +char* SHA512_Data(const cm_sha2_uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); #ifdef __cplusplus } -- cgit v0.12 From 73efd4a5044d2346e14d019197e2ddced3f9b7a8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Nov 2011 20:22:51 -0500 Subject: sha2: Build as part of CMakeLib Mangle sha2 symbols to avoid conflict with system libs. --- Source/CMakeLists.txt | 2 ++ Source/cm_sha2.h | 2 ++ Source/cm_sha2_mangle.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 Source/cm_sha2_mangle.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 284c84d..5205738 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -261,6 +261,8 @@ SET(SRCS cmakewizard.cxx cmakewizard.h + cm_sha2.h + cm_sha2.c cm_utf8.h cm_utf8.c ) diff --git a/Source/cm_sha2.h b/Source/cm_sha2.h index 284ee6a..ebe5e5a 100644 --- a/Source/cm_sha2.h +++ b/Source/cm_sha2.h @@ -36,6 +36,8 @@ #ifndef __SHA2_H__ #define __SHA2_H__ +#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; diff --git a/Source/cm_sha2_mangle.h b/Source/cm_sha2_mangle.h new file mode 100644 index 0000000..e73d131 --- /dev/null +++ b/Source/cm_sha2_mangle.h @@ -0,0 +1,51 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 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_sha2_mangle_h +#define cm_sha2_mangle_h + +/* Mangle sha2 symbol names to avoid possible conflict with + implementations in other libraries to which CMake links. */ +#define SHA1_Data cmSHA1_Data +#define SHA1_End cmSHA1_End +#define SHA1_Final cmSHA1_Final +#define SHA1_Init cmSHA1_Init +#define SHA1_Internal_Transform cmSHA1_Internal_Transform +#define SHA1_Update cmSHA1_Update +#define SHA224_Data cmSHA224_Data +#define SHA224_End cmSHA224_End +#define SHA224_Final cmSHA224_Final +#define SHA224_Init cmSHA224_Init +#define SHA224_Internal_Transform cmSHA224_Internal_Transform +#define SHA224_Update cmSHA224_Update +#define SHA256_Data cmSHA256_Data +#define SHA256_End cmSHA256_End +#define SHA256_Final cmSHA256_Final +#define SHA256_Init cmSHA256_Init +#define SHA256_Internal_Init cmSHA256_Internal_Init +#define SHA256_Internal_Last cmSHA256_Internal_Last +#define SHA256_Internal_Transform cmSHA256_Internal_Transform +#define SHA256_Update cmSHA256_Update +#define SHA384_Data cmSHA384_Data +#define SHA384_End cmSHA384_End +#define SHA384_Final cmSHA384_Final +#define SHA384_Init cmSHA384_Init +#define SHA384_Update cmSHA384_Update +#define SHA512_Data cmSHA512_Data +#define SHA512_End cmSHA512_End +#define SHA512_Final cmSHA512_Final +#define SHA512_Init cmSHA512_Init +#define SHA512_Internal_Init cmSHA512_Internal_Init +#define SHA512_Internal_Last cmSHA512_Internal_Last +#define SHA512_Internal_Transform cmSHA512_Internal_Transform +#define SHA512_Update cmSHA512_Update + +#endif -- cgit v0.12 From 38771d3bdf51b81d46578e0c81ebddbdea0ce3b2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Nov 2011 20:32:43 -0500 Subject: Add file(SHA*) commands to compute cryptographic hashes Add a file() command API for SHA1, SHA224, SHA256, SHA384, and SHA512. --- Source/cmCryptoHash.cxx | 21 +++++++++++++++++++++ Source/cmCryptoHash.h | 21 +++++++++++++++++++++ Source/cmFileCommand.cxx | 17 ++++++++++++++++- Source/cmFileCommand.h | 4 ++-- Tests/CMakeTests/File-SHA1-Works.cmake | 2 ++ Tests/CMakeTests/File-SHA224-Works.cmake | 2 ++ Tests/CMakeTests/File-SHA256-Works.cmake | 2 ++ Tests/CMakeTests/File-SHA384-Works.cmake | 2 ++ Tests/CMakeTests/File-SHA512-Works.cmake | 2 ++ Tests/CMakeTests/FileTest.cmake.in | 15 +++++++++++++++ 10 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 Tests/CMakeTests/File-SHA1-Works.cmake create mode 100644 Tests/CMakeTests/File-SHA224-Works.cmake create mode 100644 Tests/CMakeTests/File-SHA256-Works.cmake create mode 100644 Tests/CMakeTests/File-SHA384-Works.cmake create mode 100644 Tests/CMakeTests/File-SHA512-Works.cmake diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 3a73398..411da58 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -12,6 +12,7 @@ #include "cmCryptoHash.h" #include +#include "cm_sha2.h" //---------------------------------------------------------------------------- std::string cmCryptoHash::HashString(const char* input) @@ -88,3 +89,23 @@ std::string cmCryptoHashMD5::Finalize() cmsysMD5_FinalizeHex(this->MD5, md5out); return std::string(md5out, 32); } + + +#define cmCryptoHash_SHA_CLASS_IMPL(SHA) \ +cmCryptoHash##SHA::cmCryptoHash##SHA(): SHA(new SHA_CTX) {} \ +cmCryptoHash##SHA::~cmCryptoHash##SHA() { delete this->SHA; } \ +void cmCryptoHash##SHA::Initialize() { SHA##_Init(this->SHA); } \ +void cmCryptoHash##SHA::Append(unsigned char const* buf, int sz) \ +{ SHA##_Update(this->SHA, buf, sz); } \ +std::string cmCryptoHash##SHA::Finalize() \ +{ \ + char out[SHA##_DIGEST_STRING_LENGTH]; \ + SHA##_End(this->SHA, out); \ + return std::string(out, SHA##_DIGEST_STRING_LENGTH-1); \ +} + +cmCryptoHash_SHA_CLASS_IMPL(SHA1) +cmCryptoHash_SHA_CLASS_IMPL(SHA224) +cmCryptoHash_SHA_CLASS_IMPL(SHA256) +cmCryptoHash_SHA_CLASS_IMPL(SHA384) +cmCryptoHash_SHA_CLASS_IMPL(SHA512) diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index 670624c..c17104b 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -37,4 +37,25 @@ protected: virtual std::string Finalize(); }; +#define cmCryptoHash_SHA_CLASS_DECL(SHA) \ + class cmCryptoHash##SHA: public cmCryptoHash \ + { \ + union _SHA_CTX* SHA; \ + public: \ + cmCryptoHash##SHA(); \ + ~cmCryptoHash##SHA(); \ + protected: \ + virtual void Initialize(); \ + virtual void Append(unsigned char const* buf, int sz); \ + virtual std::string Finalize(); \ + } + +cmCryptoHash_SHA_CLASS_DECL(SHA1); +cmCryptoHash_SHA_CLASS_DECL(SHA224); +cmCryptoHash_SHA_CLASS_DECL(SHA256); +cmCryptoHash_SHA_CLASS_DECL(SHA384); +cmCryptoHash_SHA_CLASS_DECL(SHA512); + +#undef cmCryptoHash_SHA_CLASS_DECL + #endif diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 32454f5..35c743d 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -85,7 +85,12 @@ bool cmFileCommand { return this->HandleReadCommand(args); } - else if ( subCommand == "MD5" ) + else if ( subCommand == "MD5" || + subCommand == "SHA1" || + subCommand == "SHA224" || + subCommand == "SHA256" || + subCommand == "SHA384" || + subCommand == "SHA512" ) { return this->HandleHashCommand(args); } @@ -358,6 +363,16 @@ bool cmFileCommand::HandleHashCommand(std::vector const& args) cmsys::auto_ptr hash; if(args[0] == "MD5") { hash.reset(new cmCryptoHashMD5); } + else if(args[0] == "SHA1") + { hash.reset(new cmCryptoHashSHA1); } + else if(args[0] == "SHA224") + { hash.reset(new cmCryptoHashSHA224); } + else if(args[0] == "SHA256") + { hash.reset(new cmCryptoHashSHA256); } + else if(args[0] == "SHA384") + { hash.reset(new cmCryptoHashSHA384); } + else if(args[0] == "SHA512") + { hash.reset(new cmCryptoHashSHA512); } if(hash.get()) { std::string out = hash->HashFile(args[1].c_str()); diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index dce6478..9e2ed0f 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -65,7 +65,7 @@ public: " file(WRITE filename \"message to write\"... )\n" " file(APPEND filename \"message to write\"... )\n" " file(READ filename variable [LIMIT numBytes] [OFFSET offset] [HEX])\n" - " file(MD5 filename variable)\n" + " file( filename variable)\n" " file(STRINGS filename variable [LIMIT_COUNT num]\n" " [LIMIT_INPUT numBytes] [LIMIT_OUTPUT numBytes]\n" " [LENGTH_MINIMUM numBytes] [LENGTH_MAXIMUM numBytes]\n" @@ -95,7 +95,7 @@ public: "variable. It will start at the given offset and read up to numBytes. " "If the argument HEX is given, the binary data will be converted to " "hexadecimal representation and this will be stored in the variable.\n" - "MD5 " + "MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 " "will compute a cryptographic hash of the content of a file.\n" "STRINGS will parse a list of ASCII strings from a file and " "store it in a variable. Binary data in the file are ignored. Carriage " diff --git a/Tests/CMakeTests/File-SHA1-Works.cmake b/Tests/CMakeTests/File-SHA1-Works.cmake new file mode 100644 index 0000000..03ea3ac --- /dev/null +++ b/Tests/CMakeTests/File-SHA1-Works.cmake @@ -0,0 +1,2 @@ +file(SHA1 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake sha1) +message("${sha1}") diff --git a/Tests/CMakeTests/File-SHA224-Works.cmake b/Tests/CMakeTests/File-SHA224-Works.cmake new file mode 100644 index 0000000..0295346 --- /dev/null +++ b/Tests/CMakeTests/File-SHA224-Works.cmake @@ -0,0 +1,2 @@ +file(SHA224 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake sha224) +message("${sha224}") diff --git a/Tests/CMakeTests/File-SHA256-Works.cmake b/Tests/CMakeTests/File-SHA256-Works.cmake new file mode 100644 index 0000000..32bc9fe --- /dev/null +++ b/Tests/CMakeTests/File-SHA256-Works.cmake @@ -0,0 +1,2 @@ +file(SHA256 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake sha256) +message("${sha256}") diff --git a/Tests/CMakeTests/File-SHA384-Works.cmake b/Tests/CMakeTests/File-SHA384-Works.cmake new file mode 100644 index 0000000..5c56de2 --- /dev/null +++ b/Tests/CMakeTests/File-SHA384-Works.cmake @@ -0,0 +1,2 @@ +file(SHA384 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake sha384) +message("${sha384}") diff --git a/Tests/CMakeTests/File-SHA512-Works.cmake b/Tests/CMakeTests/File-SHA512-Works.cmake new file mode 100644 index 0000000..cf10706 --- /dev/null +++ b/Tests/CMakeTests/File-SHA512-Works.cmake @@ -0,0 +1,2 @@ +file(SHA512 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake sha512) +message("${sha512}") diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index 3aa88a7..824aba7 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -22,6 +22,16 @@ set(MD5-BadArg4-RESULT 1) set(MD5-BadArg4-STDERR "file MD5 requires a file name and output variable") set(MD5-Works-RESULT 0) set(MD5-Works-STDERR "a28a44fb5b58a6acf0cbec46557bc775") +set(SHA1-Works-RESULT 0) +set(SHA1-Works-STDERR "e0ce452a7e34e9c705b46e4e7c9cd959082c0777") +set(SHA224-Works-RESULT 0) +set(SHA224-Works-STDERR "d1f1c9db3df73586a5a200014505ef03b70da5e0539eb35c11b4ef6f") +set(SHA256-Works-RESULT 0) +set(SHA256-Works-STDERR "bb38de1c34713f750a4f84404ef5fb1efb93cf815cb09182db457ba91de19195") +set(SHA384-Works-RESULT 0) +set(SHA384-Works-STDERR "2f01d58436bd04a40ec2c938a15f2bb661bf1bf1560a5f2d40a3ebbb716a58e400ab2992c23ba19fa96dc519e0042c26") +set(SHA512-Works-RESULT 0) +set(SHA512-Works-STDERR "349d02e347ddb133afb4557c9e541163f54b6eaa9eb345672bfd7bbce90c9872bf1fad9c6662248eb7b092aef719e4b8c3b8bb1cf47f287abbde12360c073686") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(File @@ -37,6 +47,11 @@ check_cmake_test(File MD5-BadArg2 MD5-BadArg4 MD5-Works + SHA1-Works + SHA224-Works + SHA256-Works + SHA384-Works + SHA512-Works ) # Also execute each test listed in FileTestScript.cmake: -- cgit v0.12 From 46ab0561fc29446a736985816b005200aad9489c Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Nov 2011 07:56:31 -0500 Subject: sha2: Use "static const" instead of "const static" declarations Fix old-style declarations in the original code. --- Source/cm_sha2.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c index 0bf62f2..ecb2d9c 100644 --- a/Source/cm_sha2.c +++ b/Source/cm_sha2.c @@ -228,7 +228,7 @@ void SHA512_Internal_Transform(SHA_CTX*, const sha_word64*); #define K1_60_TO_79 0xca62c1d6UL /* Initial hash value H for SHA-1: */ -const static sha_word32 sha1_initial_hash_value[5] = { +static const sha_word32 sha1_initial_hash_value[5] = { 0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, @@ -237,7 +237,7 @@ const static sha_word32 sha1_initial_hash_value[5] = { }; /* Hash constant words K for SHA-224 and SHA-256: */ -const static sha_word32 K256[64] = { +static const sha_word32 K256[64] = { 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, @@ -257,7 +257,7 @@ const static sha_word32 K256[64] = { }; /* Initial hash value H for SHA-224: */ -const static sha_word32 sha224_initial_hash_value[8] = { +static const sha_word32 sha224_initial_hash_value[8] = { 0xc1059ed8UL, 0x367cd507UL, 0x3070dd17UL, @@ -269,7 +269,7 @@ const static sha_word32 sha224_initial_hash_value[8] = { }; /* Initial hash value H for SHA-256: */ -const static sha_word32 sha256_initial_hash_value[8] = { +static const sha_word32 sha256_initial_hash_value[8] = { 0x6a09e667UL, 0xbb67ae85UL, 0x3c6ef372UL, @@ -281,7 +281,7 @@ const static sha_word32 sha256_initial_hash_value[8] = { }; /* Hash constant words K for SHA-384 and SHA-512: */ -const static sha_word64 K512[80] = { +static const sha_word64 K512[80] = { 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, @@ -325,7 +325,7 @@ const static sha_word64 K512[80] = { }; /* Initial hash value H for SHA-384 */ -const static sha_word64 sha384_initial_hash_value[8] = { +static const sha_word64 sha384_initial_hash_value[8] = { 0xcbbb9d5dc1059ed8ULL, 0x629a292a367cd507ULL, 0x9159015a3070dd17ULL, @@ -337,7 +337,7 @@ const static sha_word64 sha384_initial_hash_value[8] = { }; /* Initial hash value H for SHA-512 */ -const static sha_word64 sha512_initial_hash_value[8] = { +static const sha_word64 sha512_initial_hash_value[8] = { 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL, -- cgit v0.12 From 293a7f4e2ae9b458d3efefcfe133d0ad5320a1b2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Nov 2011 10:04:41 -0500 Subject: cmCryptoHash: Provide factory "New" method Construct a cmCryptoHash subclass instance based on the name of the desired hash algorithm. --- Source/cmCryptoHash.cxx | 19 +++++++++++++++++++ Source/cmCryptoHash.h | 3 +++ Source/cmFileCommand.cxx | 14 +------------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 411da58..a1505bd 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -15,6 +15,25 @@ #include "cm_sha2.h" //---------------------------------------------------------------------------- +cmsys::auto_ptr cmCryptoHash::New(const char* algo) +{ + if(strcmp(algo,"MD5") == 0) + { return cmsys::auto_ptr(new cmCryptoHashMD5); } + else if(strcmp(algo,"SHA1") == 0) + { return cmsys::auto_ptr(new cmCryptoHashSHA1); } + else if(strcmp(algo,"SHA224") == 0) + { return cmsys::auto_ptr(new cmCryptoHashSHA224); } + else if(strcmp(algo,"SHA256") == 0) + { return cmsys::auto_ptr(new cmCryptoHashSHA256); } + else if(strcmp(algo,"SHA384") == 0) + { return cmsys::auto_ptr(new cmCryptoHashSHA384); } + else if(strcmp(algo,"SHA512") == 0) + { return cmsys::auto_ptr(new cmCryptoHashSHA512); } + else + { return cmsys::auto_ptr(0); } +} + +//---------------------------------------------------------------------------- std::string cmCryptoHash::HashString(const char* input) { this->Initialize(); diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index c17104b..0a33365 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -14,9 +14,12 @@ #include "cmStandardIncludes.h" +#include + class cmCryptoHash { public: + static cmsys::auto_ptr New(const char* algo); std::string HashString(const char* input); std::string HashFile(const char* file); protected: diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 35c743d..bab3116 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -360,19 +360,7 @@ bool cmFileCommand::HandleHashCommand(std::vector const& args) return false; } - cmsys::auto_ptr hash; - if(args[0] == "MD5") - { hash.reset(new cmCryptoHashMD5); } - else if(args[0] == "SHA1") - { hash.reset(new cmCryptoHashSHA1); } - else if(args[0] == "SHA224") - { hash.reset(new cmCryptoHashSHA224); } - else if(args[0] == "SHA256") - { hash.reset(new cmCryptoHashSHA256); } - else if(args[0] == "SHA384") - { hash.reset(new cmCryptoHashSHA384); } - else if(args[0] == "SHA512") - { hash.reset(new cmCryptoHashSHA512); } + cmsys::auto_ptr hash(cmCryptoHash::New(args[0].c_str())); if(hash.get()) { std::string out = hash->HashFile(args[1].c_str()); -- cgit v0.12 From 2e9c26cf9616fead92ec65eefc696bcf9761b996 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Nov 2011 10:12:18 -0500 Subject: Add string(MD5) and string(SHA*) commands to compute hashes Provide a CMake-language binding to these cryptographic hashes. Add a string() command API for MD5, SHA1, SHA224, SHA256, SHA384, and SHA512. --- Source/cmStringCommand.cxx | 32 ++++++++++++++++++++++++++++++ Source/cmStringCommand.h | 5 +++++ Tests/CMakeTests/String-MD5-BadArg1.cmake | 1 + Tests/CMakeTests/String-MD5-BadArg2.cmake | 1 + Tests/CMakeTests/String-MD5-BadArg4.cmake | 1 + Tests/CMakeTests/String-MD5-Works.cmake | 2 ++ Tests/CMakeTests/String-SHA1-Works.cmake | 2 ++ Tests/CMakeTests/String-SHA224-Works.cmake | 2 ++ Tests/CMakeTests/String-SHA256-Works.cmake | 2 ++ Tests/CMakeTests/String-SHA384-Works.cmake | 2 ++ Tests/CMakeTests/String-SHA512-Works.cmake | 2 ++ Tests/CMakeTests/StringTest.cmake.in | 32 ++++++++++++++++++++++++++++++ 12 files changed, 84 insertions(+) create mode 100644 Tests/CMakeTests/String-MD5-BadArg1.cmake create mode 100644 Tests/CMakeTests/String-MD5-BadArg2.cmake create mode 100644 Tests/CMakeTests/String-MD5-BadArg4.cmake create mode 100644 Tests/CMakeTests/String-MD5-Works.cmake create mode 100644 Tests/CMakeTests/String-SHA1-Works.cmake create mode 100644 Tests/CMakeTests/String-SHA224-Works.cmake create mode 100644 Tests/CMakeTests/String-SHA256-Works.cmake create mode 100644 Tests/CMakeTests/String-SHA384-Works.cmake create mode 100644 Tests/CMakeTests/String-SHA512-Works.cmake diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index d239c06..f2f2681 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -10,6 +10,8 @@ See the License for more information. ============================================================================*/ #include "cmStringCommand.h" +#include "cmCryptoHash.h" + #include #include @@ -36,6 +38,15 @@ bool cmStringCommand { return this->HandleReplaceCommand(args); } + else if ( subCommand == "MD5" || + subCommand == "SHA1" || + subCommand == "SHA224" || + subCommand == "SHA256" || + subCommand == "SHA384" || + subCommand == "SHA512" ) + { + return this->HandleHashCommand(args); + } else if(subCommand == "TOLOWER") { return this->HandleToUpperLowerCommand(args, false); @@ -83,6 +94,27 @@ bool cmStringCommand } //---------------------------------------------------------------------------- +bool cmStringCommand::HandleHashCommand(std::vector const& args) +{ + if(args.size() != 3) + { + cmOStringStream e; + e << args[0] << " requires an output variable and an input string"; + this->SetError(e.str().c_str()); + return false; + } + + cmsys::auto_ptr hash(cmCryptoHash::New(args[0].c_str())); + if(hash.get()) + { + std::string out = hash->HashString(args[2].c_str()); + this->Makefile->AddDefinition(args[1].c_str(), out.c_str()); + return true; + } + return false; +} + +//---------------------------------------------------------------------------- bool cmStringCommand::HandleToUpperLowerCommand( std::vector const& args, bool toUpper) { diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 52b83d9..452f4a1 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -76,6 +76,8 @@ public: " string(REPLACE \n" " \n" " [...])\n" + " string(\n" + " )\n" " string(COMPARE EQUAL )\n" " string(COMPARE NOTEQUAL )\n" " string(COMPARE LESS )\n" @@ -103,6 +105,8 @@ public: "backslash through argument parsing.\n" "REPLACE will replace all occurrences of match_string in the input with " "replace_string and store the result in the output.\n" + "MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 " + "will compute a cryptographic hash of the input string.\n" "COMPARE EQUAL/NOTEQUAL/LESS/GREATER will compare the strings and " "store true or false in the output variable.\n" "ASCII will convert all numbers into corresponding ASCII characters.\n" @@ -150,6 +154,7 @@ protected: bool RegexMatch(std::vector const& args); bool RegexMatchAll(std::vector const& args); bool RegexReplace(std::vector const& args); + bool HandleHashCommand(std::vector const& args); bool HandleToUpperLowerCommand(std::vector const& args, bool toUpper); bool HandleCompareCommand(std::vector const& args); diff --git a/Tests/CMakeTests/String-MD5-BadArg1.cmake b/Tests/CMakeTests/String-MD5-BadArg1.cmake new file mode 100644 index 0000000..8946476 --- /dev/null +++ b/Tests/CMakeTests/String-MD5-BadArg1.cmake @@ -0,0 +1 @@ +string(MD5) diff --git a/Tests/CMakeTests/String-MD5-BadArg2.cmake b/Tests/CMakeTests/String-MD5-BadArg2.cmake new file mode 100644 index 0000000..abbbf87 --- /dev/null +++ b/Tests/CMakeTests/String-MD5-BadArg2.cmake @@ -0,0 +1 @@ +string(MD5 md5) diff --git a/Tests/CMakeTests/String-MD5-BadArg4.cmake b/Tests/CMakeTests/String-MD5-BadArg4.cmake new file mode 100644 index 0000000..edd4427 --- /dev/null +++ b/Tests/CMakeTests/String-MD5-BadArg4.cmake @@ -0,0 +1 @@ +string(MD5 md5 input extra_arg) diff --git a/Tests/CMakeTests/String-MD5-Works.cmake b/Tests/CMakeTests/String-MD5-Works.cmake new file mode 100644 index 0000000..4ef7a07 --- /dev/null +++ b/Tests/CMakeTests/String-MD5-Works.cmake @@ -0,0 +1,2 @@ +string(MD5 md5 "sample input string\n") +message("${md5}") diff --git a/Tests/CMakeTests/String-SHA1-Works.cmake b/Tests/CMakeTests/String-SHA1-Works.cmake new file mode 100644 index 0000000..2f3b51b --- /dev/null +++ b/Tests/CMakeTests/String-SHA1-Works.cmake @@ -0,0 +1,2 @@ +string(SHA1 sha1 "sample input string\n") +message("${sha1}") diff --git a/Tests/CMakeTests/String-SHA224-Works.cmake b/Tests/CMakeTests/String-SHA224-Works.cmake new file mode 100644 index 0000000..5b7f880 --- /dev/null +++ b/Tests/CMakeTests/String-SHA224-Works.cmake @@ -0,0 +1,2 @@ +string(SHA224 sha224 "sample input string\n") +message("${sha224}") diff --git a/Tests/CMakeTests/String-SHA256-Works.cmake b/Tests/CMakeTests/String-SHA256-Works.cmake new file mode 100644 index 0000000..e3e89ae --- /dev/null +++ b/Tests/CMakeTests/String-SHA256-Works.cmake @@ -0,0 +1,2 @@ +string(SHA256 sha256 "sample input string\n") +message("${sha256}") diff --git a/Tests/CMakeTests/String-SHA384-Works.cmake b/Tests/CMakeTests/String-SHA384-Works.cmake new file mode 100644 index 0000000..828a190 --- /dev/null +++ b/Tests/CMakeTests/String-SHA384-Works.cmake @@ -0,0 +1,2 @@ +string(SHA384 sha384 "sample input string\n") +message("${sha384}") diff --git a/Tests/CMakeTests/String-SHA512-Works.cmake b/Tests/CMakeTests/String-SHA512-Works.cmake new file mode 100644 index 0000000..e17db5c --- /dev/null +++ b/Tests/CMakeTests/String-SHA512-Works.cmake @@ -0,0 +1,2 @@ +string(SHA512 sha512 "sample input string\n") +message("${sha512}") diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in index 6bb60f4..49e7dc9 100644 --- a/Tests/CMakeTests/StringTest.cmake.in +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -1,3 +1,35 @@ +set(MD5-BadArg1-RESULT 1) +set(MD5-BadArg1-STDERR "string MD5 requires an output variable") +set(MD5-BadArg2-RESULT 1) +set(MD5-BadArg2-STDERR "string MD5 requires an output variable and an input string") +set(MD5-BadArg4-RESULT 1) +set(MD5-BadArg4-STDERR "string MD5 requires an output variable and an input string") +set(MD5-Works-RESULT 0) +set(MD5-Works-STDERR "10d20ddb981a6202b84aa1ce1cb7fce3") +set(SHA1-Works-RESULT 0) +set(SHA1-Works-STDERR "83f093e04289b21a9415f408ad50be8b57ad2f34") +set(SHA224-Works-RESULT 0) +set(SHA224-Works-STDERR "e995a7789922c4ef9279d94e763c8375934180a51baa7147bc48edf7") +set(SHA256-Works-RESULT 0) +set(SHA256-Works-STDERR "d1c5915d8b71150726a1eef75a29ec6bea8fd1bef6b7299ef8048760b0402025") +set(SHA384-Works-RESULT 0) +set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") +set(SHA512-Works-RESULT 0) +set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +check_cmake_test(String + MD5-BadArg1 + MD5-BadArg2 + MD5-BadArg4 + MD5-Works + SHA1-Works + SHA224-Works + SHA256-Works + SHA384-Works + SHA512-Works + ) + # Execute each test listed in StringTestScript.cmake: # set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/StringTestScript.cmake") -- cgit v0.12 From 23b3df76a069ab314a4828ad651f1a14319ff660 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Nov 2011 10:48:10 -0500 Subject: sha2: Use KWIML fixed-size integer constant macros Define SHA_UINT32_C and SHA_UINT64_C using the KWIML versions. Use them in place of hard-coded UL and ULL constant suffixes. --- Source/cm_sha2.c | 223 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 121 insertions(+), 102 deletions(-) diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c index ecb2d9c..c64a597 100644 --- a/Source/cm_sha2.c +++ b/Source/cm_sha2.c @@ -101,21 +101,24 @@ 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) /*** ENDIAN REVERSAL MACROS *******************************************/ #if BYTE_ORDER == LITTLE_ENDIAN #define REVERSE32(w,x) { \ sha_word32 tmp = (w); \ tmp = (tmp >> 16) | (tmp << 16); \ - (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \ + (x) = ((tmp & SHA_UINT32_C(0xff00ff00)) >> 8) | \ + ((tmp & SHA_UINT32_C(0x00ff00ff)) << 8); \ } #define REVERSE64(w,x) { \ sha_word64 tmp = (w); \ tmp = (tmp >> 32) | (tmp << 32); \ - tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | \ - ((tmp & 0x00ff00ff00ff00ffULL) << 8); \ - (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \ - ((tmp & 0x0000ffff0000ffffULL) << 16); \ + tmp = ((tmp & SHA_UINT64_C(0xff00ff00ff00ff00)) >> 8) | \ + ((tmp & SHA_UINT64_C(0x00ff00ff00ff00ff)) << 8); \ + (x) = ((tmp & SHA_UINT64_C(0xffff0000ffff0000)) >> 16) | \ + ((tmp & SHA_UINT64_C(0x0000ffff0000ffff)) << 16); \ } #endif /* BYTE_ORDER == LITTLE_ENDIAN */ @@ -222,130 +225,146 @@ void SHA512_Internal_Transform(SHA_CTX*, const sha_word64*); /*** SHA2 INITIAL HASH VALUES AND CONSTANTS ***************************/ /* Hash constant words K for SHA-1: */ -#define K1_0_TO_19 0x5a827999UL -#define K1_20_TO_39 0x6ed9eba1UL -#define K1_40_TO_59 0x8f1bbcdcUL -#define K1_60_TO_79 0xca62c1d6UL +#define K1_0_TO_19 SHA_UINT32_C(0x5a827999) +#define K1_20_TO_39 SHA_UINT32_C(0x6ed9eba1) +#define K1_40_TO_59 SHA_UINT32_C(0x8f1bbcdc) +#define K1_60_TO_79 SHA_UINT32_C(0xca62c1d6) /* Initial hash value H for SHA-1: */ static const sha_word32 sha1_initial_hash_value[5] = { - 0x67452301UL, - 0xefcdab89UL, - 0x98badcfeUL, - 0x10325476UL, - 0xc3d2e1f0UL + SHA_UINT32_C(0x67452301), + SHA_UINT32_C(0xefcdab89), + SHA_UINT32_C(0x98badcfe), + SHA_UINT32_C(0x10325476), + SHA_UINT32_C(0xc3d2e1f0) }; /* Hash constant words K for SHA-224 and SHA-256: */ static const sha_word32 K256[64] = { - 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, - 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, - 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, - 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, - 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, - 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, - 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, - 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, - 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, - 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, - 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, - 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, - 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, - 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, - 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, - 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL + SHA_UINT32_C(0x428a2f98), SHA_UINT32_C(0x71374491), + SHA_UINT32_C(0xb5c0fbcf), SHA_UINT32_C(0xe9b5dba5), + SHA_UINT32_C(0x3956c25b), SHA_UINT32_C(0x59f111f1), + SHA_UINT32_C(0x923f82a4), SHA_UINT32_C(0xab1c5ed5), + SHA_UINT32_C(0xd807aa98), SHA_UINT32_C(0x12835b01), + SHA_UINT32_C(0x243185be), SHA_UINT32_C(0x550c7dc3), + SHA_UINT32_C(0x72be5d74), SHA_UINT32_C(0x80deb1fe), + SHA_UINT32_C(0x9bdc06a7), SHA_UINT32_C(0xc19bf174), + SHA_UINT32_C(0xe49b69c1), SHA_UINT32_C(0xefbe4786), + SHA_UINT32_C(0x0fc19dc6), SHA_UINT32_C(0x240ca1cc), + SHA_UINT32_C(0x2de92c6f), SHA_UINT32_C(0x4a7484aa), + SHA_UINT32_C(0x5cb0a9dc), SHA_UINT32_C(0x76f988da), + SHA_UINT32_C(0x983e5152), SHA_UINT32_C(0xa831c66d), + SHA_UINT32_C(0xb00327c8), SHA_UINT32_C(0xbf597fc7), + SHA_UINT32_C(0xc6e00bf3), SHA_UINT32_C(0xd5a79147), + SHA_UINT32_C(0x06ca6351), SHA_UINT32_C(0x14292967), + SHA_UINT32_C(0x27b70a85), SHA_UINT32_C(0x2e1b2138), + SHA_UINT32_C(0x4d2c6dfc), SHA_UINT32_C(0x53380d13), + SHA_UINT32_C(0x650a7354), SHA_UINT32_C(0x766a0abb), + SHA_UINT32_C(0x81c2c92e), SHA_UINT32_C(0x92722c85), + SHA_UINT32_C(0xa2bfe8a1), SHA_UINT32_C(0xa81a664b), + SHA_UINT32_C(0xc24b8b70), SHA_UINT32_C(0xc76c51a3), + SHA_UINT32_C(0xd192e819), SHA_UINT32_C(0xd6990624), + SHA_UINT32_C(0xf40e3585), SHA_UINT32_C(0x106aa070), + SHA_UINT32_C(0x19a4c116), SHA_UINT32_C(0x1e376c08), + SHA_UINT32_C(0x2748774c), SHA_UINT32_C(0x34b0bcb5), + SHA_UINT32_C(0x391c0cb3), SHA_UINT32_C(0x4ed8aa4a), + SHA_UINT32_C(0x5b9cca4f), SHA_UINT32_C(0x682e6ff3), + SHA_UINT32_C(0x748f82ee), SHA_UINT32_C(0x78a5636f), + SHA_UINT32_C(0x84c87814), SHA_UINT32_C(0x8cc70208), + SHA_UINT32_C(0x90befffa), SHA_UINT32_C(0xa4506ceb), + SHA_UINT32_C(0xbef9a3f7), SHA_UINT32_C(0xc67178f2) }; /* Initial hash value H for SHA-224: */ static const sha_word32 sha224_initial_hash_value[8] = { - 0xc1059ed8UL, - 0x367cd507UL, - 0x3070dd17UL, - 0xf70e5939UL, - 0xffc00b31UL, - 0x68581511UL, - 0x64f98fa7UL, - 0xbefa4fa4UL + SHA_UINT32_C(0xc1059ed8), + SHA_UINT32_C(0x367cd507), + SHA_UINT32_C(0x3070dd17), + SHA_UINT32_C(0xf70e5939), + SHA_UINT32_C(0xffc00b31), + SHA_UINT32_C(0x68581511), + SHA_UINT32_C(0x64f98fa7), + SHA_UINT32_C(0xbefa4fa4) }; /* Initial hash value H for SHA-256: */ static const sha_word32 sha256_initial_hash_value[8] = { - 0x6a09e667UL, - 0xbb67ae85UL, - 0x3c6ef372UL, - 0xa54ff53aUL, - 0x510e527fUL, - 0x9b05688cUL, - 0x1f83d9abUL, - 0x5be0cd19UL + SHA_UINT32_C(0x6a09e667), + SHA_UINT32_C(0xbb67ae85), + SHA_UINT32_C(0x3c6ef372), + SHA_UINT32_C(0xa54ff53a), + SHA_UINT32_C(0x510e527f), + SHA_UINT32_C(0x9b05688c), + SHA_UINT32_C(0x1f83d9ab), + SHA_UINT32_C(0x5be0cd19) }; /* Hash constant words K for SHA-384 and SHA-512: */ static const sha_word64 K512[80] = { - 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, - 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, - 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, - 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, - 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, - 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, - 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, - 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, - 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, - 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, - 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, - 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, - 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, - 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, - 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, - 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, - 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, - 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, - 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, - 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, - 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, - 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, - 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, - 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, - 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, - 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, - 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, - 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, - 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, - 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, - 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, - 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, - 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, - 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, - 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, - 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, - 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, - 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, - 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, - 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL + SHA_UINT64_C(0x428a2f98d728ae22), SHA_UINT64_C(0x7137449123ef65cd), + SHA_UINT64_C(0xb5c0fbcfec4d3b2f), SHA_UINT64_C(0xe9b5dba58189dbbc), + SHA_UINT64_C(0x3956c25bf348b538), SHA_UINT64_C(0x59f111f1b605d019), + SHA_UINT64_C(0x923f82a4af194f9b), SHA_UINT64_C(0xab1c5ed5da6d8118), + SHA_UINT64_C(0xd807aa98a3030242), SHA_UINT64_C(0x12835b0145706fbe), + SHA_UINT64_C(0x243185be4ee4b28c), SHA_UINT64_C(0x550c7dc3d5ffb4e2), + SHA_UINT64_C(0x72be5d74f27b896f), SHA_UINT64_C(0x80deb1fe3b1696b1), + SHA_UINT64_C(0x9bdc06a725c71235), SHA_UINT64_C(0xc19bf174cf692694), + SHA_UINT64_C(0xe49b69c19ef14ad2), SHA_UINT64_C(0xefbe4786384f25e3), + SHA_UINT64_C(0x0fc19dc68b8cd5b5), SHA_UINT64_C(0x240ca1cc77ac9c65), + SHA_UINT64_C(0x2de92c6f592b0275), SHA_UINT64_C(0x4a7484aa6ea6e483), + SHA_UINT64_C(0x5cb0a9dcbd41fbd4), SHA_UINT64_C(0x76f988da831153b5), + SHA_UINT64_C(0x983e5152ee66dfab), SHA_UINT64_C(0xa831c66d2db43210), + SHA_UINT64_C(0xb00327c898fb213f), SHA_UINT64_C(0xbf597fc7beef0ee4), + SHA_UINT64_C(0xc6e00bf33da88fc2), SHA_UINT64_C(0xd5a79147930aa725), + SHA_UINT64_C(0x06ca6351e003826f), SHA_UINT64_C(0x142929670a0e6e70), + SHA_UINT64_C(0x27b70a8546d22ffc), SHA_UINT64_C(0x2e1b21385c26c926), + SHA_UINT64_C(0x4d2c6dfc5ac42aed), SHA_UINT64_C(0x53380d139d95b3df), + SHA_UINT64_C(0x650a73548baf63de), SHA_UINT64_C(0x766a0abb3c77b2a8), + SHA_UINT64_C(0x81c2c92e47edaee6), SHA_UINT64_C(0x92722c851482353b), + SHA_UINT64_C(0xa2bfe8a14cf10364), SHA_UINT64_C(0xa81a664bbc423001), + SHA_UINT64_C(0xc24b8b70d0f89791), SHA_UINT64_C(0xc76c51a30654be30), + SHA_UINT64_C(0xd192e819d6ef5218), SHA_UINT64_C(0xd69906245565a910), + SHA_UINT64_C(0xf40e35855771202a), SHA_UINT64_C(0x106aa07032bbd1b8), + SHA_UINT64_C(0x19a4c116b8d2d0c8), SHA_UINT64_C(0x1e376c085141ab53), + SHA_UINT64_C(0x2748774cdf8eeb99), SHA_UINT64_C(0x34b0bcb5e19b48a8), + SHA_UINT64_C(0x391c0cb3c5c95a63), SHA_UINT64_C(0x4ed8aa4ae3418acb), + SHA_UINT64_C(0x5b9cca4f7763e373), SHA_UINT64_C(0x682e6ff3d6b2b8a3), + SHA_UINT64_C(0x748f82ee5defb2fc), SHA_UINT64_C(0x78a5636f43172f60), + SHA_UINT64_C(0x84c87814a1f0ab72), SHA_UINT64_C(0x8cc702081a6439ec), + SHA_UINT64_C(0x90befffa23631e28), SHA_UINT64_C(0xa4506cebde82bde9), + SHA_UINT64_C(0xbef9a3f7b2c67915), SHA_UINT64_C(0xc67178f2e372532b), + SHA_UINT64_C(0xca273eceea26619c), SHA_UINT64_C(0xd186b8c721c0c207), + SHA_UINT64_C(0xeada7dd6cde0eb1e), SHA_UINT64_C(0xf57d4f7fee6ed178), + SHA_UINT64_C(0x06f067aa72176fba), SHA_UINT64_C(0x0a637dc5a2c898a6), + SHA_UINT64_C(0x113f9804bef90dae), SHA_UINT64_C(0x1b710b35131c471b), + SHA_UINT64_C(0x28db77f523047d84), SHA_UINT64_C(0x32caab7b40c72493), + SHA_UINT64_C(0x3c9ebe0a15c9bebc), SHA_UINT64_C(0x431d67c49c100d4c), + SHA_UINT64_C(0x4cc5d4becb3e42b6), SHA_UINT64_C(0x597f299cfc657e2a), + SHA_UINT64_C(0x5fcb6fab3ad6faec), SHA_UINT64_C(0x6c44198c4a475817) }; /* Initial hash value H for SHA-384 */ static const sha_word64 sha384_initial_hash_value[8] = { - 0xcbbb9d5dc1059ed8ULL, - 0x629a292a367cd507ULL, - 0x9159015a3070dd17ULL, - 0x152fecd8f70e5939ULL, - 0x67332667ffc00b31ULL, - 0x8eb44a8768581511ULL, - 0xdb0c2e0d64f98fa7ULL, - 0x47b5481dbefa4fa4ULL + SHA_UINT64_C(0xcbbb9d5dc1059ed8), + SHA_UINT64_C(0x629a292a367cd507), + SHA_UINT64_C(0x9159015a3070dd17), + SHA_UINT64_C(0x152fecd8f70e5939), + SHA_UINT64_C(0x67332667ffc00b31), + SHA_UINT64_C(0x8eb44a8768581511), + SHA_UINT64_C(0xdb0c2e0d64f98fa7), + SHA_UINT64_C(0x47b5481dbefa4fa4) }; /* Initial hash value H for SHA-512 */ static const sha_word64 sha512_initial_hash_value[8] = { - 0x6a09e667f3bcc908ULL, - 0xbb67ae8584caa73bULL, - 0x3c6ef372fe94f82bULL, - 0xa54ff53a5f1d36f1ULL, - 0x510e527fade682d1ULL, - 0x9b05688c2b3e6c1fULL, - 0x1f83d9abfb41bd6bULL, - 0x5be0cd19137e2179ULL + SHA_UINT64_C(0x6a09e667f3bcc908), + SHA_UINT64_C(0xbb67ae8584caa73b), + SHA_UINT64_C(0x3c6ef372fe94f82b), + SHA_UINT64_C(0xa54ff53a5f1d36f1), + SHA_UINT64_C(0x510e527fade682d1), + SHA_UINT64_C(0x9b05688c2b3e6c1f), + SHA_UINT64_C(0x1f83d9abfb41bd6b), + SHA_UINT64_C(0x5be0cd19137e2179) }; /* -- cgit v0.12 From 9da8340a6d68ec1dce9248d0d83f59ba6f41003e Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Nov 2011 10:54:56 -0500 Subject: sha2: Suppress Borland warnings in third-party code The sha2 implementation performs cleanup on local variables. Suppress the warning instead of fixing it to minimize modification. --- Source/cm_sha2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c index c64a597..b89f8fe 100644 --- a/Source/cm_sha2.c +++ b/Source/cm_sha2.c @@ -103,6 +103,9 @@ 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) +#if defined(__BORLANDC__) +# pragma warn -8004 /* variable assigned value that is never used */ +#endif /*** ENDIAN REVERSAL MACROS *******************************************/ #if BYTE_ORDER == LITTLE_ENDIAN -- cgit v0.12 From b0853b5fae2681f31f023a37d04cea1209b34dbd Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Nov 2011 11:03:30 -0500 Subject: Disable file() and string() hash commands during bootstrap We do not compile support for the cryptographic hashes during bootstrap. Disable the APIs that use them. --- Source/cmFileCommand.cxx | 7 +++++++ Source/cmStringCommand.cxx | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index bab3116..6df5ab3 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -352,6 +352,7 @@ bool cmFileCommand::HandleReadCommand(std::vector const& args) //---------------------------------------------------------------------------- bool cmFileCommand::HandleHashCommand(std::vector const& args) { +#if defined(CMAKE_BUILD_WITH_CMAKE) if(args.size() != 3) { cmOStringStream e; @@ -375,6 +376,12 @@ bool cmFileCommand::HandleHashCommand(std::vector const& args) this->SetError(e.str().c_str()); } return false; +#else + cmOStringStream e; + e << args[0] << " not available during bootstrap"; + this->SetError(e.str().c_str()); + return false; +#endif } //---------------------------------------------------------------------------- diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index f2f2681..ec10d57 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -96,6 +96,7 @@ bool cmStringCommand //---------------------------------------------------------------------------- bool cmStringCommand::HandleHashCommand(std::vector const& args) { +#if defined(CMAKE_BUILD_WITH_CMAKE) if(args.size() != 3) { cmOStringStream e; @@ -112,6 +113,12 @@ bool cmStringCommand::HandleHashCommand(std::vector const& args) return true; } return false; +#else + cmOStringStream e; + e << args[0] << " not available during bootstrap"; + this->SetError(e.str().c_str()); + return false; +#endif } //---------------------------------------------------------------------------- -- cgit v0.12 From 9fb1a9cf1dc45672b38350f2c4ae560359521566 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Nov 2011 11:05:13 -0500 Subject: sha2: Wrap long lines in third-party declarations --- Source/cm_sha2.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/cm_sha2.h b/Source/cm_sha2.h index ebe5e5a..71395f0 100644 --- a/Source/cm_sha2.h +++ b/Source/cm_sha2.h @@ -102,31 +102,36 @@ void SHA1_Init(SHA_CTX*); void SHA1_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); void SHA1_Final(cm_sha2_uint8_t[SHA1_DIGEST_LENGTH], SHA_CTX*); char* SHA1_End(SHA_CTX*, char[SHA1_DIGEST_STRING_LENGTH]); -char* SHA1_Data(const cm_sha2_uint8_t*, size_t, char[SHA1_DIGEST_STRING_LENGTH]); +char* SHA1_Data(const cm_sha2_uint8_t*, size_t, + char[SHA1_DIGEST_STRING_LENGTH]); void SHA224_Init(SHA_CTX*); void SHA224_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); void SHA224_Final(cm_sha2_uint8_t[SHA224_DIGEST_LENGTH], SHA_CTX*); char* SHA224_End(SHA_CTX*, char[SHA224_DIGEST_STRING_LENGTH]); -char* SHA224_Data(const cm_sha2_uint8_t*, size_t, char[SHA224_DIGEST_STRING_LENGTH]); +char* SHA224_Data(const cm_sha2_uint8_t*, size_t, + char[SHA224_DIGEST_STRING_LENGTH]); void SHA256_Init(SHA_CTX*); void SHA256_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); void SHA256_Final(cm_sha2_uint8_t[SHA256_DIGEST_LENGTH], SHA_CTX*); char* SHA256_End(SHA_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); -char* SHA256_Data(const cm_sha2_uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); +char* SHA256_Data(const cm_sha2_uint8_t*, size_t, + char[SHA256_DIGEST_STRING_LENGTH]); void SHA384_Init(SHA_CTX*); void SHA384_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); void SHA384_Final(cm_sha2_uint8_t[SHA384_DIGEST_LENGTH], SHA_CTX*); char* SHA384_End(SHA_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); -char* SHA384_Data(const cm_sha2_uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); +char* SHA384_Data(const cm_sha2_uint8_t*, size_t, + char[SHA384_DIGEST_STRING_LENGTH]); void SHA512_Init(SHA_CTX*); void SHA512_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); void SHA512_Final(cm_sha2_uint8_t[SHA512_DIGEST_LENGTH], SHA_CTX*); char* SHA512_End(SHA_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); -char* SHA512_Data(const cm_sha2_uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); +char* SHA512_Data(const cm_sha2_uint8_t*, size_t, + char[SHA512_DIGEST_STRING_LENGTH]); #ifdef __cplusplus } -- cgit v0.12 From 8302608a744c3a4df3495f8db88784fb3f04660f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Nov 2011 11:26:10 -0500 Subject: Fix CMake.File hash test for CRLF checkouts Use a dedicated test input file for the file() hash API tests. Set attribute crlf=input so it is always checked out correctly. --- Tests/CMakeTests/.gitattributes | 1 + Tests/CMakeTests/File-HASH-Input.txt | 1 + Tests/CMakeTests/File-MD5-BadArg2.cmake | 2 +- Tests/CMakeTests/File-MD5-BadArg4.cmake | 2 +- Tests/CMakeTests/File-MD5-Works.cmake | 2 +- Tests/CMakeTests/File-SHA1-Works.cmake | 2 +- Tests/CMakeTests/File-SHA224-Works.cmake | 2 +- Tests/CMakeTests/File-SHA256-Works.cmake | 2 +- Tests/CMakeTests/File-SHA384-Works.cmake | 2 +- Tests/CMakeTests/File-SHA512-Works.cmake | 2 +- Tests/CMakeTests/FileTest.cmake.in | 12 ++++++------ 11 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 Tests/CMakeTests/.gitattributes create mode 100644 Tests/CMakeTests/File-HASH-Input.txt diff --git a/Tests/CMakeTests/.gitattributes b/Tests/CMakeTests/.gitattributes new file mode 100644 index 0000000..c34e350 --- /dev/null +++ b/Tests/CMakeTests/.gitattributes @@ -0,0 +1 @@ +File-HASH-Input.txt crlf=input diff --git a/Tests/CMakeTests/File-HASH-Input.txt b/Tests/CMakeTests/File-HASH-Input.txt new file mode 100644 index 0000000..a1d315b --- /dev/null +++ b/Tests/CMakeTests/File-HASH-Input.txt @@ -0,0 +1 @@ +sample input string diff --git a/Tests/CMakeTests/File-MD5-BadArg2.cmake b/Tests/CMakeTests/File-MD5-BadArg2.cmake index 68a172f..2acc075 100644 --- a/Tests/CMakeTests/File-MD5-BadArg2.cmake +++ b/Tests/CMakeTests/File-MD5-BadArg2.cmake @@ -1 +1 @@ -file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake) +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt) diff --git a/Tests/CMakeTests/File-MD5-BadArg4.cmake b/Tests/CMakeTests/File-MD5-BadArg4.cmake index a11efcb..79b2755 100644 --- a/Tests/CMakeTests/File-MD5-BadArg4.cmake +++ b/Tests/CMakeTests/File-MD5-BadArg4.cmake @@ -1 +1 @@ -file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake md5 extra_arg) +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt md5 extra_arg) diff --git a/Tests/CMakeTests/File-MD5-Works.cmake b/Tests/CMakeTests/File-MD5-Works.cmake index 2989e98..0fabe54 100644 --- a/Tests/CMakeTests/File-MD5-Works.cmake +++ b/Tests/CMakeTests/File-MD5-Works.cmake @@ -1,2 +1,2 @@ -file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake md5) +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt md5) message("${md5}") diff --git a/Tests/CMakeTests/File-SHA1-Works.cmake b/Tests/CMakeTests/File-SHA1-Works.cmake index 03ea3ac..f2ab5d7 100644 --- a/Tests/CMakeTests/File-SHA1-Works.cmake +++ b/Tests/CMakeTests/File-SHA1-Works.cmake @@ -1,2 +1,2 @@ -file(SHA1 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake sha1) +file(SHA1 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha1) message("${sha1}") diff --git a/Tests/CMakeTests/File-SHA224-Works.cmake b/Tests/CMakeTests/File-SHA224-Works.cmake index 0295346..3e86b17 100644 --- a/Tests/CMakeTests/File-SHA224-Works.cmake +++ b/Tests/CMakeTests/File-SHA224-Works.cmake @@ -1,2 +1,2 @@ -file(SHA224 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake sha224) +file(SHA224 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha224) message("${sha224}") diff --git a/Tests/CMakeTests/File-SHA256-Works.cmake b/Tests/CMakeTests/File-SHA256-Works.cmake index 32bc9fe..b72d89e 100644 --- a/Tests/CMakeTests/File-SHA256-Works.cmake +++ b/Tests/CMakeTests/File-SHA256-Works.cmake @@ -1,2 +1,2 @@ -file(SHA256 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake sha256) +file(SHA256 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha256) message("${sha256}") diff --git a/Tests/CMakeTests/File-SHA384-Works.cmake b/Tests/CMakeTests/File-SHA384-Works.cmake index 5c56de2..0eeca33 100644 --- a/Tests/CMakeTests/File-SHA384-Works.cmake +++ b/Tests/CMakeTests/File-SHA384-Works.cmake @@ -1,2 +1,2 @@ -file(SHA384 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake sha384) +file(SHA384 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha384) message("${sha384}") diff --git a/Tests/CMakeTests/File-SHA512-Works.cmake b/Tests/CMakeTests/File-SHA512-Works.cmake index cf10706..d74ee44 100644 --- a/Tests/CMakeTests/File-SHA512-Works.cmake +++ b/Tests/CMakeTests/File-SHA512-Works.cmake @@ -1,2 +1,2 @@ -file(SHA512 ${CMAKE_CURRENT_LIST_DIR}/File-Copy-NoDest.cmake sha512) +file(SHA512 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha512) message("${sha512}") diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index 824aba7..3c3d85d 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -21,17 +21,17 @@ set(MD5-BadArg2-STDERR "file MD5 requires a file name and output variable") set(MD5-BadArg4-RESULT 1) set(MD5-BadArg4-STDERR "file MD5 requires a file name and output variable") set(MD5-Works-RESULT 0) -set(MD5-Works-STDERR "a28a44fb5b58a6acf0cbec46557bc775") +set(MD5-Works-STDERR "10d20ddb981a6202b84aa1ce1cb7fce3") set(SHA1-Works-RESULT 0) -set(SHA1-Works-STDERR "e0ce452a7e34e9c705b46e4e7c9cd959082c0777") +set(SHA1-Works-STDERR "83f093e04289b21a9415f408ad50be8b57ad2f34") set(SHA224-Works-RESULT 0) -set(SHA224-Works-STDERR "d1f1c9db3df73586a5a200014505ef03b70da5e0539eb35c11b4ef6f") +set(SHA224-Works-STDERR "e995a7789922c4ef9279d94e763c8375934180a51baa7147bc48edf7") set(SHA256-Works-RESULT 0) -set(SHA256-Works-STDERR "bb38de1c34713f750a4f84404ef5fb1efb93cf815cb09182db457ba91de19195") +set(SHA256-Works-STDERR "d1c5915d8b71150726a1eef75a29ec6bea8fd1bef6b7299ef8048760b0402025") set(SHA384-Works-RESULT 0) -set(SHA384-Works-STDERR "2f01d58436bd04a40ec2c938a15f2bb661bf1bf1560a5f2d40a3ebbb716a58e400ab2992c23ba19fa96dc519e0042c26") +set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") set(SHA512-Works-RESULT 0) -set(SHA512-Works-STDERR "349d02e347ddb133afb4557c9e541163f54b6eaa9eb345672bfd7bbce90c9872bf1fad9c6662248eb7b092aef719e4b8c3b8bb1cf47f287abbde12360c073686") +set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(File -- cgit v0.12 From 6495b595c4953ce29e66ff4919d69a74300c3532 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Nov 2011 11:32:01 -0500 Subject: cmCryptoHash: Add virtual destructor Instances of this class are always subclasses. Use a virtual destructor to ensure the subclasses cleanup correctly. --- Source/cmCryptoHash.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index 0a33365..1bea9ab 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -19,6 +19,7 @@ class cmCryptoHash { public: + virtual ~cmCryptoHash() {} static cmsys::auto_ptr New(const char* algo); std::string HashString(const char* input); std::string HashFile(const char* file); -- cgit v0.12 From 65dde30dddbe495877a3ecfef5a2d0015449b69c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 16 Nov 2011 20:53:59 +0100 Subject: FindGettext: two more fixes for files with multiple dots Another patch by Albert Astals Cid for dealing with translation files with multiple dots. Alex --- Modules/FindGettext.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index ffe3f26..c44adb4 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -52,7 +52,8 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) SET(_firstPoFile "${_firstPoFileArg}") SET(_gmoFiles) - GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE) + GET_FILENAME_COMPONENT(_potName ${_potFile} NAME) + STRING(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName}) GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE) SET(_addToAll) @@ -92,7 +93,8 @@ FUNCTION(GETTEXT_PROCESS_POT_FILE _potFile) CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) - GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE) + GET_FILENAME_COMPONENT(_potName ${_potFile} NAME) + STRING(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName}) GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE) FOREACH (_lang ${_parsedArguments_LANGUAGES}) -- cgit v0.12 From 21469b65dd9238b1737acfcd57886f83578ecab7 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 17 Nov 2011 00:05:11 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 4458c1d..5f70f8d 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 16) +SET(KWSYS_DATE_STAMP_DAY 17) -- cgit v0.12 From 8be93fc487064c5b417ab9b0ebd4e027a5e6b9ea Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Nov 2011 08:54:46 -0500 Subject: KWIML: Test header inclusion after system headers Some system headers may define macros that interfere with preprocessor tests in KWIML headers. Test this case to be sure that the verification checks at the bottom of the headers do not fail. --- test/CMakeLists.txt | 2 ++ test/test.c | 4 ++++ test/test_include_C.c | 22 ++++++++++++++++++++++ test/test_include_CXX.cxx | 22 ++++++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 test/test_include_C.c create mode 100644 test/test_include_CXX.cxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index febc994..a2359cc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -35,6 +35,7 @@ if(KWIML_LANGUAGE_C) list(APPEND test_srcs test_ABI_C.c test_INT_C.c + test_include_C.c ) endif() if(KWIML_LANGUAGE_CXX) @@ -42,6 +43,7 @@ if(KWIML_LANGUAGE_CXX) list(APPEND test_srcs test_ABI_CXX.cxx test_INT_CXX.cxx + test_include_CXX.cxx ) endif() diff --git a/test/test.c b/test/test.c index d71a284..131c81f 100644 --- a/test/test.c +++ b/test/test.c @@ -16,6 +16,8 @@ extern int test_ABI_C(void); extern int test_INT_C(void); extern int test_ABI_CXX(void); extern int test_INT_CXX(void); +extern int test_include_C(void); +extern int test_include_CXX(void); #ifdef __cplusplus } // extern "C" #endif @@ -26,10 +28,12 @@ int main(void) #ifdef KWIML_LANGUAGE_C result = test_ABI_C() && result; result = test_INT_C() && result; + result = test_include_C() && result; #endif #ifdef KWIML_LANGUAGE_CXX result = test_ABI_CXX() && result; result = test_INT_CXX() && result; + result = test_include_CXX() && result; #endif return result? 0 : 1; } diff --git a/test/test_include_C.c b/test/test_include_C.c new file mode 100644 index 0000000..fb3e4cf --- /dev/null +++ b/test/test_include_C.c @@ -0,0 +1,22 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + 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. +============================================================================*/ +#include + +/* Test KWIML header inclusion after above system headers. */ +#include "test.h" +#include KWIML_HEADER(ABI.h) +#include KWIML_HEADER(INT.h) + +int test_include_C(void) +{ + return 1; +} diff --git a/test/test_include_CXX.cxx b/test/test_include_CXX.cxx new file mode 100644 index 0000000..057b7c2 --- /dev/null +++ b/test/test_include_CXX.cxx @@ -0,0 +1,22 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + 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. +============================================================================*/ +#include + +/* Test KWIML header inclusion after above system headers. */ +#include "test.h" +#include KWIML_HEADER(ABI.h) +#include KWIML_HEADER(INT.h) + +extern "C" int test_include_CXX(void) +{ + return 1; +} -- cgit v0.12 From 9ccd639ad70c65b844f6610c5ae08a63e25f6806 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Nov 2011 10:15:02 -0500 Subject: KWIML: Ignore _LONGLONG on MS compiler The VS 7.0 header included by most C++ system headers defines the macro _LONGLONG as __int64. Teach ABI.h to ignore the definition in this case because "long long" does not exist. --- ABI.h.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ABI.h.in b/ABI.h.in index c4121ff..0ec6d0e 100644 --- a/ABI.h.in +++ b/ABI.h.in @@ -216,7 +216,8 @@ suppression macro @KWIML@_ABI_NO_VERIFY was defined. # endif #endif #if !defined(@KWIML@_ABI_SIZEOF_LONG_LONG) -# if defined(_LONGLONG) /* SGI, some GNU, perhaps others. */ +# if defined(_LONGLONG) /* SGI, some GNU, perhaps others. */ \ + && !defined(_MSC_VER) # define @KWIML@_ABI_SIZEOF_LONG_LONG 8 # elif defined(_LONG_LONG) /* IBM XL, perhaps others. */ # define @KWIML@_ABI_SIZEOF_LONG_LONG 8 -- cgit v0.12 From 24b1feb5ca9dbc3461d373e4de30a33157f81375 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Nov 2011 11:07:43 -0500 Subject: sha2: Cast safe conversions to smaller integer types Add a cast to lines converting "uint64_t" to "unsigned int" that are known safe due to use of modulus with a small integer. This avoids compiler warnings such as conversion from 'cm_sha2_uint64_t' to 'unsigned int', possible loss of data from MSVC. --- Source/cm_sha2.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c index b89f8fe..7991d27 100644 --- a/Source/cm_sha2.c +++ b/Source/cm_sha2.c @@ -652,7 +652,7 @@ void SHA1_Update(SHA_CTX* context, const sha_byte *data, size_t len) { /* Sanity check: */ assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); - usedspace = (context->s1.bitcount >> 3) % 64; + usedspace = (unsigned int)((context->s1.bitcount >> 3) % 64); if (usedspace > 0) { /* Calculate how much free space is available in the buffer */ freespace = 64 - usedspace; @@ -705,7 +705,7 @@ void SHA1_Final(sha_byte digest[], SHA_CTX* context) { return; } - usedspace = (context->s1.bitcount >> 3) % 64; + usedspace = (unsigned int)((context->s1.bitcount >> 3) % 64); if (usedspace == 0) { /* Set-up for the last transform: */ MEMSET_BZERO(context->s1.buffer, 56); @@ -992,7 +992,7 @@ void SHA256_Update(SHA_CTX* context, const sha_byte *data, size_t len) { /* Sanity check: */ assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); - usedspace = (context->s256.bitcount >> 3) % 64; + usedspace = (unsigned int)((context->s256.bitcount >> 3) % 64); if (usedspace > 0) { /* Calculate how much free space is available in the buffer */ freespace = 64 - usedspace; @@ -1032,7 +1032,7 @@ void SHA256_Update(SHA_CTX* context, const sha_byte *data, size_t len) { void SHA256_Internal_Last(SHA_CTX* context) { unsigned int usedspace; - usedspace = (context->s256.bitcount >> 3) % 64; + usedspace = (unsigned int)((context->s256.bitcount >> 3) % 64); #if BYTE_ORDER == LITTLE_ENDIAN /* Convert FROM host byte order */ REVERSE64(context->s256.bitcount,context->s256.bitcount); @@ -1399,7 +1399,7 @@ void SHA512_Update(SHA_CTX* context, const sha_byte *data, size_t len) { /* Sanity check: */ assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); - usedspace = (context->s512.bitcount[0] >> 3) % 128; + usedspace = (unsigned int)((context->s512.bitcount[0] >> 3) % 128); if (usedspace > 0) { /* Calculate how much free space is available in the buffer */ freespace = 128 - usedspace; @@ -1439,7 +1439,7 @@ void SHA512_Update(SHA_CTX* context, const sha_byte *data, size_t len) { void SHA512_Internal_Last(SHA_CTX* context) { unsigned int usedspace; - usedspace = (context->s512.bitcount[0] >> 3) % 128; + usedspace = (unsigned int)((context->s512.bitcount[0] >> 3) % 128); #if BYTE_ORDER == LITTLE_ENDIAN /* Convert FROM host byte order */ REVERSE64(context->s512.bitcount[0],context->s512.bitcount[0]); -- cgit v0.12 From 0a6705cbda8171667c4b37872136cd102ccc328c Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Nov 2011 11:12:00 -0500 Subject: sha2: Suppress -Wcast-align warning from Clang The code does contain a cast that increases alignment but only for pointers into structures known to be sufficiently aligned. --- Source/cm_sha2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c index 7991d27..b1798a8 100644 --- a/Source/cm_sha2.c +++ b/Source/cm_sha2.c @@ -106,6 +106,9 @@ typedef cm_sha2_uint64_t sha_word64; /* Exactly 8 bytes */ #if defined(__BORLANDC__) # pragma warn -8004 /* variable assigned value that is never used */ #endif +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wcast-align" +#endif /*** ENDIAN REVERSAL MACROS *******************************************/ #if BYTE_ORDER == LITTLE_ENDIAN -- cgit v0.12 From 0599c5f546c8b3e04c0dd9fcdc19a6b3825849a7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Nov 2011 11:18:08 -0500 Subject: sha2: Zero entire SHA_CTX structure during cleanup Convert lines of the form MEMSET_BZERO(context, sizeof(context)); to the correct form MEMSET_BZERO(context, sizeof(*context)); as suggested by Clang. --- Source/cm_sha2.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c index b1798a8..12c39ed 100644 --- a/Source/cm_sha2.c +++ b/Source/cm_sha2.c @@ -704,7 +704,7 @@ void SHA1_Final(sha_byte digest[], SHA_CTX* context) { * No digest buffer, so we can do nothing * except clean up and go home */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); return; } @@ -760,7 +760,7 @@ void SHA1_Final(sha_byte digest[], SHA_CTX* context) { #endif /* Clean up: */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *SHA1_End(SHA_CTX* context, char buffer[]) { @@ -780,7 +780,7 @@ char *SHA1_End(SHA_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA1_DIGEST_LENGTH); return buffer; @@ -1099,7 +1099,7 @@ void SHA256_Final(sha_byte digest[], SHA_CTX* context) { } /* Clean up state data: */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *SHA256_End(SHA_CTX* context, char buffer[]) { @@ -1119,7 +1119,7 @@ char *SHA256_End(SHA_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA256_DIGEST_LENGTH); return buffer; @@ -1173,7 +1173,7 @@ void SHA224_Final(sha_byte digest[], SHA_CTX* context) { } /* Clean up state data: */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *SHA224_End(SHA_CTX* context, char buffer[]) { @@ -1193,7 +1193,7 @@ char *SHA224_End(SHA_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA224_DIGEST_LENGTH); return buffer; @@ -1508,7 +1508,7 @@ void SHA512_Final(sha_byte digest[], SHA_CTX* context) { } /* Zero out state data */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *SHA512_End(SHA_CTX* context, char buffer[]) { @@ -1528,7 +1528,7 @@ char *SHA512_End(SHA_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA512_DIGEST_LENGTH); return buffer; @@ -1578,7 +1578,7 @@ void SHA384_Final(sha_byte digest[], SHA_CTX* context) { } /* Zero out state data */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *SHA384_End(SHA_CTX* context, char buffer[]) { @@ -1598,7 +1598,7 @@ char *SHA384_End(SHA_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA384_DIGEST_LENGTH); return buffer; -- cgit v0.12 From 8e1bbee4d948025dfb1888e0a8b0365d7bd360c8 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 18 Nov 2011 00:05:04 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 5f70f8d..c9e53f6 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 17) +SET(KWSYS_DATE_STAMP_DAY 18) -- cgit v0.12 From 46c70540ede37c5f2ebeeeba4178340abf92fadb Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 18 Nov 2011 10:15:58 -0500 Subject: VS: Use "call " keyword with .cmd and .bat file custom commands (#12445) Similar fix to commit d093abef for the Makefile generators. Prevents premature exit from sequence of commands. Even when no errors occur, the previous construct without "call " was exiting the sequence before executing the full set of commands... --- Source/cmLocalVisualStudioGenerator.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 4d16409..de1ac30 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -250,6 +250,20 @@ cmLocalVisualStudioGenerator // Add this command line. std::string cmd = ccg.GetCommand(c); + + // Use "call " before any invocations of .bat or .cmd files + // invoked as custom commands. + // + std::string suffix; + if (cmd.size() > 4) + { + suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size()-4)); + if (suffix == ".bat" || suffix == ".cmd") + { + script += "call "; + } + } + script += this->Convert(cmd.c_str(), relativeRoot, SHELL); ccg.AppendArguments(c, script); -- cgit v0.12 From 20cb5edbcaaf89c35638911c27e6aec1c7fc022f Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 18 Nov 2011 16:14:54 +0100 Subject: FindBISON: Fix matching output of "bison --version" The output may contain semicolons, which will confuse the IF() because of missing quoting. --- Modules/FindBISON.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index 25fd51d..edde9eb 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -68,11 +68,11 @@ IF(BISON_EXECUTABLE) MESSAGE(SEND_ERROR "Command \"${BISON_EXECUTABLE} --version\" failed with output:\n${BISON_version_error}") ELSE() # Bison++ - IF(${BISON_version_output} MATCHES "^bison\\+\\+") + IF("${BISON_version_output}" MATCHES "^bison\\+\\+") STRING(REGEX REPLACE "^bison\\+\\+ Version ([^,]+).*" "\\1" BISON_VERSION "${BISON_version_output}") # GNU Bison - ELSEIF(${BISON_version_output} MATCHES "^bison[^+]") + ELSEIF("${BISON_version_output}" MATCHES "^bison[^+]") STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1" BISON_VERSION "${BISON_version_output}") ELSE() -- cgit v0.12 From df0f302485c6f93a473e1958830b69b9c165b01a Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Fri, 18 Nov 2011 19:20:07 +0100 Subject: FindPNG: provide PNG_INCLUDE_DIRS, as the readme.txt says (#11312) Also improve the documentation a bit. Alex --- Modules/FindPNG.cmake | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index f607dc6..f616973 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -1,14 +1,18 @@ # - Find the native PNG includes and library # -# This module defines -# PNG_INCLUDE_DIR, where to find png.h, etc. +# This module searches libpng, the library for working with PNG images. +# +# It defines the following variables +# PNG_INCLUDE_DIRS, where to find png.h, etc. # PNG_LIBRARIES, the libraries to link against to use PNG. # PNG_DEFINITIONS - You should add_definitons(${PNG_DEFINITIONS}) before compiling code that includes png library files. # PNG_FOUND, If false, do not try to use PNG. -# also defined, but not for general use are +# Also defined, but not for general use are # PNG_LIBRARY, where to find the PNG library. -# None of the above will be defined unles zlib can be found. -# PNG depends on Zlib +# For backward compatiblity the variable PNG_INCLUDE_DIR is also set. It has the same value as PNG_INCLUDE_DIRS. +# +# Since PNG depends on the ZLib compression library, none of the above will be +# defined unless ZLib can be found. #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -38,7 +42,8 @@ if(ZLIB_FOUND) if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) # png.h includes zlib.h. Sigh. - SET(PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ) + SET(PNG_INCLUDE_DIRS ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ) + SET(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIRS} ) # for backward compatiblity SET(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY}) if (CYGWIN) -- cgit v0.12 From ae7cf91b1376cc313dc39e41c7d3e2026ac79b6b Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 18 Nov 2011 13:46:22 -0500 Subject: KWIML: Teach ABI.h about PGI compiler The PGI compiler appears to define "long long" as size 8 but does not provide a feature macro for it. It does provide options for the signedness of char (-Mschar, -Muchar) but does not define a feature macro indicating the choice. The default is signed, at least on Linux. --- ABI.h.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ABI.h.in b/ABI.h.in index 0ec6d0e..e95a4ff 100644 --- a/ABI.h.in +++ b/ABI.h.in @@ -148,6 +148,8 @@ suppression macro @KWIML@_ABI_NO_VERIFY was defined. # define @KWIML@_ABI_CHAR_IS_SIGNED 1 # elif defined(_SGI_COMPILER_VERSION) /* SGI MIPSpro default */ # define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 +# elif defined(__PGIC__) /* PGI default */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 # elif defined(_MSC_VER) /* MSVC default */ # define @KWIML@_ABI_CHAR_IS_SIGNED 1 # elif defined(__WATCOMC__) /* Watcom default */ @@ -231,6 +233,8 @@ suppression macro @KWIML@_ABI_NO_VERIFY was defined. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8 # elif defined(__HP_cc) || defined(__HP_aCC) /* HP */ # define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__PGIC__) /* PGI */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 # elif defined(__WATCOMC__) /* Watcom */ # define @KWIML@_ABI_SIZEOF_LONG_LONG 8 # elif defined(__INTEL_COMPILER) /* Intel */ -- cgit v0.12 From 92af1dad0652951e8f7adc1a4a59527bd98435fa Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 18 Nov 2011 17:13:07 -0500 Subject: CTest: Disallow problem chars in build and site names (#11792) Also, use "(empty)" rather than actually sending an empty string if build or site name is not set properly. --- Source/cmCTest.cxx | 57 ++++++++++++++++++++++++++++++++++++++++++++++++------ Source/cmCTest.h | 4 ++++ 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 7bb8b27..14055a4 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1441,6 +1441,43 @@ int cmCTest::RunTest(std::vector argv, } //---------------------------------------------------------------------- +std::string cmCTest::SafeBuildIdField(const std::string& value) +{ + std::string safevalue(value); + + if (safevalue != "") + { + // Disallow non-filename and non-space whitespace characters. + // If they occur, replace them with "" + // + const char *disallowed = "\\/:*?\"<>|\n\r\t\f\v"; + + if (safevalue.find_first_of(disallowed) != value.npos) + { + std::string::size_type i = 0; + std::string::size_type n = strlen(disallowed); + char replace[2]; + replace[1] = 0; + + for (i= 0; iCurrentTag.empty()) @@ -1450,19 +1487,27 @@ void cmCTest::StartXML(std::ostream& ostr, bool append) " NightlStartTime was not set correctly." << std::endl); cmSystemTools::SetFatalErrorOccured(); } + // find out about the system cmsys::SystemInformation info; info.RunCPUCheck(); info.RunOSCheck(); info.RunMemoryCheck(); + + std::string buildname = cmCTest::SafeBuildIdField( + this->GetCTestConfiguration("BuildName")); + std::string stamp = cmCTest::SafeBuildIdField( + this->CurrentTag + "-" + this->GetTestModelString()); + std::string site = cmCTest::SafeBuildIdField( + this->GetCTestConfiguration("Site")); + ostr << "\n" - << "GetCTestConfiguration("BuildName") - << "\"\n\tBuildStamp=\"" << this->CurrentTag << "-" - << this->GetTestModelString() << "\"\n\tName=\"" - << this->GetCTestConfiguration("Site") << "\"\n\tGenerator=\"ctest-" - << cmVersion::GetCMakeVersion() << "\"\n" + << "GetCTestConfiguration("Compiler") + << "\tCompilerName=\"" << this->GetCTestConfiguration("Compiler") << "\"\n" #ifdef _COMPILER_VERSION << "\tCompilerVersion=\"_COMPILER_VERSION\"\n" diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 44a5349..7c71b00 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -259,6 +259,10 @@ public: std::string* stdOut, std::string* stdErr, int* retVal = 0, const char* dir = 0, double timeout = 0.0); + //! Clean/make safe for xml the given value such that it may be used as + // one of the key fields by CDash when computing the buildid. + static std::string SafeBuildIdField(const std::string& value); + //! Start CTest XML output file void StartXML(std::ostream& ostr, bool append); -- cgit v0.12 From fa878d27bf3585e9ea2bc07ceb150268a114944a Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 19 Nov 2011 00:05:04 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index c9e53f6..48e1f30 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 18) +SET(KWSYS_DATE_STAMP_DAY 19) -- cgit v0.12 From 1110e455c20598983bbf435bd9356c1a952e305a Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 19 Nov 2011 11:01:03 +0100 Subject: Eclipse: create links to subprojects also in the source-project (#12579) Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 20 +++++++++++++++----- Source/cmExtraEclipseCDT4Generator.h | 5 +++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 248a30a..2e4e68f 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -113,7 +113,7 @@ void cmExtraEclipseCDT4Generator::Generate() this->CreateCProjectFile(); } -void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() const +void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() { assert(this->HomeDirectory != this->HomeOutputDirectory); @@ -141,6 +141,16 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() const "\t\n" "\t\n" "\t\n" + "\t\n"; + + if (this->SupportsVirtualFolders) + { + this->CreateLinksToSubprojects(fout, this->HomeDirectory); + this->SrcLinkedResources.clear(); + } + + fout << + "\t\n" "\n" ; } @@ -434,7 +444,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() if (this->SupportsVirtualFolders) { - this->CreateLinksToSubprojects(fout); + this->CreateLinksToSubprojects(fout, this->HomeOutputDirectory); this->CreateLinksForTargets(fout); } @@ -541,7 +551,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( - cmGeneratedFileStream& fout) + cmGeneratedFileStream& fout, const std::string& baseDir) { // for each sub project create a linked resource to the source dir // - only if it is an out-of-source build @@ -557,8 +567,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( it->second[0]->GetMakefile()->GetStartDirectory()); // a linked resource must not point to a parent directory of .project or // .project itself - if ((this->HomeOutputDirectory != linkSourceDirectory) && - !cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), + if ((baseDir != linkSourceDirectory) && + !cmSystemTools::IsSubDirectory(baseDir.c_str(), linkSourceDirectory.c_str())) { std::string linkName = "[Subprojects]/"; diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index 61302e7..ebd8c08 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -46,7 +46,7 @@ public: private: // create .project file in the source tree - void CreateSourceProjectFile() const; + void CreateSourceProjectFile(); // create .project file void CreateProjectFile(); @@ -104,7 +104,8 @@ private: static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar, cmMakefile* mf); - void CreateLinksToSubprojects(cmGeneratedFileStream& fout); + void CreateLinksToSubprojects(cmGeneratedFileStream& fout, + const std::string& baseDir); void CreateLinksForTargets(cmGeneratedFileStream& fout); std::vector SrcLinkedResources; -- cgit v0.12 From 982b766f29086b851fb4aee891e5e6d4bae95eb9 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 19 Nov 2011 11:18:51 +0100 Subject: Eclipse: use new variable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT Previously ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT was used, but the new name CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT is more in line with the general naming conventions in cmake, and, more importantly IMO, in cmake-gui it now appears right next to the other eclipse-related variables, which all start with CMAKE_ECLIPSE_. A warning is printed if the old variable is TRUE and the new one isn't, so users should notice that they have to enable the new one. Alex --- Modules/CMakeFindEclipseCDT4.cmake | 4 ++-- Source/cmExtraEclipseCDT4Generator.cxx | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index f7a6e29..dd06128 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -70,8 +70,8 @@ ENDIF() SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "${_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j to get parallel builds") # This variable is used by the Eclipse generator in out-of-source builds only. -SET(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR") -MARK_AS_ADVANCED(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT) +SET(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR") +MARK_AS_ADVANCED(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT) # Determine builtin macros and include dirs: INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 2e4e68f..07549e9 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -85,7 +85,16 @@ void cmExtraEclipseCDT4Generator::Generate() this->IsOutOfSourceBuild = (this->HomeDirectory!=this->HomeOutputDirectory); this->GenerateSourceProject = (this->IsOutOfSourceBuild && - mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT")); + mf->IsOn("CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT")); + + if ((this->GenerateSourceProject == false) + && (mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT"))) + { + mf->IssueMessage(cmake::WARNING, + "ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT is set to TRUE, " + "but this variable is not supported anymore since CMake 2.8.7.\n" + "Enable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT instead."); + } if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), this->HomeDirectory.c_str())) -- cgit v0.12 From 08c59af4dec0628964d9534ac165d75914bf580c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 19 Nov 2011 22:19:48 +0100 Subject: Remove trailing whitespace Alex --- Source/QtDialog/AddCacheEntry.cxx | 8 ++++---- Source/QtDialog/CMakeSetupDialog.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index b4d9191..412d443 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -14,11 +14,11 @@ #include static const int NumTypes = 4; -static const QString TypeStrings[NumTypes] = +static const QString TypeStrings[NumTypes] = { "BOOL", "PATH", "FILEPATH", "STRING" }; -static const QCMakeProperty::PropertyType Types[NumTypes] = - { QCMakeProperty::BOOL, QCMakeProperty::PATH, - QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; +static const QCMakeProperty::PropertyType Types[NumTypes] = + { QCMakeProperty::BOOL, QCMakeProperty::PATH, + QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; AddCacheEntry::AddCacheEntry(QWidget* p) : QWidget(p) diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 5121759..b905077 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -36,7 +36,7 @@ public slots: void setBinaryDirectory(const QString& dir); void setSourceDirectory(const QString& dir); -protected slots: +protected slots: void initialize(); void doConfigure(); void doGenerate(); @@ -46,7 +46,7 @@ protected slots: void doInterrupt(); void error(const QString& message); void message(const QString& message); - + void doSourceBrowse(); void doBinaryBrowse(); void doReloadCache(); @@ -118,8 +118,8 @@ class QCMakeThread : public QThread public: QCMakeThread(QObject* p); QCMake* cmakeInstance() const; - -signals: + +signals: void cmakeInitialized(); protected: -- cgit v0.12 From b0d01c306bd8dc6c636e65d38dc0d9e483568a67 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 19 Nov 2011 22:21:41 +0100 Subject: cmake-gui: add completion for the names when adding cache entries Up to 100 completion strings for the names of added variables are saved in the settings, so it will remember the variables you are usually adding. It also ensures that CMAKE_INSTALL_PREFIX is always there, since this is maybe the one which is set most often. Alex --- Source/QtDialog/AddCacheEntry.cxx | 4 +++- Source/QtDialog/AddCacheEntry.h | 3 ++- Source/QtDialog/CMakeSetupDialog.cxx | 25 ++++++++++++++++++++++++- Source/QtDialog/CMakeSetupDialog.h | 2 ++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index 412d443..00aaf69 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -12,6 +12,7 @@ #include "AddCacheEntry.h" #include +#include static const int NumTypes = 4; static const QString TypeStrings[NumTypes] = @@ -20,7 +21,7 @@ static const QCMakeProperty::PropertyType Types[NumTypes] = { QCMakeProperty::BOOL, QCMakeProperty::PATH, QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; -AddCacheEntry::AddCacheEntry(QWidget* p) +AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& completions) : QWidget(p) { this->setupUi(this); @@ -42,6 +43,7 @@ AddCacheEntry::AddCacheEntry(QWidget* p) this->setTabOrder(path, filepath); this->setTabOrder(filepath, string); this->setTabOrder(string, this->Description); + this->Name->setCompleter(new QCompleter(completions, this)); } QString AddCacheEntry::name() const diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h index db6baf9..e219d4e 100644 --- a/Source/QtDialog/AddCacheEntry.h +++ b/Source/QtDialog/AddCacheEntry.h @@ -15,6 +15,7 @@ #include #include +#include #include "QCMake.h" #include "ui_AddCacheEntry.h" @@ -23,7 +24,7 @@ class AddCacheEntry : public QWidget, public Ui::AddCacheEntry { Q_OBJECT public: - AddCacheEntry(QWidget* p); + AddCacheEntry(QWidget* p, const QStringList& completions); QString name() const; QVariant value() const; diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index c8c4bfa..1c058d3 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -68,6 +68,9 @@ CMakeSetupDialog::CMakeSetupDialog() int w = settings.value("Width", 700).toInt(); this->resize(w, h); + this->AddVariableCompletions = settings.value("AddVariableCompletionEntries", + QStringList("CMAKE_INSTALL_PREFIX")).toStringList(); + QWidget* cont = new QWidget(this); this->setupUi(cont); this->Splitter->setStretchFactor(0, 3); @@ -1008,7 +1011,7 @@ void CMakeSetupDialog::addCacheEntry() dialog.resize(400, 200); dialog.setWindowTitle(tr("Add Cache Entry")); QVBoxLayout* l = new QVBoxLayout(&dialog); - AddCacheEntry* w = new AddCacheEntry(&dialog); + AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableCompletions); QDialogButtonBox* btns = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog); @@ -1021,6 +1024,26 @@ void CMakeSetupDialog::addCacheEntry() { QCMakeCacheModel* m = this->CacheValues->cacheModel(); m->insertProperty(w->type(), w->name(), w->description(), w->value(), false); + + // only add variable names to the completion which are new + if (!this->AddVariableCompletions.contains(w->name())) + { + this->AddVariableCompletions << w->name(); + // limit to at most 100 completion items + if (this->AddVariableCompletions.size() > 100) + { + this->AddVariableCompletions.removeFirst(); + } + // make sure CMAKE_INSTALL_PREFIX is always there + if (!this->AddVariableCompletions.contains("CMAKE_INSTALL_PREFIX")) + { + this->AddVariableCompletions << QString("CMAKE_INSTALL_PREFIX"); + } + QSettings settings; + settings.beginGroup("Settings/StartPath"); + settings.setValue("AddVariableCompletionEntries", + this->AddVariableCompletions); + } } } diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index b905077..2599675 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -105,6 +105,8 @@ protected: QTextCharFormat ErrorFormat; QTextCharFormat MessageFormat; + QStringList AddVariableCompletions; + QEventLoop LocalLoop; float ProgressOffset; -- cgit v0.12 From 6580434f16cf4c6db1fde6d804e95d40f27c0f45 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 20 Nov 2011 00:05:04 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 48e1f30..d10bb99 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 19) +SET(KWSYS_DATE_STAMP_DAY 20) -- cgit v0.12 From ad9bffdc3c1b43e0a3c3f47e9ee8d3bff487324e Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 21 Nov 2011 00:05:04 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index d10bb99..30a0b06 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 20) +SET(KWSYS_DATE_STAMP_DAY 21) -- cgit v0.12 From b421c2477c4c4f9d4c93997661f1698812cdae36 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 21 Nov 2011 11:02:26 -0500 Subject: KWIML: Avoid MSVC linker warning about not using C++ runtime Teach KWIML_test to use part of the C++ runtime library. Otherwise the linker complains: warning LNK4089: all references to 'MSVCP71.dll' discarded by /OPT:REF --- test/test_include_CXX.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_include_CXX.cxx b/test/test_include_CXX.cxx index 057b7c2..111311a 100644 --- a/test/test_include_CXX.cxx +++ b/test/test_include_CXX.cxx @@ -11,6 +11,12 @@ ============================================================================*/ #include +#if defined(_MSC_VER) && defined(NDEBUG) +// Use C++ runtime to avoid linker warning: +// warning LNK4089: all references to 'MSVCP71.dll' discarded by /OPT:REF +std::string test_include_CXX_use_stl_string; +#endif + /* Test KWIML header inclusion after above system headers. */ #include "test.h" #include KWIML_HEADER(ABI.h) -- cgit v0.12 From 3bbe46daa27a2f405bf97622ad30fd6090e2958e Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 22 Nov 2011 00:05:06 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 30a0b06..1df5ca9 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 21) +SET(KWSYS_DATE_STAMP_DAY 22) -- cgit v0.12 From a2be068c75890a9b6723c0bbb2d32a108cb84eed Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 12 Nov 2011 18:12:07 +0100 Subject: install(EXPORT): Enforce existence of imported target files Typical Config.cmake files for find_package() rely only on the files generated by install(EXPORT). They might be wrong, for whatever reasons, like people manually deleted files, projects were packaged wrong by distributions, whatever. To protect against this, add checks that the file locations we are importing actually exist on disk. Alex --- Source/cmExportFileGenerator.cxx | 66 +++++++++++++++++++++++++++++++++ Source/cmExportFileGenerator.h | 5 +++ Source/cmExportInstallFileGenerator.cxx | 30 ++++++++++----- Source/cmExportInstallFileGenerator.h | 4 +- 4 files changed, 94 insertions(+), 11 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 9e5c91e..7777373 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -368,3 +368,69 @@ cmExportFileGenerator os << " )\n" << "\n"; } + + +//---------------------------------------------------------------------------- +void +cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os) +{ + // Add code which verifies at cmake time that the file which is being + // imported actually exists on disk. This should in theory always be theory + // case, but still when packages are split into normal and development + // packages this might get broken (e.g. the Config.cmake could be part of + // the non-development package, something similar happened to me without + // on SUSE with a mysql pkg-config file, which claimed everything is fine, + // but the development package was not installed.). + os << "# Loop over all imported files and verify that they actually exist\n" + "FOREACH(target ${_IMPORT_CHECK_TARGETS} )\n" + " FOREACH(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n" + " IF(NOT EXISTS \"${file}\" )\n" + " MESSAGE(FATAL_ERROR \"The imported target \\\"${target}\\\" " + "references the file \\\"${file}\\\", but this file does not exist. " + "There are multiple possible reasons:\n" + " * The file \\\"${file}\\\" has been manually " + "deleted, renamed or moved to another location.\n" + " * A previous install or uninstall procedure did not complete " + " successfully.\n" + " * The installation package was faulty, and contained\n" + "\\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n" + "but not\n" + "\\\"${file}\\\"\n" + "which must always be installed together.\\n\"\n" + " )\n" + " ENDIF()\n" + " ENDFOREACH()\n" + " UNSET(_IMPORT_CHECK_FILES_FOR_${target})\n" + "ENDFOREACH()\n" + "UNSET(_IMPORT_CHECK_TARGETS)\n" + "\n"; +} + + +//---------------------------------------------------------------------------- +void +cmExportFileGenerator +::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, + ImportPropertyMap const& properties, + const std::set& importedLocations) +{ + // Construct the imported target name. + std::string targetName = this->Namespace; + targetName += target->GetName(); + + os << "LIST(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n" + "LIST(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " "; + + for(std::set::const_iterator li = importedLocations.begin(); + li != importedLocations.end(); + ++li) + { + ImportPropertyMap::const_iterator pi = properties.find(*li); + if (pi != properties.end()) + { + os << "\"" << pi->second << "\" "; + } + } + + os << ")\n\n"; +} diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 05f73a2..f271e55 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -56,6 +56,11 @@ protected: void GenerateImportPropertyCode(std::ostream& os, const char* config, cmTarget* target, ImportPropertyMap const& properties); + void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, + ImportPropertyMap const& properties, + const std::set& importedLocations); + void GenerateImportedFileCheckLoop(std::ostream& os); + // Collect properties with detailed information about targets beyond // their location on disk. diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 23ff5fb..da14dd7 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -167,16 +167,18 @@ cmExportInstallFileGenerator // Collect import properties for this target. cmTargetExport* te = *tei; ImportPropertyMap properties; + std::set importedLocations; + this->SetImportLocationProperty(config, suffix, te->ArchiveGenerator, + properties, importedLocations); + this->SetImportLocationProperty(config, suffix, te->LibraryGenerator, + properties, importedLocations); this->SetImportLocationProperty(config, suffix, - te->ArchiveGenerator, properties); - this->SetImportLocationProperty(config, suffix, - te->LibraryGenerator, properties); - this->SetImportLocationProperty(config, suffix, - te->RuntimeGenerator, properties); - this->SetImportLocationProperty(config, suffix, - te->FrameworkGenerator, properties); - this->SetImportLocationProperty(config, suffix, - te->BundleGenerator, properties); + te->RuntimeGenerator, properties, + importedLocations); + this->SetImportLocationProperty(config, suffix, te->FrameworkGenerator, + properties, importedLocations); + this->SetImportLocationProperty(config, suffix, te->BundleGenerator, + properties, importedLocations); // If any file location was set for the target add it to the // import file. @@ -194,9 +196,13 @@ cmExportInstallFileGenerator // Generate code in the export file. this->GenerateImportPropertyCode(os, config, te->Target, properties); + this->GenerateImportedFileChecksCode(os, te->Target, properties, + importedLocations); } } + this->GenerateImportedFileCheckLoop(os); + // Cleanup the import prefix variable. if(!this->ImportPrefix.empty()) { @@ -211,7 +217,9 @@ void cmExportInstallFileGenerator ::SetImportLocationProperty(const char* config, std::string const& suffix, cmInstallTargetGenerator* itgen, - ImportPropertyMap& properties) + ImportPropertyMap& properties, + std::set& importedLocations + ) { // Skip rules that do not match this configuration. if(!(itgen && itgen->InstallsForConfig(config))) @@ -249,6 +257,7 @@ cmExportInstallFileGenerator // Store the property. properties[prop] = value; + importedLocations.insert(prop); } else { @@ -291,6 +300,7 @@ cmExportInstallFileGenerator // Store the property. properties[prop] = value; + importedLocations.insert(prop); } } diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 8c8fb44..fb678e8 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -75,7 +75,9 @@ protected: void SetImportLocationProperty(const char* config, std::string const& suffix, cmInstallTargetGenerator* itgen, - ImportPropertyMap& properties); + ImportPropertyMap& properties, + std::set& importedLocations + ); void ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen); -- cgit v0.12 From 5c03438661c285a7cc5f1e691198ac4e8a68a8f6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Nov 2011 16:39:24 -0500 Subject: install(EXPORT): Improve target import failure message format --- Source/cmExportFileGenerator.cxx | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 7777373..c4f5dfb 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -385,19 +385,16 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os) "FOREACH(target ${_IMPORT_CHECK_TARGETS} )\n" " FOREACH(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n" " IF(NOT EXISTS \"${file}\" )\n" - " MESSAGE(FATAL_ERROR \"The imported target \\\"${target}\\\" " - "references the file \\\"${file}\\\", but this file does not exist. " - "There are multiple possible reasons:\n" - " * The file \\\"${file}\\\" has been manually " - "deleted, renamed or moved to another location.\n" - " * A previous install or uninstall procedure did not complete " - " successfully.\n" - " * The installation package was faulty, and contained\n" - "\\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n" - "but not\n" - "\\\"${file}\\\"\n" - "which must always be installed together.\\n\"\n" - " )\n" + " MESSAGE(FATAL_ERROR \"The imported target \\\"${target}\\\"" + " references the file\n" + " \\\"${file}\\\"\n" + "but this file does not exist. Possible reasons include:\n" + "* The file was deleted, renamed, or moved to another location.\n" + "* An install or uninstall procedure did not complete successfully.\n" + "* The installation package was faulty and contained\n" + " \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n" + "but not all the files it references.\n" + "\")\n" " ENDIF()\n" " ENDFOREACH()\n" " UNSET(_IMPORT_CHECK_FILES_FOR_${target})\n" -- cgit v0.12 From cf64218eeb7dbe8a0d71292c42df63c4cb982fed Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 2 Nov 2011 12:43:01 +0100 Subject: target_link_libraries: Trim trailing whitespace --- Source/cmTargetLinkLibrariesCommand.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index ce57df7..a9b5d8b 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -19,7 +19,7 @@ * * cmTargetLinkLibrariesCommand is used to specify a list of libraries to link * into executable(s) or shared objects. The names of the libraries - * should be those defined by the LIBRARY(library) command(s). + * should be those defined by the LIBRARY(library) command(s). */ class cmTargetLinkLibrariesCommand : public cmCommand { @@ -27,7 +27,7 @@ public: /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { return new cmTargetLinkLibrariesCommand; } @@ -47,12 +47,12 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { - return + return "Link a target to given libraries."; } - + /** * More documentation. */ @@ -130,7 +130,7 @@ public: ")" ; } - + cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand); private: void LinkLibraryTypeSpecifierWarning(int left, int right); -- cgit v0.12 From 914382224d34cfb86a67c8191b6e7b3a3e918f88 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 7 Oct 2011 02:41:37 +0200 Subject: target_link_libraries: Add LINK_(PUBLIC|PRIVATE) options Makes it possible to specify the link dependencies and link interfaces in one command without repetition. --- Source/cmTargetLinkLibrariesCommand.cxx | 52 +++++++++++++++---- Source/cmTargetLinkLibrariesCommand.h | 21 +++++++- .../target_link_libraries/CMakeLists.txt | 58 ++++++++++++++++++++++ Tests/CMakeCommands/target_link_libraries/depA.cpp | 7 +++ Tests/CMakeCommands/target_link_libraries/depA.h | 7 +++ Tests/CMakeCommands/target_link_libraries/depB.cpp | 11 ++++ Tests/CMakeCommands/target_link_libraries/depB.h | 7 +++ Tests/CMakeCommands/target_link_libraries/depC.cpp | 13 +++++ Tests/CMakeCommands/target_link_libraries/depC.h | 12 +++++ .../target_link_libraries/targetA.cpp | 12 +++++ Tests/CMakeLists.txt | 2 + 11 files changed, 191 insertions(+), 11 deletions(-) create mode 100644 Tests/CMakeCommands/target_link_libraries/CMakeLists.txt create mode 100644 Tests/CMakeCommands/target_link_libraries/depA.cpp create mode 100644 Tests/CMakeCommands/target_link_libraries/depA.h create mode 100644 Tests/CMakeCommands/target_link_libraries/depB.cpp create mode 100644 Tests/CMakeCommands/target_link_libraries/depB.h create mode 100644 Tests/CMakeCommands/target_link_libraries/depC.cpp create mode 100644 Tests/CMakeCommands/target_link_libraries/depC.h create mode 100644 Tests/CMakeCommands/target_link_libraries/targetA.cpp diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 805959d..0db5943 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -95,8 +95,8 @@ bool cmTargetLinkLibrariesCommand bool haveLLT = false; // Start with primary linking and switch to link interface - // specification when the keyword is encountered. - this->DoingInterface = false; + // specification if the keyword is encountered as the first argument. + this->CurrentProcessingState = ProcessingLinkLibraries; // add libraries, nothe that there is an optional prefix // of debug and optimized than can be used @@ -104,7 +104,7 @@ bool cmTargetLinkLibrariesCommand { if(args[i] == "LINK_INTERFACE_LIBRARIES") { - this->DoingInterface = true; + this->CurrentProcessingState = ProcessingLinkInterface; if(i != 1) { this->Makefile->IssueMessage( @@ -115,6 +115,32 @@ bool cmTargetLinkLibrariesCommand return true; } } + else if(args[i] == "LINK_PUBLIC") + { + if(i != 1 && this->CurrentProcessingState != ProcessingPrivateInterface) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second " + "argument, just after the target name." + ); + return true; + } + this->CurrentProcessingState = ProcessingPublicInterface; + } + else if(args[i] == "LINK_PRIVATE") + { + if(i != 1 && this->CurrentProcessingState != ProcessingPublicInterface) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second " + "argument, just after the target name." + ); + return true; + } + this->CurrentProcessingState = ProcessingPrivateInterface; + } else if(args[i] == "debug") { if(haveLLT) @@ -186,11 +212,13 @@ bool cmTargetLinkLibrariesCommand cmSystemTools::SetFatalErrorOccured(); } - // If the INTERFACE option was given, make sure the - // LINK_INTERFACE_LIBRARIES property exists. This allows the - // command to be used to specify an empty link interface. - if(this->DoingInterface && - !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) + // If any of the LINK_ options were given, make sure the + // LINK_INTERFACE_LIBRARIES target property exists. + // Use of any of the new keywords implies awareness of + // this property. And if no libraries are named, it should + // result in an empty link interface. + if((this->CurrentProcessingState != ProcessingLinkLibraries) + && !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) { this->Target->SetProperty("LINK_INTERFACE_LIBRARIES", ""); } @@ -217,11 +245,15 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt) { // Handle normal case first. - if(!this->DoingInterface) + if(this->CurrentProcessingState != ProcessingLinkInterface) { this->Makefile ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); - return; + if (this->CurrentProcessingState != ProcessingPublicInterface + || this->CurrentProcessingState == ProcessingPrivateInterface) + { + return; + } } // Get the list of configurations considered to be DEBUG. diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index a9b5d8b..e91c46d 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -107,6 +107,18 @@ public: "Libraries specified as \"general\" (or without any keyword) are " "treated as if specified for both \"debug\" and \"optimized\"." "\n" + " target_link_libraries(\n" + " \n" + " [[debug|optimized|general] ] ...\n" + " [\n" + " [[debug|optimized|general] ] ...])\n" + "The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify both the" + "link dependencies and the link interface in one command. " + "Libraries and targets following LINK_PUBLIC are linked to, and are " + "made part of the LINK_INTERFACE_LIBRARIES. Libraries and targets " + "following LINK_PRIVATE are linked to, but are not made part of the " + "LINK_INTERFACE_LIBRARIES. " + "\n" "The library dependency graph is normally acyclic (a DAG), but in the " "case of mutually-dependent STATIC libraries CMake allows the graph " "to contain cycles (strongly connected components). " @@ -137,7 +149,14 @@ private: static const char* LinkLibraryTypeNames[3]; cmTarget* Target; - bool DoingInterface; + enum ProcessingState { + ProcessingLinkLibraries, + ProcessingLinkInterface, + ProcessingPublicInterface, + ProcessingPrivateInterface + }; + + ProcessingState CurrentProcessingState; void HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt); }; diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt new file mode 100644 index 0000000..1faa888 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 2.8) + +project(target_link_libraries) + +file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + "int main() { return 0; } +" +) + +add_executable( + target_link_libraries + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" +) + +macro(ASSERT_PROPERTY _target _property _value) + get_target_property(_out ${_target} ${_property}) + if (NOT _out) + set(_out "") + endif() + if (NOT "${_out}" STREQUAL "${_value}") + message(SEND_ERROR "Target ${_target} does not have property ${_property} with value ${_value}. Actual value: ${_out}") + endif() +endmacro() + +include(GenerateExportHeader) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_library(depA SHARED depA.cpp) +generate_export_header(depA) + +add_library(depB SHARED depB.cpp) +generate_export_header(depB) + +target_link_libraries(depB LINK_PRIVATE depA) + +add_library(depC SHARED depC.cpp) +generate_export_header(depC) + +target_link_libraries(depC LINK_PUBLIC depA) + +assert_property(depA LINK_INTERFACE_LIBRARIES "") +assert_property(depB LINK_INTERFACE_LIBRARIES "") +assert_property(depC LINK_INTERFACE_LIBRARIES "depA") + +add_executable(targetA targetA.cpp) + +target_link_libraries(targetA LINK_INTERFACE_LIBRARIES depA depB) + +assert_property(targetA LINK_INTERFACE_LIBRARIES "depA;depB") + +set_target_properties(targetA PROPERTIES LINK_INTERFACE_LIBRARIES "") + +assert_property(targetA LINK_INTERFACE_LIBRARIES "") + +target_link_libraries(targetA depB depC) + +assert_property(targetA LINK_INTERFACE_LIBRARIES "") diff --git a/Tests/CMakeCommands/target_link_libraries/depA.cpp b/Tests/CMakeCommands/target_link_libraries/depA.cpp new file mode 100644 index 0000000..c2e8e7b --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depA.cpp @@ -0,0 +1,7 @@ + +#include "depA.h" + +int DepA::foo() +{ + return 0; +} diff --git a/Tests/CMakeCommands/target_link_libraries/depA.h b/Tests/CMakeCommands/target_link_libraries/depA.h new file mode 100644 index 0000000..7a85948 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depA.h @@ -0,0 +1,7 @@ + +#include "depa_export.h" + +struct DEPA_EXPORT DepA +{ + int foo(); +}; diff --git a/Tests/CMakeCommands/target_link_libraries/depB.cpp b/Tests/CMakeCommands/target_link_libraries/depB.cpp new file mode 100644 index 0000000..97e5be2 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depB.cpp @@ -0,0 +1,11 @@ + +#include "depB.h" + +#include "depA.h" + +int DepB::foo() +{ + DepA a; + + return 0; +} diff --git a/Tests/CMakeCommands/target_link_libraries/depB.h b/Tests/CMakeCommands/target_link_libraries/depB.h new file mode 100644 index 0000000..e617813 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depB.h @@ -0,0 +1,7 @@ + +#include "depb_export.h" + +struct DEPB_EXPORT DepB +{ + int foo(); +}; diff --git a/Tests/CMakeCommands/target_link_libraries/depC.cpp b/Tests/CMakeCommands/target_link_libraries/depC.cpp new file mode 100644 index 0000000..93410a8 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depC.cpp @@ -0,0 +1,13 @@ + +#include "depC.h" + +int DepC::foo() +{ + return 0; +} + +DepA DepC::getA() +{ + DepA a; + return a; +} \ No newline at end of file diff --git a/Tests/CMakeCommands/target_link_libraries/depC.h b/Tests/CMakeCommands/target_link_libraries/depC.h new file mode 100644 index 0000000..4d65c9e --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depC.h @@ -0,0 +1,12 @@ + +#include "depc_export.h" + +#include "depA.h" + +struct DEPC_EXPORT DepC +{ + int foo(); + + DepA getA(); + +}; diff --git a/Tests/CMakeCommands/target_link_libraries/targetA.cpp b/Tests/CMakeCommands/target_link_libraries/targetA.cpp new file mode 100644 index 0000000..3c6472e --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/targetA.cpp @@ -0,0 +1,12 @@ + +#include "depB.h" +#include "depC.h" + +int main(int argc, char **argv) +{ + DepA a; + DepB b; + DepC c; + + return a.foo() + b.foo() + c.foo(); +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 78db39d..44ed2f5 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1574,6 +1574,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ -P "${CMake_SOURCE_DIR}/Tests/CMakeCommands/build_command/RunCMake.cmake" ) + ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries) + CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake" -- cgit v0.12 From 5fc95dff464b08c83df2c904a281bb4c45278a35 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 22 Nov 2011 17:19:04 -0500 Subject: target_link_libraries: Add missing space in documentation Change "thelink" to "the link". --- Source/cmTargetLinkLibrariesCommand.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index e91c46d..8df4ac0 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -112,8 +112,8 @@ public: " [[debug|optimized|general] ] ...\n" " [\n" " [[debug|optimized|general] ] ...])\n" - "The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify both the" - "link dependencies and the link interface in one command. " + "The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify both " + "the link dependencies and the link interface in one command. " "Libraries and targets following LINK_PUBLIC are linked to, and are " "made part of the LINK_INTERFACE_LIBRARIES. Libraries and targets " "following LINK_PRIVATE are linked to, but are not made part of the " -- cgit v0.12 From b1f12f8042ef0d7b190c04644905d3b3a325d4ae Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 22 Nov 2011 17:20:23 -0500 Subject: target_link_libraries: Simplify argument processing state tests Remove extra parens in test for not handling LINK_INTERFACE_LIBRARIES. Remove redundant test for equality with ProcessingPrivateInterface subsumed by test for inequality with ProcessingPublicInterface. --- Source/cmTargetLinkLibrariesCommand.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 0db5943..36c4ca8 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -217,8 +217,8 @@ bool cmTargetLinkLibrariesCommand // Use of any of the new keywords implies awareness of // this property. And if no libraries are named, it should // result in an empty link interface. - if((this->CurrentProcessingState != ProcessingLinkLibraries) - && !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) + if(this->CurrentProcessingState != ProcessingLinkLibraries && + !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) { this->Target->SetProperty("LINK_INTERFACE_LIBRARIES", ""); } @@ -249,9 +249,9 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, { this->Makefile ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); - if (this->CurrentProcessingState != ProcessingPublicInterface - || this->CurrentProcessingState == ProcessingPrivateInterface) + if (this->CurrentProcessingState != ProcessingPublicInterface) { + // Not LINK_INTERFACE_LIBRARIES or LINK_PUBLIC, do not add to interface. return; } } -- cgit v0.12 From 57a85237ac8ebc429ebe442897169bc9369e0380 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 23 Nov 2011 00:05:08 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 1df5ca9..0a1f936 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 22) +SET(KWSYS_DATE_STAMP_DAY 23) -- cgit v0.12 From 27e6ea9d2a28bf53fe284b08bfd441b57af64f7a Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 24 Nov 2011 00:05:05 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 0a1f936..4385024 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 23) +SET(KWSYS_DATE_STAMP_DAY 24) -- cgit v0.12 From d63af6df7cceaa2c727490001b1ab0382b6c899c Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 25 Nov 2011 00:05:06 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 4385024..99fb16e 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 24) +SET(KWSYS_DATE_STAMP_DAY 25) -- cgit v0.12 From 66f44dcdf4ba725735d6e2023b79bbed4033c728 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 26 Nov 2011 00:05:08 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 99fb16e..6ee8947 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 25) +SET(KWSYS_DATE_STAMP_DAY 26) -- cgit v0.12 From a8286235a31437505a53f5874e8bf98524b6dca3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 26 Nov 2011 15:15:33 +0100 Subject: moc is now part of the Qt5Core module There is no separate SrcTools module anymore. --- Modules/AutomocInfo.cmake.in | 2 +- Source/cmQtAutomoc.cxx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutomocInfo.cmake.in index 8542ff6..2c7c724 100644 --- a/Modules/AutomocInfo.cmake.in +++ b/Modules/AutomocInfo.cmake.in @@ -11,5 +11,5 @@ set(AM_QT_MOC_EXECUTABLE "@QT_MOC_EXECUTABLE@") set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/") set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/") set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" ) -set(AM_Qt5SrcTools_VERSION_MAJOR "@Qt5SrcTools_VERSION_MAJOR@" ) +set(AM_Qt5Core_VERSION_MAJOR "@Qt5Core_VERSION_MAJOR@" ) set(AM_TARGET_NAME "@_moc_target_name@") diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 7a80f28..d07f84b 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -49,11 +49,11 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) { cmMakefile* makefile = target->GetMakefile(); const char* targetName = target->GetName(); - // don't do anything if there is no Qt4 or Qt5SrcTools (which contains moc): + // don't do anything if there is no Qt4 or Qt5Core (which contains moc): std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); if (qtMajorVersion == "") { - qtMajorVersion = makefile->GetSafeDefinition("Qt5SrcTools_VERSION_MAJOR"); + qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); } if (qtMajorVersion != "4" && qtMajorVersion != "5") { @@ -229,7 +229,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, if (this->QtMajorVersion == "") { this->QtMajorVersion = makefile->GetSafeDefinition( - "AM_Qt5SrcTools_VERSION_MAJOR"); + "AM_Qt5Core_VERSION_MAJOR"); } this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); -- cgit v0.12 From 10c3113464eb66739550f18dd06f8b2f75affe99 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 27 Nov 2011 00:05:05 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 6ee8947..58aca97 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 26) +SET(KWSYS_DATE_STAMP_DAY 27) -- cgit v0.12 From 912c02c68222f86a3a10f3ab9a63f9566e131dac Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 28 Nov 2011 00:05:05 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 58aca97..2c9a603 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 27) +SET(KWSYS_DATE_STAMP_DAY 28) -- cgit v0.12 From a1f976ce0e62baf513c8726c59aba5f75a0335c6 Mon Sep 17 00:00:00 2001 From: Aaron Ten Clay Date: Wed, 23 Nov 2011 14:11:00 -0500 Subject: VS: Add support for three new project properties (#12586) VS_GLOBAL_PROJECT_TYPES: A string containing UUIDs to embed in the Visual Studio project file under . VS_GLOBAL_KEYWORD: Allows specification of a keyword like "ManagedCProj" instead of the default "Win32Proj", under VS_DOTNET_REFERENCES: Semicolon-delimited list of .NET references to add to the project, which creates a new . --- Source/cmTarget.cxx | 23 ++++++++++++ Source/cmVisualStudio10TargetGenerator.cxx | 57 +++++++++++++++++++++++++++++- Source/cmVisualStudio10TargetGenerator.h | 1 + 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index dad0353..d021990 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1038,6 +1038,29 @@ void cmTarget::DefineProperties(cmake *cm) "Can be set to change the visual studio source code control " "auxpath property."); cm->DefineProperty + ("VS_GLOBAL_PROJECT_TYPES", cmProperty::TARGET, + "Visual Studio project type(s).", + "Can be set to one or more UUIDs recognized by Visual Studio " + "to indicate the type of project. This value is copied " + "verbatim into the generated project file. Example for a " + "managed C++ unit testing project: \"" + "{3AC096D0-A1C2-E12C-1390-A8335801FDAB};" + "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\". UUIDs are " + "semicolon-delimited."); + cm->DefineProperty + ("VS_GLOBAL_KEYWORD", cmProperty::TARGET, + "Visual Studio project keyword.", + "Sets the \"keyword\" attribute for a generated Visual Studio " + "project. Defaults to \"Win32Proj\". You may wish to override " + "this value with \"ManagedCProj\", for example, in a Visual " + "Studio managed C++ unit test project."); + cm->DefineProperty + ("VS_DOTNET_REFERENCES", cmProperty::TARGET, + "Visual Studio managed project .NET references", + "Adds one or more semicolon-delimited .NET references to a " + "generated Visual Studio project. For example, \"System;" + "System.Windows.Forms\"."); + cm->DefineProperty ("VS_GLOBAL_", cmProperty::TARGET, "Visual Studio project-specific global variable.", "Tell the Visual Studio generator to set the global variable " diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index fcb668a..a219ae9 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -178,6 +178,15 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("", 2); (*this->BuildFileStream) << "{" << this->GUID << "}\n"; + const char* vsProjectTypes = + this->Target->GetProperty("VS_GLOBAL_PROJECT_TYPES"); + if(vsProjectTypes) + { + this->WriteString("", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectTypes) << + "\n"; + } + const char* vsProjectName = this->Target->GetProperty("VS_SCC_PROJECTNAME"); const char* vsLocalPath = this->Target->GetProperty("VS_SCC_LOCALPATH"); const char* vsProvider = this->Target->GetProperty("VS_SCC_PROVIDER"); @@ -203,7 +212,19 @@ void cmVisualStudio10TargetGenerator::Generate() } } - this->WriteString("Win32Proj\n", 2); + const char* vsGlobalKeyword = + this->Target->GetProperty("VS_GLOBAL_KEYWORD"); + if(!vsGlobalKeyword) + { + this->WriteString("Win32Proj\n", 2); + } + else + { + this->WriteString("", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword) << + "\n"; + } + this->WriteString("", 2); (*this->BuildFileStream) << this->Platform << "\n"; const char* projLabel = this->Target->GetProperty("PROJECT_LABEL"); @@ -233,6 +254,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteCustomCommands(); this->WriteObjSources(); this->WriteCLSources(); + this->WriteDotNetReferences(); this->WriteProjectReferences(); this->WriteString( "WriteGroups(); } +void cmVisualStudio10TargetGenerator::WriteDotNetReferences() +{ + const char* vsDotNetReferences + = this->Target->GetProperty("VS_DOTNET_REFERENCES"); + if(vsDotNetReferences) + { + std::string references(vsDotNetReferences); + std::string::size_type position = 0; + + this->WriteString("\n", 1); + while(references.length() > 0) + { + if((position = references.find(";")) == std::string::npos) + { + position = references.length() + 1; + } + + this->WriteString("BuildFileStream) << + cmVS10EscapeXML(references.substr(0, position)) << "\">\n"; + this->WriteString("true" + "\n", 3); + this->WriteString("true" + "\n", 3); + this->WriteString("\n", 2); + + references.erase(0, position + 1); + } + + this->WriteString("\n", 1); + } +} + // ConfigurationType Application, Utility StaticLibrary DynamicLibrary void cmVisualStudio10TargetGenerator::WriteProjectConfigurations() diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index c3c27f4..6702509 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -47,6 +47,7 @@ private: void WriteProjectConfigurations(); void WriteProjectConfigurationValues(); void WriteCLSources(); + void WriteDotNetReferences(); void WriteObjSources(); void WritePathAndIncrementalLinkOptions(); void WriteItemDefinitionGroups(); -- cgit v0.12 From a087490697c416d429d30fdf389cca2f13d9d14e Mon Sep 17 00:00:00 2001 From: Peter Kuemmel Date: Sun, 20 Nov 2011 14:04:11 +0100 Subject: Add NEWLINE_STYLE option to configure_file (#3957) --- Source/CMakeLists.txt | 2 + Source/cmConfigureFileCommand.cxx | 15 +++- Source/cmConfigureFileCommand.h | 11 ++- Source/cmMakefile.cxx | 18 +++- Source/cmMakefile.h | 5 +- Source/cmNewLineStyle.cxx | 95 ++++++++++++++++++++++ Source/cmNewLineStyle.h | 48 +++++++++++ .../ConfigureFile-NewLineStyle-COPYONLY.cmake | 3 + .../ConfigureFile-NewLineStyle-NoArg.cmake | 3 + .../ConfigureFile-NewLineStyle-ValidArg.cmake | 17 ++++ .../ConfigureFile-NewLineStyle-WrongArg.cmake | 3 + Tests/CMakeTests/ConfigureFileTest.cmake.in | 12 +++ 12 files changed, 225 insertions(+), 7 deletions(-) create mode 100644 Source/cmNewLineStyle.cxx create mode 100644 Source/cmNewLineStyle.h create mode 100644 Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake create mode 100644 Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake create mode 100644 Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake create mode 100644 Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ba41d98..7dcb6c3 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -214,6 +214,8 @@ SET(SRCS cmMakefileExecutableTargetGenerator.cxx cmMakefileLibraryTargetGenerator.cxx cmMakefileUtilityTargetGenerator.cxx + cmNewLineStyle.h + cmNewLineStyle.cxx cmOrderDirectories.cxx cmOrderDirectories.h cmPolicies.h diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index c1327fb..ea98326 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -65,6 +65,12 @@ bool cmConfigureFileCommand cmSystemTools::SetFatalErrorOccured(); return false; } + std::string errorMessage; + if (!this->NewLineStyle.ReadFromArguments(args, errorMessage)) + { + this->SetError(errorMessage.c_str()); + return false; + } this->CopyOnly = false; this->EscapeQuotes = false; @@ -78,6 +84,12 @@ bool cmConfigureFileCommand if(args[i] == "COPYONLY") { this->CopyOnly = true; + if (this->NewLineStyle.IsValid()) + { + this->SetError("COPYONLY could not be used in combination " + "with NEWLINE_STYLE"); + return false; + } } else if(args[i] == "ESCAPE_QUOTES") { @@ -122,7 +134,8 @@ int cmConfigureFileCommand::ConfigureFile() this->OutputFile.c_str(), this->CopyOnly, this->AtOnly, - this->EscapeQuotes); + this->EscapeQuotes, + this->NewLineStyle); } diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 844a23c..be33569 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -56,7 +56,8 @@ public: { return " configure_file( \n" - " [COPYONLY] [ESCAPE_QUOTES] [@ONLY])\n" + " [COPYONLY] [ESCAPE_QUOTES] [@ONLY] \n" + " [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])\n" "Copies a file to file and substitutes variable " "values referenced in the file content. " "If is a relative path it is evaluated with respect to " @@ -81,14 +82,20 @@ public: "either #define VAR or /* #undef VAR */ depending on " "the setting of VAR in CMake. Any occurrences of #cmakedefine01 VAR " "will be replaced with either #define VAR 1 or #define VAR 0 " - "depending on whether VAR evaluates to TRUE or FALSE in CMake"; + "depending on whether VAR evaluates to TRUE or FALSE in CMake.\n" + "With NEWLINE_STYLE the line ending could be adjusted: \n" + " 'UNIX' or 'LF' for \\n, 'DOS', 'WIN32' or 'CRLF' for \\r\\n.\n" + "COPYONLY must not be used with NEWLINE_STYLE.\n"; } virtual void FinalPass(); virtual bool HasFinalPass() const { return !this->Immediate; } + private: int ConfigureFile(); + cmNewLineStyle NewLineStyle; + std::string InputFile; std::string OutputFile; bool CopyOnly; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 573c430..7939d73 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3213,7 +3213,8 @@ void cmMakefile::ConfigureString(const std::string& input, } int cmMakefile::ConfigureFile(const char* infile, const char* outfile, - bool copyonly, bool atOnly, bool escapeQuotes) + bool copyonly, bool atOnly, bool escapeQuotes, + const cmNewLineStyle& newLine) { int res = 1; if ( !this->CanIWriteThisFile(outfile) ) @@ -3250,9 +3251,20 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, } else { + std::string newLineCharacters; + std::ios_base::openmode omode = std::ios_base::out | std::ios_base::trunc; + if (newLine.IsValid()) + { + newLineCharacters = newLine.GetCharacters(); + omode |= std::ios::binary; + } + else + { + newLineCharacters = "\n"; + } std::string tempOutputFile = soutfile; tempOutputFile += ".tmp"; - std::ofstream fout(tempOutputFile.c_str()); + std::ofstream fout(tempOutputFile.c_str(), omode); if(!fout) { cmSystemTools::Error( @@ -3277,7 +3289,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, { outLine = ""; this->ConfigureString(inLine, outLine, atOnly, escapeQuotes); - fout << outLine.c_str() << "\n"; + fout << outLine.c_str() << newLineCharacters; } // close the files before attempting to copy fin.close(); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 7c3e4ee..1236787 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -19,6 +19,7 @@ #include "cmPropertyMap.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cmNewLineStyle.h" #include "cmake.h" #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -703,7 +704,9 @@ public: * Copy file but change lines acording to ConfigureString */ int ConfigureFile(const char* infile, const char* outfile, - bool copyonly, bool atOnly, bool escapeQuotes); + bool copyonly, bool atOnly, bool escapeQuotes, + const cmNewLineStyle& = cmNewLineStyle()); + #if defined(CMAKE_BUILD_WITH_CMAKE) /** diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx new file mode 100644 index 0000000..6f7b6a9 --- /dev/null +++ b/Source/cmNewLineStyle.cxx @@ -0,0 +1,95 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 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. +============================================================================*/ +#include "cmNewLineStyle.h" + + + +cmNewLineStyle::cmNewLineStyle() : NewLineStyle(Invalid) +{ +} + + +bool cmNewLineStyle::IsValid() const +{ + return NewLineStyle != Invalid; +} + + +bool cmNewLineStyle::ReadFromArguments(const std::vector& args, + std::string& errorString) +{ + NewLineStyle = Invalid; + + for (size_t i = 0; i< args.size(); i++) + { + if (args[i] == "NEWLINE_STYLE") + { + size_t const styleIndex = i + 1; + if (args.size() > styleIndex) + { + const std::string eol = args[styleIndex]; + if (eol == "LF" || eol == "UNIX") + { + NewLineStyle = LF; + return true; + } + else if (eol == "CRLF" || eol == "WIN32" || eol == "DOS") + { + NewLineStyle = CRLF; + return true; + } + else + { + errorString = "NEWLINE_STYLE sets an unknown style, only LF, " + "CRLF, UNIX, DOS, and WIN32 are supported"; + return false; + } + } + else + { + errorString = "NEWLINE_STYLE must set a style: " + "LF, CRLF, UNIX, DOS, or WIN32"; + return false; + } + } + } + return true; +} + + +const std::string cmNewLineStyle::GetCharacters() const +{ + switch (NewLineStyle) + { + case Invalid: + return ""; + case LF: + return "\n"; + case CRLF: + return "\r\n"; + default: + ; + }; + return ""; +} + + +void cmNewLineStyle::SetStyle(Style style) +{ + NewLineStyle = style; +} + + +cmNewLineStyle::Style cmNewLineStyle::GetStyle() const +{ + return NewLineStyle; +} diff --git a/Source/cmNewLineStyle.h b/Source/cmNewLineStyle.h new file mode 100644 index 0000000..567a4ea --- /dev/null +++ b/Source/cmNewLineStyle.h @@ -0,0 +1,48 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 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 cmNewLineStyle_h +#define cmNewLineStyle_h + +#include +#include + + +class cmNewLineStyle +{ +public: + + cmNewLineStyle(); + + enum Style + { + Invalid, + // LF = '\n', 0x0A, 10 + // CR = '\r', 0x0D, 13 + LF, // Unix + CRLF, // Dos + }; + + void SetStyle(Style); + Style GetStyle() const; + + bool IsValid() const; + + bool ReadFromArguments(const std::vector& args, + std::string &errorString); + + const std::string GetCharacters() const; + +private: + Style NewLineStyle; +}; + +#endif diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake new file mode 100644 index 0000000..3b09eb0 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out COPYONLY NEWLINE_STYLE DOS) diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake new file mode 100644 index 0000000..133a67a --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out NEWLINE_STYLE) diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake new file mode 100644 index 0000000..b7e619c --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake @@ -0,0 +1,17 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) + +function(test_eol style in out) + file(WRITE ${file_name} "${in}") + configure_file(${file_name} ${file_name}.out NEWLINE_STYLE ${style}) + file(READ ${file_name}.out new HEX) + if(NOT "${new}" STREQUAL "${out}") + message(FATAL_ERROR "No ${style} line endings") + endif() +endfunction() + +test_eol(DOS "a\n" "610d0a") +test_eol(WIN32 "b\n" "620d0a") +test_eol(CRLF "c\n" "630d0a") + +test_eol(UNIX "d\n" "640a") +test_eol(LF "e\n" "650a") diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake new file mode 100644 index 0000000..e8887c1 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out NEWLINE_STYLE FOO) diff --git a/Tests/CMakeTests/ConfigureFileTest.cmake.in b/Tests/CMakeTests/ConfigureFileTest.cmake.in index c78a470..6cc61d9 100644 --- a/Tests/CMakeTests/ConfigureFileTest.cmake.in +++ b/Tests/CMakeTests/ConfigureFileTest.cmake.in @@ -6,6 +6,14 @@ set(Relative-RESULT 0) set(Relative-STDERR "Relative test file") set(BadArg-RESULT 1) set(BadArg-STDERR "called with incorrect number of arguments") +set(NewLineStyle-NoArg-RESULT 1) +set(NewLineStyle-NoArg-STDERR "NEWLINE_STYLE must set a style:") +set(NewLineStyle-WrongArg-RESULT 1) +set(NewLineStyle-WrongArg-STDERR "NEWLINE_STYLE sets an unknown style") +set(NewLineStyle-ValidArg-RESULT 0) +set(NewLineStyle-ValidArg-STDERR ) +set(NewLineStyle-COPYONLY-RESULT 1) +set(NewLineStyle-COPYONLY-STDERR "COPYONLY could not be used in combination") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(ConfigureFile @@ -13,4 +21,8 @@ check_cmake_test(ConfigureFile DirOutput Relative BadArg + NewLineStyle-NoArg + NewLineStyle-WrongArg + NewLineStyle-ValidArg + NewLineStyle-COPYONLY ) -- cgit v0.12 From 89f6fbaae355c4b84a39640752c98a2c6d1b34e6 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 29 Nov 2011 00:05:04 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 2c9a603..082aaba 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 28) +SET(KWSYS_DATE_STAMP_DAY 29) -- cgit v0.12 From be6502c5027935cba246e654e5d3006f8da216f4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Nov 2011 07:56:28 -0500 Subject: bootstrap: Include cmNewLineStyle in build The cmNewLineStyle class is needed by cmMakefile. --- bootstrap | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap b/bootstrap index c999888..3daac2a 100755 --- a/bootstrap +++ b/bootstrap @@ -215,6 +215,7 @@ CMAKE_CXX_SOURCES="\ cmMakefileLibraryTargetGenerator \ cmMakefileTargetGenerator \ cmMakefileUtilityTargetGenerator \ + cmNewLineStyle \ cmBootstrapCommands \ cmCommands \ cmTarget \ -- cgit v0.12 From 75e83e98fa3faff93f3562e38fa851b6dd5b5a95 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Nov 2011 08:01:07 -0500 Subject: cmNewLineStyle: Remove trailing comma in enum --- Source/cmNewLineStyle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmNewLineStyle.h b/Source/cmNewLineStyle.h index 567a4ea..9d4c03b 100644 --- a/Source/cmNewLineStyle.h +++ b/Source/cmNewLineStyle.h @@ -28,7 +28,7 @@ public: // LF = '\n', 0x0A, 10 // CR = '\r', 0x0D, 13 LF, // Unix - CRLF, // Dos + CRLF // Dos }; void SetStyle(Style); -- cgit v0.12 From 6b104e107ef04fe1b68e76e562f658bf62ae12e5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Nov 2011 08:58:45 -0500 Subject: Remove trailing whitespace from cmLocalGenerator --- Source/cmLocalGenerator.cxx | 146 ++++++++++++++++++++++---------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 65d6fa6..ffbeb48 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -96,14 +96,14 @@ void cmLocalGenerator::Configure() std::string filesDir = this->Makefile->GetStartOutputDirectory(); filesDir += cmake::GetCMakeFilesDirectory(); cmSystemTools::MakeDirectory(filesDir.c_str()); - + // find & read the list file this->ReadInputFile(); // at the end of the ReadListFile handle any old style subdirs // first get all the subdirectories std::vector subdirs = this->GetChildren(); - + // for each subdir recurse std::vector::iterator sdi = subdirs.begin(); for (; sdi != subdirs.end(); ++sdi) @@ -112,7 +112,7 @@ void cmLocalGenerator::Configure() { this->Makefile->ConfigureSubDirectory(*sdi); } - } + } // Check whether relative paths should be used for optionally // relative paths. @@ -212,10 +212,10 @@ void cmLocalGenerator::ReadInputFile() } void cmLocalGenerator::SetupPathConversions() -{ +{ // Setup the current output directory components for use by // Convert - std::string outdir; + std::string outdir; outdir = cmSystemTools::CollapseFullPath(this->Makefile->GetHomeDirectory()); cmSystemTools::SplitPath(outdir.c_str(), this->HomeDirectoryComponents); @@ -225,12 +225,12 @@ void cmLocalGenerator::SetupPathConversions() outdir = cmSystemTools::CollapseFullPath (this->Makefile->GetHomeOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir.c_str(), this->HomeOutputDirectoryComponents); outdir = cmSystemTools::CollapseFullPath (this->Makefile->GetStartOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir.c_str(), this->StartOutputDirectoryComponents); } @@ -289,17 +289,17 @@ void cmLocalGenerator::GenerateTestFiles() fout.SetCopyIfDifferent(true); fout << "# CMake generated Testfile for " << std::endl - << "# Source directory: " + << "# Source directory: " << this->Makefile->GetStartDirectory() << std::endl - << "# Build directory: " + << "# Build directory: " << this->Makefile->GetStartOutputDirectory() << std::endl << "# " << std::endl << "# This file includes the relevent testing commands " << "required for " << std::endl << "# testing this directory and lists subdirectories to " << "be tested as well." << std::endl; - - const char* testIncludeFile = + + const char* testIncludeFile = this->Makefile->GetProperty("TEST_INCLUDE_FILE"); if ( testIncludeFile ) { @@ -320,7 +320,7 @@ void cmLocalGenerator::GenerateTestFiles() for(i = 0; i < this->Children.size(); ++i) { fout << "SUBDIRS("; - std::string outP = + std::string outP = this->Children[i]->GetMakefile()->GetStartOutputDirectory(); fout << this->Convert(outP.c_str(),START_OUTPUT); fout << ")" << std::endl; @@ -472,7 +472,7 @@ void cmLocalGenerator::GenerateInstallRules() // Ask each install generator to write its code. std::vector const& installers = this->Makefile->GetInstallGenerators(); - for(std::vector::const_iterator + for(std::vector::const_iterator gi = installers.begin(); gi != installers.end(); ++gi) { @@ -553,15 +553,15 @@ void cmLocalGenerator::GenerateTargetManifest() } } -void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, - const char* lang, +void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, + const char* lang, cmSourceFile& source, cmTarget& ) -{ +{ std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname)); objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL); std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL); - std::string sourceFile = + std::string sourceFile = this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true); std::string varString = "CMAKE_"; varString += lang; @@ -655,7 +655,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) ofname += "/"; ofname += obj; objVector.push_back(ofname); - this->AddCustomCommandToCreateObject(ofname.c_str(), + this->AddCustomCommandToCreateObject(ofname.c_str(), llang, *(*i), target); objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE); objs += " "; @@ -672,7 +672,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) // Shared Module: std::string linkLibs; // should be set std::string flags; // should be set - std::string linkFlags; // should be set + std::string linkFlags; // should be set this->GetTargetFlags(linkLibs, flags, linkFlags, target); cmLocalGenerator::RuleVariables vars; vars.Language = llang; @@ -682,17 +682,17 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) vars.LinkLibraries = linkLibs.c_str(); vars.Flags = flags.c_str(); vars.LinkFlags = linkFlags.c_str(); - + std::string langFlags; this->AddLanguageFlags(langFlags, llang, 0); this->AddArchitectureFlags(langFlags, &target, llang, 0); vars.LanguageCompileFlags = langFlags.c_str(); - + cmCustomCommandLines commandLines; std::vector rules; rules.push_back(this->Makefile->GetRequiredDefinition(createRule.c_str())); std::vector commands; - cmSystemTools::ExpandList(rules, commands); + cmSystemTools::ExpandList(rules, commands); for(std::vector::iterator i = commands.begin(); i != commands.end(); ++i) { @@ -728,21 +728,21 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) (this->Makefile->GetSource(targetFullPath.c_str())); } - + void cmLocalGenerator ::CreateCustomTargetsAndCommands(std::set const& lang) -{ +{ cmTargets &tgts = this->Makefile->GetTargets(); - for(cmTargets::iterator l = tgts.begin(); + for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& target = l->second; switch(target.GetType()) - { + { case cmTarget::STATIC_LIBRARY: case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: - case cmTarget::EXECUTABLE: + case cmTarget::EXECUTABLE: { const char* llang = target.GetLinkerLanguage(); if(!llang) @@ -759,7 +759,7 @@ void cmLocalGenerator this->AddBuildTargetRule(llang, target); } } - break; + break; default: break; } @@ -769,14 +769,14 @@ void cmLocalGenerator // List of variables that are replaced when // rules are expanced. These variables are // replaced in the form with GetSafeDefinition(var). -// ${LANG} is replaced in the variable first with all enabled +// ${LANG} is replaced in the variable first with all enabled // languages. static const char* ruleReplaceVars[] = { "CMAKE_${LANG}_COMPILER", "CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS", "CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS", - "CMAKE_SHARED_MODULE_${LANG}_FLAGS", + "CMAKE_SHARED_MODULE_${LANG}_FLAGS", "CMAKE_SHARED_LIBRARY_${LANG}_FLAGS", "CMAKE_${LANG}_LINK_FLAGS", "CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG", @@ -807,7 +807,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, return replaceValues.Flags; } } - + if(replaceValues.Source) { if(variable == "SOURCE") @@ -870,7 +870,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(replaceValues.Target) - { + { if(variable == "TARGET_QUOTED") { std::string targetQuoted = replaceValues.Target; @@ -1018,13 +1018,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, int pos = 0; while(ruleReplaceVars[pos]) { - for(std::vector::iterator i = enabledLanguages.begin(); - i != enabledLanguages.end(); ++i) - { + for(std::vector::iterator i = enabledLanguages.begin(); + i != enabledLanguages.end(); ++i) + { const char* lang = i->c_str(); std::string actualReplace = ruleReplaceVars[pos]; // If this is the compiler then look for the extra variable - // _COMPILER_ARG1 which must be the first argument to the compiler + // _COMPILER_ARG1 which must be the first argument to the compiler const char* compilerArg1 = 0; if(actualReplace == "CMAKE_${LANG}_COMPILER") { @@ -1038,7 +1038,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(actualReplace == variable) { - std::string replace = + std::string replace = this->Makefile->GetSafeDefinition(variable.c_str()); // if the variable is not a FLAG then treat it like a path if(variable.find("_FLAG") == variable.npos) @@ -1062,7 +1062,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } -void +void cmLocalGenerator::ExpandRuleVariables(std::string& s, const RuleVariables& replaceValues) { @@ -1213,7 +1213,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, std::string flagVar = "CMAKE_INCLUDE_FLAG_"; flagVar += lang; - const char* includeFlag = + const char* includeFlag = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagVar = "CMAKE_INCLUDE_FLAG_SEP_"; flagVar += lang; @@ -1223,7 +1223,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, { quotePaths = true; } - bool repeatFlag = true; + bool repeatFlag = true; // should the include flag be repeated like ie. -IA -IB if(!sep) { @@ -1354,15 +1354,15 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs, this->Makefile->GetDefinition("VTK_SOURCE_DIR"); if(vtkSourceDir) { - const char* vtk_major = + const char* vtk_major = this->Makefile->GetDefinition("VTK_MAJOR_VERSION"); - const char* vtk_minor = + const char* vtk_minor = this->Makefile->GetDefinition("VTK_MINOR_VERSION"); vtk_major = vtk_major? vtk_major : "4"; vtk_minor = vtk_minor? vtk_minor : "4"; int vmajor = 0; int vminor = 0; - if(sscanf(vtk_major, "%d", &vmajor) && + if(sscanf(vtk_major, "%d", &vmajor) && sscanf(vtk_minor, "%d", &vminor) && vmajor == 4 && vminor <= 4) { includeSourceDir = true; @@ -1403,7 +1403,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs, } // Get the project-specified include directories. - std::vector& includes = + std::vector& includes = this->Makefile->GetIncludeDirectories(); // Support putting all the in-project include directories first if @@ -1446,17 +1446,17 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, std::string& linkFlags, cmTarget& target) { - std::string buildType = + std::string buildType = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - buildType = cmSystemTools::UpperCase(buildType); - const char* libraryLinkVariable = + buildType = cmSystemTools::UpperCase(buildType); + const char* libraryLinkVariable = "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library - + switch(target.GetType()) { - case cmTarget::STATIC_LIBRARY: + case cmTarget::STATIC_LIBRARY: { - const char* targetLinkFlags = + const char* targetLinkFlags = target.GetProperty("STATIC_LIBRARY_FLAGS"); if(targetLinkFlags) { @@ -1475,11 +1475,11 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } } } - break; + break; case cmTarget::MODULE_LIBRARY: libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; case cmTarget::SHARED_LIBRARY: - { + { linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable); linkFlags += " "; if(!buildType.empty()) @@ -1489,8 +1489,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, build += buildType; linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; - } - if(this->Makefile->IsOn("WIN32") && + } + if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) { const std::vector& sources = target.GetSourceFiles(); @@ -1500,14 +1500,14 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, cmSourceFile* sf = *i; if(sf->GetExtension() == "def") { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); linkFlags += this->Convert(sf->GetFullPath().c_str(), START_OUTPUT, SHELL); linkFlags += " "; } } - } + } const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); if(targetLinkFlags) { @@ -1520,11 +1520,11 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, configLinkFlags += buildType; targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) - { + { linkFlags += targetLinkFlags; linkFlags += " "; } - } + } cmOStringStream linklibsStr; this->OutputLinkLibraries(linklibsStr, target, false); linkLibs = linklibsStr.str(); @@ -1532,7 +1532,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, break; case cmTarget::EXECUTABLE: { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); linkFlags += " "; if(!buildType.empty()) @@ -1541,7 +1541,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, build += buildType; linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; - } + } const char* linkLanguage = target.GetLinkerLanguage(); if(!linkLanguage) { @@ -1566,7 +1566,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, if(cmSystemTools::IsOn (this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { - std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + linkLanguage + std::string("_FLAGS"); linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str()); linkFlags += " "; @@ -1579,7 +1579,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } else { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); linkFlags += " "; } @@ -1595,13 +1595,13 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, configLinkFlags += buildType; targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) - { + { linkFlags += targetLinkFlags; linkFlags += " "; } } } - break; + break; default: break; } @@ -1661,9 +1661,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, const char* linkLanguage = cli.GetLinkLanguage(); - std::string libPathFlag = + std::string libPathFlag = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); - std::string libPathTerminator = + std::string libPathTerminator = this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); // Flags to link an executable to shared libraries. @@ -1786,11 +1786,11 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, { std::vector archs; target->GetAppleArchs(config, archs); - const char* sysroot = + const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT"); - const char* sysrootDefault = + const char* sysrootDefault = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT"); - const char* deploymentTarget = + const char* deploymentTarget = this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); std::string isysrootVar = std::string("CMAKE_") + lang + "_HAS_ISYSROOT"; bool hasIsysroot = this->Makefile->IsOn(isysrootVar.c_str()); @@ -1876,7 +1876,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, if(cmSystemTools::FileIsFullPath(inName)) { std::string tLocation; - if(target->GetType() >= cmTarget::EXECUTABLE && + if(target->GetType() >= cmTarget::EXECUTABLE && target->GetType() <= cmTarget::MODULE_LIBRARY) { tLocation = target->GetLocation(config); @@ -2904,7 +2904,7 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars, else { cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags); - } + } return std::string(&arg[0]); } @@ -2976,9 +2976,9 @@ cmLocalGenerator::GetTargetDirectory(cmTarget const&) const //---------------------------------------------------------------------------- -void +void cmLocalGenerator::GetTargetObjectFileDirectories(cmTarget* , - std::vector& + std::vector& ) { cmSystemTools::Error("GetTargetObjectFileDirectories" -- cgit v0.12 From 3cd08ce0489b95e75004fd8a26c2cfcf57cbf49b Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Tue, 29 Nov 2011 09:02:40 -0700 Subject: Qt4: Fix dependencies of QtDeclartive. --- Modules/UseQt4.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index b824392..027504f 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -68,7 +68,7 @@ SET(QT_QAXCONTAINER_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QAXSERVER_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTSCRIPTTOOLS_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTWEBKIT_MODULE_DEPENDS QTXMLPATTERNS QTGUI QTCORE) -SET(QT_QTDECLARATIVE_MODULE_DEPENDS QTWEBKIT QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTXML QTOPENGL QTGUI QTNETWORK QTCORE) +SET(QT_QTDECLARATIVE_MODULE_DEPENDS QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTGUI QTCORE) SET(QT_QTMULTIMEDIA_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTOPENGL_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTSCRIPT_MODULE_DEPENDS QTCORE) @@ -81,8 +81,8 @@ SET(QT_QTNETWORK_MODULE_DEPENDS QTCORE) # Qt modules (in order of dependence) FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN QAXSERVER QAXCONTAINER QTDECLARATIVE QTSCRIPT QTSVG QTUITOOLS QTHELP - QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTGUI QTTEST QTDBUS QTXML QTSQL - QTXMLPATTERNS QTNETWORK QTCORE) + QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTXMLPATTERNS QTGUI QTTEST + QTDBUS QTXML QTSQL QTNETWORK QTCORE) IF (QT_USE_${module} OR QT_USE_${module}_DEPENDS) IF (QT_${module}_FOUND) -- cgit v0.12 From 17388037fdf435295dac220a482a16b05c621a19 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 30 Nov 2011 00:05:04 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 082aaba..0a31302 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 29) +SET(KWSYS_DATE_STAMP_DAY 30) -- cgit v0.12 From 28c46ca6cd6ffd344e83c79108bc5b54eb7d7428 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Nov 2011 09:19:32 -0500 Subject: cmNewLineStyle: Use cmStandardIncludes.h This ensures that stl types are compiled consistently with the reset of CMake. Otherwise one may get errors like Undefined symbol: .cmNewLineStyle::ReadFromArguments( const std::vector -#include - +#include "cmStandardIncludes.h" class cmNewLineStyle { -- cgit v0.12 From ac2e45d0893dd283c04c600e626bf80ea57d4a71 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Nov 2011 09:27:18 -0500 Subject: Provide std::ios_base typedef on GCC < 3 The ancient GNU standard library provided std::ios but not std::ios_base. Define the latter in terms of the former. --- Source/cmStandardIncludes.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index e8decbb..ea299ca 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -161,6 +161,11 @@ extern int putenv (char *__string) __THROW; #define for if(false) {} else for #endif +// Provide std::ios_base on ancient GCC 2.9x +#if defined(__GNUC__) && __GNUC__ < 3 +namespace std { typedef ios ios_base; } +#endif + // check for the 720 compiler on the SGI // which has some strange properties that I don't think are worth // checking for in a general way in configure -- cgit v0.12 From 985dee4f548451745b6065fd4c23aad9e2ce117b Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Nov 2011 08:40:58 -0500 Subject: FindZLIB: Search under ZLIB_ROOT if it is set Perform multiple separate searches in order. If ZLIB_ROOT is set search it exclusively so it takes precedence over CMAKE_PREFIX_PATH. This allows a user to provide -DZLIB_ROOT=/path/to/zlib/prefix on the CMake command line to tell it exactly where to find zlib. Otherwise fall back to a normal search. Inspired-by: Andreas Schneider --- Modules/FindZLIB.cmake | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 77f9fda..166e291 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -17,9 +17,12 @@ # ZLIB_MAJOR_VERSION - The major version of zlib # ZLIB_MINOR_VERSION - The minor version of zlib # ZLIB_PATCH_VERSION - The patch version of zlib +# +# An includer may set ZLIB_ROOT to a zlib installation root to tell +# this module where to look. #============================================================================= -# Copyright 2001-2009 Kitware, Inc. +# Copyright 2001-2011 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -31,17 +34,29 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -FIND_PATH(ZLIB_INCLUDE_DIR zlib.h - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/include" -) +SET(_ZLIB_SEARCHES) + +# Search ZLIB_ROOT first if it is set. +IF(ZLIB_ROOT) + SET(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT} NO_DEFAULT_PATH) + LIST(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_ROOT) +ENDIF() + +# Normal search. +SET(_ZLIB_SEARCH_NORMAL + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]" + "$ENV{PROGRAMFILES}/zlib" + ) +LIST(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL) SET(ZLIB_NAMES z zlib zdll zlib1 zlibd zlibd1) -FIND_LIBRARY(ZLIB_LIBRARY - NAMES - ${ZLIB_NAMES} - PATHS - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/lib" -) + +# Try each search configuration. +FOREACH(search ${_ZLIB_SEARCHES}) + FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include) + FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib) +ENDFOREACH() + MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR) IF(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") -- cgit v0.12 From 0393aa61d191a766c9ea2759cf376a8475087f56 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 1 Dec 2011 00:05:04 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 0a31302..bd72486 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 11) +SET(KWSYS_DATE_STAMP_MONTH 12) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 30) +SET(KWSYS_DATE_STAMP_DAY 01) -- cgit v0.12 From 363d3962c476a6018c0be9fde18f347816034b97 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 1 Dec 2011 15:41:01 -0500 Subject: Factor out target location undefined behavior helper macro Move CM_LOCATION_UNDEFINED_BEHAVIOR into a dedicated header. Add a parameter to describe the action that leads to the undefined target location. --- Source/CMakeLists.txt | 1 + Source/cmDocumentLocationUndefined.h | 24 ++++++++++++++++++++++++ Source/cmTarget.cxx | 14 +++----------- 3 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 Source/cmDocumentLocationUndefined.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 2aa32d8..b5115b7 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -162,6 +162,7 @@ SET(SRCS cmDocumentationSection.cxx cmDocumentCompileDefinitions.h cmDocumentGeneratorExpressions.h + cmDocumentLocationUndefined.h cmDocumentVariables.cxx cmDynamicLoader.cxx cmDynamicLoader.h diff --git a/Source/cmDocumentLocationUndefined.h b/Source/cmDocumentLocationUndefined.h new file mode 100644 index 0000000..d1be77a --- /dev/null +++ b/Source/cmDocumentLocationUndefined.h @@ -0,0 +1,24 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 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 cmDocumentLocationUndefined_h +#define cmDocumentLocationUndefined_h + +#define CM_LOCATION_UNDEFINED_BEHAVIOR(action) \ + "\n" \ + "Do not set properties that affect the location of a target after " \ + action ". These include properties whose names match " \ + "\"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_)?\" " \ + "or \"(IMPLIB_)?(PREFIX|SUFFIX)\". " \ + "Failure to follow this rule is not diagnosed and leaves the location " \ + "of the target undefined." + +#endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d021990..7e02a39 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -17,6 +17,7 @@ #include "cmGlobalGenerator.h" #include "cmComputeLinkInformation.h" #include "cmDocumentCompileDefinitions.h" +#include "cmDocumentLocationUndefined.h" #include "cmListFileCache.h" #include "cmGeneratorExpression.h" #include @@ -584,15 +585,6 @@ void cmTarget::DefineProperties(cmake *cm) "value is the default. " "See documentation of CMAKE__LINKER_PREFERENCE variables."); -#define CM_LOCATION_UNDEFINED_BEHAVIOR \ - "\n" \ - "Do not set properties that affect the location of the target after " \ - "reading this property. These include properties whose names match " \ - "\"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_)?\" " \ - "or \"(IMPLIB_)?(PREFIX|SUFFIX)\". " \ - "Failure to follow this rule is not diagnosed and leaves the location " \ - "of the target undefined." - cm->DefineProperty ("LOCATION", cmProperty::TARGET, "Read-only location of a target on disk.", @@ -612,7 +604,7 @@ void cmTarget::DefineProperties(cmake *cm) "In CMake 2.8.4 and above add_custom_command recognizes generator " "expressions to refer to target locations anywhere in the command. " "Therefore this property is not needed for creating custom commands." - CM_LOCATION_UNDEFINED_BEHAVIOR); + CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property")); cm->DefineProperty ("LOCATION_", cmProperty::TARGET, @@ -626,7 +618,7 @@ void cmTarget::DefineProperties(cmake *cm) "arbitrary available configuration. " "Use the MAP_IMPORTED_CONFIG_ property to map imported " "configurations explicitly." - CM_LOCATION_UNDEFINED_BEHAVIOR); + CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property")); cm->DefineProperty ("LINK_DEPENDS", cmProperty::TARGET, -- cgit v0.12 From fea3e84ee3670e2d6b333d844ea431cf6f193e67 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 1 Dec 2011 15:41:19 -0500 Subject: export(): Document undefined behavior of location properties Since the export() command needs to know the final location of a target in the build tree we cannot allow properties affecting the location or name of a target file to be set after the target is passed to export(). Fix a violation of this rule in the SimpleInstall test. --- Source/cmExportCommand.h | 2 ++ Tests/SimpleInstall/CMakeLists.txt | 11 ++++++----- Tests/SimpleInstallS2/CMakeLists.txt | 11 ++++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index f33e9e2..eb19d2e 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -13,6 +13,7 @@ #define cmExportCommand_h #include "cmCommand.h" +#include "cmDocumentLocationUndefined.h" class cmExportBuildFileGenerator; @@ -80,6 +81,7 @@ public: "should never be installed. " "See the install(EXPORT) command to export targets from an " "installation tree." + CM_LOCATION_UNDEFINED_BEHAVIOR("passing it to this command") "\n" " export(PACKAGE )\n" "Store the current build directory in the CMake user package registry " diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index 564db9f..378b529 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -173,6 +173,12 @@ ELSE(STAGE2) TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4) SET(install_target SimpleInstall) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) + # Disable VERSION test until it is implemented in the Xcode generator. + IF(NOT XCODE) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) + ENDIF(NOT XCODE) + # Make sure the test executable can run from the install tree. SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) @@ -293,11 +299,6 @@ ELSE(STAGE2) ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) - # Disable VERSION test until it is implemented in the Xcode generator. - IF(NOT XCODE) - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) - ENDIF(NOT XCODE) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index 564db9f..378b529 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -173,6 +173,12 @@ ELSE(STAGE2) TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4) SET(install_target SimpleInstall) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) + # Disable VERSION test until it is implemented in the Xcode generator. + IF(NOT XCODE) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) + ENDIF(NOT XCODE) + # Make sure the test executable can run from the install tree. SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) @@ -293,11 +299,6 @@ ELSE(STAGE2) ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) - # Disable VERSION test until it is implemented in the Xcode generator. - IF(NOT XCODE) - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) - ENDIF(NOT XCODE) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT -- cgit v0.12 From 8bda047b8e53f9bcbba60bc43ba6c116693c99a3 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 2 Dec 2011 00:05:04 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index bd72486..9ce66ab 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 12) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 01) +SET(KWSYS_DATE_STAMP_DAY 02) -- cgit v0.12 From 1f49d725abf458070db063b81dd7093a00835274 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 2 Dec 2011 10:08:15 -0500 Subject: Recognize the Tiny C Compiler (#12605) See compiler home page here: http://tinycc.org/ http://bellard.org/tcc/ Use the id "TinyCC" as it appears in their online documentation. --- Modules/CMakeCCompilerId.c.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index c91553a..4cc690a 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -48,6 +48,9 @@ #elif defined(__TI_COMPILER_VERSION__) # define COMPILER_ID "TI_DSP" +#elif defined(__TINYC__) +# define COMPILER_ID "TinyCC" + #elif defined(__SCO_VERSION__) # define COMPILER_ID "SCO" -- cgit v0.12 From ec636e299ff1b74457dc4fa306cbd9f33fabce9e Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 2 Dec 2011 10:22:44 -0500 Subject: TinyCC: Add compiler info for shared libs on Linux (#12605) Use the "-shared" option to link shared libraries. The compiler does not support "-Wl," or "-rpath" but does know how to pass "-soname" through to the linker. --- Modules/Compiler/TinyCC-C.cmake | 1 + Modules/Platform/Linux-TinyCC-C.cmake | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 Modules/Compiler/TinyCC-C.cmake create mode 100644 Modules/Platform/Linux-TinyCC-C.cmake diff --git a/Modules/Compiler/TinyCC-C.cmake b/Modules/Compiler/TinyCC-C.cmake new file mode 100644 index 0000000..bb27ead --- /dev/null +++ b/Modules/Compiler/TinyCC-C.cmake @@ -0,0 +1 @@ +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") diff --git a/Modules/Platform/Linux-TinyCC-C.cmake b/Modules/Platform/Linux-TinyCC-C.cmake new file mode 100644 index 0000000..b753268 --- /dev/null +++ b/Modules/Platform/Linux-TinyCC-C.cmake @@ -0,0 +1,4 @@ +SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") +SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") +SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "") +SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-soname ") -- cgit v0.12 From 901e6d023f3027ab2256a178fcff113fda66106f Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 3 Dec 2011 00:05:06 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 9ce66ab..c88794d 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 12) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 02) +SET(KWSYS_DATE_STAMP_DAY 03) -- cgit v0.12 From 9b07c19f9239241f81a74128f9abc088ccb91636 Mon Sep 17 00:00:00 2001 From: Pierre-Francois Laquerre Date: Wed, 2 Nov 2011 16:13:52 -0400 Subject: Fix path quoting in Qt4 macros Adding VERBATIM to the ADD_CUSTOM_COMMAND calls in the qt4 macros ensures that paths are properly quoted when passed to the shell. This fixes issues when building projects that contained paths with special characters (according to /bin/sh), such as parentheses or spaces. --- Modules/Qt4Macros.cmake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 630a0ba..4da1a3f 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -118,7 +118,7 @@ MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options) ADD_CUSTOM_COMMAND(OUTPUT ${outfile} COMMAND ${QT_MOC_EXECUTABLE} ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile} - DEPENDS ${infile}) + DEPENDS ${infile} VERBATIM) ENDIF (WIN32) ENDMACRO (QT4_CREATE_MOC_COMMAND) @@ -165,7 +165,7 @@ MACRO (QT4_WRAP_UI outfiles ) ADD_CUSTOM_COMMAND(OUTPUT ${outfile} COMMAND ${QT_UIC_EXECUTABLE} ARGS ${ui_options} -o ${outfile} ${infile} - MAIN_DEPENDENCY ${infile}) + MAIN_DEPENDENCY ${infile} VERBATIM) SET(${outfiles} ${${outfiles}} ${outfile}) ENDFOREACH (it) @@ -203,7 +203,7 @@ MACRO (QT4_ADD_RESOURCES outfiles ) COMMAND ${QT_RCC_EXECUTABLE} ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile} MAIN_DEPENDENCY ${infile} - DEPENDS ${_RC_DEPENDS} "${out_depends}") + DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM) SET(${outfiles} ${${outfiles}} ${outfile}) ENDFOREACH (it) @@ -235,7 +235,7 @@ MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename) ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile} - DEPENDS ${_infile}) + DEPENDS ${_infile} VERBATIM) SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE) @@ -280,7 +280,7 @@ MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options ADD_CUSTOM_COMMAND(OUTPUT ${_target} COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target} - DEPENDS ${_in_file} + DEPENDS ${_in_file} VERBATIM ) ENDMACRO(QT4_GENERATE_DBUS_INTERFACE) @@ -304,12 +304,12 @@ MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optional IF(_optionalClassName) ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile} - DEPENDS ${_infile} + DEPENDS ${_infile} VERBATIM ) ELSE(_optionalClassName) ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile} - DEPENDS ${_infile} + DEPENDS ${_infile} VERBATIM ) ENDIF(_optionalClassName) @@ -398,7 +398,7 @@ MACRO(QT4_CREATE_TRANSLATION _qm_files) ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file} COMMAND ${QT_LUPDATE_EXECUTABLE} ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file} - DEPENDS ${_my_sources} ${_ts_pro}) + DEPENDS ${_my_sources} ${_ts_pro} VERBATIM) ENDFOREACH(_ts_file) QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles}) ENDMACRO(QT4_CREATE_TRANSLATION) @@ -419,7 +419,7 @@ MACRO(QT4_ADD_TRANSLATION _qm_files) ADD_CUSTOM_COMMAND(OUTPUT ${qm} COMMAND ${QT_LRELEASE_EXECUTABLE} ARGS ${_abs_FILE} -qm ${qm} - DEPENDS ${_abs_FILE} + DEPENDS ${_abs_FILE} VERBATIM ) SET(${_qm_files} ${${_qm_files}} ${qm}) ENDFOREACH (_current_FILE) -- cgit v0.12 From e21e5cf289b79b7c260c93a19c52b63810a0efa3 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 4 Dec 2011 00:05:11 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index c88794d..818aaf2 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 12) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 03) +SET(KWSYS_DATE_STAMP_DAY 04) -- cgit v0.12 From e0bc42aa4ff086e9c6976ab91ba924530df0bf72 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 5 Dec 2011 00:05:05 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 818aaf2..d11a0eb 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 12) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 04) +SET(KWSYS_DATE_STAMP_DAY 05) -- cgit v0.12 From 0efe602c595e78c5e7cef6c85dc7983be7a905df Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Sat, 3 Dec 2011 12:21:48 +0100 Subject: TinyCC: Add default compilation flags (#12605) --- Modules/Compiler/TinyCC-C.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Modules/Compiler/TinyCC-C.cmake b/Modules/Compiler/TinyCC-C.cmake index bb27ead..4a48c0a 100644 --- a/Modules/Compiler/TinyCC-C.cmake +++ b/Modules/Compiler/TinyCC-C.cmake @@ -1 +1,8 @@ SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") + +# no optimization in tcc: +SET (CMAKE_C_FLAGS_INIT "") +SET (CMAKE_C_FLAGS_DEBUG_INIT "-g") +SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG") +SET (CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG") +SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g") -- cgit v0.12 From f44f053a52db8f78288705454a04e001b8f2c74c Mon Sep 17 00:00:00 2001 From: Alexey Ozeritsky Date: Fri, 2 Dec 2011 15:14:52 +0400 Subject: FindLAPACK: Fix linking to static LAPACK on Unix (#12477) --- Modules/FindLAPACK.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index bccf789..f88eed0 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -106,7 +106,7 @@ endforeach(_library ${_list}) if(_libraries_work) # Test this combination of libraries. if(UNIX AND BLA_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group ${${LIBRARIES}} ${_blas};-Wl,--end-group" ${_threads}) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blas} "-Wl,--end-group" ${_threads}) else(UNIX AND BLA_STATIC) set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads}) endif(UNIX AND BLA_STATIC) -- cgit v0.12 From f529ddcea0228e6919ef09af8d7d8afa7f1e7c19 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 1 Nov 2011 18:38:52 +0100 Subject: Tests: ExternalProject: Remove unnecessary 'svn --version' call This test will fail to get a proper version number if running on a (e.g. German) localized system because the regular expression used to match the Subversion version output does not match. Instead of duplicating code just remove the local test altogether and use the version that FindSubversion.cmake already detects. --- Tests/ExternalProject/CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 4a542d7..ac70129 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -343,13 +343,6 @@ endif() # Only do svn tests with svn >= version 1.2 # if(do_svn_tests) - execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} --version - OUTPUT_VARIABLE Subversion_VERSION_SVN - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*" - "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") - message(STATUS "Subversion_VERSION_SVN='${Subversion_VERSION_SVN}'") - if(Subversion_VERSION_SVN VERSION_LESS 1.2) message(STATUS "No ExternalProject svn tests with svn client less than version 1.2") set(do_svn_tests 0) -- cgit v0.12 From ecd8414757368f45152f6e3e4841a5b3715fa2d3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Nov 2011 15:13:47 -0500 Subject: Fortran: Detect pointer size in gfortran on MinGW Use __SIZEOF_POINTER__ which the GNU Fortran compiler defines at least on 64-bit MinGW. Assume default size 4 on MinGW if gfortran does not define the size. --- Modules/CMakeDetermineCompilerABI.cmake | 2 ++ Modules/CMakeFortranCompilerABI.F | 5 +++++ Modules/Platform/Windows-GNU-Fortran.cmake | 3 +++ 3 files changed, 10 insertions(+) diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index a808a28..1c9899e 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -57,6 +57,8 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) IF(ABI_SIZEOF_DPTR) SET(CMAKE_${lang}_SIZEOF_DATA_PTR "${ABI_SIZEOF_DPTR}" PARENT_SCOPE) + ELSEIF(CMAKE_${lang}_SIZEOF_DATA_PTR_DEFAULT) + SET(CMAKE_${lang}_SIZEOF_DATA_PTR "${CMAKE_${lang}_SIZEOF_DATA_PTR_DEFAULT}" PARENT_SCOPE) ENDIF(ABI_SIZEOF_DPTR) IF(ABI_NAME) diff --git a/Modules/CMakeFortranCompilerABI.F b/Modules/CMakeFortranCompilerABI.F index b8efb42..7e24553 100644 --- a/Modules/CMakeFortranCompilerABI.F +++ b/Modules/CMakeFortranCompilerABI.F @@ -15,6 +15,11 @@ PRINT *, 'INFO:sizeof_dptr[4]' #elif defined(_M_IX86) PRINT *, 'INFO:sizeof_dptr[4]' + +#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8 + PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4 + PRINT *, 'INFO:sizeof_dptr[4]' #endif #if 0 diff --git a/Modules/Platform/Windows-GNU-Fortran.cmake b/Modules/Platform/Windows-GNU-Fortran.cmake index c66feed..b81b796 100644 --- a/Modules/Platform/Windows-GNU-Fortran.cmake +++ b/Modules/Platform/Windows-GNU-Fortran.cmake @@ -1,2 +1,5 @@ include(Platform/Windows-GNU) __windows_compiler_gnu(Fortran) + +# gfortran on 64-bit MinGW defines __SIZEOF_POINTER__ +set(CMAKE_Fortran_SIZEOF_DATA_PTR_DEFAULT 4) -- cgit v0.12 From a603250a132d3a38428b6c3e2f425c1a0b2c3878 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Nov 2011 15:17:06 -0500 Subject: Load platform files that need to know the ABI when possible Load platform files named in CMAKE__ABI_FILES for each language once the ABI sizeof(void*) is known. During the first configuration this is after the test for working compiler and ABI detection checks. During later configurations the ABI information is immediately available because it has been saved in CMakeCompiler.cmake. --- Modules/CMakeCInformation.cmake | 6 ++++++ Modules/CMakeCXXInformation.cmake | 6 ++++++ Modules/CMakeFortranInformation.cmake | 6 ++++++ Modules/CMakeTestCCompiler.cmake | 6 ++++++ Modules/CMakeTestCXXCompiler.cmake | 6 ++++++ Modules/CMakeTestFortranCompiler.cmake | 6 ++++++ Source/cmDocumentVariables.cxx | 2 ++ 7 files changed, 38 insertions(+) diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 9285fef..6b5efba 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -68,6 +68,12 @@ IF (NOT _INCLUDED_FILE) INCLUDE(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL) ENDIF (NOT _INCLUDED_FILE) +IF(CMAKE_C_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_C_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_C_ABI_FILES) +ENDIF() # This should be included before the _INIT variables are # used to initialize the cache. Since the rule variables diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 620de63..b97a69c 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -67,6 +67,12 @@ IF (NOT _INCLUDED_FILE) INCLUDE(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL) ENDIF (NOT _INCLUDED_FILE) +IF(CMAKE_CXX_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_CXX_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_CXX_ABI_FILES) +ENDIF() # This should be included before the _INIT variables are # used to initialize the cache. Since the rule variables diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index dc15e55..aed1fd2 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -44,6 +44,12 @@ IF (NOT _INCLUDED_FILE) INCLUDE(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL) ENDIF (NOT _INCLUDED_FILE) +IF(CMAKE_Fortran_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_Fortran_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_Fortran_ABI_FILES) +ENDIF() # This should be included before the _INIT variables are # used to initialize the cache. Since the rule variables diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index 038c2fd..4d4e35f 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -76,5 +76,11 @@ ELSE(NOT CMAKE_C_COMPILER_WORKS) ) INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCCompiler.cmake) ENDIF(CMAKE_C_COMPILER_FORCED) + IF(CMAKE_C_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_C_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_C_ABI_FILES) + ENDIF() ENDIF(NOT CMAKE_C_COMPILER_WORKS) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index c1a3b3a..494add3 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -69,4 +69,10 @@ ELSE(NOT CMAKE_CXX_COMPILER_WORKS) ) INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXCompiler.cmake) ENDIF(CMAKE_CXX_COMPILER_FORCED) + IF(CMAKE_CXX_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_CXX_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_CXX_ABI_FILES) + ENDIF() ENDIF(NOT CMAKE_CXX_COMPILER_WORKS) diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index 33f62eb..b4dcea6 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -92,4 +92,10 @@ ELSE(NOT CMAKE_Fortran_COMPILER_WORKS) ) INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeFortranCompiler.cmake) ENDIF(CMAKE_Fortran_COMPILER_FORCED) + IF(CMAKE_Fortran_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_Fortran_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_Fortran_ABI_FILES) + ENDIF() ENDIF(NOT CMAKE_Fortran_COMPILER_WORKS) diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index ed303c9..7da07f8 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1515,6 +1515,8 @@ void cmDocumentVariables::DefineVariables(cmake* cm) cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE__COMPILER_ID_RUN", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE__ABI_FILES", + cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE__CREATE_ASSEMBLY_SOURCE", cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE__CREATE_PREPROCESSED_SOURCE", -- cgit v0.12 From 61e862986ae56e111533c21759a4e01a41968d1e Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 5 Dec 2011 16:28:03 -0500 Subject: Factor makefile generator link rule lookup into helper function This provides a place in the makefile generators to adjust the link rules for both libraries and executables. --- Source/cmMakefileExecutableTargetGenerator.cxx | 3 +-- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmMakefileTargetGenerator.cxx | 7 +++++++ Source/cmMakefileTargetGenerator.h | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index cd75d79..0fcd269 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -270,8 +270,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_LINK_EXECUTABLE"; - std::string linkRule = - this->Makefile->GetRequiredDefinition(linkRuleVar.c_str()); + std::string linkRule = this->GetLinkRule(linkRuleVar.c_str()); std::vector commands1; cmSystemTools::ExpandListArgument(linkRule, real_link_commands); if(this->Target->IsExecutableWithExports()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 31f7be5..337b286 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -772,7 +772,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules else { // Get the set of commands. - std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); + std::string linkRule = this->GetLinkRule(linkRuleVar); cmSystemTools::ExpandListArgument(linkRule, real_link_commands); // Expand placeholders. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 8b91194..004e780 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1634,6 +1634,13 @@ void cmMakefileTargetGenerator } //---------------------------------------------------------------------------- +std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar) +{ + std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); + return linkRule; +} + +//---------------------------------------------------------------------------- void cmMakefileTargetGenerator ::CloseFileStreams() { diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 674cd13..8fba13f 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -120,6 +120,9 @@ protected: // Append link rule dependencies (objects, etc.). void AppendLinkDepends(std::vector& depends); + // Lookup the link rule for this target. + std::string GetLinkRule(const char* linkRuleVar); + /** In order to support parallel builds for custom commands with multiple outputs the outputs are given a serial order, and only the first output actually has the build rule. Other outputs -- cgit v0.12 From 893093835157c0a0e593f00c244869ffd4a11b91 Mon Sep 17 00:00:00 2001 From: James Bigler Date: Mon, 5 Dec 2011 16:04:00 -0700 Subject: Added support for CUDA_PATH which is present in the CUDA toolkit 3.2 onward. This required changing how the paths were used. I now use the PATH_SUFFIXES parameter instead of putting the whole path in the command. --- Modules/FindCUDA.cmake | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index d5ef430..4b176f1 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -443,7 +443,10 @@ if(NOT CUDA_TOOLKIT_ROOT_DIR) # Search in the CUDA_BIN_PATH first. find_path(CUDA_TOOLKIT_ROOT_DIR NAMES nvcc nvcc.exe - PATHS ENV CUDA_BIN_PATH + PATHS + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 DOC "Toolkit location." NO_DEFAULT_PATH ) @@ -472,9 +475,10 @@ endif (NOT CUDA_TOOLKIT_ROOT_DIR) # CUDA_NVCC_EXECUTABLE find_program(CUDA_NVCC_EXECUTABLE NAMES nvcc - PATHS "${CUDA_TOOLKIT_ROOT_DIR}/bin" - "${CUDA_TOOLKIT_ROOT_DIR}/bin64" + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 NO_DEFAULT_PATH ) # Search default search paths, after we search our own set of paths. @@ -500,8 +504,10 @@ set(CUDA_VERSION_STRING "${CUDA_VERSION}") # CUDA_TOOLKIT_INCLUDE find_path(CUDA_TOOLKIT_INCLUDE device_functions.h # Header included in toolkit - PATHS "${CUDA_TOOLKIT_ROOT_DIR}/include" + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH ENV CUDA_INC_PATH + PATH_SUFFIXES include NO_DEFAULT_PATH ) # Search default search paths, after we search our own set of paths. @@ -516,19 +522,16 @@ macro(FIND_LIBRARY_LOCAL_FIRST _var _names _doc) if(CMAKE_SIZEOF_VOID_P EQUAL 8) # CUDA 3.2+ on Windows moved the library directoryies, so we need the new # and old paths. - set(_cuda_64bit_lib_dir - "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" - "${CUDA_TOOLKIT_ROOT_DIR}/lib64" - ) + set(_cuda_64bit_lib_dir "lib/x64" "lib64" ) endif() # CUDA 3.2+ on Windows moved the library directories, so we need to new # (lib/Win32) and the old path (lib). find_library(${_var} NAMES ${_names} - PATHS ${_cuda_64bit_lib_dir} - "${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32" - "${CUDA_TOOLKIT_ROOT_DIR}/lib" + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH ENV CUDA_LIB_PATH + PATH_SUFFIXES ${_cuda_64bit_lib_dir} "lib/Win32" "lib" DOC ${_doc} NO_DEFAULT_PATH ) -- cgit v0.12 From afb00fef193b1000aa76e3a523899712065d53d0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 5 Dec 2011 16:39:07 -0500 Subject: Add CMAKE_GNUtoMS option to convert GNU .dll.a to MS .lib Teach the Windows-GNU.cmake platform file to look for Visual Studio tools matching the target ABI. Add an extra step to the link command for shared libraries and executables that export symbols and on which a new GNUtoMS property is set (initialized by the CMAKE_GNUtoMS option). Tell the GNU linker to output a module definition (.def) file listing exported symbols in addition to the GNU-format import library (.dll.a). Pass the .def file to the MS "lib" tool to construct a MS-format DLL import library (.lib). Teach the install(TARGETS) command to install the MS import library next to the GNU one. Teach the install(EXPORT) and export() command to set the IMPORTED_IMPLIB property pointing at the import library to use the import library matching the tools in the importing project. --- .gitattributes | 1 + Modules/Platform/GNUtoMS_lib.bat.in | 3 ++ Modules/Platform/GNUtoMS_lib.cmake | 10 +++++ Modules/Platform/Windows-GNU-C-ABI.cmake | 1 + Modules/Platform/Windows-GNU-CXX-ABI.cmake | 1 + Modules/Platform/Windows-GNU-Fortran-ABI.cmake | 1 + Modules/Platform/Windows-GNU.cmake | 54 ++++++++++++++++++++++++++ Source/cmDocumentVariables.cxx | 9 +++++ Source/cmExportBuildFileGenerator.cxx | 2 + Source/cmInstallTargetGenerator.cxx | 26 ++++++++++++- Source/cmMakefileExecutableTargetGenerator.cxx | 7 ++++ Source/cmMakefileLibraryTargetGenerator.cxx | 7 ++++ Source/cmMakefileTargetGenerator.cxx | 10 +++++ Source/cmTarget.cxx | 38 ++++++++++++++++++ Source/cmTarget.h | 8 ++++ 15 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 Modules/Platform/GNUtoMS_lib.bat.in create mode 100644 Modules/Platform/GNUtoMS_lib.cmake create mode 100644 Modules/Platform/Windows-GNU-C-ABI.cmake create mode 100644 Modules/Platform/Windows-GNU-CXX-ABI.cmake create mode 100644 Modules/Platform/Windows-GNU-Fortran-ABI.cmake diff --git a/.gitattributes b/.gitattributes index d9d64d6..d21f1dd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,6 +8,7 @@ configure crlf=input *.sh.in crlf=input *.bat -crlf +*.bat.in -crlf *.dsp -crlf *.dsptemplate -crlf *.dsw -crlf diff --git a/Modules/Platform/GNUtoMS_lib.bat.in b/Modules/Platform/GNUtoMS_lib.bat.in new file mode 100644 index 0000000..2da920a --- /dev/null +++ b/Modules/Platform/GNUtoMS_lib.bat.in @@ -0,0 +1,3 @@ +@echo off +call "@CMAKE_GNUtoMS_BAT@" +lib /machine:"@CMAKE_GNUtoMS_ARCH@" %* diff --git a/Modules/Platform/GNUtoMS_lib.cmake b/Modules/Platform/GNUtoMS_lib.cmake new file mode 100644 index 0000000..ca9b0f8 --- /dev/null +++ b/Modules/Platform/GNUtoMS_lib.cmake @@ -0,0 +1,10 @@ +# Usage: cmake -Dlib=lib.bat -Ddef=out.def -Ddll=out.dll -Dimp=out.dll.a -P GNUtoMS_lib.cmake +get_filename_component(name ${dll} NAME) # .dll file name +string(REGEX REPLACE "\\.dll\\.a$" ".lib" out "${imp}") # .dll.a -> .lib +execute_process( + COMMAND ${lib} /def:${def} /name:${name} /out:${out} + RESULT_VARIABLE res + ) +if(res) + message(FATAL_ERROR "lib failed: ${res}") +endif() diff --git a/Modules/Platform/Windows-GNU-C-ABI.cmake b/Modules/Platform/Windows-GNU-C-ABI.cmake new file mode 100644 index 0000000..1189263 --- /dev/null +++ b/Modules/Platform/Windows-GNU-C-ABI.cmake @@ -0,0 +1 @@ +__windows_compiler_gnu_abi(C) diff --git a/Modules/Platform/Windows-GNU-CXX-ABI.cmake b/Modules/Platform/Windows-GNU-CXX-ABI.cmake new file mode 100644 index 0000000..f3c701c --- /dev/null +++ b/Modules/Platform/Windows-GNU-CXX-ABI.cmake @@ -0,0 +1 @@ +__windows_compiler_gnu_abi(CXX) diff --git a/Modules/Platform/Windows-GNU-Fortran-ABI.cmake b/Modules/Platform/Windows-GNU-Fortran-ABI.cmake new file mode 100644 index 0000000..179280b --- /dev/null +++ b/Modules/Platform/Windows-GNU-Fortran-ABI.cmake @@ -0,0 +1 @@ +__windows_compiler_gnu_abi(Fortran) diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index 1d3e4b5..c255d6b 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -108,6 +108,8 @@ macro(__windows_compiler_gnu lang) set(CMAKE_${lang}_LINK_EXECUTABLE " -o -Wl,--out-implib, ${CMAKE_GNULD_IMAGE_VERSION} ") + list(APPEND CMAKE_${lang}_ABI_FILES "Platform/Windows-GNU-${lang}-ABI") + # Support very long lists of object files. if("${CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG}" STREQUAL "@") foreach(rule CREATE_SHARED_MODULE CREATE_SHARED_LIBRARY LINK_EXECUTABLE) @@ -125,3 +127,55 @@ macro(__windows_compiler_gnu lang) endforeach() endif() endmacro() + +macro(__windows_compiler_gnu_abi lang) + if(CMAKE_NO_GNUtoMS) + set(CMAKE_GNUtoMS 0) + else() + option(CMAKE_GNUtoMS "Convert GNU import libraries to MS format (requires Visual Studio)" OFF) + endif() + + if(CMAKE_GNUtoMS AND NOT CMAKE_GNUtoMS_LIB) + # Find MS development environment setup script for this architecture. + if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) + find_program(CMAKE_GNUtoMS_VCVARS NAMES vcvars32.bat + DOC "Visual Studio vcvars32.bat" + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual C++;ProductDir]/bin" + ) + set(CMAKE_GNUtoMS_ARCH x86) + elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) + find_program(CMAKE_GNUtoMS_VCVARS NAMES vcvarsamd64.bat + DOC "Visual Studio vcvarsamd64.bat" + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VC;ProductDir]/bin/amd64" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VC;ProductDir]/bin/amd64" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC;ProductDir]/bin/amd64" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/bin/amd64" + ) + set(CMAKE_GNUtoMS_ARCH amd64) + endif() + set_property(CACHE CMAKE_GNUtoMS_VCVARS PROPERTY ADVANCED 1) + if(CMAKE_GNUtoMS_VCVARS) + # Create helper script to run lib.exe from MS environment. + string(REPLACE "/" "\\" CMAKE_GNUtoMS_BAT "${CMAKE_GNUtoMS_VCVARS}") + set(CMAKE_GNUtoMS_LIB ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeGNUtoMS_lib.bat) + configure_file(${CMAKE_ROOT}/Modules/Platform/GNUtoMS_lib.bat.in ${CMAKE_GNUtoMS_LIB}) + else() + message(WARNING "Disabling CMAKE_GNUtoMS option because CMAKE_GNUtoMS_VCVARS is not set.") + set(CMAKE_GNUtoMS 0) + endif() + endif() + + if(CMAKE_GNUtoMS) + # Teach CMake how to create a MS import library at link time. + set(CMAKE_${lang}_GNUtoMS_RULE " -Wl,--output-def,.def" + " -Dlib=\"${CMAKE_GNUtoMS_LIB}\" -Ddef=\".def\" -Ddll=\"\" -Dimp=\"\" -P \"${CMAKE_ROOT}/Modules/Platform/GNUtoMS_lib.cmake\"" + ) + endif() +endmacro() diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 7da07f8..c8c83b9 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1112,6 +1112,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables that Control the Build"); cm->DefineProperty + ("CMAKE_GNUtoMS", cmProperty::VARIABLE, + "Convert GNU import libraries (.dll.a) to MS format (.lib).", + "This variable is used to initialize the GNUtoMS property on targets " + "when they are created. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + + cm->DefineProperty ("CMAKE_DEBUG_POSTFIX", cmProperty::VARIABLE, "See variable CMAKE__POSTFIX.", "This variable is a special case of the more-general " diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 7e73e36..32595ee 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -125,6 +125,8 @@ cmExportBuildFileGenerator std::string prop = "IMPORTED_IMPLIB"; prop += suffix; std::string value = target->GetFullPath(config, true); + target->GetImplibGNUtoMS(value, value, + "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); properties[prop] = value; } } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 33ffbfb..ac1c949 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -101,6 +101,13 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string to1 = toDir + targetNameImport; filesFrom.push_back(from1); filesTo.push_back(to1); + std::string targetNameImportLib; + if(this->Target->GetImplibGNUtoMS(targetNameImport, + targetNameImportLib)) + { + filesFrom.push_back(fromDirConfig + targetNameImportLib); + filesTo.push_back(toDir + targetNameImportLib); + } // An import library looks like a static library. type = cmTarget::STATIC_LIBRARY; @@ -157,6 +164,13 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string to1 = toDir + targetNameImport; filesFrom.push_back(from1); filesTo.push_back(to1); + std::string targetNameImportLib; + if(this->Target->GetImplibGNUtoMS(targetNameImport, + targetNameImportLib)) + { + filesFrom.push_back(fromDirConfig + targetNameImportLib); + filesTo.push_back(toDir + targetNameImportLib); + } // An import library looks like a static library. type = cmTarget::STATIC_LIBRARY; @@ -314,7 +328,11 @@ std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, if(nameType == NameImplib) { // Use the import library name. - fname = targetNameImport; + if(!target->GetImplibGNUtoMS(targetNameImport, fname, + "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) + { + fname = targetNameImport; + } } else if(nameType == NameReal) { @@ -339,7 +357,11 @@ std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, if(nameType == NameImplib) { // Use the import library name. - fname = targetNameImport; + if(!target->GetImplibGNUtoMS(targetNameImport, fname, + "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) + { + fname = targetNameImport; + } } else if(nameType == NameSO) { diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 0fcd269..78278cb 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -241,6 +241,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) exeCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); + std::string implib; + if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) + { + exeCleanFiles.push_back(this->Convert(implib.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } } // List the PDB for cleaning only when the whole target is diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 337b286..b4174cc 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -512,6 +512,13 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); + std::string implib; + if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) + { + libCleanFiles.push_back(this->Convert(implib.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } } // List the PDB for cleaning only when the whole target is diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 004e780..a3a832b 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1637,6 +1637,16 @@ void cmMakefileTargetGenerator std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar) { std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); + if(this->Target->HasImplibGNUtoMS()) + { + std::string ruleVar = "CMAKE_"; + ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += "_GNUtoMS_RULE"; + if(const char* rule = this->Makefile->GetDefinition(ruleVar.c_str())) + { + linkRule += rule; + } + } return linkRule; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index dad0353..48368de 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -980,6 +980,23 @@ void cmTarget::DefineProperties(cmake *cm) "is created its value is used to initialize this property."); cm->DefineProperty + ("GNUtoMS", cmProperty::TARGET, + "Convert GNU import library (.dll.a) to MS format (.lib).", + "When linking a shared library or executable that exports symbols " + "using GNU tools on Windows (MinGW/MSYS) with Visual Studio installed " + "convert the import library (.dll.a) from GNU to MS format (.lib). " + "Both import libraries will be installed by install(TARGETS) and " + "exported by install(EXPORT) and export() to be linked by applications " + "with either GNU- or MS-compatible tools." + "\n" + "If the variable CMAKE_GNUtoMS is set when a target " + "is created its value is used to initialize this property. " + "The variable must be set prior to the first command that enables " + "a language such as project() or enable_language(). " + "CMake provides the variable as an option to the user automatically " + "when configuring on Windows with GNU tools."); + + cm->DefineProperty ("XCODE_ATTRIBUTE_", cmProperty::TARGET, "Set Xcode target attributes directly.", "Tell the Xcode generator to set '' to a given value " @@ -1195,6 +1212,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("Fortran_FORMAT", 0); this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); + this->SetPropertyDefault("GNUtoMS", 0); this->SetPropertyDefault("OSX_ARCHITECTURES", 0); this->SetPropertyDefault("AUTOMOC", 0); this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0); @@ -3457,6 +3475,26 @@ void cmTarget::GetExecutableNames(std::string& name, } //---------------------------------------------------------------------------- +bool cmTarget::HasImplibGNUtoMS() +{ + return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); +} + +//---------------------------------------------------------------------------- +bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, + std::string& out, const char* newExt) +{ + if(this->HasImplibGNUtoMS() && + gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a") + { + out = gnuName.substr(0, gnuName.size()-6); + out += newExt? newExt : ".lib"; + return true; + } + return false; +} + +//---------------------------------------------------------------------------- void cmTarget::GenerateTargetManifest(const char* config) { cmMakefile* mf = this->Makefile; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0abdddb..09fee6c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -369,6 +369,14 @@ public: std::string& impName, std::string& pdbName, const char* config); + /** Does this target have a GNU implib to convert to MS format? */ + bool HasImplibGNUtoMS(); + + /** Convert the given GNU import library name (.dll.a) to a name with a new + extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ + bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, + const char* newExt = 0); + /** Add the target output files to the global generator manifest. */ void GenerateTargetManifest(const char* config); -- cgit v0.12 From ae62a1cd35fcd9be8d1beb11c864fbe417de429e Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 5 Dec 2011 16:49:10 -0500 Subject: Test CMAKE_GNUtoMS option in ExportImport on MinGW and MSys --- Tests/ExportImport/CMakeLists.txt | 5 +++++ Tests/ExportImport/InitialCache.cmake.in | 1 + 2 files changed, 6 insertions(+) diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt index 2e01c50..ccfb894 100644 --- a/Tests/ExportImport/CMakeLists.txt +++ b/Tests/ExportImport/CMakeLists.txt @@ -22,6 +22,11 @@ else(CMAKE_CONFIGURATION_TYPES) endif(CMAKE_BUILD_TYPE) endif(CMAKE_CONFIGURATION_TYPES) +if(MINGW OR MSYS) + # Test CMAKE_GNUtoMS whether we have VS or not. + set(ExportImport_GNUtoMS 1) +endif() + configure_file(${ExportImport_SOURCE_DIR}/InitialCache.cmake.in ${ExportImport_BINARY_DIR}/InitialCache.cmake @ONLY) diff --git a/Tests/ExportImport/InitialCache.cmake.in b/Tests/ExportImport/InitialCache.cmake.in index f920b1f..4893f70 100644 --- a/Tests/ExportImport/InitialCache.cmake.in +++ b/Tests/ExportImport/InitialCache.cmake.in @@ -12,3 +12,4 @@ SET(CMAKE_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@" CACHE STRING "C++ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@" CACHE STRING "C++ Flags") SET(CMAKE_INSTALL_PREFIX "@ExportImport_BINARY_DIR@/Root" CACHE STRING "Installation Prefix") SET(CMAKE_SKIP_RPATH ON CACHE BOOL "No RPATH") +SET(CMAKE_GNUtoMS "@ExportImport_GNUtoMS@" CACHE BOOL "CMAKE_GNUtoMS") -- cgit v0.12 From aa595440786dcd84cbca81410c76c0b170b3abac Mon Sep 17 00:00:00 2001 From: James Bigler Date: Mon, 5 Dec 2011 16:29:28 -0700 Subject: Reset dependency file list when a dependency disappeared. Fix a long outstanding bug when a file in the dependency list wasn't found. This bug wouldn't reset the dependencies, so the makefile would still want the missing file when building. The work around was to configure twice, but this is no longer necessary. --- Modules/FindCUDA.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index d5ef430..f696f2e 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -339,6 +339,8 @@ macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) # output depend on the dependency file itself, which should cause the # rule to re-run. if(CUDA_NVCC_DEPEND_REGENERATE) + set(CUDA_NVCC_DEPEND ${dependency_file}) + #message("Generating an empty dependency_file: ${dependency_file}") file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") endif(CUDA_NVCC_DEPEND_REGENERATE) -- cgit v0.12 From 83d4eeadac5a656949127d4e2b67c4e973bbab48 Mon Sep 17 00:00:00 2001 From: James Bigler Date: Mon, 5 Dec 2011 16:54:06 -0700 Subject: Add work around for CUDA in UNC paths. Nvcc can emit '/path' instead of '//path' which can cause a lot of grief later. We test to see if the file exists, if it doesn't then we see if the file exists with '/' prepended. Files that don't exist won't be added to the list. --- Modules/FindCUDA/make2cmake.cmake | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Modules/FindCUDA/make2cmake.cmake b/Modules/FindCUDA/make2cmake.cmake index 7fce167..d41b72d 100644 --- a/Modules/FindCUDA/make2cmake.cmake +++ b/Modules/FindCUDA/make2cmake.cmake @@ -54,13 +54,27 @@ if (${depend_text} MATCHES ".+") string(REGEX REPLACE "^ +" "" file ${file}) - if(NOT IS_DIRECTORY ${file}) + # OK, now if we had a UNC path, nvcc has a tendency to only output the first '/' + # instead of '//'. Here we will test to see if the file exists, if it doesn't then + # try to prepend another '/' to the path and test again. If it still fails remove the + # path. + + if(NOT EXISTS "${file}") + if (EXISTS "/${file}") + set(file "/${file}") + else() + message(WARNING " Removing non-existant dependency file: ${file}") + set(file "") + endif() + endif() + + if(NOT IS_DIRECTORY "${file}") # If softlinks start to matter, we should change this to REALPATH. For now we need # to flatten paths, because nvcc can generate stuff like /bin/../include instead of # just /include. get_filename_component(file_absolute "${file}" ABSOLUTE) list(APPEND dependency_list "${file_absolute}") - endif(NOT IS_DIRECTORY ${file}) + endif() endforeach(file) -- cgit v0.12 From c3c7a0cfb84526693d33d7469719518aab91ff31 Mon Sep 17 00:00:00 2001 From: James Bigler Date: Mon, 5 Dec 2011 17:16:05 -0700 Subject: Fixes for handling quotes in args and other places (Fix Bug 11726 and 12099). --- Modules/FindCUDA.cmake | 12 ++++++------ Modules/FindCUDA/run_nvcc.cmake | 30 +++++++++++++++--------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index d5ef430..df3b6be 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -707,7 +707,7 @@ find_package_handle_standard_args(CUDA # Add include directories to pass to the nvcc command. macro(CUDA_INCLUDE_DIRECTORIES) foreach(dir ${ARGN}) - list(APPEND CUDA_NVCC_INCLUDE_ARGS_USER "-I${dir}") + list(APPEND CUDA_NVCC_INCLUDE_ARGS_USER -I${dir}) endforeach(dir ${ARGN}) endmacro(CUDA_INCLUDE_DIRECTORIES) @@ -736,13 +736,13 @@ macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options) arg STREQUAL "SHARED" OR arg STREQUAL "MODULE" ) - list(APPEND ${_cmake_options} "${arg}") + list(APPEND ${_cmake_options} ${arg}) else() if ( _found_options ) - list(APPEND ${_options} "${arg}") + list(APPEND ${_options} ${arg}) else() # Assume this is a file - list(APPEND ${_sources} "${arg}") + list(APPEND ${_sources} ${arg}) endif() endif() endforeach() @@ -890,7 +890,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) get_directory_property(CUDA_NVCC_INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES) if(CUDA_NVCC_INCLUDE_DIRECTORIES) foreach(dir ${CUDA_NVCC_INCLUDE_DIRECTORIES}) - list(APPEND CUDA_NVCC_INCLUDE_ARGS "-I${dir}") + list(APPEND CUDA_NVCC_INCLUDE_ARGS -I${dir}) endforeach() endif() @@ -956,7 +956,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) # Note that if we ever want CUDA_NVCC_FLAGS_ to be string (instead of a list # like it is currently), we can remove the quotes around the # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_ variable. - set(CUDA_NVCC_FLAGS_CONFIG "${CUDA_NVCC_FLAGS_CONFIG}\nset(CUDA_NVCC_FLAGS_${config_upper} \"${CUDA_NVCC_FLAGS_${config_upper}};;${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}}\")") + set(CUDA_NVCC_FLAGS_CONFIG "${CUDA_NVCC_FLAGS_CONFIG}\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") endforeach() if(compile_to_ptx) diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake index 7349da3..b31011c 100644 --- a/Modules/FindCUDA/run_nvcc.cmake +++ b/Modules/FindCUDA/run_nvcc.cmake @@ -55,25 +55,25 @@ if(NOT generated_file) endif() # Set these up as variables to make reading the generated file easier -set(CMAKE_COMMAND "@CMAKE_COMMAND@") -set(source_file "@source_file@") -set(NVCC_generated_dependency_file "@NVCC_generated_dependency_file@") -set(cmake_dependency_file "@cmake_dependency_file@") -set(CUDA_make2cmake "@CUDA_make2cmake@") -set(CUDA_parse_cubin "@CUDA_parse_cubin@") -set(build_cubin @build_cubin@) +set(CMAKE_COMMAND "@CMAKE_COMMAND@") # path +set(source_file "@source_file@") # path +set(NVCC_generated_dependency_file "@NVCC_generated_dependency_file@") # path +set(cmake_dependency_file "@cmake_dependency_file@") # path +set(CUDA_make2cmake "@CUDA_make2cmake@") # path +set(CUDA_parse_cubin "@CUDA_parse_cubin@") # path +set(build_cubin @build_cubin@) # bool # We won't actually use these variables for now, but we need to set this, in # order to force this file to be run again if it changes. -set(generated_file_path "@generated_file_path@") -set(generated_file_internal "@generated_file@") -set(generated_cubin_file_internal "@generated_cubin_file@") +set(generated_file_path "@generated_file_path@") # path +set(generated_file_internal "@generated_file@") # path +set(generated_cubin_file_internal "@generated_cubin_file@") # path -set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") -set(CUDA_NVCC_FLAGS "@CUDA_NVCC_FLAGS@;;@CUDA_WRAP_OPTION_NVCC_FLAGS@") +set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") # path +set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list @CUDA_NVCC_FLAGS_CONFIG@ -set(nvcc_flags "@nvcc_flags@") -set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@") -set(format_flag "@format_flag@") +set(nvcc_flags @nvcc_flags@) # list +set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@") # list (needs to be in quotes to handle spaces properly). +set(format_flag "@format_flag@") # string if(build_cubin AND NOT generated_cubin_file) message(FATAL_ERROR "You must specify generated_cubin_file on the command line") -- cgit v0.12 From 759323ad0b93ba9b31eb736988df382d0cc1fe7f Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 6 Dec 2011 00:05:06 -0500 Subject: KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index d11a0eb..280d3f3 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 12) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 05) +SET(KWSYS_DATE_STAMP_DAY 06) -- cgit v0.12