summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-06-10 15:46:06 (GMT)
committerBrad King <brad.king@kitware.com>2009-06-10 15:46:06 (GMT)
commit776e21d1c7a3414aff8d307aaaef56abd907d8d5 (patch)
treebe9cf7f403df4f2e21a12df8f09321d782acbf78
parent7a839be9724be4d17c746823b32aeff33c6498eb (diff)
downloadCMake-776e21d1c7a3414aff8d307aaaef56abd907d8d5.zip
CMake-776e21d1c7a3414aff8d307aaaef56abd907d8d5.tar.gz
CMake-776e21d1c7a3414aff8d307aaaef56abd907d8d5.tar.bz2
COMP: Avoid String.c inclusion by Compaq templates
The Compaq compiler (on VMS) includes 'String.c' in source files that use the stl string while looking for template definitions. This was the true cause of double-inclusion of the 'kwsysPrivate.h' header. We work around the problem by conditionally compiling the entire source file on a condition only true when really building the source.
-rw-r--r--Source/kwsys/CMakeLists.txt6
-rw-r--r--Source/kwsys/String.c10
-rw-r--r--Source/kwsys/kwsysPrivate.h4
-rwxr-xr-xbootstrap4
4 files changed, 20 insertions, 4 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 871049b..0a816e2 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -848,6 +848,12 @@ ENDIF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
# line to configure the namespace in the C and C++ source files.
ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}")
+IF(KWSYS_USE_String)
+ # Activate code in "String.c". See the comment in the source.
+ SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES
+ COMPILE_FLAGS "-DKWSYS_STRING_C")
+ENDIF(KWSYS_USE_String)
+
#-----------------------------------------------------------------------------
# Process execution on windows needs to build a forwarding executable
# that works around a Win9x bug. We encode the executable into a C
diff --git a/Source/kwsys/String.c b/Source/kwsys/String.c
index 1aade12..9d2afc6 100644
--- a/Source/kwsys/String.c
+++ b/Source/kwsys/String.c
@@ -11,6 +11,14 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
+#ifdef KWSYS_STRING_C
+/*
+All code in this source file is conditionally compiled to work-around
+template definition auto-search on VMS. Other source files in this
+directory that use the stl string cause the compiler to load this
+source to try to get the definition of the string template. This
+condition blocks the compiler from seeing the symbols defined here.
+*/
#include "kwsysPrivate.h"
#include KWSYS_HEADER(String.h)
@@ -105,3 +113,5 @@ int kwsysString_strncasecmp(const char* lhs, const char* rhs, size_t n)
return result;
#endif
}
+
+#endif /* KWSYS_STRING_C */
diff --git a/Source/kwsys/kwsysPrivate.h b/Source/kwsys/kwsysPrivate.h
index 822ea53..200acc1 100644
--- a/Source/kwsys/kwsysPrivate.h
+++ b/Source/kwsys/kwsysPrivate.h
@@ -39,7 +39,5 @@
#define KWSYS_NAMESPACE_STRING1(x) #x
#else
-# ifndef __VMS /* Avoid strange false positive on VMS compiler. */
-# error "kwsysPrivate.h included multiple times."
-# endif
+# error "kwsysPrivate.h included multiple times."
#endif
diff --git a/bootstrap b/bootstrap
index a450911..93ad54d 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1286,6 +1286,7 @@ if [ "x${cmake_cxx_flags}" != "x" ]; then
cmake_cxx_flags="${cmake_cxx_flags} "
fi
+cmake_c_flags_String="-DKWSYS_STRING_C"
cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
-I`cmake_escape \"${cmake_bootstrap_dir}\"`"
cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
@@ -1305,8 +1306,9 @@ for a in ${CMAKE_C_SOURCES}; do
done
for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do
src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
+ src_flags=`eval echo \\${cmake_c_flags_\${a}}`
echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
- echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
+ echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
done
for a in ${KWSYS_CXX_SOURCES}; do
src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`