Commit 2b77f88a authored by Ben Boeckel's avatar Ben Boeckel

superbuild: port over to the common-superbuild

parent 83dbfbe9
*.patch whitespace=-blank-at-eol -text
# We hardcode the version numbers since we cannot determine versions during
# configure stage.
set (cmb_version_major 4)
set (cmb_version_minor 0)
set (cmb_version_patch 0)
set (cmb_version_suffix)
set (cmb_version "${cmb_version_major}.${cmb_version_minor}")
cmake_minimum_required(VERSION 2.8.11)
project("cpack-@name@" NONE)
set(CMAKE_MODULE_PATH "@CMAKE_MODULE_PATH@")
set(CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
set(CMBSuperBuild_SOURCE_DIR "@CMBSuperBuild_SOURCE_DIR@")
set(install_location "@install_location@")
set(USE_SYSTEM_mpi "@USE_SYSTEM_mpi@")
set(USE_SYSTEM_qt "@USE_SYSTEM_qt@")
set(USE_SYSTEM_python "@USE_SYSTEM_python@")
set(matplotlib_ENABLED "@matplotlib_ENABLED@")
set(mpi_ENABLED "@mpi_ENABLED@")
set(cmbworkflows_ENABLED "@cmbworkflows_ENABLED@")
set(python_ENABLED "@python_ENABLED@")
set(shiboken_ENABLED "@shiboken_ENABLED@")
set(qt_ENABLED "@qt_ENABLED@")
include("@name@.bundle")
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "bin")
include(InstallRequiredSystemLibraries)
include(CPack)
execute_process(
COMMAND "${CMAKE_COMMAND}"
-G "${cmake_generator}"
"${working_directory}"
RESULT_VARIABLE res
WORKING_DIRECTORY "${working_directory}")
if (res)
message(FATAL_ERROR "CMake failed with exit code ${res}")
endif ()
execute_process(
COMMAND "${CMAKE_CPACK_COMMAND}"
-V
-G "${cpack_generator}"
-B "${output_directory}"
RESULT_VARIABLE res
WORKING_DIRECTORY "${working_directory}")
if (res)
message(FATAL_ERROR "CPack failed with exit code ${res}")
endif ()
# We hardcode the version numbers since we cannot determine versions during
# configure stage.
set (pv_version_major 5)
set (pv_version_minor 0)
set (pv_version_patch 0)
set (pv_version_suffix -RC1)
set (pv_version "${pv_version_major}.${pv_version_minor}")
if (pv_version_suffix)
set (pv_version_long "${pv_version}.${pv_version_patch}-${pv_version_suffix}")
else()
set (pv_version_long "${pv_version}.${pv_version_patch}")
endif()
......@@ -21,12 +21,10 @@ function (superbuild_find_projects var)
bzip2
cmb
cmbworkflows
fontconfig
freetype
gdal
hdf5
kml
libxml2
moab
netcdf
paraview
......@@ -41,6 +39,12 @@ function (superbuild_find_projects var)
zeromq
zlib)
if (NOT WIN32)
list(APPEND projects
fontconfig
libxml2)
endif ()
option(USE_NONFREE_COMPONENTS "Enable the non-free parts of the superbuild" OFF)
mark_as_advanced(USE_NONFREE_COMPONENTS)
if (USE_NONFREE_COMPONENTS)
......@@ -67,12 +71,12 @@ function (superbuild_add_packaging)
endif ()
foreach (generator IN LISTS generators)
superbuild_add_extra_package_test(modelbuilder "${generator}"
LABELS "CMB"
TIMEOUT 1200)
superbuild_add_extra_package_test(hydrology "${generator}"
LABELS "CMB"
TIMEOUT 1200)
#superbuild_add_extra_package_test(modelbuilder "${generator}"
# LABELS "CMB"
# TIMEOUT 1200)
#superbuild_add_extra_package_test(hydrology "${generator}"
# LABELS "CMB"
# TIMEOUT 1200)
endforeach ()
endfunction ()
......
foreach(program IN LISTS cmb_programs_to_install)
install(CODE
"
set(PV_PYTHON_LIB_INSTALL_PREFIX
\"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}/${program}.app/Contents/Python\")
"
COMPONENT superbuild)
# install paraview python module into the application bundle.
install(CODE " file(INSTALL DESTINATION \"\${PV_PYTHON_LIB_INSTALL_PREFIX}\"
USE_SOURCE_PERMISSIONS TYPE DIRECTORY FILES
\"${install_location}/Applications/paraview.app/Contents/Python/paraview\")
"
COMPONENT superbuild)
install(CODE " file(GLOB vtk-so \"${install_location}/Applications/paraview.app/Contents/Libraries/vtk*Python.so\")
file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}/${program}.app/Contents/Libraries\"
USE_SOURCE_PERMISSIONS TYPE DIRECTORY FILES
\${vtk-so})
"
COMPONENT superbuild)
install(CODE " file(GLOB vtk-pydll \"${install_location}/Applications/paraview.app/Contents/Libraries/libvtk*pv*.dylib\")
file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}/${program}.app/Contents/Libraries\"
USE_SOURCE_PERMISSIONS TYPE DIRECTORY FILES
\${vtk-pydll})
"
COMPONENT superbuild)
#list all the smtk session plugins so that we make sure to install any
#library that they reference. This won't actually install those smtk session
#plugins, that is handled by custom install rules in cmb.cmake
install(CODE "
file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}\" USE_SOURCE_PERMISSIONS TYPE DIRECTORY FILES
\"${install_location}/Applications/${program}.app\")
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}/${program}.app/Contents/Resources/qt.conf\")
execute_process(
COMMAND ${CMAKE_CURRENT_LIST_DIR}/fixup_bundle.py
\"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}/${program}.app\"
\"${install_location}/lib\"
\"${install_location}/plugins\"
\"${install_location}/lib/libsmtkDiscreteSessionPlugin.dylib\"
\"${install_location}/lib/libsmtkExodusSessionPlugin.dylib\"
\"${install_location}/lib/libsmtkRemusMeshOperatorPlugin.dylib\"
\"${install_location}/lib/libsmtkCGMSessionPlugin.dylib\")
"
COMPONENT superbuild)
if (numpy_ENABLED)
# install numpy module into the application bundle.
install(CODE "
# install numpy
file(GLOB numpy-root \"${install_location}/lib/python*/site-packages/numpy\")
file(INSTALL DESTINATION \"\${PV_PYTHON_LIB_INSTALL_PREFIX}\"
USE_SOURCE_PERMISSIONS TYPE DIRECTORY FILES
\"\${numpy-root}\")
"
COMPONENT superbuild)
endif()
#-----------------------------------------------------------------------------
if (mpi_ENABLED AND NOT USE_SYSTEM_mpi)
# install MPI executables (the dylib are already installed by a previous rule).
install(CODE "
file(INSTALL
DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${program}.app/Contents/MacOS\"
USE_SOURCE_PERMISSIONS
FILES \"${install_location}/bin/hydra_pmi_proxy\")
file(INSTALL
DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${program}.app/Contents/MacOS\"
USE_SOURCE_PERMISSIONS
FILES \"${install_location}/bin/mpiexec.hydra\")
file(RENAME
\"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}/${program}.app/Contents/MacOS/mpiexec.hydra\"
\"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}/${program}.app/Contents/MacOS/mpiexec\")
# Fixup MPI bundled libraries
execute_process(
COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change
\"${install_location}/lib/libmpl.1.dylib\"
@executable_path/../Libraries/libmpl.1.dylib
\"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}/${program}.app/Contents/MacOS/mpiexec\"
)
execute_process(
COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change
\"${install_location}/lib/libmpl.1.dylib\"
@executable_path/../Libraries/libmpl.1.dylib
\"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}/${program}.app/Contents/MacOS/hydra_pmi_proxy\"
)
"
COMPONENT superbuild)
endif()
#-----------------------------------------------------------------------------
if (matplotlib_ENABLED)
# install matplotlib module into the application bundle.
install(CODE "
# install matplotlib
file(GLOB matplotlib-root \"${install_location}/lib/python*/site-packages/matplotlib\")
file(INSTALL
DESTINATION \"\${PV_PYTHON_LIB_INSTALL_PREFIX}\"
USE_SOURCE_PERMISSIONS
TYPE DIRECTORY
FILES \"\${matplotlib-root}\")
# install libpng (needed for matplotlib)
file(GLOB png-libs \"${install_location}/lib/libpng*dylib\")
foreach(png-lib \${png-libs})
file(INSTALL
DESTINATION
\"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}/${program}.app/Contents/Libraries\"
USE_SOURCE_PERMISSIONS
TYPE SHARED_LIBRARY
FILES \"\${png-lib}\")
endforeach()
# install libfreetype (needed for matplotlib)
file(GLOB freetype-libs \"${install_location}/lib/libfreetype*dylib\")
foreach(freetype-lib \${freetype-libs})
file(INSTALL
DESTINATION
\"\${CMAKE_INSTALL_PREFIX}/${Package_Folder}/${program}.app/Contents/Libraries\"
USE_SOURCE_PERMISSIONS
TYPE SHARED_LIBRARY
FILES \"\${freetype-lib}\")
endforeach()
# fixup matplotlib to find the bundled libraries.
execute_process(
COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change
libpng14.14.dylib
@executable_path/../Libraries/libpng14.14.dylib
\"\${PV_PYTHON_LIB_INSTALL_PREFIX}/matplotlib/_png.so\"
)
execute_process(
COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change
\"${install_location}/lib/libfreetype.6.dylib\"
@executable_path/../Libraries/libfreetype.6.dylib
\"\${PV_PYTHON_LIB_INSTALL_PREFIX}/matplotlib/ft2font.so\"
)
"
COMPONENT superbuild)
endif()
endforeach() #done building all the CMB App bundles
if (cmbworkflows_ENABLED)
install(
DIRECTORY "${install_location}/share/cmb/workflows/"
DESTINATION "Workflows/"
COMPONENT superbuild)
endif ()
include(hydrology.bundle.common)
set(Package_Folder "CMB-Hydro ${cmb_version_major}.${cmb_version_minor}.${cmb_version_patch}")
include(cmb.bundle.apple)
include(modelbuilder.bundle.common)
set(Package_Folder "ModelBuilder ${cmb_version_major}.${cmb_version_minor}.${cmb_version_patch}")
include(cmb.bundle.apple)
add_external_dummy_project(png)
add_external_project(shiboken
DEPENDS qt python
CMAKE_ARGS
-DDISABLE_DOCSTRINGS:BOOL=ON
)
set(smtk_libdir lib)
if (WIN32)
set(smtk_libdir bin)
endif ()
set(SMTK_PLUGIN_SUBDIR "${smtk_libdir}" CACHE INTERNAL "SMTK's plugin directory")
add_external_project_or_just_build_dependencies(smtk
DEPENDS boost qt shiboken paraview remus hdf5 zeroMQ
DEPENDS_OPTIONAL moab netcdf
CMAKE_ARGS
${extra_cmake_args}
-DBUILD_SHARED_LIBS:BOOL=ON
-DSMTK_ENABLE_QT_SUPPORT:BOOL=ON
-DSMTK_ENABLE_VTK_SUPPORT:BOOL=ON
-DSMTK_ENABLE_PARAVIEW_SUPPORT:BOOL=ON
-DSMTK_ENABLE_DISCRETE_SESSION:BOOL=ON
-DSMTK_ENABLE_EXODUS_SESSION:BOOL=ON
-DSMTK_ENABLE_REMOTE_SESSION:BOOL=ON
-DSMTK_ENABLE_REMUS_SUPPORT:BOOL=ON
# TODO: remove this variable since MOAB is always available.
-DSMTK_ENABLE_MOAB_DISCRETE_READER:BOOL=ON
-DSMTK_USE_SYSTEM_MOAB:BOOL=${moab_ENABLED}
-DMOAB_INCLUDE_DIR:PATH=<INSTALL_DIR>/include
# MOAB bits
-DENABLE_HDF5:BOOL=${hdf5_ENABLED}
-DParaView_DIR:PATH=${SuperBuild_BINARY_DIR}/paraview/src/paraview-build/
-DSMTK_ENABLE_PYTHON_WRAPPING:BOOL=${shiboken_ENABLED}
-DBOOST_INCLUDEDIR:PATH=<INSTALL_DIR>/include/boost
-DBOOST_LIBRARYDIR:PATH=<INSTALL_DIR>/lib
-DMACOSX_APP_INSTALL_PREFIX:PATH=<INSTALL_DIR>/Applications
-DSMTK_FIND_SHIBOKEN:STRING=
)
STRING(REGEX REPLACE ".*/libpython([0-9\\.]+)\\.dylib" "\\1" PYTHON_VERSION "${PYTHON_LIBRARY}" )
if(shiboken_ENABLED)
add_external_project_step(install_shiboken_python_plugin
COMMENT "smtk: fixing missing include files"
COMMAND ${CMAKE_COMMAND}
-DBUILD_SHARED_LIBS:BOOL=ON
-DINSTALL_DIR:PATH=<INSTALL_DIR>
-DSMTK_BIN_DIR:PATH=${install_location}
-DTMP_DIR:PATH=<TMP_DIR>
-DPYTHON_VERSION:STRING=${PYTHON_VERSION}
-P ${CMAKE_CURRENT_LIST_DIR}/install_smtk_python_plugin.cmake
DEPENDEES install)
endif()
# Consolidates platform independent stub for cmb.bundle.cmake files.
include(cmb_version)
include(paraview_version)
set(CPACK_PACKAGE_VENDOR "Kitware, Inc.")
set(CPACK_RESOURCE_FILE_LICENSE
"${CMBSuperBuild_SOURCE_DIR}/License.txt")
set(CPACK_PACKAGE_VERSION_MAJOR ${cmb_version_major})
set(CPACK_PACKAGE_VERSION_MINOR ${cmb_version_minor})
if (cmb_version_suffix)
set(CPACK_PACKAGE_VERSION_PATCH ${cmb_version_patch}-${cmb_version_suffix})
else()
set(CPACK_PACKAGE_VERSION_PATCH ${cmb_version_patch})
endif()
SET(CPACK_PACKAGE_INSTALL_DIRECTORY
"${cmb_package_name} ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${cmb_package_name}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
if(NOT DEFINED CPACK_SYSTEM_NAME)
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
endif()
if(${CPACK_SYSTEM_NAME} MATCHES Windows)
if(CMAKE_CL_64)
set(CPACK_SYSTEM_NAME win64)
else(CMAKE_CL_64)
set(CPACK_SYSTEM_NAME win32)
endif()
endif()
if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
endif()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"CMB Tools for Hydrologigal Simulations")
set(CPACK_PACKAGE_NAME "CMB")
set(cmb_package_name "CMB-Hydro")
include(cmb.bundle.common)
#set the programs we want to install
set(cmb_programs_to_install
#GeologyBuilder
SceneBuilder
ModelBuilder
MeshViewer
PointsBuilder
paraview
)
#sort the list so the package order is reasonable and deducible to the user
list(SORT cmb_programs_to_install)
# Don't import CPack yet, let the platform specific code get another chance at
# changing the variables.
include(GNUInstallDirs)
if (UNIX) #Apple should never happen
set (SHARED_LIBRARY_SUFFIX "so")
set (PYTHON_SITE "lib/python2.7/site-packages")
set (PYTHON_INSTALL "lib/paraview-${pv_version}/site-packages")
set (LIB_SHIBOKEN_PY "lib/libshiboken-python2.7.so.1.2")
if( NOT EXISTS ${SMTK_BIN_DIR}/${LIB_SHIBOKEN_PY} )
set (LIB_SHIBOKEN_PY "lib/libshiboken-python2.7-dbg.so.1.2")
if( NOT EXISTS ${SMTK_BIN_DIR}/${LIB_SHIBOKEN_PY} )
message( SEND_ERROR "could not create smtk python package. libshiboken is missing" )
return()
endif()
endif()
elseif (WIN32)
set (SHARED_LIBRARY_SUFFIX "pyd")
set (PYTHON_SITE "bin/Lib/site-packages")
set (PYTHON_INSTALL ${PYTHON_SITE})
set (LIB_SHIBOKEN_PY "bin/shiboken-python2.7.dll")
endif()
file(REMOVE_RECURSE "${TMP_DIR}/SMTKPlugin")
file(MAKE_DIRECTORY "${TMP_DIR}/SMTKPlugin")
set(plugin_install_dir ${SMTK_BIN_DIR}/${PYTHON_INSTALL}/smtk)
file(MAKE_DIRECTORY "${plugin_install_dir}")
if (UNIX)
set(PYTHON_COPY_SOURCE_LOC lib/python2.7/site-packages)
elseif (WIN32)
set(PYTHON_COPY_SOURCE_LOC bin/Lib/site-packages)
endif()
set(py_files_libs ${SMTK_BIN_DIR}/${PYTHON_SITE}/smtk/smtkCorePython.${SHARED_LIBRARY_SUFFIX}
${SMTK_BIN_DIR}/${LIB_SHIBOKEN_PY}
${SMTK_BIN_DIR}/${PYTHON_SITE}/shiboken.${SHARED_LIBRARY_SUFFIX}
${SMTK_BIN_DIR}/${PYTHON_COPY_SOURCE_LOC}/smtk/simple.py)
foreach(lib IN LISTS py_files_libs)
configure_file("${lib}" "${TMP_DIR}/SMTKPlugin" COPYONLY)
endforeach()
#okay the plugin is fixed up, now we need to install it into paraviews bundle
file(GLOB fixedUpLibs "${TMP_DIR}/SMTKPlugin/*")
foreach(lib IN LISTS fixedUpLibs)
configure_file("${lib}" "${plugin_install_dir}" COPYONLY)
endforeach()
# For linux, also copy smtk libs where standalone export app can find them
if (UNIX)
set(STANDALONE_EXPORT_DIR ${SMTK_BIN_DIR}/${PYTHON_SITE}/smtk)
file(MAKE_DIRECTORY "${STANDALONE_EXPORT_DIR}")
foreach(lib IN LISTS fixedUpLibs)
configure_file("${lib}" "${STANDALONE_EXPORT_DIR}" COPYONLY)
endforeach()
endif()
add_external_project(kml
# kml has problems with newer gcc compilers with not including unistd.h
PATCH_COMMAND ${CMAKE_COMMAND} -E copy_if_different
${SuperBuild_PROJECTS_DIR}/patches/kml.src.kml.base.file_posix.cc
<SOURCE_DIR>/src/kml/base/file_posix.cc
CMAKE_ARGS
-DBUILD_SHARED_LIBS=OFF
)
if (WIN32)
# Patch for MSVC2010+
add_external_project_step(kml-patch-util-header
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${SuperBuild_PROJECTS_DIR}/patches/kml.src.kml.base.util.h
<SOURCE_DIR>/src/kml/base/util.h
DEPENDEES configure
DEPENDERS build)
endif ()
#reset back the c/cppflag to the pre netcdf values.
#this works since the only project that depends on netcdf is moab
if (build-projects)
set (cppflags "${pre_netcdf_cpp_flags}")
set (cflags "${pre_netcdf_c_flags}")
endif()
#set(cgm_find_flags )
#if(cgm_ENABLED)
# set(cgm_find_flags "-DCGM_CFG:PATH=${SuperBuild_BINARY_DIR}/cgm/src/cgm/cgm.make")
#endif()
add_external_project(moab
DEPENDS hdf5 netcdf
# DEPENDS_OPTIONAL cgm
CMAKE_ARGS
-DBUILD_SHARED_LIBS:BOOL=OFF
-DMOAB_USE_SZIP:BOOL=ON
-DMOAB_USE_CGM:BOOL=OFF
-DMOAB_USE_CGNS:BOOL=OFF
-DMOAB_USE_MPI:BOOL=OFF
-DMOAB_USE_HDF:BOOL=ON
-DENABLE_HDF5:BOOL=ON #also required to get hdf5 support enabled
-DMOAB_USE_NETCDF:BOOL=ON
-DMOAB_ENABLE_TESTING:BOOL=ON #build can't handle this being disabled
${cgm_find_flags}
)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"CMB ModelBuilder Application")
set(CPACK_PACKAGE_NAME "CMB")
set(cmb_package_name "ModelBuilder")
include(cmb.bundle.common)
#set the programs we want to install
set(cmb_programs_to_install
ModelBuilder
)
#sort the list so the package order is reasonable and deducible to the user
list(SORT cmb_programs_to_install)
// Copyright 2008, Google 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:
//
// 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 Google 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 AUTHOR ``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 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.
// The file contains the implementation of the File methods specific to
// POSIX platforms.
#include "kml/base/file.h"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
// posix compile fix:
#include <unistd.h>
namespace kmlbase {
// Internal to the POSIX File class.
static bool StatFile(const char* path, struct stat* stat_data) {
struct stat tmp;
if (stat(path, &tmp) !=0) {
return false;
}
*stat_data = tmp;
return true;
}
bool File::Exists(const string& full_path) {
struct stat stat_data;
if (!StatFile(full_path.c_str(), &stat_data)) {
return false;
}
return S_ISREG(stat_data.st_mode);
}
bool File::Delete(const string& filepath) {
return unlink(filepath.c_str()) == 0;
}
bool File::CreateNewTempFile(string* path) {
if (!path) {
return false;
}
char temp_path[] = "/tmp/libkmlXXXXXX";
int fd = mkstemp(temp_path);
if (fd == -1) {
return false;
}
close(fd);
path->assign(temp_path, strlen(temp_path));
return true;
}
} // end namespace kmlbase
// Copyright 2008, Google 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:
//
// 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 Google 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 AUTHOR ``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 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 KML_BASE_UTIL_H__
#define KML_BASE_UTIL_H__
#if !defined(_MSC_VER) || (_MSC_VER >= 1600)
// Visual Studio versions < 10 do not contain stdint. Assumes
// all other platforms include this c99 standard header.
# include <stdint.h>
#else
// MSVC versions prior to v10 have no header for C99 typedefs.
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#endif
typedef unsigned int uint;
// A macro to disallow the evil copy constructor and assignment operator.
// Should be used in the private: declarations for a class.
#define LIBKML_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \
TypeName(const TypeName&);\
void operator=(const TypeName&)
#include <string>
// A convenience for the internal build system at Google.
#ifndef HAS_GLOBAL_STRING
using std::string;
#endif
#endif // KML_BASE_UTIL_H__
// This is core/vul/vul_psfile.h
#ifndef vul_psfile_h_
#define vul_psfile_h_
//:
// \file
// \brief write out images, points, lines, circles and/or ellipses to PostScript
// \author Alan S. Liu
//
// \verbatim
// Modifications
// 7 Jan 2003 - Peter Vanroose - bug fix in image output: complete rewrite of
// print_greyscale_image() & print_color_image()
// \endverbatim
#include <vcl_string.h>
#include <vcl_fstream.h>
//: Write a PostScript file
class vul_psfile: public vcl_ofstream
{
public:
enum paper_type {
US_NORMAL,
A4,
B5,
A3,
US_LEGAL,
ELEVEN_BY_SEVENTEEN,
FOUR_BY_FIVE,
THIRTY_FIVE_mm};
enum paper_orientation{
PORTRAIT,
LANDSCAPE };
enum paper_layout{
CENTER,
MAX };
vul_psfile(char const* filename, bool debug_output=false);
~vul_psfile();
operator bool() { return output_filestream; }
void set_paper_type(vul