diff --git a/.travis.yml b/.travis.yml index b98aeac..f3c6cd3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,10 +40,16 @@ before_install: - gmt-config --all install: - - gmt --version + - mkdir build + - cd build + - cmake .. + - make + - cd .. script: - - gmt --version + - gmt set GMT_CUSTOM_LIBS ${PWD}/build/src/plugins/custom.so + - gmt --version -Vd + - gmt average notifications: email: false diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c0775e..895eb18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,5 @@ # -# $Id: CMakeLists.txt 11803 2013-06-24 23:06:22Z pwessel $ -# -# Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe +# Copyright (c) 1991-2020 by the GMT Team (https://www.generic-mapping-tools.org/team.html) # See LICENSE.TXT file for copying and redistribution conditions. # # This program is free software; you can redistribute it and/or modify @@ -13,11 +11,9 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # -# Contact info: gmt.soest.hawaii.edu +# Contact info: www.generic-mapping-tools.org #------------------------------------------------------------------------------- # -# To modify the cmake process: Edit your cmake/ConfigUser.cmake file -# # To build out-of-source do (for example): # # mkdir build @@ -26,14 +22,10 @@ # # CMAKE_BUILD_TYPE can be: empty, Debug, Release, RelWithDebInfo or MinSizeRel # -# cmake creates a new file cmake/ConfigUser.cmake if it does not already -# exist. You can configure additional options there. -# -## Section 0: Define project name. Change this to what your plugin should be named. +## Define project name. Change this to what your plugin should be named. project (custom) -#------------------------------------------------------------------------ # Make sure the user doesn't play dirty with symlinks get_filename_component (srcdir "${CMAKE_SOURCE_DIR}" REALPATH) get_filename_component (bindir "${CMAKE_BINARY_DIR}" REALPATH) @@ -54,16 +46,14 @@ cmake_minimum_required (VERSION 2.8.5) set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/" CACHE INTERNAL "Location of our custom CMake modules." FORCE) -# Include configuration options (default options and options overridden by user). -include (ConfigCMake) - -# Find UNIX commands -include (FindUnixCommands) - # Add subdirectories add_subdirectory (src) -get_property(GMT_CUSTOM_LIB_PATH TARGET customlib PROPERTY LOCATION) -GET_FILENAME_COMPONENT (GMT_CUSTOM_LIB_NAME ${GMT_CUSTOM_LIB_PATH} NAME) + +# Get name of the custom supplemental library +get_directory_property (_suppl_lib_name DIRECTORY "src" DEFINITION "SUPPL_LIB_NAME") +get_target_property (_name ${_suppl_lib_name} OUTPUT_NAME) +get_target_property (_prefix ${_suppl_lib_name} PREFIX) +set (GMT_CUSTOM_LIB_NAME ${_prefix}${_name}${CMAKE_SHARED_MODULE_SUFFIX}) # Configuration done message( @@ -76,5 +66,3 @@ message( "* CUSTOM library : ${GMT_CUSTOM_LIB_NAME}\n" "* Installing CUSTOM in : ${CMAKE_INSTALL_PREFIX}\n" "* CUSTOM_SHARE_PATH : ${CMAKE_INSTALL_PREFIX}/${CUSTOM_SHARE_PATH}") - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/ConfigDefault.cmake b/cmake/ConfigDefault.cmake deleted file mode 100644 index c7be8a6..0000000 --- a/cmake/ConfigDefault.cmake +++ /dev/null @@ -1,128 +0,0 @@ -# -# $Id: ConfigDefault.cmake 11782 2013-06-23 18:10:30Z pwessel $ -# -# Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe -# See LICENSE.TXT file for copying and redistribution conditions. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; version 3 or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# Contact info: gmt.soest.hawaii.edu -#------------------------------------------------------------------------------- -# -# Default CUSTOM settings. DO NOT EDIT THIS FILE! -# -# There are two configuration files: -# 1) "ConfigDefault.cmake" - is version controlled and used to add new default -# variables and set defaults for everyone. -# 2) "ConfigUser.cmake" - is not version controlled (currently listed in -# svn:ignore property) and used to override defaults on a per-user basis. -# -# NOTE: If you want to change CMake behaviour just for yourself then copy -# "ConfigUserTemplate.cmake" to "ConfigUser.cmake" and then edit -# "ConfigUser.cmake" (not "ConfigDefault.cmake" or "ConfigUserTemplate.cmake"). -# - -# The CUSTOM package name. -set (CUSTOM_PACKAGE_NAME "CUSTOM") - -# a short description of the custom project (only a few words). -set (CUSTOM_PACKAGE_DESCRIPTION_SUMMARY "Custom Extension to The Generic Mapping Tools") - -# The CUSTOM package version. -set (CUSTOM_PACKAGE_VERSION_MAJOR "5") -set (CUSTOM_PACKAGE_VERSION_MINOR "0") -set (CUSTOM_PACKAGE_VERSION_PATCH "1b") - -# The subversion revision of the CUSTOM source code. -# This is manually set when making CUSTOM *public* releases. -# However, when making internal releases or just an ordinary developer build, leave it -# empty; if it is empty, the revision number is automatically populated for you on build. -#set (CUSTOM_SOURCE_CODE_CONTROL_VERSION_STRING "9047") - -# The CUSTOM package version. -set (CUSTOM_PACKAGE_VERSION "${CUSTOM_PACKAGE_VERSION_MAJOR}.${CUSTOM_PACKAGE_VERSION_MINOR}.${CUSTOM_PACKAGE_VERSION_PATCH}") - -# CUSTOM_VERSION_YEAR set to current date in cmake/modules/ConfigCMake.cmake -# if not specified here: -#set (CUSTOM_VERSION_YEAR "2013") - -# Directory in which to install the release sources per default -if (NOT DEFINED CUSTOM_RELEASE_PREFIX) - set (CUSTOM_RELEASE_PREFIX ${CUSTOM_BINARY_DIR}/CUSTOM-${CUSTOM_PACKAGE_VERSION}-src) -endif (NOT DEFINED CUSTOM_RELEASE_PREFIX) - - -# The CUSTOM copyright - string version to be used in a source file. -set (CUSTOM_COPYRIGHT_STRING) -set (CUSTOM_COPYRIGHT_STRING "${CUSTOM_COPYRIGHT_STRING}Copyright 1991-${CUSTOM_VERSION_YEAR} Tne list of autors\\n") -set (CUSTOM_COPYRIGHT_STRING "${CUSTOM_COPYRIGHT_STRING}This program comes with NO WARRANTY, to the extent permitted by law.\\n") -set (CUSTOM_COPYRIGHT_STRING "${CUSTOM_COPYRIGHT_STRING}You may redistribute copies of this program under the terms of the\\n") -set (CUSTOM_COPYRIGHT_STRING "${CUSTOM_COPYRIGHT_STRING}GNU General Public License.\\n") -set (CUSTOM_COPYRIGHT_STRING "${CUSTOM_COPYRIGHT_STRING}For more information about these matters, see the file named LICENSE.TXT.\\n") -set (CUSTOM_COPYRIGHT_STRING "${CUSTOM_COPYRIGHT_STRING}\\n") - - -# You can set the build configuration type as a command-line argument to 'cmake' using -DCMAKE_BUILD_TYPE:STRING=Debug for example. -# If no build configuration type was given as a command-line option to 'cmake' then a default cache entry is set here. -# A cache entry is what appears in the 'CMakeCache.txt' file that CMake generates - you can edit that file directly or use the CMake GUI to edit it. -# The user can then set this parameter via the CMake GUI before generating the native build system. -# NOTE: this is not needed for visual studio because it has multiple configurations in the ide (and CMake includes them all). -# however makefile generators can only have one build type (to have multiple build types you'll need multiple out-of-place builds - one for each build type). -# -# The following are some valid build configuration types: -# 1) Debug - no optimisation with debug info. -# 2) Release - release build optimised for speed. -# 3) RelWithDebInfo - release build optimised for speed with debug info. -# 4) MinSizeRel - release build optimised for size. - -# The following is from http://mail.kde.org/pipermail/kde-buildsystem/2008-November/005112.html... -# -# "The way to identify whether a generator is multi-configuration is to -# check whether CMAKE_CONFIGURATION_TYPES is set. The VS/XCode generators -# set it (and ignore CMAKE_BUILD_TYPE). The Makefile generators do not -# set it (and use CMAKE_BUILD_TYPE). If CMAKE_CONFIGURATION_TYPES is not -# already set, don't set it." -# -if (NOT DEFINED CMAKE_CONFIGURATION_TYPES) - if (NOT DEFINED CMAKE_BUILD_TYPE) - # Should we set build type to RelWithDebInfo for developers and - # to release for general public (ie when GPLATES_SOURCE_RELEASE is true) ? - # Currently it's Release for both. - set (CMAKE_BUILD_TYPE Release CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ${extra_build_configurations}." - FORCE) - endif (NOT DEFINED CMAKE_BUILD_TYPE) -endif (NOT DEFINED CMAKE_CONFIGURATION_TYPES) - - -# Turn this on if you want to... -# Unix: see compiler commands echoed to console and messages about make -# entering and leaving directories. -# VisualStudio: see compiler commands. -# Setting CMAKE_VERBOSE_MAKEFILE to 'true'... -# Unix: puts 'VERBOSE=1' in the top Makefile. -# VisualStudio: sets SuppressStartupBanner to FALSE. -# If CMAKE_VERBOSE_MAKEFILE is set to 'false' and you want to turn on -# verbosity temporarily you can... -# Unix: type 'make VERBOSE=1' on the command-line when building. -# VisualStudio: change SuppressStartupBanner to 'no' in "project -# settings->configuration properties->*->general". -if (NOT DEFINED CMAKE_VERBOSE_MAKEFILE) - set (CMAKE_VERBOSE_MAKEFILE false) -endif (NOT DEFINED CMAKE_VERBOSE_MAKEFILE) - -# prefer shared libs over static -set (BUILD_SHARED_LIBS true) -set (CMAKE_FIND_STATIC LAST) - -# search order for find_* -set (CMAKE_FIND_FRAMEWORK LAST) - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/ConfigUserTemplate.cmake b/cmake/ConfigUserTemplate.cmake deleted file mode 100644 index 8796e59..0000000 --- a/cmake/ConfigUserTemplate.cmake +++ /dev/null @@ -1,79 +0,0 @@ -# -# $Id: ConfigUserTemplate.cmake 11801 2013-06-24 21:19:31Z pwessel $ -# -# Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe -# See LICENSE.TXT file for copying and redistribution conditions. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; version 3 or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# Contact info: gmt.soest.hawaii.edu -#------------------------------------------------------------------------------- - -## Use this file to override variables in 'ConfigDefault.cmake' on a per-user basis. -## First copy 'ConfigUserTemplate.cmake' to 'ConfigUser.cmake', then edit 'ConfigUser.cmake'. -## 'ConfigUser.cmake' is not version controlled (currently listed in svn:ignore property) -## -## Note: CMake considers an empty string, "FALSE", "OFF", "NO", or any string ending -## in "-NOTFOUND" to be false. (This happens to be case-insensitive, so "False", -## "off", "no", and "something-NotFound" are all false.) Other values are true. Thus -## it matters not whether you use TRUE and FALSE, ON and OFF, or YES and NO for your -## booleans. - -## Basic setup begins here. All settings are optional. In most cases, setting -## CMAKE_INSTALL_PREFIX should be all you need to do in order to build GMT with -## reasonable defaults enabled. - -## -## Section 1: Setting up PATHs -## - -# 1a) Installation path (usually defaults to /usr/local) [auto]: -#set (CMAKE_INSTALL_PREFIX "prefix_path") - -# 1b) Set location of GMT (can be root directory, path to header file or path to gmt-config) [auto]: -#set (GMT_ROOT "gmt_install_prefix") - -## -## Section 2: Advanced tweaking -## - -# 2a) Set build type can be: empty, Debug, Release, RelWithDebInfo or MinSizeRel [Release]: -#set (CMAKE_BUILD_TYPE Debug) - -# 2b) Extra debugging for developers: -#add_definitions(-DDEBUG) -#set (CMAKE_C_FLAGS "-Wall -Wdeclaration-after-statement") # recommended even for release build -#set (CMAKE_C_FLAGS "-Wextra ${CMAKE_C_FLAGS}") # extra warnings -#set (CMAKE_C_FLAGS_DEBUG -ggdb3) # gdb debugging symbols -#set (CMAKE_C_FLAGS_RELEASE "-ggdb3 -O2 -Wuninitialized") # check uninitialized variables -#set (CMAKE_LINK_DEPENDS_DEBUG_MODE TRUE) # debug link dependencies - -# 2c) This is for GCC on Solaris to avoid "relocations remain against -# allocatable but non-writable sections" problems: -#set (USER_GMTLIB_LINK_FLAGS -mimpure-text) - -# 2d) This may be needed to enable strdup and extended math functions -# with GCC and Suncc on Solaris: -#set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__") - -# 2e) Do not warn when building with Windows SDK or Visual Studio Express: -#set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON) - -# 2f) If want to rename the DLLs to something else than the default (e.g. to append the bitness - Windows only) -# if (WIN32) -# set (BITAGE 32) -# # Detect if we are building a 32 or 64 bits version -# if (CMAKE_SIZEOF_VOID_P EQUAL 8) -# set(BITAGE 64) -# endif () -# set (CUSTOM_DLL_RENAME custom_w${BITAGE}) -# endif(WIN32) - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/dist/CMakeLists.txt.saved b/cmake/dist/CMakeLists.txt.saved deleted file mode 100644 index 5e68449..0000000 --- a/cmake/dist/CMakeLists.txt.saved +++ /dev/null @@ -1,216 +0,0 @@ -# -# $Id: CMakeLists.txt 11523 2013-05-21 19:02:42Z fwobbe $ -# -# Copyright (c) 1991-2013 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe -# See LICENSE.TXT file for copying and redistribution conditions. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; version 3 or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# Contact info: gmt.soest.hawaii.edu -#------------------------------------------------------------------------------- -# - -# Common CPack settings: -set (CPACK_PACKAGE_NAME ${PROJECT_NAME}) -set (CPACK_PACKAGE_VENDOR "The ${PROJECT_NAME} Team") -set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Extension ${PROJECT_NAME} for The Generic Mapping Tools") -set (CPACK_PACKAGE_VERSION_MAJOR ${CUSTOM_PACKAGE_VERSION_MAJOR}) -set (CPACK_PACKAGE_VERSION_MINOR ${CUSTOM_PACKAGE_VERSION_MINOR}) -set (CPACK_PACKAGE_VERSION_PATCH ${CUSTOM_PACKAGE_VERSION_PATCH}) -set (CPACK_PACKAGE_VERSION ${CUSTOM_PACKAGE_VERSION_WITH_SVN_REVISION}) -if (NOT DEFINED CPACK_PACKAGE_INSTALL_DIRECTORY) - if (WIN32) - set (CPACK_PACKAGE_INSTALL_DIRECTORY ${CMAKE_PROJECT_NAME}${CUSTOM_PACKAGE_VERSION_MAJOR}) - else (WIN32) - set (CPACK_PACKAGE_INSTALL_DIRECTORY CUSTOM-${CUSTOM_PACKAGE_VERSION_WITH_SVN_REVISION}) - endif (WIN32) -endif (NOT DEFINED CPACK_PACKAGE_INSTALL_DIRECTORY) -set (CPACK_PACKAGE_DESCRIPTION_FILE - "${CMAKE_CURRENT_SOURCE_DIR}/cpack_package_description.txt") -set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/COPYING.COMBINED") - - -# Read GPL and LGPL license files -file(READ ${COPYING_GPL} _license_gpl) -file(READ ${COPYING_LGPL} _license_lgpl) - -set (_license_extra) -if (NOT LICENSE_RESTRICTED) - # Read extra license files - foreach (_license_file ${CUSTOM_EXTRA_LICENSE_FILES}) - file(READ ${_license_file} _license_string) - set (_license_extra - "${_license_extra}\n---------------------------------------------------------------------------\n\n${_license_string}") - endforeach (_license_file ${CUSTOM_EXTRA_LICENSE_FILES}) - - # Copy combined license template - execute_process(COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_SOURCE_DIR}/COPYING.RESTRICTED.template - ${CMAKE_CURRENT_BINARY_DIR}/COPYING.COMBINED) -else (NOT LICENSE_RESTRICTED) - # Clear contents of license file if it exists - execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f - ${CMAKE_CURRENT_BINARY_DIR}/COPYING.COMBINED) -endif (NOT LICENSE_RESTRICTED) - -# Append GPL, LGPL, and licenses from CUSTOM_EXTRA_LICENSE_FILES -set (_license_combined "${_license_gpl}") -if (NOT LICENSE_RESTRICTED STREQUAL GPL) - set (_license_combined - "${_license_combined}\n---------------------------------------------------------------------------\n\n${_license_lgpl}") -endif (NOT LICENSE_RESTRICTED STREQUAL GPL) -set (_license_combined "${_license_combined}\n${_license_extra}") - -# Append to COPYING.COMBINED or create new combined license file -file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/COPYING.COMBINED "${_license_combined}") - - -# Install components: -set (CPACK_COMPONENTS_ALL Runtime Documentation) -set (CPACK_COMPONENT_DOCUMENTATION_DISABLED ON) -set (CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "Runtime files") -set (CPACK_COMPONENT_RUNTIME_DESCRIPTION - "CUSTOM programs, libraries and shared files.") -set (CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION - "Documentation and example files.") -set (CPACK_COMPONENT_GSHHG_DESCRIPTION - "Shoreline database files.") - -# Create two installation types with pre-selected components: -set (CPACK_ALL_INSTALL_TYPES Full Minimal) -set (CPACK_INSTALL_TYPE_FULL_DISPLAY_NAME "Everything") -set (CPACK_COMPONENT_RUNTIME_INSTALL_TYPES Minimal Full) -set (CPACK_COMPONENT_DOCUMENTATION_INSTALL_TYPES Full) -set (CPACK_COMPONENT_GSHHG_INSTALL_TYPES Full) - -# One package per COMPONENT: -set(CPACK_COMPONENTS_GROUPING "IGNORE") - -# Enable component install for archive generators: -set (CPACK_ARCHIVE_COMPONENT_INSTALL ON) - -# Debian: -set (CPACK_DEBIAN_PACKAGE_MAINTAINER "CUSTOM Team ") -set (CPACK_DEBIAN_PACKAGE_SECTION science) -#set (CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) -#set (CPACK_PACKAGE_DESCRIPTION "CUSTOM is an open source collection of ~65 tools -#for manipulating geographic and Cartesian data sets (including filtering, -#trend fitting, gridding, projecting, etc.) and producing Encapsulated -#PostScript File (EPS) illustrations ranging from simple x-y plots via contour -#maps to artificially illuminated surfaces and 3-D perspective views; the CUSTOM -#supplements add another ~70 more specialized tools. CUSTOM supports over 30 map -#projections and transformations and comes with support data such as GSHHG -#coastlines, rivers, and political boundaries.") - -#set (CPACK_MONOLITHIC_INSTALL TRUE) -set (CPACK_RPM_COMPONENT_INSTALL ON) - -#set(CPACK_COMPONENT_RUNTIME_GROUP "Runtime") -#set(CPACK_COMPONENT_LEFTOVER_GROUP "Documentation") - -#set(CPACK_COMPONENTS_IGNORE_GROUPS 1) - -set (CPACK_COMPONENT_UNSPECIFIED_HIDDEN FALSE) -set (CPACK_COMPONENT_UNSPECIFIED_REQUIRED FALSE) - - -# Windows: -if (WIN32 AND NOT CYGWIN) - # By default, do not warn when built on machines using only VS Express: - #set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON) - - # Install MSVC runtime DLLs: - include (InstallRequiredSystemLibraries) - - # InstallRequiredSystemLibraries installs the runtime libraries without - # specifying COMPONENT Runtime. We have to do it manually here: - set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) - install (PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} - DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION} - COMPONENT Runtime) - - set (CPACK_GENERATOR ZIP NSIS) - set (CPACK_NSIS_DISPLAY_NAME - "${CPACK_PACKAGE_NAME}${CUSTOM_PACKAGE_VERSION_MAJOR}") - if (NOT DEFINED CPACK_NSIS_INSTALL_ROOT) - set (CPACK_NSIS_INSTALL_ROOT "c:\\\\programs") - endif (NOT DEFINED CPACK_NSIS_INSTALL_ROOT) - set (CPACK_NSIS_MODIFY_PATH ON) - string(REPLACE "/" "\\\\" _native_share_path "${CUSTOM_SHARE_PATH}") - set (CPACK_NSIS_ADD_ENVVAR1 "CUSTOM5_SHAREDIR") - set (CPACK_NSIS_ADD_ENVVAL1 "\\\$INSTDIR\\\\${_native_share_path}") - - # StartMenu items: - set (CPACK_NSIS_MENU_LINKS - "${CUSTOM_BINDIR}/startup_win.bat" "CUSTOM Command Prompt" - "${CUSTOM_DOC_PATH}" "Documentation") - - # Install startup batch file: - install (PROGRAMS startup_win.bat - DESTINATION ${CUSTOM_BINDIR} - COMPONENT Runtime) - - # Fix bundle: - install (CODE " - if (CMAKE_INSTALL_PREFIX MATCHES \"_CPack_Packages\") - include (BundleUtilities) - fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CUSTOM_BINDIR}/gmt${CMAKE_EXECUTABLE_SUFFIX}\" \"\" \"\") - endif () - " COMPONENT Runtime) -endif(WIN32 AND NOT CYGWIN) - -# MacOSX: -if (APPLE) - # Generate startup script: - configure_file (startup_macosx.sh.in startup_macosx.sh @ONLY) - configure_file (Info.plist.in Info.plist @ONLY) - - # Configure CPack: - set (CPACK_GENERATOR Bundle TGZ TBZ2) - set (CPACK_BUNDLE_NAME - "${CPACK_PACKAGE_NAME}-${CUSTOM_PACKAGE_VERSION_WITH_SVN_REVISION}") - set (CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/CUSTOM.icns") - set (CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist") - set (CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/startup_macosx.sh") - - # Fix bundle: - install (CODE " - set (BU_CHMOD_BUNDLE_ITEMS TRUE CACHE INTERNAL - \"make bundle items writable before invoking install_name_tool\") - if (CMAKE_INSTALL_PREFIX MATCHES \"_CPack_Packages.+[.]app/Contents/Resources\") - cmake_policy (SET CMP0009 NEW) - cmake_policy (SET CMP0011 NEW) - # Workaround incompatible 'file' utilities possibly used in - # is_file_executable() from GetPrerequisites.cmake: - set (file_cmd /usr/bin/file) - include (BundleUtilities) - fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CUSTOM_BINDIR}/gmt${CMAKE_EXECUTABLE_SUFFIX}\" \"\" \"\") - endif () - " COMPONENT Runtime) - - # Workaround: move documentation: - install (CODE " - if (CMAKE_INSTALL_PREFIX MATCHES \"_CPack_Packages.+[.]app/Contents/Resources\") - execute_process (COMMAND ${CMAKE_COMMAND} -E rename - \${CMAKE_INSTALL_PREFIX}/${CUSTOM_DOC_PATH} - \${CMAKE_INSTALL_PREFIX}/../../../Documentation) - endif () - " COMPONENT Documentation) -endif (APPLE) - -# Linux, Cygwin & Co: -if (UNIX AND NOT APPLE) - set (CPACK_GENERATOR TGZ TBZ2) -endif (UNIX AND NOT APPLE) - -# This must always be last: -include (CPack) - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/dist/COPYING.RESTRICTED.template b/cmake/dist/COPYING.RESTRICTED.template deleted file mode 100644 index 4d900a3..0000000 --- a/cmake/dist/COPYING.RESTRICTED.template +++ /dev/null @@ -1,12 +0,0 @@ -GMT is distributed under the GNU Lesser General Public License -(LGPL) version 3 or later. Copies of the The GNU General Public -License (GPL) and the GNU Lesser General Public License (LGPL) are -distributed along with this package and are printed below. - -NOTE: This package uses code that is distributed under a -proprietary non-permissive license. Refer to the additional -license terms below. - ------------------------------------------------------------------- - - diff --git a/cmake/dist/GMT.icns b/cmake/dist/GMT.icns deleted file mode 100644 index 6035a94..0000000 Binary files a/cmake/dist/GMT.icns and /dev/null differ diff --git a/cmake/dist/Info.plist.in b/cmake/dist/Info.plist.in deleted file mode 100644 index 1e7bc57..0000000 --- a/cmake/dist/Info.plist.in +++ /dev/null @@ -1,35 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - GMT-@GMT_PACKAGE_VERSION_WITH_SVN_REVISION@ - CFBundleGetInfoString - GMT is an open source collection of ~65 tools for manipulating geographic and cartesian data sets. - CFBundleIconFile - GMT-@GMT_PACKAGE_VERSION_WITH_SVN_REVISION@.icns - CFBundleIdentifier - edu.hawaii.soest.gmt5 - CFBundleInfoDictionaryVersion - 6.0 - CFBundleLongVersionString - GMT-@GMT_PACKAGE_VERSION_WITH_SVN_REVISION@ - CFBundleName - GMT - CFBundlePackageType - APPL - CFBundleShortVersionString - @GMT_PACKAGE_VERSION_WITH_SVN_REVISION@ - CFBundleSignature - ???? - CFBundleVersion - @GMT_PACKAGE_VERSION_WITH_SVN_REVISION@ - CSResourcesFileMapped - - NSHumanReadableCopyright - Copyright (c) 1991-@GMT_VERSION_YEAR@ by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe -This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 3 or any later version. - - diff --git a/cmake/dist/cpack_package_description.txt b/cmake/dist/cpack_package_description.txt deleted file mode 100644 index f00618a..0000000 --- a/cmake/dist/cpack_package_description.txt +++ /dev/null @@ -1,13 +0,0 @@ -GMT is an open source collection of ~65 tools for manipulating -geographic and Cartesian data sets (including filtering, trend -fitting, gridding, projecting, etc.) and producing Encapsulated -PostScript File (EPS) illustrations ranging from simple x-y plots -via contour maps to artificially illuminated surfaces and 3-D -perspective views; the GMT supplements add another ~70 more -specialized tools. GMT supports over 30 map projections and -transformations and comes with support data such as GSHHG -coastlines, rivers, and political boundaries. GMT is developed and -maintained by Paul Wessel, Walter H. F. Smith, Remko Scharroo, -Joaquim Luis and Florian Wobbe, with help from a global set of -volunteers, and is supported by the National Science Foundation. -It is released under the GNU Lesser General Public License. diff --git a/cmake/dist/startup_macosx.sh.in b/cmake/dist/startup_macosx.sh.in deleted file mode 100755 index 3c8f83b..0000000 --- a/cmake/dist/startup_macosx.sh.in +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# Startup script for GMT.app in MacOSX. -# Setup environment and start Terminal. - -RUNDIR=$(dirname "$0") -cd "${RUNDIR}/.." -BUNDLE_RESOURCES="${PWD}/Resources" - -# run terminal, set path, and run gmt -osascript << EOF - tell application "Terminal" - activate - do script with command "export PATH=\"${BUNDLE_RESOURCES}/@GMT_BINDIR@:\${PATH}\" gmt" - end tell -EOF - -exit 0 diff --git a/cmake/dist/startup_win.bat b/cmake/dist/startup_win.bat deleted file mode 100644 index 77a49a3..0000000 --- a/cmake/dist/startup_win.bat +++ /dev/null @@ -1,11 +0,0 @@ -@ECHO OFF - -REM Startup script for GMT in Windows. - -set RUNDIR=%~dp0 -set PATH=%RUNDIR%;%PATH% - -cd %HOMEDRIVE% -cd %HOMEPATH% - -cmd /k gmt diff --git a/cmake/modules/CMakePushCheckState.cmake b/cmake/modules/CMakePushCheckState.cmake deleted file mode 100644 index c591678..0000000 --- a/cmake/modules/CMakePushCheckState.cmake +++ /dev/null @@ -1,59 +0,0 @@ -# This module defines two macros: -# CMAKE_PUSH_CHECK_STATE() -# and -# CMAKE_POP_CHECK_STATE() -# These two macros can be used to save and restore the state of the variables -# CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES -# and CMAKE_REQUIRED_INCLUDES used by the various Check-files coming with CMake, -# like e.g. check_function_exists() etc. -# The variable contents are pushed on a stack, pushing multiple times is supported. -# This is useful e.g. when executing such tests in a Find-module, where they have to be set, -# but after the Find-module has been executed they should have the same value -# as they had before. -# -# Usage: -# cmake_push_check_state() -# set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF) -# check_function_exists(...) -# cmake_pop_check_state() - -#============================================================================= -# Copyright 2006-2011 Alexander Neundorf, -# -# 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 COPYING-CMAKE-SCRIPTS for more information. -#============================================================================= - - -MACRO(CMAKE_PUSH_CHECK_STATE) - - IF(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER) - SET(_CMAKE_PUSH_CHECK_STATE_COUNTER 0) - ENDIF() - - MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1") - - SET(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) - SET(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) - SET(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) - SET(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) -ENDMACRO(CMAKE_PUSH_CHECK_STATE) - -MACRO(CMAKE_POP_CHECK_STATE) - -# don't pop more than we pushed - IF("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0") - - SET(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - SET(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - SET(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - SET(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - - MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") - ENDIF() - -ENDMACRO(CMAKE_POP_CHECK_STATE) diff --git a/cmake/modules/COPYING-CMAKE-SCRIPTS b/cmake/modules/COPYING-CMAKE-SCRIPTS deleted file mode 100644 index 35f7e4b..0000000 --- a/cmake/modules/COPYING-CMAKE-SCRIPTS +++ /dev/null @@ -1,56 +0,0 @@ -CMake - Cross Platform Makefile Generator -Copyright 2000-2009 Kitware, Inc., Insight Software Consortium -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 names of Kitware, Inc., the Insight Software Consortium, - nor the names of their 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. - ------------------------------------------------------------------------------- - -The above copyright and license notice applies to distributions of -CMake in source and binary form. Some source files contain additional -notices of original copyright by their contributors; see each source -for details. Third-party software packages supplied with CMake under -compatible licenses provide their own copyright notices documented in -corresponding subdirectories. - ------------------------------------------------------------------------------- - -CMake was initially developed by Kitware with the following sponsorship: - - * National Library of Medicine at the National Institutes of Health - as part of the Insight Segmentation and Registration Toolkit (ITK). - - * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel - Visualization Initiative. - - * National Alliance for Medical Image Computing (NAMIC) is funded by the - National Institutes of Health through the NIH Roadmap for Medical Research, - Grant U54 EB005149. - - * Kitware, Inc. diff --git a/cmake/modules/CheckPrototypeExists.cmake b/cmake/modules/CheckPrototypeExists.cmake deleted file mode 100644 index 91ecdbb..0000000 --- a/cmake/modules/CheckPrototypeExists.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# -# $Id: CheckPrototypeExists.cmake 9340 2011-10-27 11:28:21Z fwobbe $ -# -# - Check if the prototype for a function exists. -# CHECK_PROTOTYPE_EXISTS (FUNCTION HEADER VARIABLE) -# -# FUNCTION - the name of the function you are looking for -# HEADER - the header(s) where the prototype should be declared -# VARIABLE - variable to store the result -# -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories - -# Copyright (c) 2006, Alexander Neundorf, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - - -INCLUDE (CheckCXXSourceCompiles) -INCLUDE (CheckCSourceCompiles) - -MACRO (CHECK_PROTOTYPE_EXISTS _SYMBOL _HEADER _RESULT) - SET(_INCLUDE_FILES) - FOREACH (it ${_HEADER}) - SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n") - ENDFOREACH (it) - - SET(_CHECK_PROTO_EXISTS_SOURCE_CODE " -${_INCLUDE_FILES} -int main() -{ -#ifndef ${_SYMBOL} - int i = sizeof(&${_SYMBOL}); -#endif - return 0; -} -") - CHECK_CXX_SOURCE_COMPILES("${_CHECK_PROTO_EXISTS_SOURCE_CODE}" ${_RESULT}) -ENDMACRO (CHECK_PROTOTYPE_EXISTS _SYMBOL _HEADER _RESULT) diff --git a/cmake/modules/CheckTypeExists.cmake b/cmake/modules/CheckTypeExists.cmake deleted file mode 100644 index edbe77d..0000000 --- a/cmake/modules/CheckTypeExists.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# -# $Id: CheckTypeExists.cmake 9127 2011-09-26 13:48:05Z remko $ -# -# - Check if the given struct or class has the specified member variable -# CHECK_STRUCT_MEMBER (STRUCT MEMBER HEADER VARIABLE) -# -# STRUCT - the name of the struct or class you are interested in -# MEMBER - the member which existence you want to check -# HEADER - the header(s) where the prototype should be declared -# VARIABLE - variable to store the result -# -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories - -# Copyright (c) 2006, Alexander Neundorf, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - - -INCLUDE(CheckTypeSize) - -MACRO (CHECK_TYPE_EXISTS _TYPE _HEADER _RESULT) - SET(CMAKE_EXTRA_INCLUDE_FILES ${_HEADER}) - CHECK_TYPE_SIZE(${_TYPE} ${_RESULT}) -ENDMACRO (CHECK_TYPE_EXISTS) - diff --git a/cmake/modules/ConfigCMake.cmake b/cmake/modules/ConfigCMake.cmake deleted file mode 100644 index f0e6ddf..0000000 --- a/cmake/modules/ConfigCMake.cmake +++ /dev/null @@ -1,114 +0,0 @@ -# -# $Id: ConfigCMake.cmake 10119 2012-05-19 08:08:25Z fwobbe $ -# -# Useful CMake variables. -# -# There are three configuration files: -# 1) "ConfigDefault.cmake" - is version controlled and used to add new default -# variables and set defaults for everyone. -# 2) "ConfigUser.cmake" in the source tree - is not version controlled -# (currently listed in svn:ignore property) and used to override defaults on -# a per-user basis. -# 3) "ConfigUser.cmake" in the build tree - is used to override -# "ConfigUser.cmake" in the source tree. -# -# NOTE: If you want to change CMake behaviour just for yourself then copy -# "ConfigUserTemplate.cmake" to "ConfigUser.cmake" and then edit -# "ConfigUser.cmake" (not "ConfigDefault.cmake" or "ConfigUserTemplate.cmake"). -# -include ("${CMAKE_SOURCE_DIR}/cmake/ConfigDefault.cmake") - -# If "ConfigUser.cmake" doesn't exist then create one for convenience. -if (EXISTS "${CMAKE_SOURCE_DIR}/cmake/ConfigUser.cmake") - include ("${CMAKE_SOURCE_DIR}/cmake/ConfigUser.cmake") -endif (EXISTS "${CMAKE_SOURCE_DIR}/cmake/ConfigUser.cmake") - -# If you've got a 'ConfigUser.cmake' in the build tree then that overrides the -# one in the source tree. -if (EXISTS "${CMAKE_BINARY_DIR}/cmake/ConfigUser.cmake") - include ("${CMAKE_BINARY_DIR}/cmake/ConfigUser.cmake") -endif (EXISTS "${CMAKE_BINARY_DIR}/cmake/ConfigUser.cmake") - -########################################################### -# Do any needed processing of the configuration variables # -########################################################### - -# Build type -if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE Release) -endif (NOT CMAKE_BUILD_TYPE) - -if (CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo") - set (DEBUG_BUILD TRUE) -endif (CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo") - -# Get date -try_run (_exit_today _compiled_today - ${CMAKE_BINARY_DIR}/CMakeTmp - ${CMAKE_MODULE_PATH}/today.c - CMAKE_FLAGS - RUN_OUTPUT_VARIABLE _today) - -if (NOT _compiled_today OR _exit_today EQUAL -1) - message (WARNING "Date not implemented, please file a bug report.") - set(_today "1313;13;13;Undecember") -endif (NOT _compiled_today OR _exit_today EQUAL -1) - -list(GET _today 0 YEAR) -list(GET _today 1 MONTH) -list(GET _today 2 DAY) -list(GET _today 3 MONTHNAME) -list(GET _today 0 1 2 DATE) -string (REPLACE ";" "-" DATE "${DATE}") -set (_today) - -# reset list of extra license files -set (CUSTOM_EXTRA_LICENSE_FILES) - -# location of GNU license files -set (COPYING_GPL ${CUSTOM_SOURCE_DIR}/COPYINGv3) -set (COPYING_LGPL ${CUSTOM_SOURCE_DIR}/COPYING.LESSERv3) - -# Install path for CUSTOM binaries, headers and libraries -include (GNUInstallDirs) # defines CMAKE_INSTALL_LIBDIR (lib/lib64) -if (CUSTOM_INSTALL_MONOLITHIC) - set (CUSTOM_LIBDIR ${CMAKE_INSTALL_LIBDIR}) -else (CUSTOM_INSTALL_MONOLITHIC) - set (CUSTOM_LIBDIR ${CMAKE_INSTALL_LIBDIR}/gmt${CUSTOM_INSTALL_NAME_SUFFIX}/lib) -endif (CUSTOM_INSTALL_MONOLITHIC) - -# use, i.e. don't skip the full RPATH for the build tree -set (CMAKE_SKIP_BUILD_RPATH FALSE) - -# when building, don't use the install RPATH already -# (but later on when installing) -set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - -# the RPATH to be used when installing -set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CUSTOM_LIBDIR}") - -# make executables relocatable on supported platforms -#if (UNIX AND NOT CYGWIN) -# # find relative libdir from executable dir -# file (RELATIVE_PATH _rpath /${CUSTOM_BINDIR} /${CUSTOM_LIBDIR}) -# # remove trailing / -# string (REGEX REPLACE "/$" "" _rpath "${_rpath}") -# if (APPLE) -# # relative RPATH on osx -# set (CMAKE_INSTALL_NAME_DIR @loader_path/${_rpath}) -# else (APPLE) -# # relative RPATH on Linux, Solaris, etc. -# set (CMAKE_INSTALL_RPATH "\$ORIGIN/${_rpath}") -# endif (APPLE) -#endif (UNIX AND NOT CYGWIN) - -# add the automatically determined parts of the RPATH -# which point to directories outside the build tree to the install RPATH -set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - -# Make GNU and Intel C compiler default to C99 -if (CMAKE_C_COMPILER_ID MATCHES "(GNU|Intel)" AND NOT CMAKE_C_FLAGS MATCHES "-std=") - set (CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}") -endif () - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/modules/ConfigureChecks.cmake b/cmake/modules/ConfigureChecks.cmake deleted file mode 100644 index 66602de..0000000 --- a/cmake/modules/ConfigureChecks.cmake +++ /dev/null @@ -1,559 +0,0 @@ -# -# $Id: ConfigureChecks.cmake 10841 2013-01-31 12:49:07Z fwobbe $ -# - -if(NOT DEFINED _INCLUDED_CHECK_MACROS_) - set(_INCLUDED_CHECK_MACROS_ "DEFINED") - - include (CheckCCompilerFlag) - include (CheckCSourceCompiles) - include (CheckCSourceRuns) - include (CheckFunctionExists) - include (CheckIncludeFile) - include (CheckIncludeFiles) - include (CheckLibraryExists) - include (CheckPrototypeExists) - include (CheckSymbolExists) - include (CheckTypeExists) - include (CheckTypeSize) - include (CMakePushCheckState) - include (TestBigEndian) - -endif(NOT DEFINED _INCLUDED_CHECK_MACROS_) - -# -# Check if compiler supports -traditional-cpp -# - -if (NOT HAVE_TRADITIONAL_CPP) - if (MSVC) - # Visual C++ - set (_cpp_cmdline /EP) - elseif (CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang|Intel)") - # GCC, Clang, or ICC - set (_cpp_cmdline -E -w -P -nostdinc -traditional-cpp) - endif (MSVC) - message (STATUS "Performing Test HAVE_TRADITIONAL_CPP") - execute_process (COMMAND ${CMAKE_C_COMPILER} ${_cpp_cmdline} - ${GMT_SOURCE_DIR}/config.h.in # can be any header file - RESULT_VARIABLE _cpp_traditional_result - OUTPUT_QUIET ERROR_QUIET) - if (_cpp_traditional_result EQUAL 0) - set (HAVE_TRADITIONAL_CPP TRUE CACHE INTERNAL "Test HAVE_TRADITIONAL_CPP") - message (STATUS "Performing Test HAVE_TRADITIONAL_CPP - Success") - else (_cpp_traditional_result EQUAL 0) - set (HAVE_TRADITIONAL_CPP "" CACHE INTERNAL "Test HAVE_TRADITIONAL_CPP") - message (STATUS "Performing Test HAVE_TRADITIONAL_CPP - Failed") - endif (_cpp_traditional_result EQUAL 0) -endif (NOT HAVE_TRADITIONAL_CPP) - -# -# Check if compiler supports __func__ or __FUNCTION__ identifier -# - -check_c_source_compiles ( - " - int main (){char *function_name = __func__; return 0;} - " - HAVE___FUNC__) -check_c_source_compiles ( - " - int main (){char *function_name = __FUNCTION__; return 0;} - " - HAVE___FUNCTION__) - -# -# Check for windows header -# - -check_include_file (io.h HAVE_IO_H_) -check_include_file (direct.h HAVE_DIRECT_H_) -check_include_file (process.h HAVE_PROCESS_H_) - -# -# Check for C99 and libc extensions -# - -# strdup, sincos, ... are GNU/BSD/Sun extensions: -cmake_push_check_state() -set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - -D_GNU_SOURCE - -D__EXTENSIONS__ - -D_LARGEFILE_SOURCE - -D_LARGEFILE64_SOURCE) - -check_include_file (assert.h HAVE_ASSERT_H_) -check_include_file (dirent.h HAVE_DIRENT_H_) -check_include_file (errno.h HAVE_ERRNO_H_) -check_include_file (fcntl.h HAVE_FCNTL_H_) -check_include_file (stdbool.h HAVE_STDBOOL_H_) -check_include_file (sys/dir.h HAVE_SYS_DIR_H_) -check_include_file (sys/stat.h HAVE_STAT_H_) -check_include_file (unistd.h HAVE_UNISTD_H_) - -check_function_exists (fopen64 HAVE_FOPEN64) -check_function_exists (fseeko HAVE_FSEEKO) -check_function_exists (ftello HAVE_FTELLO) -check_function_exists (getopt HAVE_GETOPT) -check_function_exists (getpwuid HAVE_GETPWUID) -check_function_exists (llabs HAVE_LLABS) -check_function_exists (pclose HAVE_PCLOSE) -check_function_exists (popen HAVE_POPEN) -check_function_exists (qsort_r HAVE_QSORT_R) -if (HAVE_QSORT_R) - # check qsort_r compatibility - check_c_source_runs ( - " - #include - #include - int cmp(const void *a, const void*b, void *c) { - assert(c == NULL); - return *(int*)a - *(int*)b; - } - int main() { - int array[5] = {7,3,5,2,8}; - int i; - qsort_r(array,5,sizeof(int),cmp,NULL); - for (i=0;i<4;++i) { - assert(array[i] < array[i+1]); - } - return 0; - } - " - HAVE_QSORT_R_GLIBC) -endif (HAVE_QSORT_R) -check_function_exists (strcasecmp HAVE_STRCASECMP) -check_function_exists (strncasecmp HAVE_STRNCASECMP) -check_function_exists (stricmp HAVE_STRICMP) -check_function_exists (strnicmp HAVE_STRNICMP) -check_function_exists (strdup HAVE_STRDUP) -check_function_exists (strsep HAVE_STRSEP) -check_function_exists (strtod HAVE_STRTOD) -# Note: trailing underscore = GDAL workaround -check_function_exists (strtof HAVE_STRTOF_) -check_function_exists (strtok_r HAVE_STRTOK_R) - -if (WIN32) - check_function_exists (_fseeki64 HAVE__FSEEKI64) - check_function_exists (_ftelli64 HAVE__FTELLI64) - check_function_exists (_pclose HAVE__PCLOSE) - check_function_exists (_popen HAVE__POPEN) - check_function_exists (_stat HAVE__STAT) - check_function_exists (_stati64 HAVE__STATI64) - check_function_exists (strtok_s HAVE_STRTOK_S) -endif (WIN32) - -# Check if these functions are declared (might not be the case although they -# are build-in) -check_symbol_exists (strdup string.h DECLARED_STRDUP) -check_symbol_exists (strsep string.h DECLARED_STRSEP) - -check_symbol_exists (basename libgen.h HAVE_BASENAME) -check_symbol_exists (fileno stdio.h HAVE_FILENO) -# Note: trailing underscore = GDAL workaround -check_symbol_exists (snprintf stdio.h HAVE_SNPRINTF_) -check_symbol_exists (vsnprintf stdio.h HAVE_VSNPRINTF_) - -if (HAVE_UNISTD_H_) - check_symbol_exists (access unistd.h HAVE_ACCESS) - check_symbol_exists (getpid unistd.h HAVE_GETPID) -else (HAVE_UNISTD_H_) - # in MinGW: - check_symbol_exists (access io.h HAVE_ACCESS) - check_symbol_exists (_getpid process.h HAVE__GETPID) -endif (HAVE_UNISTD_H_) - -if (WIN32) - check_symbol_exists (_access io.h HAVE__ACCESS) - check_symbol_exists (_fileno stdio.h HAVE__FILENO) - check_symbol_exists (_getcwd direct.h HAVE__GETCWD) - check_symbol_exists (_mkdir direct.h HAVE__MKDIR) - check_symbol_exists (_setmode io.h HAVE__SETMODE) - check_symbol_exists (_snprintf stdio.h HAVE__SNPRINTF_) - check_symbol_exists (_vsnprintf stdio.h HAVE__VSNPRINTF_) -endif (WIN32) - -if (UNIX) - # Check if -ldl is needed for dladdr - check_function_exists (dlopen HAVE_BUILTIN_DYNAMIC_LINKING_LOADER) - if (NOT HAVE_BUILTIN_DYNAMIC_LINKING_LOADER) - check_library_exists (dl dlopen "" HAVE_LIBDL) - endif (NOT HAVE_BUILTIN_DYNAMIC_LINKING_LOADER) - cmake_push_check_state() # save state of CMAKE_REQUIRED_* - if (HAVE_LIBDL) - set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-ldl") - endif (HAVE_LIBDL) - check_symbol_exists (dladdr dlfcn.h HAVE_DLADDR) - cmake_pop_check_state() # restore state of CMAKE_REQUIRED_* -endif (UNIX) - -# -# Check c types -# - -check_include_file (ctype.h HAVE_CTYPE_H_) -check_include_file (inttypes.h HAVE_INTTYPES_H_) -#check_include_file (stddef.h HAVE_STDDEF_H_) -#check_include_file (stdint.h HAVE_STDINT_H_) -#check_include_file (sys/types.h HAVE_SYS_TYPES_H_) - -# set HAVE_SYS_TYPES_H, HAVE_STDINT_H, and HAVE_STDDEF_H -# and check in , , and : -check_type_size (_Bool SIZEOF__BOOL) -check_type_size (bool SIZEOF_BOOL) -check_type_size (int SIZEOF_INT) -check_type_size (long SIZEOF_LONG) -check_type_size ("long long" SIZEOF_LONG_LONG) -check_type_size ("long double" SIZEOF_LONG_DOUBLE) -check_type_size (mode_t SIZEOF_MODE_T) -check_type_size (off_t SIZEOF_OFF_T) -check_type_size (size_t SIZEOF_SIZE_T) -check_type_size (wchar_t SIZEOF_WCHAR_T) -check_type_size ("void*" SIZEOF_VOID_P) - -# add suffix to prevent name clash with GDAL -set (HAVE_STDDEF_H_ "${HAVE_STDDEF_H}" - CACHE INTERNAL "Have include stddef.h") -set (HAVE_STDINT_H_ "${HAVE_STDINT_H}" - CACHE INTERNAL "Have include stdinf.h") -set (HAVE_SYS_TYPES_H_ "${HAVE_SYS_TYPES_H}" - CACHE INTERNAL "Have include sys/types.h") - -test_big_endian (WORDS_BIGENDIAN) - -# Byte swapping functions -check_c_source_runs ( - " - int main(void) { - return !__builtin_bswap16(0xabcd) == 0xcdab; - } - " - HAVE___BUILTIN_BSWAP16) -check_c_source_runs ( - " - int main(void) { - return !__builtin_bswap32(0xdeadbeef) == 0xefbeadde; - } - " - HAVE___BUILTIN_BSWAP32) -check_c_source_runs ( - " - int main(void) { - return !__builtin_bswap64(0x1234567890abcdef) == 0xefcdab9078563412; - } - " - HAVE___BUILTIN_BSWAP64) -if (WIN32) - check_function_exists (_byteswap_ushort HAVE__BYTESWAP_USHORT) # for uint16_t - check_function_exists (_byteswap_ulong HAVE__BYTESWAP_ULONG) # for uint32_t - check_function_exists (_byteswap_uint64 HAVE__BYTESWAP_UINT64) # for uint64_t -endif (WIN32) - -# -# Check math related stuff -# - -# extra math headers - -check_include_file (floatingpoint.h HAVE_FLOATINGPOINT_H_) -check_include_file (ieeefp.h HAVE_IEEEFP_H_) - -set (_math_h math.h float.h) -if (HAVE_FLOATINGPOINT_H_) - list (APPEND _math_h floatingpoint.h) -endif (HAVE_FLOATINGPOINT_H_) -if (HAVE_IEEEFP_H_) - list (APPEND _math_h ieeefp.h) -endif (HAVE_IEEEFP_H_) - -# Check if -lm is needed -check_function_exists (cos HAVE_M_FUNCTIONS) -if (NOT HAVE_M_FUNCTIONS) - check_library_exists (m cos "" HAVE_M_LIBRARY) -endif (NOT HAVE_M_FUNCTIONS) - -# If necessary compile with -lm -if (HAVE_M_LIBRARY) - set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-lm") -endif (HAVE_M_LIBRARY) - -# check symbols (double) -check_symbol_exists (acosh "${_math_h}" HAVE_ACOSH) -check_symbol_exists (asinh "${_math_h}" HAVE_ASINH) -check_symbol_exists (atanh "${_math_h}" HAVE_ATANH) -check_symbol_exists (copysign "${_math_h}" HAVE_COPYSIGN) -check_symbol_exists (erf "${_math_h}" HAVE_ERF) -check_symbol_exists (erfc "${_math_h}" HAVE_ERFC) -check_symbol_exists (hypot "${_math_h}" HAVE_HYPOT) -check_symbol_exists (isfinite "${_math_h}" HAVE_ISFINITE) -check_symbol_exists (isinf "${_math_h}" HAVE_ISINF) -check_symbol_exists (isnan "${_math_h}" HAVE_ISNAN) -check_symbol_exists (isnand "${_math_h}" HAVE_ISNAND) -check_symbol_exists (isnanf "${_math_h}" HAVE_ISNANF) -check_symbol_exists (isnormal "${_math_h}" HAVE_ISNORMAL) -check_symbol_exists (j0 "${_math_h}" HAVE_J0) -check_symbol_exists (j1 "${_math_h}" HAVE_J1) -check_symbol_exists (jn "${_math_h}" HAVE_JN) -check_symbol_exists (lrint "${_math_h}" HAVE_LRINT) -check_symbol_exists (log1p "${_math_h}" HAVE_LOG1P) -check_symbol_exists (log2 "${_math_h}" HAVE_LOG2) -check_symbol_exists (rint "${_math_h}" HAVE_RINT) -check_symbol_exists (sincos "${_math_h}" HAVE_SINCOS) -check_symbol_exists (y0 "${_math_h}" HAVE_Y0) -check_symbol_exists (y1 "${_math_h}" HAVE_Y1) -check_symbol_exists (yn "${_math_h}" HAVE_YN) -# check symbols (float) -check_symbol_exists (acosf "${_math_h}" HAVE_ACOSF) -check_symbol_exists (acoshf "${_math_h}" HAVE_ACOSHF) -check_symbol_exists (asinf "${_math_h}" HAVE_ASINF) -check_symbol_exists (asinhf "${_math_h}" HAVE_ASINHF) -check_symbol_exists (atanf "${_math_h}" HAVE_ATANF) -check_symbol_exists (atanhf "${_math_h}" HAVE_ATANHF) -check_symbol_exists (atan2f "${_math_h}" HAVE_ATAN2F) -check_symbol_exists (erff "${_math_h}" HAVE_ERFF) -check_symbol_exists (ceilf "${_math_h}" HAVE_CEILF) -check_symbol_exists (cosf "${_math_h}" HAVE_COSF) -check_symbol_exists (coshf "${_math_h}" HAVE_COSHF) -check_symbol_exists (erfcf "${_math_h}" HAVE_ERFCF) -check_symbol_exists (expf "${_math_h}" HAVE_EXPF) -check_symbol_exists (fabsf "${_math_h}" HAVE_FABSF) -check_symbol_exists (floorf "${_math_h}" HAVE_FLOORF) -check_symbol_exists (fmodf "${_math_h}" HAVE_FMODF) -check_symbol_exists (hypotf "${_math_h}" HAVE_HYPOTF) -check_symbol_exists (logf "${_math_h}" HAVE_LOGF) -check_symbol_exists (log2f "${_math_h}" HAVE_LOG2F) -check_symbol_exists (log10f "${_math_h}" HAVE_LOG10F) -check_symbol_exists (log1pf "${_math_h}" HAVE_LOG1PF) -check_symbol_exists (lrintf "${_math_h}" HAVE_LRINTF) -check_symbol_exists (powf "${_math_h}" HAVE_POWF) -check_symbol_exists (rintf "${_math_h}" HAVE_RINTF) -check_symbol_exists (sinf "${_math_h}" HAVE_SINF) -check_symbol_exists (sinhf "${_math_h}" HAVE_SINHF) -check_symbol_exists (sqrtf "${_math_h}" HAVE_SQRTF) -check_symbol_exists (tanf "${_math_h}" HAVE_TANF) -check_symbol_exists (tanhf "${_math_h}" HAVE_TANHF) - -if (WIN32) - check_symbol_exists (_copysign "${_math_h}" HAVE__COPYSIGN) - check_symbol_exists (_finite "${_math_h}" HAVE__FINITE) - check_symbol_exists (_fpclass "${_math_h}" HAVE__FPCLASS) - check_symbol_exists (_isnan "${_math_h}" HAVE__ISNAN) -endif (WIN32) - -# test if sincos is buggy -if (HAVE_SINCOS) - check_c_source_runs ( - " - #define _GNU_SOURCE - #define __EXTENSIONS__ - include - int main () { - double s = 0.1, c = 0.2; - double s1, c1; - s1 = s; c1 = c; - sincos (0.5, &s, &c); - return !(s == s1 || c == c1);} /* return TRUE if sincos works ok */ - " - HAVE_BUGGY_SINCOS) - if (HAVE_BUGGY_SINCOS) - set (HAVE_SINCOS "" CACHE INTERNAL "disable sincos because it is buggy" FORCE) - endif (HAVE_BUGGY_SINCOS) -endif (HAVE_SINCOS) - -# restore state of CMAKE_REQUIRED_* -cmake_pop_check_state() - -#check_symbol_exists (intptr_t "stdint.h" HAVE_STDINT_H_WITH_INTPTR) -#check_symbol_exists (intptr_t "unistdint.h" HAVE_UNISTD_H_WITH_INTPTR) - -#check_function_exists (__argz_count HAVE___ARGZ_COUNT) -#check_function_exists (__argz_next HAVE___ARGZ_NEXT) -#check_function_exists (__argz_stringify HAVE___ARGZ_STRINGIFY) -#check_function_exists (__fsetlocking HAVE___FSETLOCKING) -#check_function_exists (_close HAVE__CLOSE) -#check_function_exists (_dyld_func_lookup HAVE_DYLD) -#check_function_exists (_open HAVE__OPEN) -#check_function_exists (_pclose HAVE__PCLOSE) -#check_function_exists (_popen HAVE__POPEN) -#check_function_exists (argz_append HAVE_ARGZ_APPEND) -#check_function_exists (argz_create_sep HAVE_ARGZ_CREATE_SEP ) -#check_function_exists (argz_insert HAVE_ARGZ_INSERT ) -#check_function_exists (argz_next HAVE_ARGZ_NEXT) -#check_function_exists (argz_stringify HAVE_ARGZ_STRINGIFY ) -#check_function_exists (chmod HAVE_CHMOD) -#check_function_exists (clock_gettime HAVE_CLOCK_GETTIME) -#check_function_exists (close HAVE_CLOSE) -#check_function_exists (dcgettext HAVE_DCGETTEXT) -#check_function_exists (dladdr HAVE_DLADDR) -#check_function_exists (dlerror HAVE_DLERROR) -#check_function_exists (fcntl HAVE_FCNTL) -#check_function_exists (getcwd HAVE_GETCWD) -#check_function_exists (getegid HAVE_GETEGID) -#check_function_exists (getgid HAVE_GETGID) -#check_function_exists (gethrtime HAVE_GETHRTIME) -#check_function_exists (getpagesize HAVE_GETPAGESIZE) -#check_function_exists (gettext HAVE_GETTEXT) -#check_function_exists (getuid HAVE_GETUID) -#check_function_exists (getwd HAVE_GETWD) -#check_function_exists (index HAVE_INDEX) -#check_function_exists (mach_absolute_time HAVE_MACH_ABSOLUTE_TIME) -#check_function_exists (mempcpy HAVE_MEMPCPY) -#check_function_exists (mkfifo HAVE_MKFIFO) -#check_function_exists (mkstemp HAVE_MKSTEMP) -#check_function_exists (mktemp HAVE_MKTEMP) -#check_function_exists (mktime HAVE_MKTIME) -#check_function_exists (mmap HAVE_MMAP) -#check_function_exists (open HAVE_OPEN) -#check_function_exists (opendir HAVE_OPENDIR) -#check_function_exists (pclose HAVE_PCLOSE) -#check_function_exists (popen HAVE_POPEN) -#check_function_exists (putenv HAVE_PUTENV) -#check_function_exists (read_real_time HAVE_READ_REAL_TIME) -#check_function_exists (readdir HAVE_READDIR) -#check_function_exists (setlocale HAVE_SETLOCALE) -#check_function_exists (shl_load HAVE_SHL_LOAD) -#check_function_exists (stpcpy HAVE_STPCPY) -#check_function_exists (strcasecmp HAVE_STRCASECMP) -#check_function_exists (strcoll HAVE_STRCOLL) -#check_function_exists (strcspn HAVE_STRCSPN) -#check_function_exists (strcspn HAVE_STRERROR) -#check_function_exists (strdup HAVE_STRDUP) -#check_function_exists (strerror HAVE_STRERROR) -#check_function_exists (strftime HAVE_STRFTIME) -#check_function_exists (strlcat HAVE_STRLCAT) -#check_function_exists (strlcpy HAVE_STRLCPY) -#check_function_exists (strspn HAVE_STRSPN) -#check_function_exists (strstr HAVE_STRSTR) -#check_function_exists (strtod HAVE_STRTOD) -#check_function_exists (strtol HAVE_STRTOL) -#check_function_exists (strtoul HAVE_STRTOUL) -#check_function_exists (time_base_to_time HAVE_TIME_BASE_TO_TIME) -#check_function_exists (tsearch HAVE_TSEARCH) -#check_function_exists (vprintf HAVE_VPRINTF ) -#check_function_exists (wcslen HAVE_WCSLEN) -#check_include_file (argz.h HAVE_ARGZ_H) -#check_include_file (c_asm.h HAVE_C_ASM_H) -#check_include_file (dl.h HAVE_DL_H) -#check_include_file (dlfcn.h HAVE_DLADDR ) -#check_include_file (dlfcn.h HAVE_DLFCN_H) -#check_include_file (ffi.h HAVE_FFI_H) -#check_include_file (intrinsics.h HAVE_INTRINSICS_H) -#check_include_file (sys/time.h have_hrtime_t) -#check_include_file (mach-o/dyld.h HAVE_MACH_O_DYLD_H ) -#check_include_file (mach/mach_time.h HAVE_MACH_MACH_TIME_H) -#check_include_file (machine/endian.h HAVE_MACHINE_ENDIAN_H_) -#check_include_file (argz.h HAVE_ARGZ_H) -#check_include_file (io.h HAVE_IO_H) -#check_include_file (limits.h HAVE_LIMITS_H) -#check_include_file (locale.h HAVE_LOCALE_H) -#check_include_file (memory.h HAVE_MEMORY_H) -#check_include_file (ndir.h HAVE_NDIR_H) -#check_include_file (pthread.h HAVE_PTHREAD_H) -#check_include_file (stdlib.h HAVE_STDLIB_H) -#check_include_file (string.h HAVE_STRING_H) -#check_include_file (strings.h HAVE_STRINGS_H) -#check_include_file (sys/dl.h HAVE_SYS_DL_H ) -#check_include_file (sys/socket.h HAVE_SYS_SOCKET_H) -#check_include_file (sys/stat.h HAVE_SYS_STAT_H ) -#check_include_file (sys/stat.h HAVE_SYS_STAT_H) -#check_include_file (sys/time.h HAVE_SYS_TIME_H ) -#check_include_file (sys/time.h HAVE_SYS_TIME_H) -#check_include_file (sys/types.h HAVE_SYS_TYPES_H ) -#check_include_file (sys/types.h HAVE_SYS_TYPES_H) -#check_include_file (sys/utime.h HAVE_SYS_UTIME_H) -#check_include_file (utime.h HAVE_UTIME_H) -#check_library_exists (dl dl "/lib;/usr/lib;/usr/local/lib;/usr/pkg/lib" HAVE_LIBDL) -#check_symbol_exists (LC_MESSAGES "locale.h" HAVE_LC_MESSAGES) -#check_symbol_exists (asprintf "stdio.h" HAVE_ASPRINTF) -#check_symbol_exists (intmax_t "inttypes.h" HAVE_INTTYPES_H_WITH_UINTMAX) -#check_symbol_exists (pid_t "sys/types.h" HAVE_PID_T) -#check_symbol_exists (printf "stdio.h" HAVE_POSIX_PRINTF) -#check_symbol_exists (uintmax_t "stdint.h" HAVE_STDINT_H_WITH_UINTMAX) -#check_symbol_exists (wprintf "stdio.h" HAVE_WPRINTF) -#check_type_size ("long double" SIZEOF_LONG_DOUBLE) -#check_type_size ("long long" SIZEOF_LONG_LONG) -#check_type_size (char SIZEOF_CHAR) -#check_type_size (double SIZEOF_DOUBLE) -#check_type_size (float SIZEOF_FLOAT) -#check_type_size (int SIZEOF_INT) -#check_type_size (long SIZEOF_LONG) -#check_type_size (short SIZEOF_SHORT) - -if (NOT DEFINED STDC_HEADERS) - message (STATUS "Checking whether system has ANSI C header files") - check_include_files ("stdlib.h;stdarg.h;string.h;float.h" StandardHeadersExist) - if (StandardHeadersExist) - check_prototype_exists (memchr string.h memchrExists) - if (memchrExists) - check_prototype_exists (free stdlib.h freeExists) - if (freeExists) - #include (TestForHighBitCharacters) - #if (CMAKE_HIGH_BIT_CHARACTERS) - message (STATUS "ANSI C header files - found") - set (STDC_HEADERS 1 CACHE INTERNAL "System has ANSI C header files") - #endif (CMAKE_HIGH_BIT_CHARACTERS) - endif (freeExists) - endif (memchrExists) - endif (StandardHeadersExist) - if (NOT STDC_HEADERS) - message (STATUS "ANSI C header files - not found") - set (STDC_HEADERS 0 CACHE INTERNAL "System has ANSI C header files") - endif (NOT STDC_HEADERS) -endif (NOT DEFINED STDC_HEADERS) - -# Define to 1 if you can safely include both and -#if (HAVE_SYS_TIME_H) -# check_include_files ("sys/time.h;time.h" TIME_WITH_SYS_TIME) -#else (HAVE_SYS_TIME_H) -# set (TIME_WITH_SYS_TIME 0) -#endif (HAVE_SYS_TIME_H) - -# Define to 1 if your declares `struct tm'. */ -#check_type_exists ("struct tm" sys/time.h TM_IN_SYS_TIME) - -#check_cxx_source_compiles ( -# " -# #include -# using std::count; -# int countChar(char * b, char * e, char const c) -# { -# return count (b, e, c); -# } -# int main (){return 0;} -# " -#HAVE_STD_COUNT) - -#check_cxx_source_compiles ( -# " -# #include -# using std::tolower; -# int main (){return 0;} -# " -#CXX_GLOBAL_CSTD) - -# check_c_source_compiles ( -# " -# #include -# // this declaration will fail when there already exists a non const char** version which returns size_t -# double iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); -# int main () { return 0; } -# " -# HAVE_ICONV_CONST) -# -# check_c_source_compiles ( -# " -# #include -# int i[ ( sizeof(wchar_t)==2 ? 1 : -1 ) ]; -# int main (){return 0;} -# " -# SIZEOF_WCHAR_T_IS_2) -# -# check_c_source_compiles ( -# " -# #include -# int i[ ( sizeof(wchar_t)==4 ? 1 : -1 ) ]; -# int main (){return 0;} -# " -# SIZEOF_WCHAR_T_IS_4) - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/modules/CreateDebugSym.cmake b/cmake/modules/CreateDebugSym.cmake deleted file mode 100644 index dba50c8..0000000 --- a/cmake/modules/CreateDebugSym.cmake +++ /dev/null @@ -1,94 +0,0 @@ -# -# $Id: CreateDebugSym.cmake 11497 2013-05-16 22:31:09Z pwessel $ -# -# - Generates Mac .dSYM bundle -# CREATE_DEBUG_SYM ( TARGETS ) -# -# TARGETS - list of targets -# -# Copyright (c) 1991-2013 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe -# See LICENSE.TXT file for copying and redistribution conditions. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; version 3 or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# Contact info: gmt.soest.hawaii.edu -#------------------------------------------------------------------------------- - -set (_debug_build) -string(TOLOWER ${CMAKE_BUILD_TYPE} _build_type) -if (DEBUG_BUILD OR _build_type STREQUAL "relwithdebinfo") - set (_debug_build TRUE) -endif (DEBUG_BUILD OR _build_type STREQUAL "relwithdebinfo") - -if (APPLE AND _debug_build) - - # usefull macros - include (CustomHelperMacros) - - # Check for dsymutil only on Mac - find_program(DSYMUTIL dsymutil) - - # Macro for generating Mac debugging symbols - macro (CREATE_DEBUG_SYM _TARGETS) - if (DSYMUTIL AND "${CMAKE_GENERATOR}" MATCHES "Make") - - # generator - foreach (target ${ARGV}) # instead of _TARGETS we use ARGV to get all args - add_custom_command (TARGET ${target} - POST_BUILD - COMMAND ${DSYMUTIL} $ - COMMENT "Generating .dSYM bundle for ${target}" - VERBATIM - ) - endforeach (target) - - # create tag from current dirname - tag_from_current_source_dir (_tag "_") - - # clean target - add_custom_target (dsym_clean${_tag} - COMMAND ${RM} -rf *.dSYM - COMMENT "Removing .dSYM bundles") - - # register with spotless target - add_depend_to_spotless (dsym_clean${_tag}) - - endif (DSYMUTIL AND "${CMAKE_GENERATOR}" MATCHES "Make") - endmacro (CREATE_DEBUG_SYM _TARGETS) - -elseif (MSVC AND _debug_build) - # Macro for installing MSVC debugging symbol files - macro (CREATE_DEBUG_SYM _TARGETS) - foreach (target ${ARGV}) # instead of _TARGETS we use ARGV to get all args - install (FILES ${target}.pdb - DESTINATION ${GMT_BINDIR} - COMPONENT Debug - OPTIONAL) - endforeach (target) - - # create tag from current dirname - tag_from_current_source_dir (_tag "_") - - # clean target - add_custom_target (pdb_clean${_tag} - COMMAND ${CMAKE_COMMAND} remove *.pdb - COMMENT "Removing .pdb files") - - # register with spotless target - add_depend_to_spotless (_clean${_tag}) - endmacro (CREATE_DEBUG_SYM _TARGETS) - -else (APPLE AND _debug_build) - macro (CREATE_DEBUG_SYM _TARGETS) - # do nothing - endmacro (CREATE_DEBUG_SYM _TARGETS) -endif (APPLE AND _debug_build) - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/modules/CustomHelperMacros.cmake b/cmake/modules/CustomHelperMacros.cmake deleted file mode 100644 index 1c3af40..0000000 --- a/cmake/modules/CustomHelperMacros.cmake +++ /dev/null @@ -1,154 +0,0 @@ -# -# $Id: CustomHelperMacros.cmake 11761 2013-06-21 16:27:41Z pwessel $ -# -# - Useful CMake macros -# -# Copyright (c) 1991-2013 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe -# See LICENSE.TXT file for copying and redistribution conditions. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; version 3 or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# Contact info: gmt.soest.hawaii.edu -#------------------------------------------------------------------------------- - -# tag_from_current_source_dir (TAG [PREFIX]) -# add_depend_to_target (TARGET DEPEND [ DEPEND [ DEPEND ... ]]) -# add_depend_to_spotless (DEPEND [ DEPEND [ DEPEND ... ]]) -# add_file_to_cached_list (LIST [ FILE [ FILE ... ]]) -# get_subdir_var (VARIABLE VAR_NAME DIR [ DIR ... ]) -# get_subdir_var_files (VARIABLE VAR_NAME DIR [ DIR ... ]) -# install_module_symlink (MODULE [ MODULE ... ]) - -if(NOT DEFINED _CUSTOM_HELPER_MACROS_CMAKE_) - set(_CUSTOM_HELPER_MACROS_CMAKE_ "DEFINED") - - # tag_from_current_source_dir (TAG [PREFIX]) - # example: tag_from_current_source_dir (_tag "_") - macro (TAG_FROM_CURRENT_SOURCE_DIR _TAG) - get_filename_component (_basename ${CMAKE_CURRENT_SOURCE_DIR} NAME_WE) - string(COMPARE NOTEQUAL "${_basename}" "src" _in_subtree) - set (${_TAG}) - if (_in_subtree) - set (${_TAG} "${ARGN}${_basename}") - endif (_in_subtree) - endmacro (TAG_FROM_CURRENT_SOURCE_DIR) - - # add_depend_to_target (TARGET DEPEND [ DEPEND [ DEPEND ... ]]) - # example: add_depend_to_target (main_target custom_target) - macro (ADD_DEPEND_TO_TARGET _TARGET) - if(NOT TARGET ${_TARGET}) - add_custom_target (${_TARGET} - WORKING_DIRECTORY ${CUSTOM_BINARY_DIR}) - endif(NOT TARGET ${_TARGET}) - add_dependencies(${_TARGET} ${ARGN}) - endmacro (ADD_DEPEND_TO_TARGET) - - # add_depend_to_spotless (DEPEND [ DEPEND [ DEPEND ... ]]) - # example: add_depend_to_spotless (custom_target) - macro (ADD_DEPEND_TO_SPOTLESS) - if(NOT TARGET spotless) - add_custom_target (spotless - COMMAND make clean - WORKING_DIRECTORY ${CUSTOM_BINARY_DIR}) - endif(NOT TARGET spotless) - add_dependencies(spotless ${ARGV}) - endmacro (ADD_DEPEND_TO_SPOTLESS) - - # add_file_to_cached_list (LIST [ FILE [ FILE ... ]]) - # if FILE is omitted then the list is cleared - # if FILE is not absolute then it is assumed to be in CMAKE_CURRENT_SOURCE_DIR - # example: add_file_to_cached_list (list file) - macro (ADD_FILE_TO_CACHED_LIST _LIST) - set (_files ${ARGN}) - if (_files) - set (_files_abs) - foreach (_file ${_files}) - if (_file MATCHES "^[^/]") - # make absolute path - file(RELATIVE_PATH _file / ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) - endif () - list(APPEND _files_abs /${_file}) - endforeach (_file ${_files}) - # append to list - set (${_LIST} ${${_LIST}} ${_files_abs} - CACHE INTERNAL "Global list of files") - else (_theList) - # clear list - set (${_LIST} "" CACHE INTERNAL "Global list of files cleared") - endif (_files) - endmacro (ADD_FILE_TO_CACHED_LIST) - - # get_subdir_var (VARIABLE VAR_NAME DIR [ DIR ... ]) - # example: get_subdir_var (SUB_TARGETS PROGS ${SUB_DIRS}) - macro (GET_SUBDIR_VAR VARIABLE VAR_NAME DIR_NAME) - set (${VARIABLE}) # clear VARIABLE - foreach (_dir ${DIR_NAME} ${ARGN}) - # get value of variable ${VAR_NAME} in dir ${_dir}: - get_directory_property (_value DIRECTORY ${_dir} DEFINITION ${VAR_NAME}) - list (APPEND ${VARIABLE} "${_value}") - endforeach(_dir) - endmacro (GET_SUBDIR_VAR VARIABLE VAR_NAME DIR_NAME) - - # get_subdir_var_files (VARIABLE VAR_NAME DIR [ DIR ... ]) - # example: get_subdir_var_files (SUB_LIB_SRCS LIB_SRCS ${SUB_DIRS}) - macro (GET_SUBDIR_VAR_FILES VARIABLE VAR_NAME DIR_NAME) - set (${VARIABLE}) # clear VARIABLE - foreach (_dir ${DIR_NAME} ${ARGN}) - # get value of variable ${VAR_NAME} in dir ${_dir}: - get_directory_property (_files DIRECTORY ${_dir} DEFINITION ${VAR_NAME}) - foreach (_file ${_files}) - # prepend dirname: - list (APPEND ${VARIABLE} "${_dir}/${_file}") - endforeach (_file) - endforeach(_dir) - endmacro (GET_SUBDIR_VAR_FILES VARIABLE VAR_NAME DIR_NAME) - - # install_module_symlink (MODULE [ MODULE ... ]) - # example: install_module_symlink (grdimage psxy) - if (NOT INSTALL_MODULE_SYMLINK OR INSTALL_MODULE_SYMLINK) # If not defined or set to TRUE - set (DO_INSTALL_MODULE_LINKS TRUE) - endif () - macro (INSTALL_MODULE_SYMLINK) - if (WIN32 AND DO_INSTALL_MODULE_LINKS) - # create build targets - foreach (_custommodule ${ARGV}) - add_executable (${_custommodule} ${CUSTOM_PROGRAM}) - string (TOUPPER "${_custommodule}" UCASEname) - set_target_properties (${_custommodule} PROPERTIES - COMPILE_DEFINITIONS "MODULE=\"${_custommodule}\"" - LINK_FLAGS " /MANIFEST:NO") - target_link_libraries (${_custommodule} customlib) - endforeach (_custommodule) - - # add the install targets - install (TARGETS ${ARGV} - RUNTIME DESTINATION ${CUSTOM_BINDIR} - COMPONENT Runtime) - - # add to gmt_suppl target - add_depend_to_target (custom_module_progs ${ARGV}) - elseif (UNIX AND DO_INSTALL_MODULE_LINKS) - # create custom module symlinks to gmt - #get_target_property(CUSTOM_MAIN_NAME gmt OUTPUT_NAME) - file (RELATIVE_PATH _rpath /bin /${CUSTOM_BINDIR}/${CUSTOM_MAIN_NAME}) - foreach (_custommodule ${ARGV}) - install (CODE " - execute_process (COMMAND ${CMAKE_COMMAND} -E remove -f - \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CUSTOM_BINDIR}/${_custommodule}) - execute_process (COMMAND ${CMAKE_COMMAND} -E create_symlink - ${_rpath} \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CUSTOM_BINDIR}/${_custommodule}) - " COMPONENT Runtime) - endforeach (_custommodule) - endif (WIN32 AND DO_INSTALL_MODULE_LINKS) - endmacro (INSTALL_MODULE_SYMLINK) - -endif(NOT DEFINED _CUSTOM_HELPER_MACROS_CMAKE_) - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/modules/FindGDAL.cmake b/cmake/modules/FindGDAL.cmake index bc71b6b..33dc3e8 100644 --- a/cmake/modules/FindGDAL.cmake +++ b/cmake/modules/FindGDAL.cmake @@ -1,5 +1,4 @@ # -# $Id: FindGDAL.cmake 14889 2015-09-19 13:12:39Z remko $ # # Locate gdal # @@ -135,5 +134,3 @@ find_package_handle_standard_args (GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DI set (GDAL_LIBRARIES ${GDAL_LIBRARY}) set (GDAL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR}) - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/modules/FindGMT.cmake b/cmake/modules/FindGMT.cmake index 213f7e4..433ebaa 100644 --- a/cmake/modules/FindGMT.cmake +++ b/cmake/modules/FindGMT.cmake @@ -1,5 +1,4 @@ # -# $Id$ # # Locate GMT # @@ -25,7 +24,7 @@ # See COPYING-CMAKE-SCRIPTS for more information. #============================================================================= -# This makes the presumption that you are include gmt.h like +# This makes the presumption that you include gmt.h like # #include "gmt.h" @@ -43,6 +42,7 @@ if (UNIX AND NOT GMT_FOUND) /opt/local # DarwinPorts /opt/csw # Blastwave /opt + /usr/local ) if (GMT_CONFIG) @@ -50,18 +50,20 @@ if (UNIX AND NOT GMT_FOUND) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE GMT_CONFIG_CFLAGS) if (GMT_CONFIG_CFLAGS) - string (REGEX MATCHALL "-I[^ ]+" _gmt_dashI ${GMT_CONFIG_CFLAGS}) - string (REGEX REPLACE "-I" "" _gmt_includepath "${_gmt_dashI}") - string (REGEX REPLACE "-I[^ ]+" "" _gmt_cflags_other ${GMT_CONFIG_CFLAGS}) + string (REGEX MATCHALL "(^| )-I[^ ]+" _gmt_dashI ${GMT_CONFIG_CFLAGS}) + string (REGEX REPLACE "(^| )-I" "" _gmt_includepath "${_gmt_dashI}") + string (REGEX REPLACE "(^| )-I[^ ]+" "" _gmt_cflags_other ${GMT_CONFIG_CFLAGS}) endif (GMT_CONFIG_CFLAGS) execute_process (COMMAND ${GMT_CONFIG} --libs ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE GMT_CONFIG_LIBS) if (GMT_CONFIG_LIBS) - string (REGEX MATCHALL "-l[^ ]+" _gmt_dashl ${GMT_CONFIG_LIBS}) - string (REGEX REPLACE "-l" "" _gmt_lib "${_gmt_dashl}") - string (REGEX MATCHALL "-L[^ ]+" _gmt_dashL ${GMT_CONFIG_LIBS}) - string (REGEX REPLACE "-L" "" _gmt_libpath "${_gmt_dashL}") + # Ensure -l is precedeced by whitespace to not match + # '-l' in '-L/usr/lib/x86_64-linux-gnu/hdf5/serial' + string (REGEX MATCHALL "(^| )-l[^ ]+" _gmt_dashl ${GMT_CONFIG_LIBS}) + string (REGEX REPLACE "(^| )-l" "" _gmt_lib "${_gmt_dashl}") + string (REGEX MATCHALL "(^| )-L[^ ]+" _gmt_dashL ${GMT_CONFIG_LIBS}) + string (REGEX REPLACE "(^| )-L" "" _gmt_libpath "${_gmt_dashL}") endif (GMT_CONFIG_LIBS) endif (GMT_CONFIG) if (_gmt_lib) @@ -85,6 +87,7 @@ find_path (GMT_INCLUDE_DIR gmt.h /opt/local # DarwinPorts /opt/csw # Blastwave /opt + /usr/local ) find_library (GMT_LIBRARY @@ -95,12 +98,13 @@ find_library (GMT_LIBRARY ${GMT_ROOT} $ENV{GMT_DIR} $ENV{GMT_ROOT} - PATH_SUFFIXES lib64 lib + PATH_SUFFIXES lib PATHS /sw /opt/local /opt/csw /opt + /usr/local ) # find all libs that gmt-config reports @@ -113,10 +117,8 @@ endforeach (_extralib) include (FindPackageHandleStandardArgs) find_package_handle_standard_args (GMT - DEFAULT_MSG GMT_LIBRARY GMT_INCLUDE_DIR) + DEFAULT_MSG GMT_LIBRARY GMT_INCLUDE_DIR) set (GMT_LIBRARIES ${GMT_LIBRARY}) set (GMT_INCLUDE_DIRS ${GMT_INCLUDE_DIR}) string (REPLACE "-DNDEBUG" "" GMT_DEFINITIONS "${_gmt_cflags_other}") - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/modules/FindNETCDF.cmake b/cmake/modules/FindNETCDF.cmake index f1f7613..c0183dd 100644 --- a/cmake/modules/FindNETCDF.cmake +++ b/cmake/modules/FindNETCDF.cmake @@ -1,5 +1,4 @@ # -# $Id: FindNETCDF.cmake 14889 2015-09-19 13:12:39Z remko $ # # Locate netcdf # @@ -140,5 +139,3 @@ find_package_handle_standard_args (NETCDF set (NETCDF_LIBRARIES ${NETCDF_LIBRARY}) set (NETCDF_INCLUDE_DIRS ${NETCDF_INCLUDE_DIR}) string (REPLACE "-DNDEBUG" "" NETCDF_DEFINITIONS "${_netcdf_cflags_other}") - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/modules/ManageString.cmake b/cmake/modules/ManageString.cmake deleted file mode 100644 index e39deef..0000000 --- a/cmake/modules/ManageString.cmake +++ /dev/null @@ -1,481 +0,0 @@ -# -# $Id: ManageString.cmake 10318 2012-06-28 22:14:48Z remko $ -# -# - Collection of String utility macros. -# Defines the following macros: -# STRING_ESCAPE(var str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE]) -# - Encode characters that would be expanded '\', ';', '$', '#' -# * Parameters: -# + var: A variable that stores the result. -# + str: The NAME of a variable that holds the string. -# + NOESCAPE_SEMICOLON: (Optional) Do not escape semicolons. -# + ESCAPE_VARIABLE: (Optional) Also escape '$' -# -# STRING_UNESCAPE(var str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE]) -# - Decode '\', ';', '$', '#', the reverse of STRING_ESCAPE -# * Parameters: -# + var: A variable that stores the result. -# + str: The encoded string -# + NOESCAPE_SEMICOLON: (Optional) Do not decode semicolons. -# + ESCAPE_VARIABLE: (Optional) Also decode '$' -# -# STRING_UNQUOTE(var str) -# - Remove double quote marks and quote marks around a string. -# * Parameters: -# + var: A variable that stores the result. -# + str: The NAME of a variable that holds the string. -# -# STRING_JOIN(var delimiter str_list [str...]) -# - Concatenate strings, with delimiter inserted between strings. -# * Parameters: -# + var: A variable that stores the result. -# + str_list: A list of string. -# + str: (Optional) more string to be join. -# -# STRING_SPLIT(var delimiter str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE] [NOENCODE]) -# - Split a string into a list using a delimiter, which can be in 1 or more -# characters long. -# * Parameters: -# + var: A variable that stores the result. -# + delimiter: The NAME of a variable that holds the delimiter. -# + str: The NAME of a variable that holds the string to split. -# + NOESCAPE_SEMICOLON: (Optional) Do not escape semicolons. -# + NOENCODE: (Optional) Do not encode/decode string -# -# FILE2LIST (var filename [filename...]) -# - Read a file to list, escape '#', '\' and ';' -# * Parameters: -# + var: A variable that stores the list. -# + filename: Files to read -# -# GREP (pattern var filename [filename...] [LITERALLY] [INVERT]) -# - Read a file to list, escape '#', '\' and ';' -# * Parameters: -# + pattern: Regex to match -# + var: A variable that stores the matching lines. -# + filename: Files to read -# + LITERALLY: (Optional) Match the pattern string literally -# + INVERT: (Optional) Invert match -# -# LIST_REGEX_REPLACE ( -# [...] [MATCHES_ONLY] [STRIP]) -# - Do REGEX REPLACE for each lelement of list individually. -# * Parameters: -# + MATCHES_ONLY: (Optional) Return only matched elements in output list -# + STRIP: (Optional) Strip whitespace of each element in output list -# -# LIST_REGEX_GET ( -# [...] [INVERT]) -# - Return list with matched elements. -# * Parameters: -# + INVERT: (Optional) invert the selection -# -# STRING_PAD (string length [RIGHT] [PADDING]) -# - Pad a string with spaces to the given length. String will be left -# aligned. -# * Parameters: -# + RIGHT: (Optional) right-align the string -# + PADDING: (Optional) apply padding at the location by the marker -# string PADDING -# -# Copyright (c) 1991-2012 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe -# See LICENSE.TXT file for copying and redistribution conditions. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; version 3 or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# Contact info: gmt.soest.hawaii.edu -#------------------------------------------------------------------------------- - -if(NOT DEFINED _MANAGE_STRING_CMAKE_) - set(_MANAGE_STRING_CMAKE_ "DEFINED") - - # STRING_ESCAPE(var str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE]) - macro(STRING_ESCAPE var str) - # ';' and '\' are tricky, need to be encoded. - # '#' => '#H' - # '$' => '#D' - # ';' => '#S' - # '\' => '#B' - # '|' => '#P' - set(_ESCAPE_VARIABLE) - set(_NOESCAPE_SEMICOLON) - string(REPLACE "#" "#H" _ret "${${str}}") - string(REPLACE "\\" "#B" _ret "${_ret}") - #string(REPLACE "|" "#P" _ret "${_ret}") - foreach(_arg ${ARGN}) - if(${_arg} STREQUAL "NOESCAPE_SEMICOLON") - set(_NOESCAPE_SEMICOLON "NOESCAPE_SEMICOLON") - elseif(${_arg} STREQUAL "ESCAPE_VARIABLE") - set(_ESCAPE_VARIABLE "ESCAPE_VARIABLE") - string(REPLACE "$" "#D" _ret "${_ret}") - endif(${_arg} STREQUAL "NOESCAPE_SEMICOLON") - endforeach(_arg) - if(NOT _NOESCAPE_SEMICOLON) - string(REPLACE ";" "#S" _ret "${_ret}") - endif(NOT _NOESCAPE_SEMICOLON) - set(${var} "${_ret}") - endmacro(STRING_ESCAPE var str) - - # STRING_UNESCAPE(var str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE]) - macro(STRING_UNESCAPE var str) - # '#B' => '\' - # '#D' => '$' - # '#H' => '#' - # '#P' => '|' - # '#S' => ';' - set(_ESCAPE_VARIABLE) - set(_NOESCAPE_SEMICOLON) - set(_ret "${str}") - foreach(_arg ${ARGN}) - if(${_arg} STREQUAL "NOESCAPE_SEMICOLON") - set(_NOESCAPE_SEMICOLON "NOESCAPE_SEMICOLON") - elseif(${_arg} STREQUAL "ESCAPE_VARIABLE") - set(_ESCAPE_VARIABLE "ESCAPE_VARIABLE") - string(REPLACE "#D" "$" _ret "${_ret}") - endif(${_arg} STREQUAL "NOESCAPE_SEMICOLON") - endforeach(_arg) - - if(_NOESCAPE_SEMICOLON) - # ';' => '#s' - string(REPLACE "#S" ";" _ret "${_ret}") - else(_NOESCAPE_SEMICOLON) - string(REPLACE "#S" "\\;" _ret "${_ret}") - endif(_NOESCAPE_SEMICOLON) - - if(_ESCAPE_VARIABLE) - # '#d' => '$' - string(REPLACE "#D" "$" _ret "${_ret}") - endif(_ESCAPE_VARIABLE) - #string(REPLACE "#P" "|" _ret "${_ret}") - string(REPLACE "#B" "\\" _ret "${_ret}") - string(REPLACE "#H" "#" _ret "${_ret}") - set(${var} "${_ret}") - endmacro(STRING_UNESCAPE var str) - - # STRING_UNQUOTE(var str) - macro(STRING_UNQUOTE var str) - # escape special chars - string_escape(_str ${str} NOESCAPE_SEMICOLON) - - if(_str MATCHES "^[ \t\r\n]+") - string(REGEX REPLACE "^[ \t\r\n]+" "" _str "${_str}") - endif(_str MATCHES "^[ \t\r\n]+") - if(_str MATCHES "^\"") - # double quote - string(REGEX REPLACE "\"\(.*\)\"[ \t\r\n]*$" "\\1" _str "${_str}") - elseif(_str MATCHES "^'") - # single quote - string(REGEX REPLACE "'\(.*\)'[ \t\r\n]*$" "\\1" _str "${_str}") - else(_str MATCHES "^\"") - set(_str) - endif(_str MATCHES "^\"") - - # unencoding - string_unescape(${var} "${_str}" NOESCAPE_SEMICOLON) - endmacro(STRING_UNQUOTE _var _str) - - # STRING_JOIN(var delimiter str_list [str...]) - macro(STRING_JOIN var delimiter str_list) - set(_ret) - foreach(_str ${str_list}) - if(_ret) - set(_ret "${_ret}${delimiter}${_str}") - else(_ret) - set(_ret "${_str}") - endif(_ret) - endforeach(_str ${str_list}) - - foreach(_str ${ARGN}) - if(_ret) - set(_ret "${_ret}${delimiter}${_str}") - else(_ret) - set(_ret "${_str}") - endif(_ret) - endforeach(_str ${str_list}) - set(${var} "${_ret}") - endmacro(STRING_JOIN var delimiter str_list) - - # STRING_SPLIT(var delimiter str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE] [NOENCODE]) - macro(STRING_SPLIT var delimiter str) - set(_max_tokens) - set(_NOESCAPE_SEMICOLON) - set(_ESCAPE_VARIABLE) - set(_NOENCODE) - foreach(_arg ${ARGN}) - if(${_arg} STREQUAL "NOESCAPE_SEMICOLON") - set(_NOESCAPE_SEMICOLON "NOESCAPE_SEMICOLON") - elseif(${_arg} STREQUAL "ESCAPE_VARIABLE") - set(_ESCAPE_VARIABLE "ESCAPE_VARIABLE") - elseif(${_arg} STREQUAL "NOENCODE") - set(_NOENCODE "NOENCODE") - else(${_arg} STREQUAL "NOESCAPE_SEMICOLON") - set(_max_tokens ${_arg}) - endif(${_arg} STREQUAL "NOESCAPE_SEMICOLON") - endforeach(_arg) - - if(NOT _max_tokens) - set(_max_tokens -1) - endif(NOT _max_tokens) - - if(_NOENCODE) - set(_str ${${str}}) - set(_delimiter ${${delimiter}}) - else(_NOENCODE) - string_escape(_str ${str} ${_NOESCAPE_SEMICOLON} ${_ESCAPE_VARIABLE}) - string_escape(_delimiter ${delimiter} ${_NOESCAPE_SEMICOLON} ${_ESCAPE_VARIABLE}) - endif(_NOENCODE) - - set(_str_list) - set(_token_count 0) - string(LENGTH "${_delimiter}" _de_len) - - while(NOT _token_count EQUAL _max_tokens) - math(EXPR _token_count ${_token_count}+1) - if(_token_count EQUAL _max_tokens) - # last token, no need splitting - set(_str_list ${_str_list} "${_str}") - else(_token_count EQUAL _max_tokens) - # in case encoded characters are delimiters - string(LENGTH "${_str}" _str_len) - set(_index 0) - set(_token) - set(_str_remain) - math(EXPR _str_end ${_str_len}-${_de_len}+1) - set(_bound "k") - while(_index LESS _str_end) - string(SUBSTRING "${_str}" ${_index} ${_de_len} _str_cursor) - if(_str_cursor STREQUAL _delimiter) - # get the token - string(SUBSTRING "${_str}" 0 ${_index} _token) - # get the rest - math(EXPR _rest_index ${_index}+${_de_len}) - math(EXPR _rest_len ${_str_len}-${_index}-${_de_len}) - string(SUBSTRING "${_str}" ${_rest_index} ${_rest_len} _str_remain) - set(_index ${_str_end}) - else(_str_cursor STREQUAL _delimiter) - math(EXPR _index ${_index}+1) - endif(_str_cursor STREQUAL _delimiter) - endwhile(_index LESS _str_end) - - if(_str_remain) - list(APPEND _str_list "${_token}") - set(_str "${_str_remain}") - else(_str_remain) - # meaning: end of string - list(APPEND _str_list "${_str}") - set(_max_tokens ${_token_count}) - endif(_str_remain) - endif(_token_count EQUAL _max_tokens) - endwhile(NOT _token_count EQUAL _max_tokens) - - if(_NOENCODE) - set(${var} "${_str_list}") - else(_NOENCODE) - # unencoding - string_unescape(${var} "${_str_list}" ${_NOESCAPE_SEMICOLON} ${_ESCAPE_VARIABLE}) - endif(_NOENCODE) - endmacro(STRING_SPLIT var delimiter str) - - # FILE2LIST (var filename [filename...]) - macro (FILE2LIST _OUT _FILE) - set(${_OUT}) # clear - if (NOT FILESIZE_LIMIT) - # default: read max 512KiB - set(FILESIZE_LIMIT 524288) - endif (NOT FILESIZE_LIMIT) - foreach (_file ${_FILE} ${ARGN}) - file (READ ${_file} _file_content LIMIT ${FILESIZE_LIMIT}) - string_escape (_file_content _file_content) # ; -> #S and \ -> #B - # strip trainling "\n" and convert to list - string (REGEX REPLACE "\n+$" "" _file_content ${_file_content}) - string (REPLACE "\n" ";" _file_content ${_file_content}) - list(APPEND ${_OUT} "${_file_content}") # quotes -> also append empty lines - endforeach (_file ${_FILE} ${ARGN}) - endmacro (FILE2LIST _OUT _FILE) - - # HEAD (string): print at most 80 chars of a string - macro (HEAD _STR) - string(LENGTH "${_STR}" _len) - if (_len GREATER 80) - set(_len 80) - endif () - string(SUBSTRING "${_STR}" 0 ${_len} _prn) - message("H> ${_prn}") - endmacro (HEAD _STR) - - # GREP (pattern var filename [filename...] [LITERALLY] [INVERT]) - macro (GREP _PATTERN _OUT _FILE) - set (_args ${ARGN}) - list (FIND _args "LITERALLY" _LITERALLY) - if (_LITERALLY EQUAL -1) - set(_LITERALLY) - else(_LITERALLY EQUAL -1) - set(_LITERALLY TRUE) - list(REMOVE_ITEM _args "LITERALLY") - endif(_LITERALLY EQUAL -1) - list (FIND _args "INVERT" _INVERT) - if (_INVERT EQUAL -1) - set(_INVERT) - else(_INVERT EQUAL -1) - set(_INVERT TRUE) - list(REMOVE_ITEM _args "INVERT") - endif(_INVERT EQUAL -1) - - set(_matches) - foreach (_file ${_FILE} ${_args}) - file2list (_list ${_file}) - foreach (_line IN LISTS _list) - #message("i> ${_line}") - set(_ismatching) - if (_LITERALLY) - string(FIND "${_line}" ${_PATTERN} _position) - if (_position GREATER 0) - set(_ismatching TRUE) - endif () - else (_LITERALLY) - string(REGEX MATCH ${_PATTERN} _ismatching "${_line}") - endif (_LITERALLY) - if ((_ismatching AND NOT _INVERT) OR (NOT _ismatching AND _INVERT)) - list (APPEND _matches "${_line}") - endif () - #message("f> ${_file}") - #head(${_line}) - endforeach (_line) - endforeach (_file) - set (${_OUT} "${_matches}") - #message("p: ${_PATTERN}") - endmacro(GREP _PATTERN _OUT _FILE) - - # LIST_REGEX_REPLACE ( [...]) - # Note: have to double all escapes! - macro (LIST_REGEX_REPLACE _REGEX _REP _OUT _LIST) - #message("pattern: \"${_REGEX}\"") - set (_args ${ARGN}) - list (FIND _args "MATCHES_ONLY" _MATCHES_ONLY) - if (_MATCHES_ONLY EQUAL -1) - set(_MATCHES_ONLY) - else(_MATCHES_ONLY EQUAL -1) - set(_MATCHES_ONLY TRUE) - list(REMOVE_ITEM _args "MATCHES_ONLY") - endif(_MATCHES_ONLY EQUAL -1) - list (FIND _args "STRIP" _STRIP) - if (_STRIP EQUAL -1) - set(_STRIP) - else(_STRIP EQUAL -1) - set(_STRIP TRUE) - list(REMOVE_ITEM _args "STRIP") - endif(_STRIP EQUAL -1) - - set(${_OUT}) - foreach (_line ${_LIST} ${_args}) - string (REGEX REPLACE - "${_REGEX}" - "${_REP}" _replacement ${_line}) - if (_MATCHES_ONLY AND (_replacement STREQUAL _line)) - set(_replacement) - endif () - if (_STRIP) - string (STRIP "${_replacement}" _replacement) - endif (_STRIP) - list (APPEND ${_OUT} ${_replacement}) - #head("l: ${_line}") - #head("r: ${_replacement}") - endforeach (_line ${_LIST} ${_args}) - endmacro (LIST_REGEX_REPLACE _REGEX _REP _OUT _LIST) - - # LIST_REGEX_GET ( [...]) - # Note: have to double all escapes! - macro (LIST_REGEX_GET _REGEX _OUT _LIST) - #message("pattern: ${_REGEX}") - set (_args ${ARGN}) - list (FIND _args "INVERT" _INVERT) - if (_INVERT EQUAL -1) - set(_INVERT) - else(_INVERT EQUAL -1) - set(_INVERT TRUE) - list(REMOVE_ITEM _args "INVERT") - endif(_INVERT EQUAL -1) - - set(${_OUT}) - foreach (_line ${_LIST} ${_args}) - set(_ismatching) - string(REGEX MATCH ${_REGEX} _ismatching ${_line}) - if ((_ismatching AND NOT _INVERT) OR (NOT _ismatching AND _INVERT)) - list (APPEND ${_OUT} ${_line}) - endif () - endforeach (_line ${_LIST} ${_args}) - endmacro (LIST_REGEX_GET _REGEX _OUT _LIST) - - # STRING_PAD (string length): pad a string with spaces to the given length - macro (STRING_PAD _STR _LEN) - set (_args ${ARGN}) - list (FIND _args "RIGHT" _RIGHT) - if (_RIGHT EQUAL -1) - set (_RIGHT) - else (_RIGHT EQUAL -1) - set (_RIGHT TRUE) - list (REMOVE_ITEM _args "RIGHT") - endif (_RIGHT EQUAL -1) - - # get maker string, split string at marker, - # and make woring copy - list (LENGTH _args _padding) - if (_padding) - list(GET _args 0 _padding) - string_split (_split _padding ${_STR} - NOESCAPE_SEMICOLON - NOENCODE) - if (_RIGHT) - # need to right align 2nd part - list (GET _split 1 _copy) - else (_RIGHT) - # left align 1st part - list (GET _split 0 _copy) - endif (_RIGHT) - else (_padding) - # no marker: copy complete string - set (_copy ${${_STR}}) - endif (_padding) - - string (LENGTH ${_copy} _orig_len) - if (_orig_len LESS ${_LEN}) - set (_big_space " ") - if (_RIGHT) - # right align: prepend space - math (EXPR _extra_len "${_LEN} - ${_orig_len}") - string (SUBSTRING ${_big_space} 0 ${_extra_len} _extra_space) - set (_copy "${_extra_space}${_copy}") - else (_RIGHT) - # left align: append space - set (_big_str "${_copy}${_big_space}") - string (SUBSTRING ${_big_str} 0 ${_LEN} _copy) - endif (_RIGHT) - endif (_orig_len LESS ${_LEN}) - - # join split string - if (_padding) - if (_RIGHT) - # join copy w 1st part - list (GET _split 0 _part) - set (_copy "${_part}${_copy}") - else (_RIGHT) - # join copy w 2nd part - list (GET _split 1 _part) - set (_copy "${_copy}${_part}") - endif (_RIGHT) - endif (_padding) - - # replace string with working copy - set (${_STR} ${_copy}) - endmacro (STRING_PAD _STR _LEN) - -endif(NOT DEFINED _MANAGE_STRING_CMAKE_) - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/modules/NSIS.InstallOptions.ini.in b/cmake/modules/NSIS.InstallOptions.ini.in deleted file mode 100644 index 2c65d31..0000000 --- a/cmake/modules/NSIS.InstallOptions.ini.in +++ /dev/null @@ -1,46 +0,0 @@ -[Settings] -NumFields=5 - -[Field 1] -Type=label -Text=By default @CPACK_PACKAGE_NAME@ adds its library directory to the system PATH. -Left=0 -Right=-1 -Top=0 -Bottom=20 - -[Field 2] -Type=radiobutton -Text=Add @CPACK_PACKAGE_NAME@ to the system PATH for all users -Left=0 -Right=-1 -Top=30 -Bottom=40 -State=1 - -[Field 3] -Type=radiobutton -Text=Add @CPACK_PACKAGE_NAME@ to the system PATH for current user -Left=0 -Right=-1 -Top=40 -Bottom=50 -State=0 - -[Field 4] -Type=radiobutton -Text=Do not add @CPACK_PACKAGE_NAME@ to the system PATH -Left=0 -Right=-1 -Top=50 -Bottom=60 -State=0 - -[Field 5] -Type=CheckBox -Text=Create @CPACK_PACKAGE_NAME@ Desktop Icon -Left=0 -Right=-1 -Top=80 -Bottom=90 -State=0 diff --git a/cmake/modules/NSIS.template.in b/cmake/modules/NSIS.template.in deleted file mode 100644 index 917c43b..0000000 --- a/cmake/modules/NSIS.template.in +++ /dev/null @@ -1,1205 +0,0 @@ -; CPack install script designed for a nmake build - -;-------------------------------- -; You must define these values - - !define VERSION "@CPACK_PACKAGE_VERSION@" - !define PATCH "@CPACK_PACKAGE_VERSION_PATCH@" - !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@" - -;-------------------------------- -;Variables - - Var MUI_TEMP - Var STARTMENU_FOLDER - Var SV_ALLUSERS - Var START_MENU - Var DO_NOT_ADD_TO_PATH - Var ADD_TO_PATH_ALL_USERS - Var ADD_TO_PATH_CURRENT_USER - Var INSTALL_DESKTOP - Var IS_DEFAULT_INSTALLDIR -;-------------------------------- -;Include Modern UI - - !include "MUI.nsh" - - ;Default installation folder - InstallDir "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" - -;-------------------------------- -;General - - ;Name and file - Name "@CPACK_NSIS_PACKAGE_NAME@" - OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@" - - ;Set compression - SetCompressor @CPACK_NSIS_COMPRESSOR@ - -@CPACK_NSIS_DEFINES@ - - !include Sections.nsh - -;--- Component support macros: --- -; The code for the add/remove functionality is from: -; http://nsis.sourceforge.net/Add/Remove_Functionality -; It has been modified slightly and extended to provide -; inter-component dependencies. -Var AR_SecFlags -Var AR_RegFlags -@CPACK_NSIS_SECTION_SELECTED_VARS@ - -; Loads the "selected" flag for the section named SecName into the -; variable VarName. -!macro LoadSectionSelectedIntoVar SecName VarName - SectionGetFlags ${${SecName}} $${VarName} - IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits -!macroend - -; Loads the value of a variable... can we get around this? -!macro LoadVar VarName - IntOp $R0 0 + $${VarName} -!macroend - -; Sets the value of a variable -!macro StoreVar VarName IntValue - IntOp $${VarName} 0 + ${IntValue} -!macroend - -!macro InitSection SecName - ; This macro reads component installed flag from the registry and - ;changes checked state of the section on the components page. - ;Input: section index constant name specified in Section command. - - ClearErrors - ;Reading component status from registry - ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed" - IfErrors "default_${SecName}" - ;Status will stay default if registry value not found - ;(component was never installed) - IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits - SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags - IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off - IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit - - ; Note whether this component was installed before - !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags - IntOp $R0 $AR_RegFlags & $AR_RegFlags - - ;Writing modified flags - SectionSetFlags ${${SecName}} $AR_SecFlags - - "default_${SecName}:" - !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected -!macroend - -!macro FinishSection SecName - ; This macro reads section flag set by user and removes the section - ;if it is not selected. - ;Then it writes component installed flag to registry - ;Input: section index constant name specified in Section command. - - SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags - ;Checking lowest bit: - IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED} - IntCmp $AR_SecFlags 1 "leave_${SecName}" - ;Section is not selected: - ;Calling Section uninstall macro and writing zero installed flag - !insertmacro "Remove_${${SecName}}" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \ - "Installed" 0 - Goto "exit_${SecName}" - - "leave_${SecName}:" - ;Section is selected: - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \ - "Installed" 1 - - "exit_${SecName}:" -!macroend - -!macro RemoveSection SecName - ; This macro is used to call section's Remove_... macro - ;from the uninstaller. - ;Input: section index constant name specified in Section command. - - !insertmacro "Remove_${${SecName}}" -!macroend - -; Determine whether the selection of SecName changed -!macro MaybeSelectionChanged SecName - !insertmacro LoadVar ${SecName}_selected - SectionGetFlags ${${SecName}} $R1 - IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits - - ; See if the status has changed: - IntCmp $R0 $R1 "${SecName}_unchanged" - !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected - - IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected" - !insertmacro "Deselect_required_by_${SecName}" - goto "${SecName}_unchanged" - - "${SecName}_was_selected:" - !insertmacro "Select_${SecName}_depends" - - "${SecName}_unchanged:" -!macroend -;--- End of Add/Remove macros --- - -;-------------------------------- -;Interface Settings - - !define MUI_HEADERIMAGE - !define MUI_ABORTWARNING - -;-------------------------------- -; path functions - -!verbose 3 -!include "WinMessages.NSH" -!verbose 4 - -;---------------------------------------- -; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02" -;---------------------------------------- -!verbose 3 -!include "WinMessages.NSH" -!verbose 4 -;==================================================== -; get_NT_environment -; Returns: the selected environment -; Output : head of the stack -;==================================================== -!macro select_NT_profile UN -Function ${UN}select_NT_profile - StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single - DetailPrint "Selected environment for all users" - Push "all" - Return - environment_single: - DetailPrint "Selected environment for current user only." - Push "current" - Return -FunctionEnd -!macroend -!insertmacro select_NT_profile "" -!insertmacro select_NT_profile "un." -;---------------------------------------------------- -!define NT_current_env 'HKCU "Environment"' -!define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' - -!ifndef WriteEnvStr_RegKey - !ifdef ALL_USERS - !define WriteEnvStr_RegKey \ - 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' - !else - !define WriteEnvStr_RegKey 'HKCU "Environment"' - !endif -!endif - -; AddToPath - Adds the given dir to the search path. -; Input - head of the stack -; Note - Win9x systems requires reboot - -Function AddToPath - Exch $0 - Push $1 - Push $2 - Push $3 - - # don't add if the path doesn't exist - IfFileExists "$0\*.*" "" AddToPath_done - - ReadEnvStr $1 PATH - ; if the path is too long for a NSIS variable NSIS will return a 0 - ; length string. If we find that, then warn and skip any path - ; modification as it will trash the existing path. - StrLen $2 $1 - IntCmp $2 0 CheckPathLength_ShowPathWarning CheckPathLength_Done CheckPathLength_Done - CheckPathLength_ShowPathWarning: - Messagebox MB_OK|MB_ICONEXCLAMATION "Warning! PATH too long installer unable to modify PATH!" - Goto AddToPath_done - CheckPathLength_Done: - Push "$1;" - Push "$0;" - Call StrStr - Pop $2 - StrCmp $2 "" "" AddToPath_done - Push "$1;" - Push "$0\;" - Call StrStr - Pop $2 - StrCmp $2 "" "" AddToPath_done - GetFullPathName /SHORT $3 $0 - Push "$1;" - Push "$3;" - Call StrStr - Pop $2 - StrCmp $2 "" "" AddToPath_done - Push "$1;" - Push "$3\;" - Call StrStr - Pop $2 - StrCmp $2 "" "" AddToPath_done - - Call IsNT - Pop $1 - StrCmp $1 1 AddToPath_NT - ; Not on NT - StrCpy $1 $WINDIR 2 - FileOpen $1 "$1\autoexec.bat" a - FileSeek $1 -1 END - FileReadByte $1 $2 - IntCmp $2 26 0 +2 +2 # DOS EOF - FileSeek $1 -1 END # write over EOF - FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n" - FileClose $1 - SetRebootFlag true - Goto AddToPath_done - - AddToPath_NT: - StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey - ReadRegStr $1 ${NT_current_env} "PATH" - Goto DoTrim - ReadAllKey: - ReadRegStr $1 ${NT_all_env} "PATH" - DoTrim: - StrCmp $1 "" AddToPath_NTdoIt - Push $1 - Call Trim - Pop $1 - StrCpy $0 "$1;$0" - AddToPath_NTdoIt: - StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey - WriteRegExpandStr ${NT_current_env} "PATH" $0 - Goto DoSend - WriteAllKey: - WriteRegExpandStr ${NT_all_env} "PATH" $0 - DoSend: - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - AddToPath_done: - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - - -; RemoveFromPath - Remove a given dir from the path -; Input: head of the stack - -Function un.RemoveFromPath - Exch $0 - Push $1 - Push $2 - Push $3 - Push $4 - Push $5 - Push $6 - - IntFmt $6 "%c" 26 # DOS EOF - - Call un.IsNT - Pop $1 - StrCmp $1 1 unRemoveFromPath_NT - ; Not on NT - StrCpy $1 $WINDIR 2 - FileOpen $1 "$1\autoexec.bat" r - GetTempFileName $4 - FileOpen $2 $4 w - GetFullPathName /SHORT $0 $0 - StrCpy $0 "SET PATH=%PATH%;$0" - Goto unRemoveFromPath_dosLoop - - unRemoveFromPath_dosLoop: - FileRead $1 $3 - StrCpy $5 $3 1 -1 # read last char - StrCmp $5 $6 0 +2 # if DOS EOF - StrCpy $3 $3 -1 # remove DOS EOF so we can compare - StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine - StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine - StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine - StrCmp $3 "" unRemoveFromPath_dosLoopEnd - FileWrite $2 $3 - Goto unRemoveFromPath_dosLoop - unRemoveFromPath_dosLoopRemoveLine: - SetRebootFlag true - Goto unRemoveFromPath_dosLoop - - unRemoveFromPath_dosLoopEnd: - FileClose $2 - FileClose $1 - StrCpy $1 $WINDIR 2 - Delete "$1\autoexec.bat" - CopyFiles /SILENT $4 "$1\autoexec.bat" - Delete $4 - Goto unRemoveFromPath_done - - unRemoveFromPath_NT: - StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey - ReadRegStr $1 ${NT_current_env} "PATH" - Goto unDoTrim - unReadAllKey: - ReadRegStr $1 ${NT_all_env} "PATH" - unDoTrim: - StrCpy $5 $1 1 -1 # copy last char - StrCmp $5 ";" +2 # if last char != ; - StrCpy $1 "$1;" # append ; - Push $1 - Push "$0;" - Call un.StrStr ; Find `$0;` in $1 - Pop $2 ; pos of our dir - StrCmp $2 "" unRemoveFromPath_done - ; else, it is in path - # $0 - path to add - # $1 - path var - StrLen $3 "$0;" - StrLen $4 $2 - StrCpy $5 $1 -$4 # $5 is now the part before the path to remove - StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove - StrCpy $3 $5$6 - - StrCpy $5 $3 1 -1 # copy last char - StrCmp $5 ";" 0 +2 # if last char == ; - StrCpy $3 $3 -1 # remove last char - - StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey - WriteRegExpandStr ${NT_current_env} "PATH" $3 - Goto unDoSend - unWriteAllKey: - WriteRegExpandStr ${NT_all_env} "PATH" $3 - unDoSend: - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - unRemoveFromPath_done: - Pop $6 - Pop $5 - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - -; ReplaceEnvVar - Adds the given value to the given environment var -; Input - head of the stack: value to add ($1) -; 2nd on stack: environement variable ($0) - -Function ReplaceEnvVar - - Exch $1 ; $1 has environment variable value - Exch - Exch $0 ; $0 has environment variable name - - Push $2 - - StrCmp $0 "" ReplaceEnvVar_done ; empty variable name - DetailPrint "Replacing environment variable $0 with $1" - - Call IsNT - Pop $2 - StrCmp $2 0 ReplaceEnvVar_done ; 0 = not NT - - ;ReplaceEnvVar_NT: - StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey - WriteRegExpandStr ${NT_current_env} $0 $1 - Goto unDoSend - unWriteAllKey: - WriteRegExpandStr ${NT_all_env} $0 $1 - unDoSend: - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - ReplaceEnvVar_done: - Pop $2 - Pop $0 - Pop $1 - -FunctionEnd - -; RemoveEnvVar - Adds the given value to the given environment var -; Input - head of the stack: environement variable to remove ($0) - -Function un.RemoveEnvVar - - Exch $0 ; $0 has environment variable name - - Push $1 - - StrCmp $0 "" RemoveEnvVar_done ; empty variable name - DetailPrint "Removing environment variable $0" - - Call un.IsNT - Pop $1 - StrCmp $1 0 RemoveEnvVar_done ; 0 = not NT - - ;ReplaceEnvVar_NT: - StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey - DeleteRegValue ${NT_current_env} $0 - Goto unDoSend - unWriteAllKey: - DeleteRegValue ${NT_all_env} $0 - unDoSend: - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - RemoveEnvVar_done: - Pop $1 - Pop $0 - -FunctionEnd - -; AddToEnvVar - Adds the given value to the given environment var -; Input - head of the stack $0 environement variable $1=value to add -; Note - Win9x systems requires reboot - -Function AddToEnvVar - - Exch $1 ; $1 has environment variable value - Exch - Exch $0 ; $0 has environment variable name - - Push $2 - Push $3 - Push $4 - - - ReadEnvStr $2 $0 - Push "$2;" - Push "$1;" - Call StrStr - Pop $3 - StrCmp $3 "" "" AddToEnvVar_done - - Push "$2;" - Push "$1\;" - Call StrStr - Pop $3 - StrCmp $3 "" "" AddToEnvVar_done - - DetailPrint "Adding $1 to environment variable $0" - - Call IsNT - Pop $2 - StrCmp $2 1 AddToEnvVar_NT - ; Not on NT - StrCpy $2 $WINDIR 2 - FileOpen $2 "$2\autoexec.bat" a - FileSeek $2 -1 END - FileReadByte $2 $3 - IntCmp $3 26 0 +2 +2 # DOS EOF - FileSeek $2 -1 END # write over EOF - FileWrite $2 "$\r$\nSET $0=%$0%;$4$\r$\n" - FileClose $2 - SetRebootFlag true - Goto AddToEnvVar_done - - AddToEnvVar_NT: - ReadRegStr $2 ${WriteEnvStr_RegKey} $0 - StrCpy $3 $2 1 -1 # copy last char - StrCmp $3 ";" 0 +2 # if last char == ; - StrCpy $2 $2 -1 # remove last char - StrCmp $2 "" AddToEnvVar_NTdoIt - StrCpy $1 "$2;$1" - AddToEnvVar_NTdoIt: - WriteRegExpandStr ${WriteEnvStr_RegKey} $0 $1 - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - AddToEnvVar_done: - Pop $4 - Pop $3 - Pop $2 - Pop $0 - Pop $1 - -FunctionEnd - -; RemoveFromEnvVar - Remove a given value from a environment var -; Input: head of the stack - -Function un.RemoveFromEnvVar - - Exch $1 ; $1 has environment variable value - Exch - Exch $0 ; $0 has environment variable name - - Push $2 - Push $3 - Push $4 - Push $5 - Push $6 - Push $7 - - StrCmp $0 "" unRemoveFromEnvVar_done ; empty variable name - DetailPrint "Removing $1 from environment variable $0" - - IntFmt $7 "%c" 26 # DOS EOF - - Call un.IsNT - Pop $2 - StrCmp $2 1 unRemoveFromEnvVar_NT - ; Not on NT - StrCpy $2 $WINDIR 2 - FileOpen $2 "$2\autoexec.bat" r - GetTempFileName $5 - FileOpen $3 $5 w - GetFullPathName /SHORT $1 $1 - StrCpy $1 "SET $0=%$0%;$1" - Goto unRemoveFromEnvVar_dosLoop - - unRemoveFromEnvVar_dosLoop: - FileRead $2 $4 - StrCpy $6 $4 1 -1 # read last char - StrCmp $6 $7 0 +2 # if DOS EOF - StrCpy $4 $4 -1 # remove DOS EOF so we can compare - StrCmp $4 "$1$\r$\n" unRemoveFromEnvVar_dosLoopRemoveLine - StrCmp $4 "$1$\n" unRemoveFromEnvVar_dosLoopRemoveLine - StrCmp $4 "$1" unRemoveFromEnvVar_dosLoopRemoveLine - StrCmp $4 "" unRemoveFromEnvVar_dosLoopEnd - FileWrite $3 $4 - Goto unRemoveFromEnvVar_dosLoop - unRemoveFromEnvVar_dosLoopRemoveLine: - SetRebootFlag true - Goto unRemoveFromEnvVar_dosLoop - - unRemoveFromEnvVar_dosLoopEnd: - FileClose $3 - FileClose $2 - StrCpy $2 $WINDIR 2 - Delete "$2\autoexec.bat" - CopyFiles /SILENT $5 "$2\autoexec.bat" - Delete $5 - Goto unRemoveFromEnvVar_done - - unRemoveFromEnvVar_NT: - ReadRegStr $2 ${WriteEnvStr_RegKey} $0 - StrCpy $6 $2 1 -1 # copy last char - StrCmp $6 ";" +2 # if last char != ; - StrCpy $2 "$2;" # append ; - Push $2 - Push "$1;" - Call un.StrStr ; Find `$1;` in $2 - Pop $3 ; pos of our dir - StrCmp $3 "" unRemoveFromEnvVar_done - ; else, it is in path - # $1 - path to add - # $2 - path var - StrLen $4 "$1;" - StrLen $5 $3 - StrCpy $6 $2 -$5 # $6 is now the part before the path to remove - StrCpy $7 $3 "" $4 # $7 is now the part after the path to remove - StrCpy $4 $6$7 - - StrCpy $6 $4 1 -1 # copy last char - StrCmp $6 ";" 0 +2 # if last char == ; - StrCpy $4 $4 -1 # remove last char - - WriteRegExpandStr ${WriteEnvStr_RegKey} $0 $4 - - ; delete reg value if null - StrCmp $4 "" 0 +2 # if null delete reg - DeleteRegValue ${WriteEnvStr_RegKey} $0 - - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - unRemoveFromEnvVar_done: - Pop $7 - Pop $6 - Pop $5 - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - - -########################################### -# Utility Functions # -########################################### - -;==================================================== -; IsNT - Returns 1 if the current system is NT, 0 -; otherwise. -; Output: head of the stack -;==================================================== -; IsNT -; no input -; output, top of the stack = 1 if NT or 0 if not -; -; Usage: -; Call IsNT -; Pop $R0 -; ($R0 at this point is 1 or 0) - -!macro IsNT un -Function ${un}IsNT - Push $0 - ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion - StrCmp $0 "" 0 IsNT_yes - ; we are not NT. - Pop $0 - Push 0 - Return - - IsNT_yes: - ; NT!!! - Pop $0 - Push 1 -FunctionEnd -!macroend -!insertmacro IsNT "" -!insertmacro IsNT "un." - -; StrStr -; input, top of stack = string to search for -; top of stack-1 = string to search in -; output, top of stack (replaces with the portion of the string remaining) -; modifies no other variables. -; -; Usage: -; Push "this is a long ass string" -; Push "ass" -; Call StrStr -; Pop $R0 -; ($R0 at this point is "ass string") - -!macro StrStr un -Function ${un}StrStr -Exch $R1 ; st=haystack,old$R1, $R1=needle - Exch ; st=old$R1,haystack - Exch $R2 ; st=old$R1,old$R2, $R2=haystack - Push $R3 - Push $R4 - Push $R5 - StrLen $R3 $R1 - StrCpy $R4 0 - ; $R1=needle - ; $R2=haystack - ; $R3=len(needle) - ; $R4=cnt - ; $R5=tmp - loop: - StrCpy $R5 $R2 $R3 $R4 - StrCmp $R5 $R1 done - StrCmp $R5 "" done - IntOp $R4 $R4 + 1 - Goto loop -done: - StrCpy $R1 $R2 "" $R4 - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Exch $R1 -FunctionEnd -!macroend -!insertmacro StrStr "" -!insertmacro StrStr "un." - -Function Trim ; Added by Pelaca - Exch $R1 - Push $R2 -Loop: - StrCpy $R2 "$R1" 1 -1 - StrCmp "$R2" " " RTrim - StrCmp "$R2" "$\n" RTrim - StrCmp "$R2" "$\r" RTrim - StrCmp "$R2" ";" RTrim - GoTo Done -RTrim: - StrCpy $R1 "$R1" -1 - Goto Loop -Done: - Pop $R2 - Exch $R1 -FunctionEnd - -Function ConditionalAddToRegisty - Pop $0 - Pop $1 - StrCmp "$0" "" ConditionalAddToRegisty_EmptyString - WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" \ - "$1" "$0" - ;MessageBox MB_OK "Set Registry: '$1' to '$0'" - DetailPrint "Set install registry entry: '$1' to '$0'" - ConditionalAddToRegisty_EmptyString: -FunctionEnd - -;-------------------------------- - -!ifdef CPACK_USES_DOWNLOAD -Function DownloadFile - IfFileExists $INSTDIR\* +2 - CreateDirectory $INSTDIR - Pop $0 - - ; Skip if already downloaded - IfFileExists $INSTDIR\$0 0 +2 - Return - - StrCpy $1 "@CPACK_DOWNLOAD_SITE@" - - try_again: - NSISdl::download "$1/$0" "$INSTDIR\$0" - - Pop $1 - StrCmp $1 "success" success - StrCmp $1 "Cancelled" cancel - MessageBox MB_OK "Download failed: $1" - cancel: - Return - success: -FunctionEnd -!endif - -;-------------------------------- -; Installation types -@CPACK_NSIS_INSTALLATION_TYPES@ - -;-------------------------------- -; Component sections -@CPACK_NSIS_COMPONENT_SECTIONS@ - -;-------------------------------- -; Define some macro setting for the gui -@CPACK_NSIS_INSTALLER_MUI_ICON_CODE@ -@CPACK_NSIS_INSTALLER_ICON_CODE@ -@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@ -@CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@ - -;-------------------------------- -;Pages - !insertmacro MUI_PAGE_WELCOME - - !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@" - Page custom InstallOptionsPage - !insertmacro MUI_PAGE_DIRECTORY - - ;Start Menu Folder Page Configuration - !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" - !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" - !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" - !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER - - @CPACK_NSIS_PAGE_COMPONENTS@ - - !insertmacro MUI_PAGE_INSTFILES - - ; keep the InstFiles page from automatically progressing to the Finish page - !define MUI_FINISHPAGE_NOAUTOCLOSE - !insertmacro MUI_PAGE_FINISH - - !insertmacro MUI_UNPAGE_CONFIRM - !insertmacro MUI_UNPAGE_INSTFILES - -;-------------------------------- -;Languages - - !insertmacro MUI_LANGUAGE "English" ;first language is the default language - !insertmacro MUI_LANGUAGE "Albanian" - !insertmacro MUI_LANGUAGE "Arabic" - !insertmacro MUI_LANGUAGE "Basque" - !insertmacro MUI_LANGUAGE "Belarusian" - !insertmacro MUI_LANGUAGE "Bosnian" - !insertmacro MUI_LANGUAGE "Breton" - !insertmacro MUI_LANGUAGE "Bulgarian" - !insertmacro MUI_LANGUAGE "Croatian" - !insertmacro MUI_LANGUAGE "Czech" - !insertmacro MUI_LANGUAGE "Danish" - !insertmacro MUI_LANGUAGE "Dutch" - !insertmacro MUI_LANGUAGE "Estonian" - !insertmacro MUI_LANGUAGE "Farsi" - !insertmacro MUI_LANGUAGE "Finnish" - !insertmacro MUI_LANGUAGE "French" - !insertmacro MUI_LANGUAGE "German" - !insertmacro MUI_LANGUAGE "Greek" - !insertmacro MUI_LANGUAGE "Hebrew" - !insertmacro MUI_LANGUAGE "Hungarian" - !insertmacro MUI_LANGUAGE "Icelandic" - !insertmacro MUI_LANGUAGE "Indonesian" - !insertmacro MUI_LANGUAGE "Irish" - !insertmacro MUI_LANGUAGE "Italian" - !insertmacro MUI_LANGUAGE "Japanese" - !insertmacro MUI_LANGUAGE "Korean" - !insertmacro MUI_LANGUAGE "Kurdish" - !insertmacro MUI_LANGUAGE "Latvian" - !insertmacro MUI_LANGUAGE "Lithuanian" - !insertmacro MUI_LANGUAGE "Luxembourgish" - !insertmacro MUI_LANGUAGE "Macedonian" - !insertmacro MUI_LANGUAGE "Malay" - !insertmacro MUI_LANGUAGE "Mongolian" - !insertmacro MUI_LANGUAGE "Norwegian" - !insertmacro MUI_LANGUAGE "Polish" - !insertmacro MUI_LANGUAGE "Portuguese" - !insertmacro MUI_LANGUAGE "PortugueseBR" - !insertmacro MUI_LANGUAGE "Romanian" - !insertmacro MUI_LANGUAGE "Russian" - !insertmacro MUI_LANGUAGE "Serbian" - !insertmacro MUI_LANGUAGE "SerbianLatin" - !insertmacro MUI_LANGUAGE "SimpChinese" - !insertmacro MUI_LANGUAGE "Slovak" - !insertmacro MUI_LANGUAGE "Slovenian" - !insertmacro MUI_LANGUAGE "Spanish" - !insertmacro MUI_LANGUAGE "Swedish" - !insertmacro MUI_LANGUAGE "Thai" - !insertmacro MUI_LANGUAGE "TradChinese" - !insertmacro MUI_LANGUAGE "Turkish" - !insertmacro MUI_LANGUAGE "Ukrainian" - !insertmacro MUI_LANGUAGE "Welsh" - - -;-------------------------------- -;Reserve Files - - ;These files should be inserted before other files in the data block - ;Keep these lines before any File command - ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA) - - ReserveFile "NSIS.InstallOptions.ini" - !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS - -;-------------------------------- -;Installer Sections - -Section "-Core installation" - ;Use the entire tree produced by the INSTALL target. Keep the - ;list of directories here in sync with the RMDir commands below. - SetOutPath "$INSTDIR" - @CPACK_NSIS_FULL_INSTALL@ - - ;Store installation folder - WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR - - ;Create uninstaller - WriteUninstaller "$INSTDIR\Uninstall.exe" - Push "DisplayName" - Push "@CPACK_NSIS_DISPLAY_NAME@" - Call ConditionalAddToRegisty - Push "DisplayVersion" - Push "@CPACK_PACKAGE_VERSION@" - Call ConditionalAddToRegisty - Push "Publisher" - Push "@CPACK_PACKAGE_VENDOR@" - Call ConditionalAddToRegisty - Push "UninstallString" - Push "$INSTDIR\Uninstall.exe" - Call ConditionalAddToRegisty - Push "NoRepair" - Push "1" - Call ConditionalAddToRegisty - - !ifdef CPACK_NSIS_ADD_REMOVE - ;Create add/remove functionality - Push "ModifyPath" - Push "$INSTDIR\AddRemove.exe" - Call ConditionalAddToRegisty - !else - Push "NoModify" - Push "1" - Call ConditionalAddToRegisty - !endif - - ; Optional registration - Push "DisplayIcon" - Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@" - Call ConditionalAddToRegisty - Push "HelpLink" - Push "@CPACK_NSIS_HELP_LINK@" - Call ConditionalAddToRegisty - Push "URLInfoAbout" - Push "@CPACK_NSIS_URL_INFO_ABOUT@" - Call ConditionalAddToRegisty - Push "Contact" - Push "@CPACK_NSIS_CONTACT@" - Call ConditionalAddToRegisty - !insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State" - !insertmacro MUI_STARTMENU_WRITE_BEGIN Application - - ;Create shortcuts - CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" -@CPACK_NSIS_CREATE_ICONS@ -@CPACK_NSIS_CREATE_ICONS_EXTRA@ - CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" - - ;Read a value from an InstallOptions INI file - !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 2" "State" - !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 3" "State" - !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 4" "State" - - ; Write special uninstall registry entries - Push "StartMenu" - Push "$STARTMENU_FOLDER" - Call ConditionalAddToRegisty - Push "DoNotAddToPath" - Push "$DO_NOT_ADD_TO_PATH" - Call ConditionalAddToRegisty - Push "AddToPathAllUsers" - Push "$ADD_TO_PATH_ALL_USERS" - Call ConditionalAddToRegisty - Push "AddToPathCurrentUser" - Push "$ADD_TO_PATH_CURRENT_USER" - Call ConditionalAddToRegisty - Push "InstallToDesktop" - Push "$INSTALL_DESKTOP" - Call ConditionalAddToRegisty - - !insertmacro MUI_STARTMENU_WRITE_END - -@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@ - -SectionEnd - -Section "-Add to path" - StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath - StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0 - Push "$INSTDIR\bin" - Call AddToPath - - Push "@CPACK_NSIS_ADD_ENVVAR1@" - Push "@CPACK_NSIS_ADD_ENVVAL1@" - Call ReplaceEnvVar - - Push "@CPACK_NSIS_ADD_ENVVAR2@" - Push "@CPACK_NSIS_ADD_ENVVAL2@" - Call AddToEnvVar - - Push "@CPACK_NSIS_ADD_ENVVAR3@" - Push "@CPACK_NSIS_ADD_ENVVAL3@" - Call AddToEnvVar - - doNotAddToPath: -SectionEnd - -;-------------------------------- -; Create custom pages -Function InstallOptionsPage - !insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@" - !insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini" - -FunctionEnd - -;-------------------------------- -; determine admin versus local install -Function un.onInit - - ClearErrors - UserInfo::GetName - IfErrors noLM - Pop $0 - UserInfo::GetAccountType - Pop $1 - StrCmp $1 "Admin" 0 +3 - SetShellVarContext all - ;MessageBox MB_OK 'User "$0" is in the Admin group' - Goto done - StrCmp $1 "Power" 0 +3 - SetShellVarContext all - ;MessageBox MB_OK 'User "$0" is in the Power Users group' - Goto done - - noLM: - ;Get installation folder from registry if available - - done: - -FunctionEnd - -;--- Add/Remove callback functions: --- -!macro SectionList MacroName - ;This macro used to perform operation on multiple sections. - ;List all of your components in following manner here. -@CPACK_NSIS_COMPONENT_SECTION_LIST@ -!macroend - -Section -FinishComponents - ;Removes unselected components and writes component status to registry - !insertmacro SectionList "FinishSection" - -!ifdef CPACK_NSIS_ADD_REMOVE - ; Get the name of the installer executable - System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1' - StrCpy $R3 $R0 - - ; Strip off the last 13 characters, to see if we have AddRemove.exe - StrLen $R1 $R0 - IntOp $R1 $R0 - 13 - StrCpy $R2 $R0 13 $R1 - StrCmp $R2 "AddRemove.exe" addremove_installed - - ; We're not running AddRemove.exe, so install it - CopyFiles $R3 $INSTDIR\AddRemove.exe - - addremove_installed: -!endif -SectionEnd -;--- End of Add/Remove callback functions --- - -;-------------------------------- -; Component dependencies -Function .onSelChange - !insertmacro SectionList MaybeSelectionChanged -FunctionEnd - -;-------------------------------- -;Uninstaller Section - -Section "Uninstall" - ReadRegStr $START_MENU SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu" - ;MessageBox MB_OK "Start menu is in: $START_MENU" - ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "DoNotAddToPath" - ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathAllUsers" - ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathCurrentUser" - ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS" - ReadRegStr $INSTALL_DESKTOP SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "InstallToDesktop" - ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP " - -@CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@ - - ;Remove files we installed. - ;Keep the list of directories here in sync with the File commands above. -@CPACK_NSIS_DELETE_FILES@ -@CPACK_NSIS_DELETE_DIRECTORIES@ - -!ifdef CPACK_NSIS_ADD_REMOVE - ;Remove the add/remove program - Delete "$INSTDIR\AddRemove.exe" -!endif - - ;Remove the uninstaller itself. - Delete "$INSTDIR\Uninstall.exe" - DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" - - ;Remove the installation directory if it is empty. - RMDir "$INSTDIR" - - ; Remove the registry entries. - DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" - - ; Removes all optional components - !insertmacro SectionList "RemoveSection" - - !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP - - Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" -@CPACK_NSIS_DELETE_ICONS@ -@CPACK_NSIS_DELETE_ICONS_EXTRA@ - - ;Delete empty start menu parent diretories - StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" - - startMenuDeleteLoop: - ClearErrors - RMDir $MUI_TEMP - GetFullPathName $MUI_TEMP "$MUI_TEMP\.." - - IfErrors startMenuDeleteLoopDone - - StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop - startMenuDeleteLoopDone: - - ; If the user changed the shortcut, then untinstall may not work. This should - ; try to fix it. - StrCpy $MUI_TEMP "$START_MENU" - Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" -@CPACK_NSIS_DELETE_ICONS_EXTRA@ - - ;Delete empty start menu parent diretories - StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" - - secondStartMenuDeleteLoop: - ClearErrors - RMDir $MUI_TEMP - GetFullPathName $MUI_TEMP "$MUI_TEMP\.." - - IfErrors secondStartMenuDeleteLoopDone - - StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop - secondStartMenuDeleteLoopDone: - - DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" - - Push "$INSTDIR\bin" - StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0 - Push "$INSTDIR\bin" - Call un.RemoveFromPath - - Push "@CPACK_NSIS_ADD_ENVVAR1@" - Call un.RemoveEnvVar - - Push "@CPACK_NSIS_ADD_ENVVAR2@" - Push "@CPACK_NSIS_ADD_ENVVAL2@" - Call un.RemoveFromEnvVar - - Push "@CPACK_NSIS_ADD_ENVVAR3@" - Push "@CPACK_NSIS_ADD_ENVVAL3@" - Call un.RemoveFromEnvVar - - doNotRemoveFromPath: -SectionEnd - -;-------------------------------- -; determine admin versus local install -; Is install for "AllUsers" or "JustMe"? -; Default to "JustMe" - set to "AllUsers" if admin or on Win9x -; This function is used for the very first "custom page" of the installer. -; This custom page does not show up visibly, but it executes prior to the -; first visible page and sets up $INSTDIR properly... -; Choose different default installation folder based on SV_ALLUSERS... -; "Program Files" for AllUsers, "My Documents" for JustMe... - -Function .onInit - ; Reads components status for registry - !insertmacro SectionList "InitSection" - - ; check to see if /D has been used to change - ; the install directory by comparing it to the - ; install directory that is expected to be the - ; default - StrCpy $IS_DEFAULT_INSTALLDIR 0 - StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2 - StrCpy $IS_DEFAULT_INSTALLDIR 1 - - StrCpy $SV_ALLUSERS "JustMe" - ; if default install dir then change the default - ; if it is installed for JustMe - StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2 - StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@" - - ClearErrors - UserInfo::GetName - IfErrors noLM - Pop $0 - UserInfo::GetAccountType - Pop $1 - StrCmp $1 "Admin" 0 +3 - SetShellVarContext all - ;MessageBox MB_OK 'User "$0" is in the Admin group' - StrCpy $SV_ALLUSERS "AllUsers" - Goto done - StrCmp $1 "Power" 0 +3 - SetShellVarContext all - ;MessageBox MB_OK 'User "$0" is in the Power Users group' - StrCpy $SV_ALLUSERS "AllUsers" - Goto done - - noLM: - StrCpy $SV_ALLUSERS "AllUsers" - ;Get installation folder from registry if available - - done: - StrCmp $SV_ALLUSERS "AllUsers" 0 +3 - StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2 - StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" - - StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage - !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini" - - noOptionsPage: -FunctionEnd diff --git a/cmake/modules/ScriptToVerbatim.cmake b/cmake/modules/ScriptToVerbatim.cmake deleted file mode 100644 index cddc610..0000000 --- a/cmake/modules/ScriptToVerbatim.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# -# $Id: CMakeLists.txt 9861 2012-03-13 14:43:02Z remko $ -# -# Copyright (c) 1991-2013 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe -# See LICENSE.TXT file for copying and redistribution conditions. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; version 3 or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# Contact info: gmt.soest.hawaii.edu -#------------------------------------------------------------------------------- - -include (ManageString) - -# Convert scripts to verbatim text for inclusion in TeX documentation -if (no_strip) - grep ("[$]Id:|functions[.]sh" _file_content ${script} INVERT) -else (no_strip) - grep ("^#|functions.sh" _file_content ${script} INVERT) -endif (no_strip) -string (REPLACE ";" "\n" _file_content "${_file_content}") -string_unescape (_verbatim_txt "${_file_content}" NOESCAPE_SEMICOLON) -file (WRITE "${txt}" "${_verbatim_txt}") - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 diff --git a/cmake/modules/today.c b/cmake/modules/today.c deleted file mode 100644 index 53248e9..0000000 --- a/cmake/modules/today.c +++ /dev/null @@ -1,32 +0,0 @@ -/* $Id: today.c 10119 2012-05-19 08:08:25Z fwobbe $ - * - * called by cmake to obtain date at build time - */ - -#include -#include - -#define BUFSIZE 32 - -int main () { - char today_string[BUFSIZE]; - - /* obtain current time as time since epoch */ - time_t clock = time (NULL); - - /* convert time since epoch to calendar time expressed as local time */ - struct tm *p_time = localtime (&clock); - - /* convert tm object to custom textual representation YYYY;mm;dd;Mmm*/ - size_t result = strftime(today_string, BUFSIZE, "%Y;%m;%d;%B", p_time); - - if ( result ) { - /* success, print date string */ - printf ("%s", today_string); - return 0; - } - - /* on error, print dummy */ - printf ("1313;13;13;Undecember"); - return -1; -} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 381ac4d..dbb3763 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,5 @@ # -# $Id$ -# -# Copyright (c) 1991-2020 by the GMT Team (https://www.generic-mapping-tools.org/team.html) +# Copyright (c) 1991-2020 by GMT Team (https://www.generic-mapping-tools.org/team.html) # See LICENSE.TXT file for copying and redistribution conditions. # # This program is free software; you can redistribute it and/or modify @@ -13,129 +11,68 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # -# Contact info: www.generic-mapping-tools.org +# Contact info: http://www.soest.hawaii.edu/PT/GSFML #------------------------------------------------------------------------------- +# Below, "custom" and "CUSTOM" should be replaced with your actual supplement name # -# 1. To modify the cmake process: Customize your cmake/ConfigUser.cmake file -# 2. To add more modules: Edit CUSTOM_PROGS_SRCS below. -# 3. Edit this: LIB_STRING="GMT custom: Tools for the custom project" +# SUPPL_LIB_NAME [required] +# name of the supplement package. It can be different from the directory name. +# If not given then the modules are added to the supplements library +set (SUPPL_LIB_NAME custom) +set (SUPPL_LIB_PURPOSE "GMT custom: Tools for the CUSTOM project") -# ==> Modules in this custom library [add the ones you have]: -set (CUSTOM_PROGS_SRCS gmtaverage.c gmtmercmap.c gmtparser.c grdfourier.c) -#========================================================================= -# Most likely no changes below here +# SUPPL_PROGS_SRCS [required] +# list of C source codes for supplemental modules +set (SUPPL_PROGS_SRCS gmtaverage.c gmtmercmap.c gmtparser.c grdfourier.c) -include (ManageString) +# SUPPL_LIB_SRCS [required] +# list of C source codes for supplemental library +set (SUPPL_LIB_SRCS ${SUPPL_PROGS_SRCS}) -# Include CREATE_DEBUG_SYM macro -include (CreateDebugSym) +# SUPPL_HEADERS [optional] +# header files. Will be installed if BUILD_DEVELOPER is TRUE +set (SUPPL_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/custom_config.h) -# On Windows do not prefix the DLLs with the 'lib' prefix -if (WIN32) - set(LIB_PREFIX "") -else (WIN32) - set(LIB_PREFIX "lib") -endif (WIN32) +# SUPPL_EXAMPLE_FILES [optional] +# README and other example files +#set (SUPPL_EXAMPLE_FILES README.custom) -# Find libraries -message (STATUS "Searching dependent libraries. This may take a few minutes...") -find_package (GMT REQUIRED) -include_directories (${GMT_INCLUDE_DIR}) -find_package (NETCDF REQUIRED) -include_directories (${NETCDF_INCLUDE_DIR}) -find_package (CURL REQUIRED) -include_directories (${CURL_INCLUDE_DIR}) +# SUPPL_EXAMPLE_PROGS [optional] +# example scripts +#set (SUPPL_EXAMPLE_PROGS test1.sh test2.sh) -find_package (GDAL) -if (GDAL_FOUND) - set (HAVE_GDAL TRUE CACHE INTERNAL "System has GDAL") - include_directories (${GDAL_INCLUDE_DIR}) - list (APPEND GMT_OPTIONAL_LIBRARIES ${GDAL_LIBRARIES}) -endif (GDAL_FOUND) +# CUSTOM SPECIFIC SETTINGS -find_package (Threads) +set (CUSTOM_PACKAGE_VERSION "6.1.0") -# check for math and POSIX functions -include(ConfigureChecks) +configure_file (custom_config.h.in custom_config.h) -include_directories (${CUSTOM_SOURCE_DIR}/src) -include_directories (${CMAKE_CURRENT_BINARY_DIR}) -#include_directories (${PROJECT_BINARY_DIR}) -set(CMAKE_INCLUDE_CURRENT_DIR TRUE) +find_package (GMT REQUIRED) +include_directories (${GMT_INCLUDE_DIR}) -# Support code for the modules: -set (CUSTOM_LIB_SRCS gmt_${CMAKE_PROJECT_NAME}_module.h gmt_${CMAKE_PROJECT_NAME}_module.c) +find_package (NETCDF REQUIRED) +include_directories (${NETCDF_INCLUDE_DIR}) -# lib targets -set (CUSTOM_LIBS customlib) +find_package (GDAL) +include_directories (${GDAL_INCLUDE_DIR}) -# customlib: -set (CMAKE_SHARED_MODULE_SUFFIX .so) -add_library (customlib MODULE - ${CUSTOM_LIB_SRCS} - ${CUSTOM_PROGS_SRCS}) +add_library (${SUPPL_LIB_NAME} MODULE + ${SUPPL_LIB_SRCS} + ${CMAKE_CURRENT_BINARY_DIR}/custom_config.h + gmt_custom_glue.c + ) -target_link_libraries (customlib +target_link_libraries (${SUPPL_LIB_NAME} ${GMT_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT}) - -if (HAVE_M_LIBRARY) - # link the math library - target_link_libraries (customlib m) -endif (HAVE_M_LIBRARY) - -set_target_properties (customlib - PROPERTIES - OUTPUT_NAME ${CMAKE_PROJECT_NAME} - PREFIX "" - IMPORT_PREFIX "${LIB_PREFIX}" - LIBRARY_OUTPUT_DIRECTORY plugins - RUNTIME_OUTPUT_DIRECTORY plugins - LINK_FLAGS "${USER_CUSTOMLIB_LINK_FLAGS}" - DEFINE_SYMBOL "LIBRARY_EXPORTS") - -# If a renaming of the custom dll has been set in ConfigUser.cmake -if (WIN32 AND CUSTOM_DLL_RENAME) - set_target_properties (customlib PROPERTIES RUNTIME_OUTPUT_NAME ${CUSTOM_DLL_RENAME}) -endif () - -configure_file (custom_version.h.in custom_version.h) - -# generate Mac debugging symbols -create_debug_sym (${CUSTOM_LIBS}) - -# temporary hack -if (NOT CUSTOM_INSTALL_MONOLITHIC) - set (CUSTOM_MAIN_NAME ${CMAKE_PROJECT_NAME}${CUSTOM_INSTALL_NAME_SUFFIX}) -else (NOT CUSTOM_INSTALL_MONOLITHIC) - set (CUSTOM_MAIN_NAME ${CMAKE_PROJECT_NAME}) -endif (NOT CUSTOM_INSTALL_MONOLITHIC) - - -# add the install targets -install (TARGETS ${CUSTOM_LIBS} - ARCHIVE DESTINATION ${CUSTOM_LIBDIR} - COMPONENT Runtime - LIBRARY DESTINATION ${CUSTOM_LIBDIR} - COMPONENT Runtime - RUNTIME DESTINATION ${CUSTOM_BINDIR} - COMPONENT Runtime) - -if (WIN32 AND _debug_build) - # install program database files - set (_pdb_files) - foreach (_target ${LIB_PREFIX}${CUSTOM_CUSTOM_RENAME}) - list (APPEND _pdb_files "${CMAKE_CURRENT_BINARY_DIR}/${_target}.pdb") - endforeach () - install (FILES ${_pdb_files} - DESTINATION ${CUSTOM_BINDIR} - COMPONENT Runtime) -endif (WIN32 AND _debug_build) - -# this prints out the final version of the compiler/linker flags -string (TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER) -string(REGEX REPLACE "[ ]+" " " _using_cflags ${CMAKE_C_FLAGS} " " - ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}) -message (STATUS "Using CFLAGS = '${_using_cflags}'") - -# vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2 + ${NETCDF_LIBRARIES} + ${GDAL_LIBRARIES} +) + +set_target_properties (${SUPPL_LIB_NAME} + PROPERTIES + OUTPUT_NAME ${SUPPL_LIB_NAME} + RUNTIME_OUTPUT_NAME ${SUPPL_LIB_NAME} + LIBRARY_OUTPUT_DIRECTORY plugins + RUNTIME_OUTPUT_DIRECTORY plugins + PREFIX "" + DEFINE_SYMBOL "LIBRARY_EXPORTS") diff --git a/src/custom_config.h.in b/src/custom_config.h.in new file mode 100644 index 0000000..b882674 --- /dev/null +++ b/src/custom_config.h.in @@ -0,0 +1,23 @@ +/* + * + * Copyright (c) 2015-2020 by + * See LICENSE.TXT file for copying and redistribution conditions. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3 or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * Contact info: + *-------------------------------------------------------------------- + */ + +#pragma once +#ifndef _CUSTOM_CONFIG_H +#define _CUSTOM_CONFIG_H +#define CUSTOM_PACKAGE_VERSION "@CUSTOM_PACKAGE_VERSION@" +#endif /* !_CUSTOM_CONFIG_H */ diff --git a/src/custom_version.h.in b/src/custom_version.h.in deleted file mode 100644 index 71a45b1..0000000 --- a/src/custom_version.h.in +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * Copyright (c) 1991-2020 by the GMT Team (https://www.generic-mapping-tools.org/team.html) - * - * See LICENSE.TXT file for copying and redistribution conditions. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; version 3 or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * Contact info: www.generic-mapping-tools.org - */ - -#pragma once -#ifndef CUSTOM_VERSION_H_ -#define CUSTOM_VERSION_H_ - -#define CUSTOM_MAJOR_VERSION @CUSTOM_PACKAGE_VERSION_MAJOR@ -#define CUSTOM_MINOR_VERSION @CUSTOM_PACKAGE_VERSION_MINOR@ -#define CUSTOM_RELEASE_VERSION @CUSTOM_PACKAGE_VERSION_PATCH@ -#define CUSTOM_VERSION_YEAR @CUSTOM_VERSION_YEAR@ - -#cmakedefine CUSTOM_SOURCE_CODE_CONTROL_VERSION_STRING "@CUSTOM_SOURCE_CODE_CONTROL_VERSION_STRING@" -#ifdef CUSTOM_SOURCE_CODE_CONTROL_VERSION_STRING -# define CUSTOM_STRING "@CUSTOM_PACKAGE_VERSION_WITH_SVN_REVISION@ (r@CUSTOM_SOURCE_CODE_CONTROL_VERSION_STRING@)" -#else /* if HAVE_SVN_VERSION or if unversioned */ -# define CUSTOM_STRING "@CUSTOM_PACKAGE_VERSION_WITH_SVN_REVISION@" -#endif - -#ifdef __x86_64__ -# define CUSTOM_VER_64 " [64-bit]" -#else -# define CUSTOM_VER_64 "" -#endif - -#ifdef _OPENMP /* Open MP Parallelization is on */ -# define CUSTOM_MP " [MP]" -#else -# define CUSTOM_MP "" -#endif - -/* support for inline functions */ -#cmakedefine HAVE_C_inline -#cmakedefine HAVE_C___inline -#cmakedefine HAVE_C___inline__ -#ifndef HAVE_C_inline -# if defined(HAVE_C___inline) -# define inline __inline -# elif defined(HAVE_C___inline__) -# define inline __inline__ -# else -# define inline /* not supported */ -# endif -#endif /* !HAVE_C_inline */ -#define CUSTOM_VERSION CUSTOM_version() - -static inline char *CUSTOM_version () { - /* final string returned by CUSTOM_version() */ - static char version[] = CUSTOM_STRING CUSTOM_VER_64 CUSTOM_MP; - return version; -} - -#endif /* !CUSTOM_VERSION_H_ */ - -/* vim: set ft=c: */ diff --git a/src/gmt_custom_glue.c b/src/gmt_custom_glue.c new file mode 100644 index 0000000..2f76947 --- /dev/null +++ b/src/gmt_custom_glue.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2012-2020 by the GMT Team (https://www.generic-mapping-tools.org/team.html) + * See LICENSE.TXT file for copying and redistribution conditions. + */ +/* gmt_custom_glue.c populates the external array of this shared lib with + * module parameters such as name, group, purpose and keys strings. + * This file also contains the following convenience functions to + * display all module purposes, list their names, or return keys or group: + * + * int custom_module_show_all (void *API); + * int custom_module_list_all (void *API); + * int custom_module_classic_all (void *API); + * + * These functions may be called by gmt --help and gmt --show-modules + * + * Developers of external APIs for accessing GMT modules will use this + * function indirectly via GMT_Encode_Options to retrieve option keys + * needed for module arg processing: + * + * const char * custom_module_keys (void *API, char *candidate); + * const char * custom_module_group (void *API, char *candidate); + * + * All functions are exported by the shared custom library so that gmt can call these + * functions by name to learn about the contents of the library. + */ + +#include "gmt_dev.h" + +/* Sorted array with information for all GMT custom modules */ +static struct GMT_MODULEINFO modules[] = { + {"gmtaverage", "gmtaverage", "custom", "Block average (x,y,z) data tables by mean, median, or mode estimation", "DO,RG-"}, + {"gmtmercmap", "gmtmercmap", "custom", "Make a Mercator color map from ETOPO 1, 2, or 5 arc min global relief grids", "CCi,>XO,RG-"}, + {"gmtparser", "gmtparser", "custom", "Demonstrate parsing of input data, defaults, and options", ""}, + {"grdfourier", "grdfourier", "custom", "Create a grid, add a spike, filter it in frequency domain, and write output", " - -/* Sorted array with information for all GMT custom modules */ - -/* name, library, and purpose for each module */ -struct Gmt_moduleinfo { - const char *mname; /* Program (modern) name */ - const char *cname; /* Program (classic) name */ - const char *component; /* Component (core, supplement, custom) */ - const char *purpose; /* Program purpose */ - const char *keys; /* Program option info for external APIs */ -}; - -static int sort_on_classic (const void *vA, const void *vB) { - const struct Gmt_moduleinfo *A = vA, *B = vB; - if (A == NULL) return +1; /* Get the NULL entry to the end */ - if (B == NULL) return -1; /* Get the NULL entry to the end */ - return strcmp(A->cname, B->cname); -} - -static struct Gmt_moduleinfo g_custom_module[] = { - {"gmtaverage", "gmtaverage", "custom", , "Block average (x,y,z) data tables by mean, median, or mode estimation"}, - {"gmtmercmap", "gmtmercmap", "custom", , }, - {"gmtparser", "gmtparser", "custom", , }, - {"grdfourier", "grdfourier", "custom", , }, - {NULL, NULL, NULL, NULL, NULL} /* last element == NULL detects end of array */ -}; - -/* Pretty print all GMT custom module names and their purposes for gmt --help */ -void gmt_custom_module_show_all (void *V_API) { - unsigned int module_id = 0; - char message[GMT_LEN256]; - GMT_Message (V_API, GMT_TIME_NONE, "\n=== GMT custom: The custom modules of the Generic Mapping Tools ===\n"); - while (g_custom_module[module_id].cname != NULL) { - if (module_id == 0 || strcmp (g_custom_module[module_id-1].component, g_custom_module[module_id].component)) { - /* Start of new supplemental group */ - snprintf (message, GMT_LEN256, "\nModule name: Purpose of %s module:\n", g_custom_module[module_id].component); - GMT_Message (V_API, GMT_TIME_NONE, message); - GMT_Message (V_API, GMT_TIME_NONE, "----------------------------------------------------------------\n"); - } - snprintf (message, GMT_LEN256, "%-16s %s\n", - g_custom_module[module_id].mname, g_custom_module[module_id].purpose); - GMT_Message (V_API, GMT_TIME_NONE, message); - ++module_id; - } -} - -/* Produce single list on stdout of all GMT custom module names for gmt --show-modules */ -void gmt_custom_module_list_all (void *V_API) { - unsigned int module_id = 0; - gmt_M_unused(V_API); - while (g_custom_module[module_id].cname != NULL) { - printf ("%s\n", g_custom_module[module_id].mname); - ++module_id; - } -} - -/* Produce single list on stdout of all GMT custom module names for gmt --show-classic [i.e., classic mode names] */ -void gmt_custom_module_classic_all (void *V_API) { - unsigned int module_id = 0; - size_t n_modules = 0; - gmt_M_unused(V_API); - - while (g_custom_module[n_modules].cname != NULL) /* Count the modules */ - ++n_modules; - - /* Sort array on classic names since original array is sorted on modern names */ - qsort (g_custom_module, n_modules, sizeof (struct Gmt_moduleinfo), sort_on_classic); - - while (g_custom_module[module_id].cname != NULL) { - printf ("%s\n", g_custom_module[module_id].cname); - ++module_id; - } -} - -/* Lookup module id by name, return option keys pointer (for external API developers) */ -const char *gmt_custom_module_keys (void *API, char *candidate) { - int module_id = 0; - gmt_M_unused(API); - - /* Match actual_name against g_module[module_id].cname */ - while (g_custom_module[module_id].cname != NULL && - strcmp (candidate, g_custom_module[module_id].cname)) - ++module_id; - - /* Return Module keys or NULL */ - return (g_custom_module[module_id].keys); -} - -/* Lookup module id by name, return group char name (for external API developers) */ -const char *gmt_custom_module_group (void *API, char *candidate) { - int module_id = 0; - gmt_M_unused(API); - - /* Match actual_name against g_module[module_id].cname */ - while (g_custom_module[module_id].cname != NULL && - strcmp (candidate, g_custom_module[module_id].cname)) - ++module_id; - - /* Return Module keys or NULL */ - return (g_custom_module[module_id].component); -} diff --git a/src/gmt_custom_module.c.orig b/src/gmt_custom_module.c.orig deleted file mode 100644 index 8d9b68c..0000000 --- a/src/gmt_custom_module.c.orig +++ /dev/null @@ -1,102 +0,0 @@ -/* $Id$ - * - * Copyright (c) 2016-2018 by pwessel - * See LICENSE.TXT file for copying and redistribution conditions. - */ - -/* gmt_custom_module.c populates the local array g_custom_module - * with parameters such as name, group, purpose and keys strings. - * This file also contains the following convenience functions to - * display all module purposes or just list their names: - * - * void gmt_custom_module_show_all (void *API); - * void gmt_custom_module_list_all (void *API); - * - * These functions may be called by gmt --help and gmt --show-modules - * - * DO NOT edit this file directly! Regenerate the file by running - * gmt_make_custom_code.sh - */ - -#include "gmt.h" -#include "gmt_custom_module.h" -#include - -#ifndef gmt_M_unused -#define gmt_M_unused(x) (void)(x) -#endif - -/* Sorted array with information for all custom modules */ - -/* name, library, and purpose for each module */ -struct Gmt_moduleinfo { - const char *name; /* Program name */ - const char *component; /* Component (core, supplement, custom) */ - const char *purpose; /* Program purpose */ - const char *keys; /* Program option info for external APIs */ -}; - -static struct Gmt_moduleinfo g_custom_module[] = { - {"gmtaverage", "custom", "Block average (x,y,z) data tables by mean, median, or mode estimation", "DO,RG-"}, - {"gmtmercmap", "custom", "Make a Mercator color map from ETOPO 1, 2, or 5 arc min global relief grids", "CCi,>XO,RG-"}, - {"gmtparser", "custom", "Demonstrate parsing of input data, defaults, and options", ""}, - {"grdfourier", "custom", "Create a grid, add a spike, filter it in frequency domain, and write output", "RVabdefghior" "H" /* The H is for possible compatibility with GMT4 syntax */ -#include "custom_version.h" /* Must include this to use Custom_version */ - -EXTERN_MSC int GMT_gmtaverage (void *API, int mode, void *args); - struct GMTAVERAGE_CTRL { /* All local control options for this program (except common args) */ struct E { /* -E[b] */ unsigned int active; @@ -182,7 +178,7 @@ static int parse (void *API, struct GMTAVERAGE_CTRL *Ctrl, struct GMT_OPTION *op #define Bailout(code) {Free_Options; return (code);} #define Return(code) {Free_Ctrl (Ctrl); Bailout (code);} -int GMT_gmtaverage (void *API, int mode, void *args) { +EXTERN_MSC int GMT_gmtaverage (void *API, int mode, void *args) { int error = 0; char *module = NULL; struct GMT_OPTION *options = NULL, *t_ptr = NULL; diff --git a/src/gmtmercmap.c b/src/gmtmercmap.c index b3635b1..849a4c6 100644 --- a/src/gmtmercmap.c +++ b/src/gmtmercmap.c @@ -35,15 +35,11 @@ #define THIS_MODULE_NEEDS "JR" #define THIS_MODULE_OPTIONS "->BKOPRUVXYcnptxy" -#include "custom_version.h" /* Must include this to use Custom_version */ - #define MAP_BAR_GAP "36p" /* Offset color bar 36 points below map */ #define MAP_BAR_HEIGHT "8p" /* Height of color bar, if used */ #define MAP_OFFSET "100p" /* Start map 100p from paper edge when colorbar is requested */ #define TOPO_INC 500.0 /* Build cpt in steps of 500 meters */ -EXTERN_MSC int GMT_gmtmercmap (void *API, int mode, void *args); - enum enum_script {BASH_MODE = 0, /* Write Bash script */ CSH_MODE, /* Write C-shell script */ DOS_MODE}; /* Write DOS script */ @@ -159,7 +155,7 @@ static int parse (void *API, struct GMTMERCMAP_CTRL *Ctrl, struct GMT_OPTION *op break; case 'W': /* Map width */ Ctrl->W.active = 1; - GMT_Get_Value (API, opt->arg, &Ctrl->W.width); + GMT_Get_Values (API, opt->arg, &Ctrl->W.width, 1); break; case 'S': /* Draw scale beneath map */ Ctrl->S.active = 1; @@ -208,15 +204,15 @@ void place_var (int mode, char *name, unsigned int end) #define bailout(code) {M_free_options (mode); return (code);} #define Return(code) {Free_Ctrl (Ctrl); bailout (code);} -int GMT_gmtmercmap (void *API, int mode, void *args) { +EXTERN_MSC int GMT_gmtmercmap (void *API, int mode, void *args) { int error, min; unsigned int B_active, K_active, O_active, P_active, X_active, Y_active; unsigned int length_unit = 0; /* cm */ double area, z, z_min, z_max, wesn[4]; - char file[256], z_file[GMT_STR16], i_file[GMT_STR16]; - char cmd[BUFSIZ], c_file[GMT_STR16], t_file[GMT_STR16], def_unit[16]; + char file[256], z_file[GMT_VF_LEN], i_file[GMT_VF_LEN]; + char cmd[BUFSIZ], c_file[GMT_VF_LEN], t_file[GMT_VF_LEN], def_unit[16]; static char unit[3] = "cip"; struct GMT_GRID *G = NULL, *I = NULL; diff --git a/src/gmtparser.c b/src/gmtparser.c index 62900cf..370e40e 100644 --- a/src/gmtparser.c +++ b/src/gmtparser.c @@ -21,7 +21,7 @@ * Version: 5 API * * Brief synopsis: gmtparser tests API conversions, common settings, - * and parameters via GMT_Get_Value, GMT_Get_Default, GMT_Get_Common + * and parameters via GMT_Get_Values, GMT_Get_Default, GMT_Get_Common * */ @@ -35,11 +35,8 @@ #define THIS_MODULE_NEEDS "" #define THIS_MODULE_OPTIONS "-BIJKOPRUVXYadefghinorst" /* All the GMT common options */ -#include "custom_version.h" /* Must include this to use Custom_version */ #include -EXTERN_MSC int GMT_gmtparser (void *API, int mode, void *args); - static int usage (void *API, int level) { /* Specifies the full usage message from the program when no argument are given */ const char *name = gmt_show_name_and_purpose (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_PURPOSE); @@ -76,7 +73,7 @@ static void report (char *name, int count, double par[]) { #define Free_Options {if (GMT_Destroy_Options (API, &options) != GMT_NOERROR) return (EXIT_FAILURE);} #define Return(code) {Free_Options; return (code);} -int GMT_gmtparser (void *API, int mode, void *args) { +EXTERN_MSC int GMT_gmtparser (void *API, int mode, void *args) { int ret, k; double value[100]; char input[BUFSIZ], parameter[BUFSIZ], *commons = THIS_MODULE_OPTIONS, string[2] = {0, 0}; @@ -97,7 +94,7 @@ int GMT_gmtparser (void *API, int mode, void *args) { GMT_Message (API, GMT_TIME_CLOCK, "Enter various lengths, distances, coordinates, either one-by-one or comma/slash separated. End with - (a single hyphen):\n"); while (scanf ("%s", input) == 1 && input[0]) { /* As long as user provides input... */ if (!strcmp (input, "-")) break; /* OK, the end signal */ - ret = GMT_Get_Value (API, input, value); /* Convert one or more strings to doubles */ + ret = GMT_Get_Values (API, input, value, 10); /* Convert one or more strings to doubles */ report (input, ret, value); /* Report them as decimal values */ } diff --git a/src/grdfourier.c b/src/grdfourier.c index 35fc22f..3b9f908 100644 --- a/src/grdfourier.c +++ b/src/grdfourier.c @@ -39,8 +39,6 @@ #define MY_FFT_DIM 2 /* Dimension of FFT needed */ -#include "custom_version.h" /* Must include this to use Custom_version */ - /* Add any other include files needed by your program */ #include #include @@ -48,8 +46,6 @@ #define M_PI 3.14159265358979323846 #endif -EXTERN_MSC int GMT_grdfourier (void *API, int mode, void *args); - struct GMT_GRDFOURIER_CTRL { /* Here is where you collect your programs specific options */ struct In { /* Input grid file */ unsigned int active; /* 1 if this option was specified */ @@ -147,7 +143,7 @@ static int parse (void *API, struct GMT_GRDFOURIER_CTRL *Ctrl, struct GMT_OPTION break; case 'A': /* Location of spike */ Ctrl->A.active = 1; - if ((ret = GMT_Get_Value (API, opt->arg, value)) == 2) { + if ((ret = GMT_Get_Values (API, opt->arg, value, 2)) == 2) { Ctrl->A.row = (unsigned int)value[0]; Ctrl->A.col = (unsigned int)value[1]; } @@ -162,7 +158,7 @@ static int parse (void *API, struct GMT_GRDFOURIER_CTRL *Ctrl, struct GMT_OPTION break; case 'F': /* Gaussian filter width */ Ctrl->F.active = 1; - if ((ret = GMT_Get_Value (API, opt->arg, value)) == 1) Ctrl->F.width = value[0]; + if ((ret = GMT_Get_Values (API, opt->arg, value, 1)) == 1) Ctrl->F.width = value[0]; break; case 'G': /* Output file */ Ctrl->G.active = 1; @@ -191,7 +187,7 @@ static int parse (void *API, struct GMT_GRDFOURIER_CTRL *Ctrl, struct GMT_OPTION #define bailout(code) {Free_Options; return (code);} #define Return(code) {Free_Ctrl (API, Ctrl); bailout (code);} -int GMT_grdfourier (void *API, int mode, void *args) { +EXTERN_MSC int GMT_grdfourier (void *API, int mode, void *args) { /* 1. Define local variables */ int error; unsigned int wn_mode = 0; /* To select radial [0], x (1), or y (2) wavenumber */ @@ -236,10 +232,10 @@ int GMT_grdfourier (void *API, int mode, void *args) { y = GMT_Get_Coord (API, GMT_IS_GRID, GMT_Y, Grid); /* Get array of y coordinates */ if (!Ctrl->A.active) { /* We know the grid dimension so we can select the mid point */ - Ctrl->A.row = Grid->header->ny / 2; - Ctrl->A.col = Grid->header->nx / 2; + Ctrl->A.row = Grid->header->n_rows / 2; + Ctrl->A.col = Grid->header->n_columns / 2; } - if (Ctrl->A.row >= Grid->header->ny || Ctrl->A.col >= Grid->header->nx) { + if (Ctrl->A.row >= Grid->header->n_rows || Ctrl->A.col >= Grid->header->n_columns) { GMT_Message (API, GMT_TIME_CLOCK, "Spike is placed outside the grid! We give up.\n"); Return (EXIT_FAILURE); }