1. Jason R. Coombs
  2. gcc-xml

Commits

henderson  committed 73b644a

ENH: copying Brad's installation changes from the main tree to the ParaView 2.0 branch

  • Participants
  • Parent commits 83b5a8d
  • Branches ParaView-2-0
  • Tags ParaView-2-0-1, ParaView-2-0-2 3
    1. ParaView-2-0-2-Sandia
    2. ParaView-2-0-3
    3. ParaView-2-0-InstallSupport-post

Comments (0)

Files changed (2)

File GCC_XML/KWSys/CMakeLists.txt

View file
  • Ignore whitespace
+#=============================================================================
+#
+#  Program:   KWSys - Kitware System Library
+#  Module:    $RCSfile$
+#
+#  Copyright (c) Kitware, Inc., Insight Consortium.  All rights reserved.
+#  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+#
+#     This software is distributed WITHOUT ANY WARRANTY; without even
+#     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+#     PURPOSE.  See the above copyright notices for more information.
+#
+#=============================================================================
+
+# The Kitware System Library is intended to be included in other
+# projects.  It is completely configurable in that the library's
+# namespace can be configured and the components that are included can
+# be selected invididually.
+
+# Typical usage is to import the kwsys directory tree into a
+# subdirectory under a parent project and enable the classes that will
+# be used.  All classes are disabled by default.  The CMake listfile
+# above this one configures the library as follows:
+#
+#  SET(KWSYS_NAMESPACE foosys)
+#  SET(KWSYS_USE_Directory 1)    # Enable Directory class.
+#  SUBDIRS(kwsys)
+#
+# Optional settings are as follows:
+#
+#  KWSYS_HEADER_ROOT = The directory into which to generate the kwsys headers.
+#                      A directory called "${KWSYS_NAMESPACE}" will be
+#                      created under this root directory to hold the files.
+#
+#    Example:
+#
+#      SET(KWSYS_HEADER_ROOT ${PROJECT_BINARY_DIR})
+#      INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
+#
+#  KWSYS_LIBRARY_INSTALL_DIR = The installation target directories into
+#  KWSYS_HEADER_INSTALL_DIR    which the libraries and headers from
+#                              kwsys should be installed by a "make install".
+#                              The values should be specified relative to
+#                              the installation prefix and start with a '/'.
+#    Example:
+#
+#      SET(KWSYS_LIBRARY_INSTALL_DIR /lib)
+#      SET(KWSYS_HEADER_INSTALL_DIR /include)
+#
+#  KWSYS_IOS_FORCE_OLD = Force use of old non-ANSI C++ streams even if
+#                        new streams are available.  This may be used
+#                        by projects that cannot configure their
+#                        streams library.
+#    Example:
+#
+#      SET(KWSYS_IOS_FORCE_OLD 1)
+#
+
+# Once configured, kwsys should be used as follows from C or C++ code:
+#
+#  #include <foosys/Directory.hxx>
+#   ...
+#  foosys::Directory directory;
+#
+
+#-----------------------------------------------------------------------------
+# If a namespace is not specified, use "kwsys" and enable testing.
+# This should be the case only when kwsys is not included inside
+# another project and is being tested.
 IF(NOT KWSYS_NAMESPACE)
   SET(KWSYS_NAMESPACE "kwsys")
-  SET(KWSYS_DEFAULTS 1)
+  SET(KWSYS_STANDALONE 1)
+  SET(KWSYS_ENABLE_C 1)
+
+  # Enable all components.
+  SET(KWSYS_USE_Base64 1)
+  SET(KWSYS_USE_Directory 1)
+  SET(KWSYS_USE_Process 1)
+  SET(KWSYS_USE_RegularExpression 1)
+  SET(KWSYS_USE_SystemTools 1)
+  SET(KWSYS_USE_CommandLineArguments 1)
 ENDIF(NOT KWSYS_NAMESPACE)
 
+#-----------------------------------------------------------------------------
+# The project name is that of the specified namespace.
 PROJECT(${KWSYS_NAMESPACE})
-INCLUDE(${CMAKE_ROOT}/Modules/TestForANSIStreamHeaders.cmake)
-INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake)
-INCLUDE(${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake)
-INCLUDE(${CMAKE_ROOT}/Modules/TestForANSIForScope.cmake)
-CHECK_INCLUDE_FILE_CXX("sstream" CMAKE_HAS_ANSI_STRING_STREAM)
 
-SET(KWSYS_NO_STD_NAMESPACE ${CMAKE_NO_STD_NAMESPACE})
-SET(KWSYS_NO_ANSI_STREAM_HEADERS ${CMAKE_NO_ANSI_STREAM_HEADERS})
-SET(KWSYS_NO_ANSI_STRING_STREAM ${CMAKE_NO_ANSI_STRING_STREAM})
-SET(KWSYS_NO_ANSI_FOR_SCOPE ${CMAKE_NO_ANSI_FOR_SCOPE})
+# Enable testing if building standalone.
+IF(KWSYS_STANDALONE)
+  INCLUDE(${CMAKE_ROOT}/Modules/Dart.cmake)
+  MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
+  IF(BUILD_TESTING)
+    ENABLE_TESTING()
+  ENDIF(BUILD_TESTING)
+ENDIF(KWSYS_STANDALONE)
 
-SET(CLASSES Directory RegularExpression SystemTools)
-SET(HEADERS Configure StandardIncludes)
+# Do full dependency headers.
+INCLUDE_REGULAR_EXPRESSION("^.*$")
 
-SET(SRCS)
-SET(KWSYS_INCLUDES)
-FOREACH(c ${CLASSES})
-  SET(SRCS ${SRCS} ${c}.cxx)
-  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${c}.hxx.in
-                 ${PROJECT_BINARY_DIR}/../${KWSYS_NAMESPACE}/${c}.hxx
+# Work-around for CMake 1.6.7 bug in custom command dependencies when
+# there is no executable output path.
+IF(NOT EXECUTABLE_OUTPUT_PATH)
+  SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}" CACHE PATH
+      "Output directory for executables.")
+ENDIF(NOT EXECUTABLE_OUTPUT_PATH)
+
+# Generated source files will need this header.
+STRING(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}"
+  KWSYS_IN_SOURCE_BUILD)
+IF(NOT KWSYS_IN_SOURCE_BUILD)
+  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsysPrivate.h
+    ${PROJECT_BINARY_DIR}/kwsysPrivate.h COPY_ONLY IMMEDIATE)
+ENDIF(NOT KWSYS_IN_SOURCE_BUILD)
+
+#-----------------------------------------------------------------------------
+# We require ANSI support from the C compiler.  Add any needed flags.
+IF(CMAKE_ANSI_CFLAGS)
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
+ENDIF(CMAKE_ANSI_CFLAGS)
+
+#-----------------------------------------------------------------------------
+# Adjust compiler flags for some platforms.
+IF(NOT CMAKE_COMPILER_IS_GNUCXX)
+  IF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+    STRING(REGEX MATCH "-timplicit_local"
+      KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL "${CMAKE_CXX_FLAGS}")
+    STRING(REGEX MATCH "-no_implicit_include"
+      KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE "${CMAKE_CXX_FLAGS}")
+    IF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL)
+      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local")
+    ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL)
+    IF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
+      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include")
+    ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
+  ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
+
+#-----------------------------------------------------------------------------
+# Configure the standard library header wrappers based on compiler's
+# capabilities and parent project's request.  Enforce 0/1 as only
+# possible values for configuration into Configure.hxx.
+INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformCxxTests.cmake)
+
+KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAVE_STD
+  "Checking whether STL classes are in std namespace" DIRECT)
+
+IF(KWSYS_IOS_FORCE_OLD)
+  SET(KWSYS_IOS_USE_ANSI 0)
+ELSE(KWSYS_IOS_FORCE_OLD)
+  KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_ANSI
+    "Checking whether ANSI stream headers are available" DIRECT)
+ENDIF(KWSYS_IOS_FORCE_OLD)
+
+IF(KWSYS_IOS_USE_ANSI)
+  KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAVE_STD
+    "Checking whether ANSI streams are in std namespace" DIRECT)
+  KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_SSTREAM
+    "Checking whether ANSI string stream is available" DIRECT)
+ELSE(KWSYS_IOS_USE_ANSI)
+  SET(KWSYS_IOS_HAVE_STD 0)
+  SET(KWSYS_IOS_USE_SSTREAM 0)
+ENDIF(KWSYS_IOS_USE_ANSI)
+
+IF(KWSYS_IOS_USE_SSTREAM)
+  SET(KWSYS_IOS_USE_STRSTREAM_H 0)
+  SET(KWSYS_IOS_USE_STRSTREA_H 0)
+ELSE(KWSYS_IOS_USE_SSTREAM)
+  KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREAM_H
+    "Checking whether strstream.h is available" DIRECT)
+  IF(KWSYS_IOS_USE_STRSTREAM_H)
+    SET(KWSYS_IOS_USE_STRSTREA_H 0)
+  ELSE(KWSYS_IOS_USE_STRSTREAM_H)
+    KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREA_H
+      "Checking whether strstrea.h is available" DIRECT)
+  ENDIF(KWSYS_IOS_USE_STRSTREAM_H)
+ENDIF(KWSYS_IOS_USE_SSTREAM)
+
+IF(UNIX)
+  KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM
+    "Checking whether struct stat has st_mtim member" DIRECT)
+ENDIF(UNIX)
+
+IF(KWSYS_NAMESPACE MATCHES "^kwsys$")
+  SET(KWSYS_NAME_IS_KWSYS 1)
+ELSE(KWSYS_NAMESPACE MATCHES "^kwsys$")
+  SET(KWSYS_NAME_IS_KWSYS 0)
+ENDIF(KWSYS_NAMESPACE MATCHES "^kwsys$")
+
+# Choose default shared/static build if not specified.
+IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
+  SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
+ENDIF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
+
+IF(KWSYS_BUILD_SHARED)
+  SET(KWSYS_BUILD_SHARED 1)
+  SET(KWSYS_LIBRARY_TYPE SHARED)
+ELSE(KWSYS_BUILD_SHARED)
+  SET(KWSYS_BUILD_SHARED 0)
+  SET(KWSYS_LIBRARY_TYPE STATIC)
+ENDIF(KWSYS_BUILD_SHARED)
+
+#-----------------------------------------------------------------------------
+# Choose a directory for the generated headers.
+IF(NOT KWSYS_HEADER_ROOT)
+  SET(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}")
+ENDIF(NOT KWSYS_HEADER_ROOT)
+SET(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}")
+INCLUDE_DIRECTORIES(${KWSYS_HEADER_ROOT})
+
+#-----------------------------------------------------------------------------
+# Create STL header wrappers to block warnings in the STL headers and
+# give standard names by which they may be included.
+FOREACH(header algorithm deque iterator list map numeric queue set stack string
+               utility vector)
+  # Configure the header wrapper.
+  SET(KWSYS_STL_HEADER "${header}")
+  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl.h.in
+                 ${KWSYS_HEADER_DIR}/stl/${header}
                  @ONLY IMMEDIATE)
-  SET(KWSYS_INCLUDES ${KWSYS_INCLUDES}
-      ${PROJECT_BINARY_DIR}/../${KWSYS_NAMESPACE}/${c}.hxx)
+
+  # Create an install target for the header wrapper.
+  IF(KWSYS_HEADER_INSTALL_DIR)
+    INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/stl
+      FILES ${KWSYS_HEADER_DIR}/stl/${header})
+  ENDIF(KWSYS_HEADER_INSTALL_DIR)
+ENDFOREACH(header)
+
+#-----------------------------------------------------------------------------
+# Create streams header wrappers to give standard names by which they
+# may be included.
+FOREACH(header iostream fstream sstream iosfwd)
+  # Configure the header wrapper.
+  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_ios_${header}.h.in
+                 ${KWSYS_HEADER_DIR}/ios/${header}
+                 @ONLY IMMEDIATE)
+
+  # Create an install target for the header wrapper.
+  IF(KWSYS_HEADER_INSTALL_DIR)
+    INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/ios
+      FILES ${KWSYS_HEADER_DIR}/ios/${header})
+  ENDIF(KWSYS_HEADER_INSTALL_DIR)
+ENDFOREACH(header)
+
+#-----------------------------------------------------------------------------
+# Build a list of classes and headers we need to implement the
+# selected components.  Initialize with required components.
+SET(KWSYS_CLASSES)
+SET(KWSYS_H_FILES Configure SharedForward)
+SET(KWSYS_HXX_FILES Configure)
+
+# Enforce component dependencies.
+IF(KWSYS_USE_SystemTools)
+  SET(KWSYS_USE_Directory 1)
+ENDIF(KWSYS_USE_SystemTools)
+
+# Add selected C++ classes.
+FOREACH(c Directory RegularExpression SystemTools CommandLineArguments)
+  IF(KWSYS_USE_${c})
+    SET(KWSYS_CLASSES ${KWSYS_CLASSES} ${c})
+  ENDIF(KWSYS_USE_${c})
 ENDFOREACH(c)
 
-FOREACH(h ${HEADERS})
-  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${h}.hxx.in
-                 ${PROJECT_BINARY_DIR}/../${KWSYS_NAMESPACE}/${h}.hxx
+IF(KWSYS_USE_CommandLineArguments)
+  IF(NOT ParaView_SOURCE_DIR)
+    IF(NOT CMake_SOURCE_DIR)
+      IF(NOT KWSYS_STANDALONE)
+        MESSAGE("Command Line Arguments is experimental code for now")
+      ENDIF(NOT KWSYS_STANDALONE)
+    ENDIF(NOT CMake_SOURCE_DIR)
+  ENDIF(NOT ParaView_SOURCE_DIR)
+ENDIF(KWSYS_USE_CommandLineArguments)
+
+# Add selected C components.
+FOREACH(c Process Base64)
+  IF(KWSYS_USE_${c})
+    SET(KWSYS_H_FILES ${KWSYS_H_FILES} ${c})
+  ENDIF(KWSYS_USE_${c})
+ENDFOREACH(c)
+
+#-----------------------------------------------------------------------------
+# Build a list of sources for the library based on components that are
+# included.
+SET(KWSYS_C_SRCS)
+SET(KWSYS_CXX_SRCS)
+
+# Add the proper sources for this platform's Process implementation.
+IF(KWSYS_USE_Process)
+  IF(NOT UNIX)
+    # Use the Windows implementation.  We need the encoded forwarding executable.
+    SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c
+      ${PROJECT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c)
+    SET_SOURCE_FILES_PROPERTIES(
+      ${PROJECT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
+      PROPERTIES GENERATED 1)
+  ELSE(NOT UNIX)
+    # Use the UNIX implementation.
+    SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c)
+  ENDIF(NOT UNIX)
+ENDIF(KWSYS_USE_Process)
+
+# Add sources for Base64 encoding.
+IF(KWSYS_USE_Base64)
+  SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} Base64.c)
+ENDIF(KWSYS_USE_Base64)
+
+# Configure headers of C++ classes and construct the list of sources.
+FOREACH(c ${KWSYS_CLASSES})
+  # Add this source to the list of source files for the library.
+  SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${c}.cxx)
+
+  # Configure the header for this class.
+  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${c}.hxx.in ${KWSYS_HEADER_DIR}/${c}.hxx
                  @ONLY IMMEDIATE)
-  SET(KWSYS_INCLUDES ${KWSYS_INCLUDES}
-      ${PROJECT_BINARY_DIR}/../${KWSYS_NAMESPACE}/${h}.hxx)
+
+  # Create an install target for the header.
+  IF(KWSYS_HEADER_INSTALL_DIR)
+    INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}
+                  FILES  ${KWSYS_HEADER_DIR}/${c}.hxx)
+  ENDIF(KWSYS_HEADER_INSTALL_DIR)
+ENDFOREACH(c)
+
+# Configure C headers.
+FOREACH(h ${KWSYS_H_FILES})
+  # Configure the header into the given directory.
+  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h
+                 @ONLY IMMEDIATE)
+
+  # Create an install target for the header.
+  IF(KWSYS_HEADER_INSTALL_DIR)
+    INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}
+                  FILES  ${KWSYS_HEADER_DIR}/${h}.h)
+  ENDIF(KWSYS_HEADER_INSTALL_DIR)
 ENDFOREACH(h)
 
-ADD_LIBRARY(${KWSYS_NAMESPACE} ${SRCS})
+# Configure other C++ headers.
+FOREACH(h ${KWSYS_HXX_FILES})
+  # Configure the header into the given directory.
+  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx
+                 @ONLY IMMEDIATE)
 
+  # Create an install target for the header.
+  IF(KWSYS_HEADER_INSTALL_DIR)
+    INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}
+                  FILES  ${KWSYS_HEADER_DIR}/${h}.hxx)
+  ENDIF(KWSYS_HEADER_INSTALL_DIR)
+ENDFOREACH(h)
+
+#-----------------------------------------------------------------------------
+# Add the library with the configured name and list of sources.
+IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
+  ADD_LIBRARY(${KWSYS_NAMESPACE} ${KWSYS_LIBRARY_TYPE}
+    ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
+
+  # Create an install target for the library.
+  IF(KWSYS_LIBRARY_INSTALL_DIR)
+    INSTALL_TARGETS(${KWSYS_LIBRARY_INSTALL_DIR} ${KWSYS_NAMESPACE})
+  ENDIF(KWSYS_LIBRARY_INSTALL_DIR)
+ENDIF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
+
+# Add a C-only library if requested.
+IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
+  ADD_LIBRARY(${KWSYS_NAMESPACE}_c ${KWSYS_LIBRARY_TYPE} ${KWSYS_C_SRCS})
+
+  # Create an install target for the library.
+  IF(KWSYS_LIBRARY_INSTALL_DIR)
+    INSTALL_TARGETS(${KWSYS_LIBRARY_INSTALL_DIR} ${KWSYS_NAMESPACE}_c)
+  ENDIF(KWSYS_LIBRARY_INSTALL_DIR)
+ENDIF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
+
+# For building kwsys itself, we use a macro defined on the command
+# line to configure the namespace in the C and C++ source files.
 ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}")
-INCLUDE_DIRECTORIES(BEFORE ${PROJECT_BINARY_DIR}/../${KWSYS_NAMESPACE})
 
-IF(KWSYS_LIBRARY_INSTALL_DIR)
-  INSTALL_TARGETS(${KWSYS_LIBRARY_INSTALL_DIR} ${KWSYS_NAMESPACE})
-ENDIF(KWSYS_LIBRARY_INSTALL_DIR)
+#-----------------------------------------------------------------------------
+# Process execution on windows needs to build a forwarding executable
+# that works around a Win9x bug.  We encode the executable into a C
+# file and build it into the library.  Win9x platforms reproduce the
+# executable into a temporary directory when it is needed.
+IF(KWSYS_USE_Process)
+  IF(NOT UNIX)
+    # Build the forwarding executable itself and a program that will
+    # encode it into a C file.
+    ADD_EXECUTABLE(${KWSYS_NAMESPACE}ProcessFwd9x ProcessFwd9x.c)
+    ADD_EXECUTABLE(${KWSYS_NAMESPACE}EncodeExecutable EncodeExecutable.c)
 
-IF(KWSYS_INCLUDE_INSTALL_DIR)
-  INSTALL_FILES(${KWSYS_INCLUDE_INSTALL_DIR}/${KWSYS_NAMESPACE}
-                FILES ${KWSYS_INCLUDES})
-ENDIF(KWSYS_INCLUDE_INSTALL_DIR)
+    # Construct the location of the executable to be encoded.
+    SET(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
+    IF(EXECUTABLE_OUTPUT_PATH)
+      SET(BIN_DIR ${EXECUTABLE_OUTPUT_PATH})
+    ENDIF(EXECUTABLE_OUTPUT_PATH)
 
-IF(KWSYS_DEFAULTS)
-  INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/..)
+    SET(CFG_INTDIR "/${CMAKE_CFG_INTDIR}")
+    IF(CMAKE_BUILD_TOOL MATCHES "make")
+      SET(CFG_INTDIR "")
+    ENDIF(CMAKE_BUILD_TOOL MATCHES "make")
+
+    # Take advantage of a better custom command syntax if possible.
+    SET(CMD ${BIN_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}EncodeExecutable.exe)
+    SET(FWD ${BIN_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}ProcessFwd9x.exe)
+    IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6)
+      ADD_CUSTOM_COMMAND(
+        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
+        COMMAND ${CMD}
+        ARGS ${FWD} ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
+             ${KWSYS_NAMESPACE} ProcessFwd9x
+        DEPENDS ${CMD} ${FWD})
+    ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6)
+      ADD_CUSTOM_COMMAND(
+        TARGET ${KWSYS_NAMESPACE}
+        SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/ProcessFwd9x.c
+        COMMAND ${CMD}
+        ARGS ${FWD} ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
+             ${KWSYS_NAMESPACE} ProcessFwd9x
+        OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
+        DEPENDS ${CMD} ${FWD})
+    ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6)
+
+    # Make sure build occurs in proper order.
+    ADD_DEPENDENCIES(${KWSYS_NAMESPACE} ${KWSYS_NAMESPACE}ProcessFwd9x
+                     ${KWSYS_NAMESPACE}EncodeExecutable)
+  ENDIF(NOT UNIX)
+ENDIF(KWSYS_USE_Process)
+
+#-----------------------------------------------------------------------------
+# Setup testing if not being built as part of another project.
+IF(KWSYS_STANDALONE)
+  ADD_EXECUTABLE(testIOS testIOS.cxx)
+  ADD_EXECUTABLE(testProcess testProcess.c)
   ADD_EXECUTABLE(test1 test1.cxx)
+  ADD_EXECUTABLE(testCommandLineArguments testCommandLineArguments.cxx)
+  TARGET_LINK_LIBRARIES(testIOS ${KWSYS_NAMESPACE})
+  TARGET_LINK_LIBRARIES(testProcess ${KWSYS_NAMESPACE}_c)
   TARGET_LINK_LIBRARIES(test1 ${KWSYS_NAMESPACE})
-ENDIF(KWSYS_DEFAULTS)
+  TARGET_LINK_LIBRARIES(testCommandLineArguments ${KWSYS_NAMESPACE})
+
+  SET(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+  IF(EXECUTABLE_OUTPUT_PATH)
+    SET(EXEC_DIR "${EXECUTABLE_OUTPUT_PATH}")
+  ENDIF(EXECUTABLE_OUTPUT_PATH)
+
+  IF(BUILD_TESTING)
+    ADD_TEST(testProcess-1 ${EXEC_DIR}/testProcess 1)
+    ADD_TEST(testProcess-2 ${EXEC_DIR}/testProcess 2)
+    ADD_TEST(testProcess-3 ${EXEC_DIR}/testProcess 3)
+    ADD_TEST(testProcess-4 ${EXEC_DIR}/testProcess 4)
+    ADD_TEST(testProcess-5 ${EXEC_DIR}/testProcess 5)
+    ADD_TEST(testProcess-6 ${EXEC_DIR}/testProcess 6)
+  ENDIF(BUILD_TESTING)
+ENDIF(KWSYS_STANDALONE)

File GCC_XML/KWSys/SharedForward.h.in

View file
  • Ignore whitespace
+/*=========================================================================
+
+  Program:   KWSys - Kitware System Library
+  Module:    $RCSfile$
+
+  Copyright (c) Kitware, Inc., Insight Consortium.  All rights reserved.
+  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef @KWSYS_NAMESPACE@_SharedForward_h
+#define @KWSYS_NAMESPACE@_SharedForward_h
+
+/*
+  This header is used to create a forwarding executable sets up the
+  shared library search path and replaces itself with a real
+  executable.  This is useful when creating installations on UNIX with
+  shared libraries that will run from any install directory.  Typical
+  usage:
+
+  #define @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD "/path/to/foo-build/bin"
+  #define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD "."
+  #define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL "../lib/foo-1.2"
+  #define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD "foo-real"
+  #define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL "../lib/foo-1.2/foo-real"
+  #include <@KWSYS_NAMESPACE@/SharedForward.h>
+  int main(int argc, char** argv)
+  {
+    return @KWSYS_NAMESPACE@_shared_forward_to_real(argc, argv);
+  }
+ */
+
+/*--------------------------------------------------------------------------*/
+/* Configuration for this executable.  Specify search and executable
+   paths relative to the forwarding executable location or as full
+   paths.  Include no trailing slash.  */
+
+/* This is not useful on Windows.  */
+#if defined(_WIN32)
+# error "@KWSYS_NAMESPACE@/SharedForward.h is useless on Windows."
+#endif
+
+/* Full path to the directory in which this executable is built.  Do
+   not include a trailing slash.  */
+#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD)
+# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD"
+#endif
+#if !defined(KWSYS_SHARED_FORWARD_DIR_BUILD)
+# define KWSYS_SHARED_FORWARD_DIR_BUILD @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD
+#endif
+
+/* Library search path for build tree.  */
+#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD)
+# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD"
+#endif
+#if !defined(KWSYS_SHARED_FORWARD_PATH_BUILD)
+# define KWSYS_SHARED_FORWARD_PATH_BUILD @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD
+#endif
+
+/* Library search path for install tree.  */
+#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL)
+# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL"
+#endif
+#if !defined(KWSYS_SHARED_FORWARD_PATH_INSTALL)
+# define KWSYS_SHARED_FORWARD_PATH_INSTALL @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL
+#endif
+
+/* The real executable to which to forward in the build tree.  */
+#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD)
+# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD"
+#endif
+#if !defined(KWSYS_SHARED_FORWARD_EXE_BUILD)
+# define KWSYS_SHARED_FORWARD_EXE_BUILD @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD
+#endif
+
+/* The real executable to which to forward in the install tree.  */
+#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL)
+# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL"
+#endif
+#if !defined(KWSYS_SHARED_FORWARD_EXE_INSTALL)
+# define KWSYS_SHARED_FORWARD_EXE_INSTALL @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL
+#endif
+
+/* Create command line option to print environment setting and exit.  */
+#if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_PRINT)
+# if !defined(KWSYS_SHARED_FORWARD_OPTION_PRINT)
+#  define KWSYS_SHARED_FORWARD_OPTION_PRINT @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_PRINT
+# endif
+#else
+# undef KWSYS_SHARED_FORWARD_OPTION_PRINT
+#endif
+
+/* Create command line option to run ldd or equivalent.  */
+#if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_LDD)
+# if !defined(KWSYS_SHARED_FORWARD_OPTION_LDD)
+#  define KWSYS_SHARED_FORWARD_OPTION_LDD @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_LDD
+# endif
+#else
+# undef KWSYS_SHARED_FORWARD_OPTION_LDD
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* Include needed system headers.  */
+
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+
+/*--------------------------------------------------------------------------*/
+/* Configuration for this platform.  */
+
+/* The path separator for this platform.  */
+#define KWSYS_SHARED_FORWARD_PATH_SEP ':'
+static const char kwsys_shared_forward_path_sep[2] = {KWSYS_SHARED_FORWARD_PATH_SEP, 0};
+
+/* The maximum length of a file name.  */
+#if defined(PATH_MAX)
+# define KWSYS_SHARED_FORWARD_MAXPATH PATH_MAX
+#elif defined(MAXPATHLEN)
+# define KWSYS_SHARED_FORWARD_MAXPATH MAXPATHLEN
+#else
+# define KWSYS_SHARED_FORWARD_MAXPATH 16384
+#endif
+
+/* Select the environment variable holding the shared library runtime
+   search path for this platform and build configuration.  Also select
+   ldd command equivalent.  */
+
+/* Linux */
+#if defined(__linux)
+# define KWSYS_SHARED_FORWARD_LDD "ldd"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+#endif
+
+/* OSX */
+#if defined(__APPLE__)
+# define KWSYS_SHARED_FORWARD_LDD "otool", "-L"
+# define KWSYS_SHARED_FORWARD_LDD_N 2
+# define KWSYS_SHARED_FORWARD_LDPATH "DYLD_LIBRARY_PATH"
+#endif
+
+/* AIX */
+#if defined(_AIX)
+# define KWSYS_SHARED_FORWARD_LDD "dump", "-H"
+# define KWSYS_SHARED_FORWARD_LDD_N 2
+# define KWSYS_SHARED_FORWARD_LDPATH "LIBPATH"
+#endif
+
+/* SUN */
+#if defined(__sparc)
+# define KWSYS_SHARED_FORWARD_LDD "ldd"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# include <sys/isa_defs.h>
+# if defined(_ILP32)
+#  define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+# elif defined(_LP64)
+#  define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH_64"
+# endif
+#endif
+
+/* HP-UX */
+#if defined(__hpux)
+# define KWSYS_SHARED_FORWARD_LDD "chatr"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# if defined(__LP64__)
+#  define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+# else
+#  define KWSYS_SHARED_FORWARD_LDPATH "SHLIB_PATH"
+# endif
+#endif
+
+/* SGI MIPS */
+#if defined(__sgi) && defined(_MIPS_SIM)
+# define KWSYS_SHARED_FORWARD_LDD "ldd"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# if _MIPS_SIM == _ABIO32
+#  define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+# elif _MIPS_SIM == _ABIN32
+#  define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARYN32_PATH"
+# elif _MIPS_SIM == _ABI64
+#  define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY64_PATH"
+# endif
+#endif
+
+/* Guess on this unknown system.  */
+#if !defined(KWSYS_SHARED_FORWARD_LDPATH)
+# define KWSYS_SHARED_FORWARD_LDD "ldd"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* Function to get the directory containing the given file or directory.  */
+static void kwsys_shared_forward_dirname(const char* begin, char* result)
+{
+  /* Find the location of the last slash.  */
+  int last_slash_index = -1;
+  const char* end = begin + strlen(begin);
+  for(;begin <= end && last_slash_index < 0; --end)
+    {
+    if(*end == '/')
+      {
+      last_slash_index = end-begin;
+      }
+    }
+
+  /* Handle each case of the index of the last slash.  */
+  if(last_slash_index < 0)
+    {
+    /* No slashes.  */
+    strcpy(result, ".");
+    }
+  else if(last_slash_index == 0)
+    {
+    /* Only one leading slash.  */
+    strcpy(result, "/");
+    }
+  else
+    {
+    /* A non-leading slash.  */
+    strncpy(result, begin, last_slash_index);
+    result[last_slash_index] = 0;
+    }
+}
+
+/*--------------------------------------------------------------------------*/
+/* Function to locate the executable currently running.  */
+static int kwsys_shared_forward_self_path(const char* argv0, char* result)
+{
+  /* Check whether argv0 has a slash.  */
+  int has_slash = 0;
+  const char* p = argv0;
+  for(;*p && !has_slash; ++p)
+    {
+    if(*p == '/')
+      {
+      has_slash = 1;
+      }
+    }
+
+  if(has_slash)
+    {
+    /* There is a slash.  Use the dirname of the given location.  */
+    kwsys_shared_forward_dirname(argv0, result);
+    return 1;
+    }
+  else
+    {
+    /* There is no slash.  Search the PATH for the executable.  */
+    const char* path = getenv("PATH");
+    const char* begin = path;
+    const char* end = begin + (begin?strlen(begin):0);
+    const char* first = begin;
+    while(first != end)
+      {
+      /* Store the end of this path entry.  */
+      const char* last;
+
+      /* Skip all path separators.  */
+      for(;*first && *first == KWSYS_SHARED_FORWARD_PATH_SEP; ++first);
+
+      /* Find the next separator.  */
+      for(last = first;*last && *last != KWSYS_SHARED_FORWARD_PATH_SEP; ++last);
+
+      /* If we got a non-empty directory, look for the executable there.  */
+      if(first < last)
+        {
+        /* Determine the length without trailing slash.  */
+        int length = last-first;
+        if(*(last-1) == '/')
+          {
+          --length;
+          }
+
+        /* Construct the name of the executable in this location.  */
+        strncpy(result, first, length);
+        result[length] = '/';
+        strcpy(result+(length)+1, argv0);
+
+        /* Check if it exists.  */
+        if(access(result, X_OK) == 0)
+          {
+          /* Found it.  */
+          result[length] = 0;
+          return 1;
+          }
+        }
+
+      /* Move to the next directory in the path.  */
+      first = last;
+      }
+    }
+
+  /* We could not find the executable.  */
+  return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+/* Function to convert a specified path to a full path.  If it is not
+   already full, it is taken relative to the self path.  */
+static int kwsys_shared_forward_fullpath(const char* self_path,
+                                         const char* in_path,
+                                         char* result,
+                                         const char* desc)
+{
+  /* Check the specified path type.  */
+  if(in_path[0] == '/')
+    {
+    /* Already a full path.  */
+    strcpy(result, in_path);
+    }
+  else
+    {
+    /* Relative to self path.  */
+    char temp_path[KWSYS_SHARED_FORWARD_MAXPATH];
+    strcpy(temp_path, self_path);
+    strcat(temp_path, "/");
+    strcat(temp_path, in_path);
+    if(!realpath(temp_path, result))
+      {
+      if(desc)
+        {
+        fprintf(stderr, "Error converting %s \"%s\" to real path: %s\n",
+                desc, temp_path, strerror(errno));
+        }
+      return 0;
+      }
+    }
+  return 1;
+}
+
+/*--------------------------------------------------------------------------*/
+/* Function to compute the library search path and executable name
+   based on the self path.  */
+static int kwsys_shared_forward_get_settings(const char* self_path,
+                                             char* ldpath, char* exe)
+{
+  /* Possible search paths.  */
+  static const char* search_path_build[] = {KWSYS_SHARED_FORWARD_PATH_BUILD, 0};
+  static const char* search_path_install[] = {KWSYS_SHARED_FORWARD_PATH_INSTALL, 0};
+
+  /* Chosen paths.  */
+  const char** search_path;
+  const char* exe_path;
+
+  /* Get the real name of the build and self paths.  */
+  char build_path[KWSYS_SHARED_FORWARD_MAXPATH];
+  char self_path_real[KWSYS_SHARED_FORWARD_MAXPATH];
+  if(!realpath(self_path, self_path_real))
+    {
+    fprintf(stderr, "Error converting self path \"%s\" to real path: %s\n",
+            self_path, strerror(errno));
+    return 0;
+    }
+
+  /* Check whether we are running in the build tree or an install tree.  */
+  if(realpath(KWSYS_SHARED_FORWARD_DIR_BUILD, build_path) &&
+     strcmp(self_path_real, build_path) == 0)
+    {
+    /* Running in build tree.  Use the build path and exe.  */
+    search_path = search_path_build;
+    exe_path = KWSYS_SHARED_FORWARD_EXE_BUILD;
+    }
+  else
+    {
+    /* Running in install tree.  Use the install path and exe.  */
+    search_path = search_path_install;
+    exe_path = KWSYS_SHARED_FORWARD_EXE_INSTALL;
+    }
+
+  /* Construct the runtime search path.  */
+  {
+  const char** dir;
+  for(dir = search_path; *dir; ++dir)
+    {
+    /* Add seperator between path components.  */
+    if(dir != search_path)
+      {
+      strcat(ldpath, kwsys_shared_forward_path_sep);
+      }
+
+    /* Add this path component.  */
+    if(!kwsys_shared_forward_fullpath(self_path, *dir,
+                                      ldpath+strlen(ldpath),
+                                      "runtime path entry"))
+      {
+      return 0;
+      }
+    }
+  }
+
+  /* Construct the executable location.  */
+  if(!kwsys_shared_forward_fullpath(self_path, exe_path, exe,
+                                    "executable file"))
+    {
+    return 0;
+    }
+  return 1;
+}
+
+/*--------------------------------------------------------------------------*/
+/* Function to print why execution of a command line failed.  */
+static void kwsys_shared_forward_print_failure(char** argv, const char* msg)
+{
+  char** arg = argv;
+  fprintf(stderr, "Error running");
+  for(; *arg; ++arg)
+    {
+    fprintf(stderr, " \"%s\"", *arg);
+    }
+  fprintf(stderr, ": %s\n", msg);
+}
+
+/* Static storage space to store the updated environment variable.  */
+static char kwsys_shared_forward_ldpath[KWSYS_SHARED_FORWARD_MAXPATH*16] = KWSYS_SHARED_FORWARD_LDPATH "=";
+
+/*--------------------------------------------------------------------------*/
+/* Main driver function to be called from main.  */
+static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv)
+{
+  /* Get the directory containing this executable.  */
+  char self_path[KWSYS_SHARED_FORWARD_MAXPATH];
+  if(kwsys_shared_forward_self_path(argv[0], self_path))
+    {
+    /* Found this executable.  Use it to get the library directory.  */
+    char exe[KWSYS_SHARED_FORWARD_MAXPATH];
+    if(kwsys_shared_forward_get_settings(self_path,
+                                         kwsys_shared_forward_ldpath, exe))
+      {
+      /* Append the old runtime search path.  */
+      const char* old_ldpath = getenv(KWSYS_SHARED_FORWARD_LDPATH);
+      if(old_ldpath)
+        {
+        strcat(kwsys_shared_forward_ldpath, kwsys_shared_forward_path_sep);
+        strcat(kwsys_shared_forward_ldpath, old_ldpath);
+        }
+
+      /* Store the environment variable.  */
+      putenv(kwsys_shared_forward_ldpath);
+
+#if defined(KWSYS_SHARED_FORWARD_OPTION_PRINT)
+      /* Look for the print command line option.  */
+      if(argc > 1 && strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_PRINT) == 0)
+        {
+        fprintf(stdout, "%s\n", kwsys_shared_forward_ldpath);
+        fprintf(stdout, "%s\n", exe);
+        return 0;
+        }
+#endif
+
+#if defined(KWSYS_SHARED_FORWARD_OPTION_LDD)
+      /* Look for the ldd command line option.  */
+      if(argc > 1 && strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_LDD) == 0)
+        {
+        char* ldd_argv[] = {KWSYS_SHARED_FORWARD_LDD, 0, 0};
+        ldd_argv[KWSYS_SHARED_FORWARD_LDD_N] = exe;
+        execvp(ldd_argv[0], ldd_argv);
+
+        /* Report why execution failed.  */
+        kwsys_shared_forward_print_failure(ldd_argv, strerror(errno));
+        return 1;
+        }
+#endif
+
+      /* Replace this process with the real executable.  */
+      argv[0] = exe;
+      execv(argv[0], argv);
+
+      /* Report why execution failed.  */
+      kwsys_shared_forward_print_failure(argv, strerror(errno));
+      }
+    else
+      {
+      /* Could not convert self path to the library directory.  */
+      }
+    }
+  else
+    {
+    /* Could not find this executable.  */
+    fprintf(stderr, "Error locating executable \"%s\".", argv[0]);
+    }
+
+  /* Avoid unused argument warning.  */
+  (void)argc;
+
+  /* Exit with failure.  */
+  return 1;
+}
+
+#else
+# error "@KWSYS_NAMESPACE@/SharedForward.h should be included only once."
+#endif