diff --git a/CMake/External_Ceres.cmake b/CMake/External_Ceres.cmake index a569676a..d4af9577 100644 --- a/CMake/External_Ceres.cmake +++ b/CMake/External_Ceres.cmake @@ -1,3 +1,6 @@ +if (NOT fletch_BUILD_CXX17) + message(FATAL_ERROR "Ceres requires C++17 support, please enable fletch_BUILD_CXX17") +endif() # Set Eigen dependency if (fletch_ENABLE_Eigen) @@ -34,23 +37,12 @@ if (fletch_ENABLE_GFlags) ) endif() -set (Ceres_PATCH_DIR ${fletch_SOURCE_DIR}/Patches/Ceres/${Ceres_version}) -if (EXISTS ${Ceres_PATCH_DIR}) - set (Ceres_PATCH_COMMAND ${CMAKE_COMMAND} - -DCeres_patch=${Ceres_PATCH_DIR} - -DCeres_source=${fletch_BUILD_PREFIX}/src/Ceres - -P ${Ceres_PATCH_DIR}/Patch.cmake) -else() - set (Ceres_PATCH_COMMAND "") -endif() - ExternalProject_Add(Ceres DEPENDS ${Ceres_DEPENDS} URL ${Ceres_file} URL_MD5 ${Ceres_md5} ${COMMON_EP_ARGS} ${COMMON_CMAKE_EP_ARGS} - PATCH_COMMAND ${Ceres_PATCH_COMMAND} CMAKE_ARGS ${COMMON_CMAKE_ARGS} -DBUILD_SHARED_LIBS:BOOL=ON @@ -85,5 +77,7 @@ else() set(Ceres_DIR \${fletch_ROOT}/lib/cmake/Ceres) endif() +find_package(Ceres @Ceres_version@ REQUIRED) + set(fletch_ENABLED_Ceres TRUE) ") diff --git a/CMake/External_OpenCV.cmake b/CMake/External_OpenCV.cmake index 7ccd95ed..5da4dbe8 100644 --- a/CMake/External_OpenCV.cmake +++ b/CMake/External_OpenCV.cmake @@ -286,7 +286,9 @@ if (CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) endif() # OpenCV 3.3.0 has an option to enable C++ 11 -if (fletch_BUILD_CXX11) +if(fletch_BUILD_CXX17) + list(APPEND OpenCV_EXTRA_BUILD_FLAGS -DENABLE_CXX14:BOOL=ON) +else() list(APPEND OpenCV_EXTRA_BUILD_FLAGS -DENABLE_CXX11:BOOL=ON) endif() diff --git a/CMake/External_libjson.cmake b/CMake/External_libjson.cmake deleted file mode 100644 index 2c39bcc5..00000000 --- a/CMake/External_libjson.cmake +++ /dev/null @@ -1,38 +0,0 @@ - -# libjson must be static on Windows since they provide no exports -if (WIN32) - set(json_build_shared FALSE) -else() - set(json_build_shared TRUE) -endif() - -# The libjson external project for fletch -ExternalProject_Add(libjson - URL ${libjson_url} - URL_MD5 ${libjson_md5} - ${COMMON_EP_ARGS} - ${COMMON_CMAKE_EP_ARGS} - PATCH_COMMAND ${CMAKE_COMMAND} - -Dlibjson_source:STRING=${fletch_BUILD_PREFIX}/src/libjson - -Dlibjson_patch:STRING=${fletch_SOURCE_DIR}/Patches/libjson - -P ${fletch_SOURCE_DIR}/Patches/libjson/Patch.cmake - CMAKE_ARGS - ${COMMON_CMAKE_ARGS} - -DBUILD_SHARED_LIBS:BOOL=${json_build_shared} -) - -fletch_external_project_force_install(PACKAGE libjson) - -set(LIBJSON_ROOT ${fletch_BUILD_INSTALL_PREFIX} CACHE STRING "") -set(LIBJSON_LIBNAME json) - -file(APPEND ${fletch_CONFIG_INPUT} " -######################################## -# libjson -######################################## -set(LIBJSON_ROOT \${fletch_ROOT}) -set(LIBJSON_LIBNAME @LIBJSON_LIBNAME@) - -set(fletch_ENABLED_libjson TRUE) -") - diff --git a/CMake/External_pybind11.cmake b/CMake/External_pybind11.cmake index 032c50d6..e36de080 100644 --- a/CMake/External_pybind11.cmake +++ b/CMake/External_pybind11.cmake @@ -1,7 +1,3 @@ -if (NOT fletch_BUILD_CXX11) - message(FATAL_ERROR "CXX11 must be enabled to use pybind11") -endif() - if (PYTHON_EXECUTABLE) set(pybind_PYTHON_ARGS -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}) endif() diff --git a/CMake/fletch-tarballs.cmake b/CMake/fletch-tarballs.cmake index 89064f79..948d0a63 100644 --- a/CMake/fletch-tarballs.cmake +++ b/CMake/fletch-tarballs.cmake @@ -159,9 +159,9 @@ set(GFlags_dlname "gflags-${GFlags_version}.tar.gz") list(APPEND fletch_external_sources GFlags) # GLog -set(GLog_version "0.3.5") +set(GLog_version "0.6.0") set(GLog_url "https://github.com/google/glog/archive/v${GLog_version}.tar.gz") -set(GLog_md5 "5df6d78b81e51b90ac0ecd7ed932b0d4") +set(GLog_md5 "c98a6068bc9b8ad9cebaca625ca73aa2") set(GLog_dlname "glog-${GLog_version}.tar.gz") list(APPEND fletch_external_sources GLog) @@ -192,15 +192,15 @@ if(NOT WIN32) endif() #SuiteSparse -set(SuiteSparse_version 4.4.5) +set(SuiteSparse_version 4.5.6) set(SuiteSparse_url "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-${SuiteSparse_version}.tar.gz") -set(SuiteSparse_md5 "a2926c27f8a5285e4a10265cc68bbc18") +set(SuiteSparse_md5 "eeb87a842a9b3b0425cf08d97fb3c5ec") list(APPEND fletch_external_sources SuiteSparse) # Ceres Solver -set(Ceres_version 1.14.0) +set(Ceres_version 2.1.0) set(Ceres_url "http://ceres-solver.org/ceres-solver-${Ceres_version}.tar.gz") -set(Ceres_md5 "fd9b4eba8850f0f2ede416cd821aafa5") +set(Ceres_md5 "b75911efa91f7f1c03345fe8504be48e") set(Ceres_dlname "ceres-solver-${Ceres_version}.tar.gz") list(APPEND fletch_external_sources Ceres) @@ -220,15 +220,6 @@ if(WIN32) set(jom_md5 "a021066aefcea8999b382b1c7c12165e") endif() -# libjson -set(libjson_version_major 7) -set(libjson_version_minor 6) -set(libjson_version_patch 1) -set(libjson_version "${libjson_version_major}.${libjson_version_minor}.${libjson_version_patch}") -set(libjson_url "http://sourceforge.net/projects/libjson/files/libjson_${libjson_version}.zip") -set(libjson_md5 "82f3fcbf9f8cf3c4e25e1bdd77d65164") -list(APPEND fletch_external_sources libjson) - # shapelib set(shapelib_version 1.4.1) set(shapelib_url "http://download.osgeo.org/shapelib/shapelib-${shapelib_version}.tar.gz") diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d194fa2..4f5ab5f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.3.0) +cmake_minimum_required(VERSION 3.10.0) project(fletch) # Policy to address @foo@ variable expansion @@ -75,11 +75,11 @@ include(${fletch_CMAKE_DIR}/Utils.cmake) add_custom_target(Download) add_custom_target(fletch-build-install) -# Include CXX11 support -set(fletch_CXX_STANDARD_VERSION "98") -option(fletch_BUILD_CXX11 "" TRUE) -if (fletch_BUILD_CXX11) - set(fletch_CXX_STANDARD_VERSION "11") +set(fletch_CXX_STANDARD_VERSION "11") +# Include CXX17 support +option(fletch_BUILD_CXX17 "Enable C++17 standard" TRUE) +if (fletch_BUILD_CXX17) + set(fletch_CXX_STANDARD_VERSION "17") endif() # diff --git a/Doc/release-notes/master.txt b/Doc/release-notes/master.txt index f060f975..366e55c4 100644 --- a/Doc/release-notes/master.txt +++ b/Doc/release-notes/master.txt @@ -15,3 +15,10 @@ Updates since v1.5.0 * Update GDAL from 2.3.2 to 2.4.4 * Added option to get OpenCV source for version 4.5.1 from PyPI * Added option to use VTK 9.1.0 and made 9.1 the default +* Added option to enable C++17 which is on by default +* Change fallback C++ standard to C++11 from C++98 +* Update CMake minumum required version to 3.10 +* Update Ceres from 1.14.0 to 2.1.0 +* Update GLog from 0.3.5 to 0.6.0 +* Update SuiteSparse from 4.4.5 to 4.5.6 +* Remove libjson from Fletch diff --git a/Patches/Ceres/1.10.0/CMakeLists.txt b/Patches/Ceres/1.10.0/CMakeLists.txt deleted file mode 100644 index bf716dbe..00000000 --- a/Patches/Ceres/1.10.0/CMakeLists.txt +++ /dev/null @@ -1,836 +0,0 @@ -# Ceres Solver - A fast non-linear least squares minimizer -# Copyright 2010, 2011, 2012 Google Inc. All rights reserved. -# http://code.google.com/p/ceres-solver/ -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# * Neither the name of Google Inc. nor the names of its contributors may be -# used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE 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 OWNER 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. -# -# Authors: keir@google.com (Keir Mierle) -# alexs.mac@gmail.com (Alex Stewart) - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) -CMAKE_POLICY(VERSION 2.8) - -IF (COMMAND cmake_policy) - CMAKE_POLICY(SET CMP0003 NEW) -ENDIF (COMMAND cmake_policy) - -PROJECT(CERES C CXX) - -# Set up the git hook to make Gerrit Change-Id: lines in commit messages. -SET (LOCAL_GIT_DIRECTORY) -IF (EXISTS ${CMAKE_SOURCE_DIR}/.git) - # .git directory can be found on Unix based system, or on Windows with - # Git Bash (shipped with msysgit) - SET (LOCAL_GIT_DIRECTORY ${CMAKE_SOURCE_DIR}/.git) -ELSE (EXISTS ${CMAKE_SOURCE_DIR}/.git) - # TODO(keir) Add proper Windows support -ENDIF (EXISTS ${CMAKE_SOURCE_DIR}/.git) - -IF (EXISTS ${LOCAL_GIT_DIRECTORY}) - IF (NOT EXISTS ${LOCAL_GIT_DIRECTORY}/hooks/commit-msg) - # Download the hook only if it is not already present - FILE(DOWNLOAD https://ceres-solver-review.googlesource.com/tools/hooks/commit-msg - ${CMAKE_BINARY_DIR}/commit-msg) - - # Make the downloaded file executable, since it is not by default. - FILE(COPY ${CMAKE_BINARY_DIR}/commit-msg - DESTINATION ${LOCAL_GIT_DIRECTORY}/hooks/ - FILE_PERMISSIONS - OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_WRITE GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE) - ENDIF (NOT EXISTS ${LOCAL_GIT_DIRECTORY}/hooks/commit-msg) -ENDIF (EXISTS ${LOCAL_GIT_DIRECTORY}) - -# Make CMake aware of the cmake folder for local FindXXX scripts, -# append rather than set in case the user has passed their own -# additional paths via -D. -LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -INCLUDE(UpdateCacheVariable) - -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -# Set postfixes for generated libraries based on buildtype. -SET(CMAKE_RELEASE_POSTFIX "") -SET(CMAKE_DEBUG_POSTFIX "-debug") - -# Important: Always bump the second number (e.g. 1.3.x to 1.4.0) for any -# release that changes the ABI. The ABI changes for almost any modification to -# include/ceres (e.g. the public API). If you are unsure about whether -# something is an ABI change, please ask on the list. -# -# For versions without ABI changes, bump the smallest number in CERES_VERSION, -# but leave the CERES_ABI_VERSION unchanged. -SET(CERES_VERSION_MAJOR 1) -SET(CERES_VERSION_MINOR 10) -SET(CERES_VERSION_PATCH 0) -SET(CERES_VERSION - ${CERES_VERSION_MAJOR}.${CERES_VERSION_MINOR}.${CERES_VERSION_PATCH}) -SET(CERES_ABI_VERSION 1.10.0) - -ENABLE_TESTING() - -OPTION(MINIGLOG "Use a stripped down version of glog." OFF) -OPTION(GFLAGS "Enable Google Flags." ON) -OPTION(SUITESPARSE "Enable SuiteSparse." ON) -OPTION(CXSPARSE "Enable CXSparse." ON) -OPTION(LAPACK "Enable use of LAPACK." ON) -# Template specializations for the Schur complement based solvers. If -# compile time, binary size or compiler performance is an issue, you -# may consider disabling this. -OPTION(SCHUR_SPECIALIZATIONS "Enable fixed-size schur specializations." ON) -OPTION(CUSTOM_BLAS - "Use handcoded BLAS routines (usually faster) instead of Eigen." - ON) -# Multithreading using OpenMP -OPTION(OPENMP "Enable threaded solving in Ceres (requires OpenMP)" ON) -OPTION(EIGENSPARSE - "Enable the use of Eigen as a sparse linear algebra library for - solving the nonlinear least squares problems. Enabling this - option will result in an LGPL licensed version of Ceres Solver - as the Simplicial Cholesky factorization in Eigen is licensed under the LGPL. - This does not affect the covariance estimation algorithm, as it - depends on the sparse QR factorization algorithm, which is licensed - under the MPL." - OFF) -OPTION(BUILD_TESTING "Enable tests" ON) -OPTION(BUILD_DOCUMENTATION "Build User's Guide (html)" OFF) -OPTION(BUILD_EXAMPLES "Build examples" ON) -OPTION(BUILD_SHARED_LIBS "Build Ceres as a shared library." OFF) -IF (MSVC) - OPTION(MSVC_USE_STATIC_CRT - "MS Visual Studio: Use static C-Run Time Library in place of shared." OFF) - - IF (BUILD_TESTING AND BUILD_SHARED_LIBS) - MESSAGE( - "-- Disabling tests. The flags BUILD_TESTING and BUILD_SHARED_LIBS" - " are incompatible with MSVC." - ) - UPDATE_CACHE_VARIABLE(BUILD_TESTING OFF) - ENDIF (BUILD_TESTING AND BUILD_SHARED_LIBS) -ENDIF (MSVC) - -# Use ios-cmake to build a static library for iOS -# -# We need to add isysroot to force cmake to find the toolchains from the iOS SDK -# instead of using the standard ones. And add flag mios-simulator-version so clang -# knows we are building for ios simulator but not mac. -# -# You can build for OS (armv7, armv7s, arm64), SIMULATOR (i386) or SIMULATOR64 (x86_64) -# separately and use lipo to merge them into one static library. -# -# There are some features/algorithms are not available in iOS version and the -# minimum supported iOS version is 6.0 now. -# -# Use cmake ../ceres-solver -DCMAKE_TOOLCHAIN_FILE=../ceres-solver/cmake/iOS.cmake \ -# -DIOS_PLATFORM=PLATFORM -DEIGEN_INCLUDE_DIR=/path/to/eigen/header -# to config the cmake. The PLATFORM can be one of OS, SIMULATOR and SIMULATOR64. -# Check the documentation in iOS.cmake to find more options. -# -# After building, you will get a single library: libceres.a, which -# you need to add to your Xcode project. -# -# If you use the lapack and blas, then you also need to add Accelerate.framework -# to your Xcode project's linking dependency. -IF (IOS) - MESSAGE(STATUS "Building Ceres for iOS platform: ${IOS_PLATFORM}") - - UPDATE_CACHE_VARIABLE(MINIGLOG ON) - MESSAGE(STATUS "Building for iOS, forcing use of miniglog instead of glog.") - - UPDATE_CACHE_VARIABLE(SUITESPARSE OFF) - UPDATE_CACHE_VARIABLE(CXSPARSE OFF) - UPDATE_CACHE_VARIABLE(GFLAGS OFF) - UPDATE_CACHE_VARIABLE(OPENMP OFF) - - MESSAGE(STATUS "Building for iOS: SuiteSparse, CXSparse, gflags and OpenMP are not available.") - - UPDATE_CACHE_VARIABLE(BUILD_EXAMPLES OFF) - MESSAGE(STATUS "Building for iOS, will not build examples.") - - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-abi-version=2 -fobjc-arc -isysroot ${CMAKE_OSX_SYSROOT}") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-abi-version=2 -fobjc-arc -isysroot ${CMAKE_OSX_SYSROOT}") - - IF (${IOS_PLATFORM} STREQUAL "SIMULATOR" OR ${IOS_PLATFORM} STREQUAL "SIMULATOR64") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mios-simulator-version-min=6.0") - ENDIF() -ENDIF (IOS) - -# Prior to October 2013, Ceres used some non-CMake standardised variables to -# hold user-specified (as opposed to FindPackage found) include directory and -# library paths for Ceres dependencies. These were were of the form: -# _LIB / _INCLUDE. Since then, Ceres now has -# FindPackage() scripts for all of its dependencies which obey the standard -# CMake variables: _LIBRARIES & _INCLUDE_DIRS. In order -# to ensure backwards compatibility, we use convert any legacy variables to -# _directory_ hints for the FindPackage() scripts. -MACRO(HANDLE_LEGACY_INCLUDE_DEPENDENCY_HINT - LEGACY_VAR DIRECTORY_HINT_VAR) - IF (DEFINED ${LEGACY_VAR}) - # Get the dependency name (all caps) from the hint directory variable - # for the warning message. - STRING(REGEX MATCH "^[^_]*" DEPENDENCY_NAME ${DIRECTORY_HINT_VAR}) - MESSAGE(WARNING "You are defining a legacy variable ${LEGACY_VAR} " - "to specify the include directory for ${DEPENDENCY_NAME}. This is " - "deprecated and support for it will be removed in a future release. " - "Please use either the search directory hints variable: " - "${DIRECTORY_HINT_VAR} or ${DEPENDENCY_NAME}_INCLUDE_DIR to specify " - "exactly the directory used (no search performed), see: " - "http://homes.cs.washington.edu/~sagarwal/ceres-solver/dev/building.html " - "for more information.") - LIST(APPEND ${DIRECTORY_HINT_VAR} ${${LEGACY_VAR}}) - ENDIF (DEFINED ${LEGACY_VAR}) -ENDMACRO(HANDLE_LEGACY_INCLUDE_DEPENDENCY_HINT) - -MACRO(HANDLE_LEGACY_LIBRARY_DEPENDENCY_HINT - LEGACY_VAR DIRECTORY_HINT_VAR) - IF (DEFINED ${LEGACY_VAR}) - # Get the dependency name (all caps) from the hint directory variable - # for the warning message. - STRING(REGEX MATCH "^[^_]*" DEPENDENCY_NAME ${DIRECTORY_HINT_VAR}) - MESSAGE(WARNING "You are defining a legacy variable ${LEGACY_VAR} " - "to specify the library for ${DEPENDENCY_NAME}. This is " - "deprecated and support for it will be removed in a future release. " - "Please use either the search directory hints variable: " - "${DIRECTORY_HINT_VAR} or ${DEPENDENCY_NAME}_LIBRARY to specify " - "exactly the library used (no search performed), see: " - "http://homes.cs.washington.edu/~sagarwal/ceres-solver/dev/building.html " - "for more information.") - IF (EXISTS ${${LEGACY_VAR}} AND - NOT IS_DIRECTORY ${${LEGACY_VAR}}) - # User specified an explicit (library) file using the legacy variable - # interface, hints to FindPackage() scripts are directories so add the - # parent directory of the specified file. - GET_FILENAME_COMPONENT(DIR_HINT ${${LEGACY_VAR}} PATH) - LIST(APPEND ${DIRECTORY_HINT_VAR} ${DIR_HINT}) - ELSEIF (EXISTS ${${LEGACY_VAR}} AND - IS_DIRECTORY ${${LEGACY_VAR}}) - # User specified a directory hint using the legacy variable, use it. - LIST(APPEND ${DIRECTORY_HINT_VAR} ${${LEGACY_VAR}}) - ENDIF() - ENDIF (DEFINED ${LEGACY_VAR}) -ENDMACRO(HANDLE_LEGACY_LIBRARY_DEPENDENCY_HINT) - -UNSET(CERES_COMPILE_OPTIONS) - -# Eigen. -HANDLE_LEGACY_INCLUDE_DEPENDENCY_HINT(EIGEN_INCLUDE EIGEN_INCLUDE_DIR_HINTS) -FIND_PACKAGE(Eigen REQUIRED) -IF (EIGEN_FOUND) - MESSAGE("-- Found Eigen version ${EIGEN_VERSION}: ${EIGEN_INCLUDE_DIRS}") - # Ensure that only MPL2 licensed code is part of the default build. - MESSAGE("") - MESSAGE(" ===============================================================") - IF (EIGENSPARSE) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_USE_EIGEN_SPARSE) - MESSAGE(" Enabling the use of Eigen as a sparse linear algebra library ") - MESSAGE(" for solving the nonlinear least squares problems. Enabling ") - MESSAGE(" this option will result in an LGPL licensed version of ") - MESSAGE(" Ceres Solver as the Simplicial Cholesky factorization in Eigen") - MESSAGE(" is licensed under the LGPL. ") - - IF (EIGEN_VERSION VERSION_LESS 3.2.2) - MESSAGE(" WARNING:") - MESSAGE("") - MESSAGE(" Your version of Eigen is older than version 3.2.2.") - MESSAGE(" The performance of SPARSE_NORMAL_CHOLESKY and SPARSE_SCHUR") - MESSAGE(" linear solvers will suffer. ") - ENDIF (EIGEN_VERSION VERSION_LESS 3.2.2) - - ELSE (EIGENSPARSE) - MESSAGE(" Disabling the use of Eigen as a sparse linear algebra library.") - MESSAGE(" This does not affect the covariance estimation algorithm ") - MESSAGE(" which can still use the EIGEN_SPARSE_QR algorithm.") - ADD_DEFINITIONS(-DEIGEN_MPL2_ONLY) - ENDIF (EIGENSPARSE) - MESSAGE(" ===============================================================") - MESSAGE("") -ENDIF (EIGEN_FOUND) - -# LAPACK (& BLAS). -IF (LAPACK) - FIND_PACKAGE(LAPACK QUIET) - IF (LAPACK_FOUND) - MESSAGE("-- Found LAPACK library: ${LAPACK_LIBRARIES}") - ELSE (LAPACK_FOUND) - MESSAGE("-- Did not find LAPACK library, disabling LAPACK support.") - ENDIF (LAPACK_FOUND) - - FIND_PACKAGE(BLAS QUIET) - IF (BLAS_FOUND) - MESSAGE("-- Found BLAS library: ${BLAS_LIBRARIES}") - ELSE (BLAS_FOUND) - MESSAGE("-- Did not find BLAS library, disabling LAPACK support.") - ENDIF (BLAS_FOUND) - - IF (NOT (LAPACK_FOUND AND BLAS_FOUND)) - UPDATE_CACHE_VARIABLE(LAPACK OFF) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_LAPACK) - ENDIF (NOT (LAPACK_FOUND AND BLAS_FOUND)) -ELSE (LAPACK) - MESSAGE("-- Building without LAPACK.") - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_LAPACK) -ENDIF (LAPACK) - -# SuiteSparse. -IF (SUITESPARSE AND NOT LAPACK) - # If user has disabled LAPACK, but left SUITESPARSE ON, turn it OFF, - # LAPACK controls whether Ceres will be linked, directly or indirectly - # via SuiteSparse to LAPACK. - MESSAGE("-- Disabling SuiteSparse as use of LAPACK has been disabled, " - "turn ON LAPACK to enable (optional) building with SuiteSparse.") - UPDATE_CACHE_VARIABLE(SUITESPARSE OFF) -ENDIF (SUITESPARSE AND NOT LAPACK) -IF (SUITESPARSE) - # By default, if SuiteSparse and all dependencies are found, Ceres is - # built with SuiteSparse support. - - # Check for SuiteSparse and dependencies. - FIND_PACKAGE(SuiteSparse) - IF (SUITESPARSE_FOUND) - # On Ubuntu the system install of SuiteSparse (v3.4.0) up to at least - # Ubuntu 13.10 cannot be used to link shared libraries. - IF (BUILD_SHARED_LIBS AND - SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION) - MESSAGE(FATAL_ERROR "You are attempting to build Ceres as a shared " - "library on Ubuntu using a system package install of SuiteSparse " - "3.4.0. This package is broken and does not support the " - "construction of shared libraries (you can still build Ceres as " - "a static library). If you wish to build a shared version of Ceres " - "you should uninstall the system install of SuiteSparse " - "(libsuitesparse-dev) and perform a source install of SuiteSparse " - "(we recommend that you use the latest version), " - "see: http://homes.cs.washington.edu/~sagarwal" - "/ceres-solver/dev/building.html for more information.") - ENDIF (BUILD_SHARED_LIBS AND - SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION) - - # By default, if all of SuiteSparse's dependencies are found, Ceres is - # built with SuiteSparse support. - MESSAGE("-- Found SuiteSparse ${SUITESPARSE_VERSION}, " - "building with SuiteSparse.") - ELSE (SUITESPARSE_FOUND) - # Disable use of SuiteSparse if it cannot be found and continue. - MESSAGE("-- Did not find all SuiteSparse dependencies, disabling " - "SuiteSparse support.") - UPDATE_CACHE_VARIABLE(SUITESPARSE OFF) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_SUITESPARSE) - ENDIF (SUITESPARSE_FOUND) -ELSE (SUITESPARSE) - MESSAGE("-- Building without SuiteSparse.") - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_SUITESPARSE) -ENDIF (SUITESPARSE) - -# CXSparse. -IF (CXSPARSE) - # Don't search with REQUIRED as we can continue without CXSparse. - FIND_PACKAGE(CXSparse) - IF (CXSPARSE_FOUND) - # By default, if CXSparse and all dependencies are found, Ceres is - # built with CXSparse support. - MESSAGE("-- Found CXSparse version: ${CXSPARSE_VERSION}, " - "building with CXSparse.") - ELSE (CXSPARSE_FOUND) - # Disable use of CXSparse if it cannot be found and continue. - MESSAGE("-- Did not find CXSparse, Building without CXSparse.") - UPDATE_CACHE_VARIABLE(CXSPARSE OFF) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_CXSPARSE) - ENDIF (CXSPARSE_FOUND) -ELSE (CXSPARSE) - MESSAGE("-- Building without CXSparse.") - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_CXSPARSE) - # Mark as advanced (remove from default GUI view) the CXSparse search - # variables in case user enabled CXSPARSE, FindCXSparse did not find it, so - # made search variables visible in GUI for user to set, but then user disables - # CXSPARSE instead of setting them. - MARK_AS_ADVANCED(FORCE CXSPARSE_INCLUDE_DIR - CXSPARSE_LIBRARY) -ENDIF (CXSPARSE) - -# GFlags. -IF (GFLAGS) - HANDLE_LEGACY_INCLUDE_DEPENDENCY_HINT(GFLAGS_INCLUDE GFLAGS_INCLUDE_DIR_HINTS) - HANDLE_LEGACY_LIBRARY_DEPENDENCY_HINT(GFLAGS_LIB GFLAGS_LIBRARY_DIR_HINTS) - - # Don't search with REQUIRED as we can continue without gflags. - FIND_PACKAGE(Gflags) - IF (GFLAGS_FOUND) - MESSAGE("-- Found Google Flags header in: ${GFLAGS_INCLUDE_DIRS}, " - "in namespace: ${GFLAGS_NAMESPACE}") - ELSE (GFLAGS_FOUND) - MESSAGE("-- Did not find Google Flags (gflags), Building without gflags " - "- no tests or tools will be built!") - UPDATE_CACHE_VARIABLE(GFLAGS OFF) - ENDIF (GFLAGS_FOUND) -ELSE (GFLAGS) - MESSAGE("-- Google Flags disabled; no tests or tools will be built!") - # Mark as advanced (remove from default GUI view) the gflags search - # variables in case user enabled GFLAGS, FindGflags did not find it, so - # made search variables visible in GUI for user to set, but then user disables - # GFLAGS instead of setting them. - MARK_AS_ADVANCED(FORCE GFLAGS_INCLUDE_DIR - GFLAGS_LIBRARY) -ENDIF (GFLAGS) - -# MiniGLog. -IF (MINIGLOG) - MESSAGE("-- Compiling minimal glog substitute into Ceres.") - SET(GLOG_INCLUDE_DIRS internal/ceres/miniglog) - MESSAGE("-- Using minimal glog substitute (include): ${GLOG_INCLUDE_DIRS}") - - # Mark as advanced (remove from default GUI view) the glog search - # variables in case user disables MINIGLOG, FindGlog did not find it, so - # made search variables visible in GUI for user to set, but then user enables - # MINIGLOG instead of setting them. - MARK_AS_ADVANCED(FORCE GLOG_INCLUDE_DIR - GLOG_LIBRARY) -ELSE (MINIGLOG) - HANDLE_LEGACY_INCLUDE_DEPENDENCY_HINT(GLOG_INCLUDE GLOG_INCLUDE_DIR_HINTS) - HANDLE_LEGACY_LIBRARY_DEPENDENCY_HINT(GLOG_LIB GLOG_LIBRARY_DIR_HINTS) - - # Don't search with REQUIRED so that configuration continues if not found and - # we can output an error messages explaining MINIGLOG option. - FIND_PACKAGE(Glog) - IF (GLOG_FOUND) - MESSAGE("-- Found Google Log header in: ${GLOG_INCLUDE_DIRS}") - ELSE (GLOG_FOUND) - MESSAGE(FATAL_ERROR "Can't find Google Log. Please set GLOG_INCLUDE_DIR & " - "GLOG_LIBRARY or enable MINIGLOG option to use minimal glog " - "implementation.") - ENDIF (GLOG_FOUND) -ENDIF (MINIGLOG) - -IF (NOT SCHUR_SPECIALIZATIONS) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_RESTRICT_SCHUR_SPECIALIZATION) - MESSAGE("-- Disabling Schur specializations (faster compiles)") -ENDIF (NOT SCHUR_SPECIALIZATIONS) - -IF (NOT CUSTOM_BLAS) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_CUSTOM_BLAS) - MESSAGE("-- Disabling custom blas") -ENDIF (NOT CUSTOM_BLAS) - -IF (OPENMP) - # Clang does not (yet) support OpenMP. - IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - UPDATE_CACHE_VARIABLE(OPENMP OFF) - MESSAGE("-- Compiler is Clang, disabling OpenMP.") - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_THREADS) - ELSE (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - # Find quietly s/t as we can continue without OpenMP if it is not found. - FIND_PACKAGE(OpenMP QUIET) - IF (OPENMP_FOUND) - MESSAGE("-- Building with OpenMP.") - LIST(APPEND CERES_COMPILE_OPTIONS CERES_USE_OPENMP) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - IF (UNIX) - # At least on Linux, we need pthreads to be enabled for mutex to - # compile. This may not work on Windows or Android. - FIND_PACKAGE(Threads REQUIRED) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_HAVE_PTHREAD) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_HAVE_RWLOCK) - ENDIF (UNIX) - ELSE (OPENMP_FOUND) - MESSAGE("-- Failed to find OpenMP, disabling.") - UPDATE_CACHE_VARIABLE(OPENMP OFF) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_THREADS) - ENDIF (OPENMP_FOUND) - ENDIF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") -ELSE (OPENMP) - MESSAGE("-- Building without OpenMP (disabling multithreading).") - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_THREADS) -ENDIF (OPENMP) - -INCLUDE(CheckIncludeFileCXX) -CHECK_INCLUDE_FILE_CXX(unordered_map HAVE_STD_UNORDERED_MAP_HEADER) -IF (HAVE_STD_UNORDERED_MAP_HEADER) - # Finding the unordered_map header doesn't mean that unordered_map - # is in std namespace. - # - # In particular, MSVC 2008 has unordered_map declared in std::tr1. - # In order to support this, we do an extra check to see which - # namespace should be used. - INCLUDE(CheckCXXSourceCompiles) - CHECK_CXX_SOURCE_COMPILES("#include - int main() { - std::unordered_map map; - return 0; - }" - HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - IF (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_STD_UNORDERED_MAP) - MESSAGE("-- Found unordered_map/set in std namespace.") - ELSE (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - CHECK_CXX_SOURCE_COMPILES("#include - int main() { - std::tr1::unordered_map map; - return 0; - }" - HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - IF (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) - MESSAGE("-- Found unordered_map/set in std::tr1 namespace.") - ELSE (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - MESSAGE("-- Found but cannot find either std::unordered_map " - "or std::tr1::unordered_map.") - MESSAGE("-- Replacing unordered_map/set with map/set (warning: slower!)") - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_UNORDERED_MAP) - ENDIF (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - ENDIF (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) -ELSE (HAVE_STD_UNORDERED_MAP_HEADER) - CHECK_INCLUDE_FILE_CXX("tr1/unordered_map" HAVE_TR1_UNORDERED_MAP_HEADER) - IF (HAVE_TR1_UNORDERED_MAP_HEADER) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_TR1_UNORDERED_MAP) - MESSAGE("-- Found tr1/unordered_map/set in std::tr1 namespace.") - ELSE (HAVE_TR1_UNORDERED_MAP_HEADE) - MESSAGE("-- Unable to find or . ") - MESSAGE("-- Replacing unordered_map/set with map/set (warning: slower!)") - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_UNORDERED_MAP) - ENDIF (HAVE_TR1_UNORDERED_MAP_HEADER) -ENDIF (HAVE_STD_UNORDERED_MAP_HEADER) - -INCLUDE(FindSharedPtr) -FIND_SHARED_PTR() -IF (SHARED_PTR_FOUND) - IF (SHARED_PTR_TR1_MEMORY_HEADER) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_TR1_MEMORY_HEADER) - ENDIF (SHARED_PTR_TR1_MEMORY_HEADER) - IF (SHARED_PTR_TR1_NAMESPACE) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_TR1_SHARED_PTR) - ENDIF (SHARED_PTR_TR1_NAMESPACE) -ELSE (SHARED_PTR_FOUND) - MESSAGE(FATAL_ERROR "Unable to find shared_ptr.") -ENDIF (SHARED_PTR_FOUND) - -INCLUDE_DIRECTORIES( - include - internal - internal/ceres - ${GLOG_INCLUDE_DIRS}) -# Eigen SparseQR generates various compiler warnings related to unused and -# uninitialised local variables, which prevents Ceres compilation as we use -# -Werror. To avoid having to individually suppress these warnings around -# the #include statments for Eigen headers across all GCC/Clang versions, we -# tell CMake to treat Eigen headers as system headers. This results in all -# compiler warnings from them being suppressed. -# -# Note that this is *not* propagated to clients, ie CERES_INCLUDE_DIRS -# used by clients after find_package(Ceres) does not identify Eigen as -# as system headers. -INCLUDE_DIRECTORIES(SYSTEM ${EIGEN_INCLUDE_DIRS}) - -IF (SUITESPARSE) - INCLUDE_DIRECTORIES(${SUITESPARSE_INCLUDE_DIRS}) -ENDIF (SUITESPARSE) - -IF (CXSPARSE) - INCLUDE_DIRECTORIES(${CXSPARSE_INCLUDE_DIRS}) -ENDIF (CXSPARSE) - -IF (GFLAGS) - INCLUDE_DIRECTORIES(${GFLAGS_INCLUDE_DIRS}) -ENDIF (GFLAGS) - -IF (BUILD_SHARED_LIBS) - MESSAGE("-- Building Ceres as a shared library.") - # The CERES_BUILDING_SHARED_LIBRARY compile definition is NOT stored in - # CERES_COMPILE_OPTIONS as it must only be defined when Ceres is compiled - # not when it is used as it controls the CERES_EXPORT macro which provides - # dllimport/export support in MSVC. - ADD_DEFINITIONS(-DCERES_BUILDING_SHARED_LIBRARY) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_USING_SHARED_LIBRARY) -ELSE (BUILD_SHARED_LIBS) - MESSAGE("-- Building Ceres as a static library.") -ENDIF (BUILD_SHARED_LIBS) - -# Change the default build type from Debug to Release, while still -# supporting overriding the build type. -# -# The CACHE STRING logic here and elsewhere is needed to force CMake -# to pay attention to the value of these variables. -IF (NOT CMAKE_BUILD_TYPE) - MESSAGE("-- No build type specified; defaulting to CMAKE_BUILD_TYPE=Release.") - SET(CMAKE_BUILD_TYPE Release CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." - FORCE) -ELSE (NOT CMAKE_BUILD_TYPE) - IF (CMAKE_BUILD_TYPE STREQUAL "Debug") - MESSAGE("\n=================================================================================") - MESSAGE("\n-- Build type: Debug. Performance will be terrible!") - MESSAGE("-- Add -DCMAKE_BUILD_TYPE=Release to the CMake command line to get an optimized build.") - MESSAGE("\n=================================================================================") - ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug") -ENDIF (NOT CMAKE_BUILD_TYPE) - -# Set the default Ceres flags to an empty string. -SET (CERES_CXX_FLAGS) - -IF (CMAKE_BUILD_TYPE STREQUAL "Release") - IF (CMAKE_COMPILER_IS_GNUCXX) - # Linux - IF (CMAKE_SYSTEM_NAME MATCHES "Linux") - IF (NOT GCC_VERSION VERSION_LESS 4.2) - SET (CERES_CXX_FLAGS "${CERES_CXX_FLAGS} -march=native -mtune=native") - ENDIF (NOT GCC_VERSION VERSION_LESS 4.2) - ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux") - # Mac OS X - IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") - SET (CERES_CXX_FLAGS "${CERES_CXX_FLAGS} -msse3") - # Use of -fast only applicable for Apple's GCC - # Assume this is being used if GCC version < 4.3 on OSX - EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} - ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion - OUTPUT_VARIABLE GCC_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - IF (GCC_VERSION VERSION_LESS 4.3) - SET (CERES_CXX_FLAGS "${CERES_CXX_FLAGS} -fast") - ENDIF (GCC_VERSION VERSION_LESS 4.3) - ENDIF (CMAKE_SYSTEM_NAME MATCHES "Darwin") - ENDIF (CMAKE_COMPILER_IS_GNUCXX) - IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - # Use of -flto requires use of gold linker & LLVM-gold plugin, which might - # well not be present / in use and without which files will compile, but - # not link ('file not recognized') so explicitly check for support - INCLUDE(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-flto" HAVE_LTO_SUPPORT) - IF (HAVE_LTO_SUPPORT) - MESSAGE(STATUS "Enabling link-time optimization (-flto)") - SET(CERES_CXX_FLAGS "${CERES_CXX_FLAGS} -flto") - ELSE () - MESSAGE(STATUS "Compiler/linker does not support link-time optimization (-flto), disabling.") - ENDIF (HAVE_LTO_SUPPORT) - ENDIF () -ENDIF (CMAKE_BUILD_TYPE STREQUAL "Release") - -SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CERES_CXX_FLAGS}") - -# After the tweaks for the compile settings, disable some warnings on MSVC. -IF (MSVC) - # Disable signed/unsigned int conversion warnings. - ADD_DEFINITIONS("/wd4018") - # Disable warning about using struct/class for the same symobl. - ADD_DEFINITIONS("/wd4099") - # Disable warning about the insecurity of using "std::copy". - ADD_DEFINITIONS("/wd4996") - # Disable performance warning about int-to-bool conversion. - ADD_DEFINITIONS("/wd4800") - # Disable performance warning about fopen insecurity. - ADD_DEFINITIONS("/wd4996") - # Disable warning about int64 to int32 conversion. Disabling - # this warning may not be correct; needs investigation. - # TODO(keir): Investigate these warnings in more detail. - ADD_DEFINITIONS("/wd4244") - # It's not possible to use STL types in DLL interfaces in a portable and - # reliable way. However, that's what happens with Google Log and Google Flags - # on Windows. MSVC gets upset about this and throws warnings that we can't do - # much about. The real solution is to link static versions of Google Log and - # Google Test, but that seems tricky on Windows. So, disable the warning. - ADD_DEFINITIONS("/wd4251") - - # Google Flags doesn't have their DLL import/export stuff set up correctly, - # which results in linker warnings. This is irrelevant for Ceres, so ignore - # the warnings. - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4049") - - # Update the C/CXX flags for MSVC to use either the static or shared - # C-Run Time (CRT) library based on the user option: MSVC_USE_STATIC_CRT. - LIST(APPEND C_CXX_FLAGS - CMAKE_CXX_FLAGS - CMAKE_CXX_FLAGS_DEBUG - CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL - CMAKE_CXX_FLAGS_RELWITHDEBINFO) - - FOREACH(FLAG_VAR ${C_CXX_FLAGS}) - IF (MSVC_USE_STATIC_CRT) - # Use static CRT. - IF (${FLAG_VAR} MATCHES "/MD") - STRING(REGEX REPLACE "/MD" "/MT" ${FLAG_VAR} "${${FLAG_VAR}}") - ENDIF (${FLAG_VAR} MATCHES "/MD") - ELSE (MSVC_USE_STATIC_CRT) - # Use shared, not static, CRT. - IF (${FLAG_VAR} MATCHES "/MT") - STRING(REGEX REPLACE "/MT" "/MD" ${FLAG_VAR} "${${FLAG_VAR}}") - ENDIF (${FLAG_VAR} MATCHES "/MT") - ENDIF (MSVC_USE_STATIC_CRT) - ENDFOREACH() - - # Tuple sizes of 10 are used by Gtest. - ADD_DEFINITIONS("-D_VARIADIC_MAX=10") -ENDIF (MSVC) - -IF (UNIX) - # GCC is not strict enough by default, so enable most of the warnings. - SET(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers") - - #gcc 4.4 doesn't include these flags, so check before adding them. -# include(CheckCXXCompilerFlag) -# check_cxx_compiler_flag("-Werror=all" have_error_all) -# if (have_error_all) -# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=all -Werror=extra") -# endif() -ENDIF (UNIX) - -# Use a larger inlining threshold for Clang, since it hobbles Eigen, -# resulting in an unreasonably slow version of the blas routines. The -# -Qunused-arguments is needed because CMake passes the inline -# threshold to the linker and clang complains about it and dies. -IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - SET(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Qunused-arguments -mllvm -inline-threshold=600") - # Older versions of Clang (<= 2.9) do not support the 'return-type-c-linkage' - # option, so check for its presence before adding it to the default flags set. - INCLUDE(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-Wno-return-type-c-linkage" - HAVE_RETURN_TYPE_C_LINKAGE) - IF (HAVE_RETURN_TYPE_C_LINKAGE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage") - ENDIF(HAVE_RETURN_TYPE_C_LINKAGE) -ENDIF () - -# Xcode 4.5.x used Clang 4.1 (Apple version), this has a bug that prevents -# compilation of Ceres. -IF (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} - ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion - OUTPUT_VARIABLE CLANG_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - # Use version > 4.0 & < 4.2 to catch all 4.1(.x) versions. - IF (CLANG_VERSION VERSION_GREATER 4.0 AND - CLANG_VERSION VERSION_LESS 4.2) - MESSAGE(FATAL_ERROR "You are attempting to build Ceres on OS X using Xcode " - "4.5.x (Clang version: ${CLANG_VERSION}). This version of Clang has a " - "bug that prevents compilation of Ceres, please update to " - "Xcode >= 4.6.3.") - ENDIF (CLANG_VERSION VERSION_GREATER 4.0 AND - CLANG_VERSION VERSION_LESS 4.2) -ENDIF (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - -# Configure the Ceres config.h compile options header using the current -# compile options and put the configured header into the Ceres build -# directory. Note that the ceres/internal subdir in /config where -# the configured config.h is placed is important, because Ceres will be -# built against this configured header, it needs to have the same relative -# include path as it would if it were in the source tree (or installed). -LIST(REMOVE_DUPLICATES CERES_COMPILE_OPTIONS) -INCLUDE(CreateCeresConfig) -CREATE_CERES_CONFIG("${CERES_COMPILE_OPTIONS}" - ${CMAKE_CURRENT_BINARY_DIR}/config/ceres/internal) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/config) - -ADD_SUBDIRECTORY(internal/ceres) - -IF (BUILD_DOCUMENTATION) - MESSAGE("-- Documentation building is enabled") - - # Generate the User's Guide (html). - # The corresponding target is UserGuide, but is included in ALL. - ADD_SUBDIRECTORY(docs) -ENDIF (BUILD_DOCUMENTATION) - -IF (BUILD_EXAMPLES) - MESSAGE("-- Build the examples.") - ADD_SUBDIRECTORY(examples) -ELSE (BUILD_EXAMPLES) - MESSAGE("-- Do not build any example.") -ENDIF (BUILD_EXAMPLES) - -# Setup installation of Ceres public headers. -FILE(GLOB CERES_HDRS ${CMAKE_SOURCE_DIR}/include/ceres/*.h) -INSTALL(FILES ${CERES_HDRS} DESTINATION include/ceres) - -FILE(GLOB CERES_PUBLIC_INTERNAL_HDRS ${CMAKE_SOURCE_DIR}/include/ceres/internal/*.h) -INSTALL(FILES ${CERES_PUBLIC_INTERNAL_HDRS} DESTINATION include/ceres/internal) - -# Also setup installation of Ceres config.h configured with the current -# build options into the installed headers directory. -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/config/ceres/internal/config.h - DESTINATION include/ceres/internal) - - -IF (MINIGLOG) - # Install miniglog header if being used as logging #includes appear in - # installed public Ceres headers. - INSTALL(FILES ${CMAKE_SOURCE_DIR}/internal/ceres/miniglog/glog/logging.h - DESTINATION include/ceres/internal/miniglog/glog) -ENDIF (MINIGLOG) - -# Add an uninstall target to remove all installed files. -CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake.in" - "${CMAKE_BINARY_DIR}/cmake/uninstall.cmake" - IMMEDIATE @ONLY) - -ADD_CUSTOM_TARGET(uninstall - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake/uninstall.cmake) - -# Set relative install paths, which are appended to CMAKE_INSTALL_PREFIX to -# generate the absolute install paths. -IF (WIN32) - SET(RELATIVE_CMAKECONFIG_INSTALL_DIR CMake) -ELSE () - SET(RELATIVE_CMAKECONFIG_INSTALL_DIR share/Ceres) -ENDIF () - -# This "exports" all targets which have been put into the export set -# "CeresExport". This means that CMake generates a file with the given -# filename, which can later on be loaded by projects using this package. -# This file contains ADD_LIBRARY(bar IMPORTED) statements for each target -# in the export set, so when loaded later on CMake will create "imported" -# library targets from these, which can be used in many ways in the same way -# as a normal library target created via a normal ADD_LIBRARY(). -INSTALL(EXPORT CeresExport - DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR} FILE CeresTargets.cmake) - -# Figure out the relative path from the installed Config.cmake file to the -# install prefix (which may be at runtime different from the chosen -# CMAKE_INSTALL_PREFIX if under Windows the package was installed anywhere) -# This relative path will be configured into the CeresConfig.cmake. -FILE(RELATIVE_PATH INSTALL_ROOT_REL_CONFIG_INSTALL_DIR - ${CMAKE_INSTALL_PREFIX}/${RELATIVE_CMAKECONFIG_INSTALL_DIR} - ${CMAKE_INSTALL_PREFIX}) - -# Create a CeresConfig.cmake file. Config.cmake files are searched by -# FIND_PACKAGE() automatically. We configure that file so that we can put any -# information we want in it, e.g. version numbers, include directories, etc. -CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/CeresConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/CeresConfig.cmake" @ONLY) - -# Additionally, when CMake has found a CeresConfig.cmake, it can check for a -# CeresConfigVersion.cmake in the same directory when figuring out the version -# of the package when a version has been specified in the FIND_PACKAGE() call, -# e.g. FIND_PACKAGE(Ceres [1.4.2] REQUIRED). The version argument is optional. -CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/CeresConfigVersion.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/CeresConfigVersion.cmake" @ONLY) - -# Install these files into the same directory as the generated exports-file, -# we include the FindPackage scripts for libraries whose headers are included -# in the public API of Ceres and should thus be present in CERES_INCLUDE_DIRS. -INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/CeresConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/CeresConfigVersion.cmake" - "${CMAKE_SOURCE_DIR}/cmake/FindEigen.cmake" - "${CMAKE_SOURCE_DIR}/cmake/FindGlog.cmake" - DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR}) diff --git a/Patches/Ceres/1.10.0/Patch.cmake b/Patches/Ceres/1.10.0/Patch.cmake deleted file mode 100644 index 3e7b95ca..00000000 --- a/Patches/Ceres/1.10.0/Patch.cmake +++ /dev/null @@ -1,5 +0,0 @@ -#+ -# This file is called as CMake -P script for the patch step of - -file (COPY ${Ceres_patch}/CMakeLists.txt - DESTINATION ${Ceres_source}) diff --git a/Patches/OpenCV/3.4.0/cmake/OpenCVDetectCXXCompiler.cmake b/Patches/OpenCV/3.4.0/cmake/OpenCVDetectCXXCompiler.cmake index 89e479f0..59ae08ea 100644 --- a/Patches/OpenCV/3.4.0/cmake/OpenCVDetectCXXCompiler.cmake +++ b/Patches/OpenCV/3.4.0/cmake/OpenCVDetectCXXCompiler.cmake @@ -147,9 +147,13 @@ if(CMAKE_VERSION VERSION_LESS "3.1") endforeach() endif() -if(ENABLE_CXX11) +if(ENABLE_CXX11 OR ENABLE_CXX14) #cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) - set(CMAKE_CXX_STANDARD 11) + if(ENABLE_CXX14) + set(CMAKE_CXX_STANDARD 14) + else() + set(CMAKE_CXX_STANDARD 11) + endif() set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++11 instead of -std=gnu++11 if(CMAKE_CXX11_COMPILE_FEATURES) diff --git a/Patches/OpenCV/4.2.0/cmake/OpenCVDetectCXXCompiler.cmake b/Patches/OpenCV/4.2.0/cmake/OpenCVDetectCXXCompiler.cmake index 04e34c30..0d9cbe22 100644 --- a/Patches/OpenCV/4.2.0/cmake/OpenCVDetectCXXCompiler.cmake +++ b/Patches/OpenCV/4.2.0/cmake/OpenCVDetectCXXCompiler.cmake @@ -194,7 +194,11 @@ if(CMAKE_VERSION VERSION_LESS "3.1") endforeach() endif() -set(CMAKE_CXX_STANDARD 11) +if(ENABLE_CXX14) + set(CMAKE_CXX_STANDARD 14) +else() + set(CMAKE_CXX_STANDARD 11) +endif() set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++11 instead of -std=gnu++11 if(CMAKE_CXX11_COMPILE_FEATURES) diff --git a/Patches/SuiteSparse/CHOLMOD/Makefile b/Patches/SuiteSparse/CHOLMOD/Makefile new file mode 100644 index 00000000..efabf2e2 --- /dev/null +++ b/Patches/SuiteSparse/CHOLMOD/Makefile @@ -0,0 +1,565 @@ +#=============================================================================== +# CHOLMOD/Lib/Makefile: for compiling the CHOLMOD library +#=============================================================================== + +LIBRARY = libcholmod +VERSION = 3.0.11 +SO_VERSION = 3 + +default: library + +ccode: all + +include ../../SuiteSparse_config/SuiteSparse_config.mk + +# CHOLMOD depends on AMD, SuiteSparse_config, LAPACK, BLAS, +# and optionally METIS, CAMD, and CCOLAMD if the Partition Module is in use +LDLIBS += -lamd -lcolamd -lsuitesparseconfig \ + $(LIB_WITH_PARTITION) $(LAPACK) $(BLAS) + +SO_OPTS += $(CFOPENMP) + +#------------------------------------------------------------------------------- +# With the CUDA BLAS: +ifneq ($(GPU_CONFIG),) +LDLIBS += $(CUDART_LIB) $(CUBLAS_LIB) +endif +#------------------------------------------------------------------------------- + +# compile and install in SuiteSparse/lib +library: + $(MAKE) install INSTALL=$(SUITESPARSE) + +#------------------------------------------------------------------------------- + +I = -I../../AMD/Include -I../../AMD/Source -I../../COLAMD/Include \ + -I../../CCOLAMD/Include -I../../CAMD/Include \ + $(I_WITH_PARTITION) -I../Include -I../../SuiteSparse_config \ + $(CUDA_INC) + +#------------------------------------------------------------------------------- + +C = $(CC) $(CF) $(CHOLMOD_CONFIG) $(CONFIG_PARTITION) + +all: library + +purge: distclean + +distclean: clean + - $(RM) -r $(PURGE) + +clean: + - $(RM) -r $(CLEAN) + +#------------------------------------------------------------------------------- +# ../Include/ directory contains all include files: +#------------------------------------------------------------------------------- + +INC = ../Include/cholmod.h \ + ../Include/cholmod_blas.h \ + ../Include/cholmod_check.h \ + ../Include/cholmod_cholesky.h \ + ../Include/cholmod_complexity.h \ + ../Include/cholmod_config.h \ + ../Include/cholmod_core.h \ + ../Include/cholmod_internal.h \ + ../Include/cholmod_matrixops.h \ + ../Include/cholmod_modify.h \ + ../Include/cholmod_partition.h \ + ../Include/cholmod_supernodal.h \ + ../Include/cholmod_template.h \ + ../Include/cholmod_gpu.h + +#------------------------------------------------------------------------------- +# The 7 CHOLMOD library modules (int, double) +#------------------------------------------------------------------------------- + +CORE = cholmod_aat.o cholmod_add.o cholmod_band.o \ + cholmod_change_factor.o cholmod_common.o cholmod_complex.o \ + cholmod_copy.o cholmod_dense.o cholmod_error.o cholmod_factor.o \ + cholmod_memory.o cholmod_sparse.o \ + cholmod_transpose.o cholmod_triplet.o \ + cholmod_version.o + +CHECK = cholmod_check.o cholmod_read.o cholmod_write.o + +CHOLESKY = cholmod_amd.o cholmod_analyze.o cholmod_colamd.o \ + cholmod_etree.o cholmod_factorize.o cholmod_postorder.o \ + cholmod_rcond.o cholmod_resymbol.o cholmod_rowcolcounts.o \ + cholmod_rowfac.o cholmod_solve.o cholmod_spsolve.o + +MATRIXOPS = cholmod_drop.o cholmod_horzcat.o cholmod_norm.o \ + cholmod_scale.o cholmod_sdmult.o cholmod_ssmult.o \ + cholmod_submatrix.o cholmod_vertcat.o cholmod_symmetry.o + +PARTITION = cholmod_ccolamd.o cholmod_csymamd.o \ + cholmod_metis.o cholmod_nesdis.o cholmod_camd.o + +MODIFY = cholmod_rowadd.o cholmod_rowdel.o cholmod_updown.o + +SUPERNODAL = cholmod_super_numeric.o cholmod_super_solve.o \ + cholmod_super_symbolic.o + +ifneq ($(GPU_CONFIG),) +GPU = cholmod_gpu.o cholmod_gpu_kernels.o +else +GPU = +endif + +DI = $(CORE) $(CHECK) $(CHOLESKY) $(MATRIXOPS) $(MODIFY) $(SUPERNODAL) \ + $(GPU) $(PARTITION) + +#------------------------------------------------------------------------------- +# CHOLMOD library modules (long, double) +#------------------------------------------------------------------------------- + +LCORE = cholmod_l_aat.o cholmod_l_add.o cholmod_l_band.o \ + cholmod_l_change_factor.o cholmod_l_common.o cholmod_l_complex.o \ + cholmod_l_copy.o cholmod_l_dense.o cholmod_l_error.o \ + cholmod_l_factor.o cholmod_l_memory.o \ + cholmod_l_sparse.o cholmod_l_transpose.o cholmod_l_triplet.o \ + cholmod_l_version.o + +LCHECK = cholmod_l_check.o cholmod_l_read.o cholmod_l_write.o + +LCHOLESKY = cholmod_l_amd.o cholmod_l_analyze.o cholmod_l_colamd.o \ + cholmod_l_etree.o cholmod_l_factorize.o cholmod_l_postorder.o \ + cholmod_l_rcond.o cholmod_l_resymbol.o cholmod_l_rowcolcounts.o \ + cholmod_l_rowfac.o cholmod_l_solve.o cholmod_l_spsolve.o + +LMATRIXOPS = cholmod_l_drop.o cholmod_l_horzcat.o cholmod_l_norm.o \ + cholmod_l_scale.o cholmod_l_sdmult.o cholmod_l_ssmult.o \ + cholmod_l_submatrix.o cholmod_l_vertcat.o cholmod_l_symmetry.o + +LPARTITION = cholmod_l_ccolamd.o cholmod_l_csymamd.o \ + cholmod_l_metis.o cholmod_l_nesdis.o cholmod_l_camd.o + +LMODIFY = cholmod_l_rowadd.o cholmod_l_rowdel.o cholmod_l_updown.o + +LSUPERNODAL = cholmod_l_super_numeric.o cholmod_l_super_solve.o \ + cholmod_l_super_symbolic.o + +ifneq ($(GPU_CONFIG),) +LGPU = cholmod_l_gpu.o cholmod_gpu_kernels.o +else +LGPU = +endif + +DL = $(LCORE) $(LCHECK) $(LCHOLESKY) $(LMATRIXOPS) $(LMODIFY) $(LSUPERNODAL) \ + $(LPARTITION) $(LGPU) + +#------------------------------------------------------------------------------- + +# to compile just the double/int version, use OBJ = $(DI) +OBJ = $(DI) $(DL) + +static: $(AR_TARGET) + +$(AR_TARGET): $(OBJ) + $(ARCHIVE) $@ $^ + - $(RANLIB) $@ + +$(OBJ): $(INC) + +#------------------------------------------------------------------------------- +# Check Module: +#------------------------------------------------------------------------------- + +cholmod_check.o: ../Check/cholmod_check.c + $(C) -c $(I) $< + +cholmod_read.o: ../Check/cholmod_read.c + $(C) -c $(I) $< + +cholmod_write.o: ../Check/cholmod_write.c + $(C) -c $(I) $< + +#------------------------------------------------------------------------------- + +cholmod_l_check.o: ../Check/cholmod_check.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_read.o: ../Check/cholmod_read.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_write.o: ../Check/cholmod_write.c + $(C) -DDLONG -c $(I) $< -o $@ + + +#------------------------------------------------------------------------------- +# Core Module: +#------------------------------------------------------------------------------- + +cholmod_common.o: ../Core/cholmod_common.c + $(C) -c $(I) $< + +cholmod_dense.o: ../Core/cholmod_dense.c ../Core/t_cholmod_dense.c + $(C) -c $(I) $< + +cholmod_factor.o: ../Core/cholmod_factor.c + $(C) -c $(I) $< + +cholmod_change_factor.o: ../Core/cholmod_change_factor.c \ + ../Core/t_cholmod_change_factor.c + $(C) -c $(I) $< + +cholmod_memory.o: ../Core/cholmod_memory.c + $(C) -c $(I) $< + +cholmod_sparse.o: ../Core/cholmod_sparse.c + $(C) -c $(I) $< + +cholmod_complex.o: ../Core/cholmod_complex.c + $(C) -c $(I) $< + +cholmod_transpose.o: ../Core/cholmod_transpose.c ../Core/t_cholmod_transpose.c + $(C) -c $(I) $< + +cholmod_band.o: ../Core/cholmod_band.c + $(C) -c $(I) $< + +cholmod_copy.o: ../Core/cholmod_copy.c + $(C) -c $(I) $< + +cholmod_triplet.o: ../Core/cholmod_triplet.c ../Core/t_cholmod_triplet.c + $(C) -c $(I) $< + +cholmod_error.o: ../Core/cholmod_error.c + $(C) -c $(I) $< + +cholmod_aat.o: ../Core/cholmod_aat.c + $(C) -c $(I) $< + +cholmod_add.o: ../Core/cholmod_add.c + $(C) -c $(I) $< + +cholmod_version.o: ../Core/cholmod_version.c + $(C) -c $(I) $< + +#------------------------------------------------------------------------------- + +cholmod_l_common.o: ../Core/cholmod_common.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_dense.o: ../Core/cholmod_dense.c ../Core/t_cholmod_dense.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_factor.o: ../Core/cholmod_factor.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_change_factor.o: ../Core/cholmod_change_factor.c \ + ../Core/t_cholmod_change_factor.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_memory.o: ../Core/cholmod_memory.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_sparse.o: ../Core/cholmod_sparse.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_complex.o: ../Core/cholmod_complex.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_transpose.o: ../Core/cholmod_transpose.c ../Core/t_cholmod_transpose.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_band.o: ../Core/cholmod_band.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_copy.o: ../Core/cholmod_copy.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_triplet.o: ../Core/cholmod_triplet.c ../Core/t_cholmod_triplet.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_error.o: ../Core/cholmod_error.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_aat.o: ../Core/cholmod_aat.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_add.o: ../Core/cholmod_add.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_version.o: ../Core/cholmod_version.c + $(C) -DDLONG -c $(I) $< -o $@ + + +#------------------------------------------------------------------------------- +# Cholesky Module: +#------------------------------------------------------------------------------- + +cholmod_amd.o: ../Cholesky/cholmod_amd.c + $(C) -c $(I) $< + +cholmod_analyze.o: ../Cholesky/cholmod_analyze.c + $(C) -c $(I) $< + +cholmod_colamd.o: ../Cholesky/cholmod_colamd.c + $(C) -c $(I) $< + +cholmod_etree.o: ../Cholesky/cholmod_etree.c + $(C) -c $(I) $< + +cholmod_factorize.o: ../Cholesky/cholmod_factorize.c + $(C) -c $(I) $< + +cholmod_postorder.o: ../Cholesky/cholmod_postorder.c + $(C) -c $(I) $< + +cholmod_rcond.o: ../Cholesky/cholmod_rcond.c + $(C) -c $(I) $< + +cholmod_resymbol.o: ../Cholesky/cholmod_resymbol.c + $(C) -c $(I) $< + +cholmod_rowcolcounts.o: ../Cholesky/cholmod_rowcolcounts.c + $(C) -c $(I) $< + +cholmod_solve.o: ../Cholesky/cholmod_solve.c ../Cholesky/t_cholmod_lsolve.c \ + ../Cholesky/t_cholmod_ltsolve.c ../Cholesky/t_cholmod_solve.c + $(C) -c $(I) $< + +cholmod_spsolve.o: ../Cholesky/cholmod_spsolve.c + $(C) -c $(I) $< + +cholmod_rowfac.o: ../Cholesky/cholmod_rowfac.c ../Cholesky/t_cholmod_rowfac.c + $(C) -c $(I) $< + +#------------------------------------------------------------------------------- + +cholmod_l_amd.o: ../Cholesky/cholmod_amd.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_analyze.o: ../Cholesky/cholmod_analyze.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_colamd.o: ../Cholesky/cholmod_colamd.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_etree.o: ../Cholesky/cholmod_etree.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_factorize.o: ../Cholesky/cholmod_factorize.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_postorder.o: ../Cholesky/cholmod_postorder.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_rcond.o: ../Cholesky/cholmod_rcond.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_resymbol.o: ../Cholesky/cholmod_resymbol.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_rowcolcounts.o: ../Cholesky/cholmod_rowcolcounts.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_solve.o: ../Cholesky/cholmod_solve.c ../Cholesky/t_cholmod_lsolve.c \ + ../Cholesky/t_cholmod_ltsolve.c ../Cholesky/t_cholmod_solve.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_spsolve.o: ../Cholesky/cholmod_spsolve.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_rowfac.o: ../Cholesky/cholmod_rowfac.c ../Cholesky/t_cholmod_rowfac.c + $(C) -DDLONG -c $(I) $< -o $@ + +#------------------------------------------------------------------------------- +# Partition Module: +#------------------------------------------------------------------------------- + +cholmod_ccolamd.o: ../Partition/cholmod_ccolamd.c + $(C) -c $(I) $< + +cholmod_csymamd.o: ../Partition/cholmod_csymamd.c + $(C) -c $(I) $< + +cholmod_camd.o: ../Partition/cholmod_camd.c + $(C) -c $(I) $< + +cholmod_metis.o: ../Partition/cholmod_metis.c + $(C) -c $(I) $< + +cholmod_nesdis.o: ../Partition/cholmod_nesdis.c + $(C) -c $(I) $< + +#------------------------------------------------------------------------------- + +cholmod_l_ccolamd.o: ../Partition/cholmod_ccolamd.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_csymamd.o: ../Partition/cholmod_csymamd.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_camd.o: ../Partition/cholmod_camd.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_metis.o: ../Partition/cholmod_metis.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_nesdis.o: ../Partition/cholmod_nesdis.c + $(C) -DDLONG -c $(I) $< -o $@ + + +#------------------------------------------------------------------------------- +# MatrixOps Module: +#------------------------------------------------------------------------------- + +cholmod_horzcat.o: ../MatrixOps/cholmod_horzcat.c + $(C) -c $(I) $< + +cholmod_norm.o: ../MatrixOps/cholmod_norm.c + $(C) -c $(I) $< + +cholmod_scale.o: ../MatrixOps/cholmod_scale.c + $(C) -c $(I) $< + +cholmod_drop.o: ../MatrixOps/cholmod_drop.c + $(C) -c $(I) $< + +cholmod_sdmult.o: ../MatrixOps/cholmod_sdmult.c \ + ../MatrixOps/t_cholmod_sdmult.c + $(C) -c $(I) $< + +cholmod_ssmult.o: ../MatrixOps/cholmod_ssmult.c + $(C) -c $(I) $< + +cholmod_submatrix.o: ../MatrixOps/cholmod_submatrix.c + $(C) -c $(I) $< + +cholmod_vertcat.o: ../MatrixOps/cholmod_vertcat.c + $(C) -c $(I) $< + +cholmod_symmetry.o: ../MatrixOps/cholmod_symmetry.c + $(C) -c $(I) $< + +#------------------------------------------------------------------------------- + +cholmod_l_horzcat.o: ../MatrixOps/cholmod_horzcat.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_norm.o: ../MatrixOps/cholmod_norm.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_scale.o: ../MatrixOps/cholmod_scale.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_drop.o: ../MatrixOps/cholmod_drop.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_sdmult.o: ../MatrixOps/cholmod_sdmult.c \ + ../MatrixOps/t_cholmod_sdmult.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_ssmult.o: ../MatrixOps/cholmod_ssmult.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_submatrix.o: ../MatrixOps/cholmod_submatrix.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_vertcat.o: ../MatrixOps/cholmod_vertcat.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_symmetry.o: ../MatrixOps/cholmod_symmetry.c + $(C) -DDLONG -c $(I) $< -o $@ + +#------------------------------------------------------------------------------- +# Modify Module: +#------------------------------------------------------------------------------- + +cholmod_rowadd.o: ../Modify/cholmod_rowadd.c + $(C) -c $(I) $< + +cholmod_rowdel.o: ../Modify/cholmod_rowdel.c + $(C) -c $(I) $< + +cholmod_updown.o: ../Modify/cholmod_updown.c \ + ../Modify/t_cholmod_updown.c ../Modify/t_cholmod_updown_numkr.c + $(C) -c $(I) $< + +#------------------------------------------------------------------------------- + +cholmod_l_rowadd.o: ../Modify/cholmod_rowadd.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_rowdel.o: ../Modify/cholmod_rowdel.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_updown.o: ../Modify/cholmod_updown.c \ + ../Modify/t_cholmod_updown.c ../Modify/t_cholmod_updown_numkr.c + $(C) -DDLONG -c $(I) $< -o $@ + + +#------------------------------------------------------------------------------- +# Supernodal Module: +#------------------------------------------------------------------------------- + +cholmod_super_numeric.o: ../Supernodal/cholmod_super_numeric.c \ + ../GPU/t_cholmod_gpu.c \ + ../Supernodal/t_cholmod_super_numeric.c + $(C) -c $(I) $< + +cholmod_super_symbolic.o: ../Supernodal/cholmod_super_symbolic.c + $(C) -c $(I) $< + +cholmod_super_solve.o: ../Supernodal/cholmod_super_solve.c \ + ../Supernodal/t_cholmod_super_solve.c + $(C) -c $(I) $< + +#------------------------------------------------------------------------------- + +cholmod_l_super_numeric.o: ../Supernodal/cholmod_super_numeric.c \ + ../Supernodal/t_cholmod_super_numeric.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_super_symbolic.o: ../Supernodal/cholmod_super_symbolic.c + $(C) -DDLONG -c $(I) $< -o $@ + +cholmod_l_super_solve.o: ../Supernodal/cholmod_super_solve.c \ + ../Supernodal/t_cholmod_super_solve.c + $(C) -DDLONG -c $(I) $< -o $@ + +#------------------------------------------------------------------------------- +# GPU module +#------------------------------------------------------------------------------- + +cholmod_gpu_kernels.o: ../GPU/cholmod_gpu_kernels.cu + $(NVCC) $(I) $(NVCCFLAGS) -c ../GPU/cholmod_gpu_kernels.cu + +cholmod_gpu.o: ../GPU/cholmod_gpu.c + $(C) -c $(I) $< + +cholmod_l_gpu.o: ../GPU/cholmod_gpu.c + $(C) -DDLONG -c $(I) $< -o $@ + +#------------------------------------------------------------------------------- + +# install CHOLMOD +install: $(AR_TARGET) $(INSTALL_LIB)/$(SO_TARGET) + +$(INSTALL_LIB)/$(SO_TARGET): $(OBJ) + @mkdir -p $(INSTALL_LIB) + @mkdir -p $(INSTALL_INCLUDE) + @mkdir -p $(INSTALL_DOC) + $(CC) $(SO_OPTS) $^ -o $@ $(LDLIBS) + ( cd $(INSTALL_LIB) ; ln -sf $(SO_TARGET) $(SO_PLAIN) ) + ( cd $(INSTALL_LIB) ; ln -sf $(SO_TARGET) $(SO_MAIN) ) + $(CP) ../Include/cholmod*.h $(INSTALL_INCLUDE) + $(RM) $(INSTALL_INCLUDE)/cholmod_internal.h + $(CP) ../Doc/CHOLMOD_UserGuide.pdf $(INSTALL_DOC) + $(CP) ../README.txt $(INSTALL_DOC)/CHOLMOD_README.txt + chmod 755 $(INSTALL_LIB)/$(SO_TARGET) + chmod 644 $(INSTALL_INCLUDE)/cholmod*.h + chmod 644 $(INSTALL_DOC)/CHOLMOD_UserGuide.pdf + chmod 644 $(INSTALL_DOC)/CHOLMOD_README.txt + +# uninstall CHOLMOD +uninstall: + $(RM) $(INSTALL_LIB)/$(SO_TARGET) + $(RM) $(INSTALL_LIB)/$(SO_PLAIN) + $(RM) $(INSTALL_LIB)/$(SO_MAIN) + $(RM) $(INSTALL_INCLUDE)/cholmod*.h + $(RM) $(INSTALL_DOC)/CHOLMOD_UserGuide.pdf + $(RM) $(INSTALL_DOC)/CHOLMOD_README.txt + diff --git a/Patches/SuiteSparse/Makefile b/Patches/SuiteSparse/Makefile new file mode 100644 index 00000000..da1e766f --- /dev/null +++ b/Patches/SuiteSparse/Makefile @@ -0,0 +1,258 @@ +#------------------------------------------------------------------------------- +# Makefile for all SuiteSparse packages +#------------------------------------------------------------------------------- + +SUITESPARSE = $(CURDIR) +export SUITESPARSE + +default: go + +include SuiteSparse_config/SuiteSparse_config.mk + +# Compile the default rules for each package +go: metis + ( cd SuiteSparse_config && $(MAKE) ) + ( cd AMD && $(MAKE) library ) + ( cd BTF && $(MAKE) library ) + ( cd CAMD && $(MAKE) library ) + ( cd CCOLAMD && $(MAKE) library ) + ( cd COLAMD && $(MAKE) library ) + ( cd CHOLMOD && $(MAKE) library ) + ( cd CSparse && $(MAKE) library ) + ( cd CXSparse && $(MAKE) library ) + ( cd LDL && $(MAKE) library ) + ( cd KLU && $(MAKE) library ) + ( cd UMFPACK && $(MAKE) library ) + ( cd RBio && $(MAKE) library ) +ifneq ($(GPU_CONFIG),) + ( cd SuiteSparse_GPURuntime && $(MAKE) ) + ( cd GPUQREngine && $(MAKE) ) +endif + ( cd SPQR && $(MAKE) library ) +# ( cd PIRO_BAND && $(MAKE) ) +# ( cd SKYLINE_SVD && $(MAKE) ) + +# install all packages in /usr/local/lib and /usr/local/include +# (note that CSparse is not installed; CXSparse is installed instead) +install: metisinstall + ( cd SuiteSparse_config && $(MAKE) install ) + ( cd AMD && $(MAKE) install ) + ( cd BTF && $(MAKE) install ) + ( cd CAMD && $(MAKE) install ) + ( cd CCOLAMD && $(MAKE) install ) + ( cd COLAMD && $(MAKE) install ) + ( cd CHOLMOD && $(MAKE) install ) + ( cd CXSparse && $(MAKE) install ) + ( cd LDL && $(MAKE) install ) + ( cd KLU && $(MAKE) install ) + ( cd UMFPACK && $(MAKE) install ) + ( cd RBio && $(MAKE) install ) +ifneq (,$(GPU_CONFIG)) + ( cd SuiteSparse_GPURuntime && $(MAKE) install ) + ( cd GPUQREngine && $(MAKE) install ) +endif + ( cd SPQR && $(MAKE) install ) +# ( cd PIRO_BAND && $(MAKE) install ) +# ( cd SKYLINE_SVD && $(MAKE) install ) + $(CP) README.txt $(INSTALL_DOC)/SuiteSparse_README.txt + chmod 644 $(INSTALL_DOC)/SuiteSparse_README.txt + +metisinstall: metis +ifeq (,$(MY_METIS_LIB)) + # install METIS from SuiteSparse/metis-5.1.0 + @mkdir -p $(INSTALL_LIB) + @mkdir -p $(INSTALL_INCLUDE) + @mkdir -p $(INSTALL_DOC) + - $(CP) lib/libmetis.* $(INSTALL_LIB) + - $(CP) metis-5.1.0/manual/manual.pdf $(INSTALL_DOC)/METIS_manual.pdf + - $(CP) metis-5.1.0/README.txt $(INSTALL_DOC)/METIS_README.txt + # the following is needed only on the Mac, so *.dylib is hardcoded: + - $(SO_INSTALL_NAME) $(INSTALL_LIB)/libmetis.dylib $(INSTALL_LIB)/libmetis.dylib + - $(CP) include/metis.h $(INSTALL_INCLUDE) + chmod 755 $(INSTALL_LIB)/libmetis.* + chmod 644 $(INSTALL_INCLUDE)/metis.h + chmod 644 $(INSTALL_DOC)/METIS_manual.pdf + chmod 644 $(INSTALL_DOC)/METIS_README.txt +endif + +# uninstall all packages +uninstall: + $(RM) $(INSTALL_DOC)/SuiteSparse_README.txt + ( cd SuiteSparse_config && $(MAKE) uninstall ) + - ( cd metis-5.1.0 && $(MAKE) uninstall ) + ( cd AMD && $(MAKE) uninstall ) + ( cd CAMD && $(MAKE) uninstall ) + ( cd COLAMD && $(MAKE) uninstall ) + ( cd BTF && $(MAKE) uninstall ) + ( cd KLU && $(MAKE) uninstall ) + ( cd LDL && $(MAKE) uninstall ) + ( cd CCOLAMD && $(MAKE) uninstall ) + ( cd UMFPACK && $(MAKE) uninstall ) + ( cd CHOLMOD && $(MAKE) uninstall ) + ( cd CSparse && $(MAKE) uninstall ) + ( cd CXSparse && $(MAKE) uninstall ) + ( cd RBio && $(MAKE) uninstall ) + ( cd SuiteSparse_GPURuntime && $(MAKE) uninstall ) + ( cd GPUQREngine && $(MAKE) uninstall ) + ( cd SPQR && $(MAKE) uninstall ) +# ( cd PIRO_BAND && $(MAKE) uninstall ) +# ( cd SKYLINE_SVD && $(MAKE) uninstall ) +ifeq (,$(MY_METIS_LIB)) + # uninstall METIS, which came from SuiteSparse/metis-5.1.0 + $(RM) $(INSTALL_LIB)/libmetis.* + $(RM) $(INSTALL_INCLUDE)/metis.h + $(RM) $(INSTALL_DOC)/METIS_manual.pdf + $(RM) $(INSTALL_DOC)/METIS_README.txt +endif + $(RM) -r $(INSTALL_DOC) + +# compile the dynamic libraries +library: metis + ( cd SuiteSparse_config && $(MAKE) ) + ( cd AMD && $(MAKE) library ) + ( cd BTF && $(MAKE) library ) + ( cd CAMD && $(MAKE) library ) + ( cd CCOLAMD && $(MAKE) library ) + ( cd COLAMD && $(MAKE) library ) + ( cd CHOLMOD && $(MAKE) library ) + ( cd KLU && $(MAKE) library ) + ( cd LDL && $(MAKE) library ) + ( cd UMFPACK && $(MAKE) library ) + ( cd CSparse && $(MAKE) library ) + ( cd CXSparse && $(MAKE) library ) + ( cd RBio && $(MAKE) library ) +ifneq (,$(GPU_CONFIG)) + ( cd SuiteSparse_GPURuntime && $(MAKE) library ) + ( cd GPUQREngine && $(MAKE) library ) +endif + ( cd SPQR && $(MAKE) library ) +# ( cd PIRO_BAND && $(MAKE) library ) +# ( cd SKYLINE_SVD && $(MAKE) library ) + +# compile the static libraries (except for metis, which is only dynamic) +static: metis + ( cd SuiteSparse_config && $(MAKE) static ) + ( cd AMD && $(MAKE) static ) + ( cd BTF && $(MAKE) static ) + ( cd CAMD && $(MAKE) static ) + ( cd CCOLAMD && $(MAKE) static ) + ( cd COLAMD && $(MAKE) static ) + ( cd CHOLMOD && $(MAKE) static ) + ( cd KLU && $(MAKE) static ) + ( cd LDL && $(MAKE) static ) + ( cd UMFPACK && $(MAKE) static ) + ( cd CSparse && $(MAKE) static ) + ( cd CXSparse && $(MAKE) static ) + ( cd RBio && $(MAKE) static ) +ifneq (,$(GPU_CONFIG)) + ( cd SuiteSparse_GPURuntime && $(MAKE) static ) + ( cd GPUQREngine && $(MAKE) static ) +endif + ( cd SPQR && $(MAKE) static ) +# ( cd PIRO_BAND && $(MAKE) static ) +# ( cd SKYLINE_SVD && $(MAKE) static ) + +# Remove all files not in the original distribution +purge: + - ( cd SuiteSparse_config && $(MAKE) purge ) + - ( cd metis-5.1.0 && $(MAKE) distclean ) + - ( cd AMD && $(MAKE) purge ) + - ( cd CAMD && $(MAKE) purge ) + - ( cd COLAMD && $(MAKE) purge ) + - ( cd BTF && $(MAKE) purge ) + - ( cd KLU && $(MAKE) purge ) + - ( cd LDL && $(MAKE) purge ) + - ( cd CCOLAMD && $(MAKE) purge ) + - ( cd UMFPACK && $(MAKE) purge ) + - ( cd CHOLMOD && $(MAKE) purge ) + - ( cd CSparse && $(MAKE) purge ) + - ( cd CXSparse && $(MAKE) purge ) + - ( cd RBio && $(MAKE) purge ) + - ( cd MATLAB_Tools/UFcollection && $(RM) *.mex* ) + - ( cd MATLAB_Tools/SSMULT && $(RM) *.mex* ) + - ( cd SuiteSparse_GPURuntime && $(MAKE) purge ) + - ( cd GPUQREngine && $(MAKE) purge ) + - ( cd SPQR && $(MAKE) purge ) +# - ( cd PIRO_BAND && $(MAKE) purge ) +# - ( cd SKYLINE_SVD && $(MAKE) purge ) + - $(RM) MATLAB_Tools/*/*.mex* MATLAB_Tools/spok/private/*.mex* + - $(RM) -r include/* bin/* lib/* share/* + +# Remove all files not in the original distribution, but keep the libraries +clean: + - ( cd SuiteSparse_config && $(MAKE) clean ) + - ( cd metis-5.1.0 && $(MAKE) clean ) + - ( cd AMD && $(MAKE) clean ) + - ( cd CAMD && $(MAKE) clean ) + - ( cd COLAMD && $(MAKE) clean ) + - ( cd BTF && $(MAKE) clean ) + - ( cd KLU && $(MAKE) clean ) + - ( cd LDL && $(MAKE) clean ) + - ( cd CCOLAMD && $(MAKE) clean ) + - ( cd UMFPACK && $(MAKE) clean ) + - ( cd CHOLMOD && $(MAKE) clean ) + - ( cd CSparse && $(MAKE) clean ) + - ( cd CXSparse && $(MAKE) clean ) + - ( cd RBio && $(MAKE) clean ) + - ( cd SuiteSparse_GPURuntime && $(MAKE) clean ) + - ( cd GPUQREngine && $(MAKE) clean ) + - ( cd SPQR && $(MAKE) clean ) +# - ( cd PIRO_BAND && $(MAKE) clean ) +# - ( cd SKYLINE_SVD && $(MAKE) clean ) + +# Create the PDF documentation +docs: + ( cd AMD && $(MAKE) docs ) + ( cd CAMD && $(MAKE) docs ) + ( cd KLU && $(MAKE) docs ) + ( cd LDL && $(MAKE) docs ) + ( cd UMFPACK && $(MAKE) docs ) + ( cd CHOLMOD && $(MAKE) docs ) + ( cd SPQR && $(MAKE) docs ) +# ( cd PIRO_BAND && $(MAKE) docs ) +# ( cd SKYLINE_SVD && $(MAKE) docs ) + +distclean: purge + +# Create CXSparse from CSparse +# Note that the CXSparse directory should initially not exist. +cx: + ( cd CSparse ; $(MAKE) purge ) + ( cd SuiteSparse_config && $(MAKE) ) + ( cd CXSparse_newfiles ; tar cfv - * | gzip -9 > ../CXSparse_newfiles.tar.gz ) + ./CSparse_to_CXSparse CSparse CXSparse CXSparse_newfiles.tar.gz + ( cd CXSparse/Demo ; $(MAKE) ) + ( cd CXSparse/Demo ; $(MAKE) > cs_demo.out ) + ( cd CXSparse ; $(MAKE) purge ) + $(RM) -f CXSparse_newfiles.tar.gz + +# statement coverage (Linux only); this requires a lot of time. +# The umfpack tcov requires a lot of disk space in /tmp +cov: purge + ( cd CXSparse && $(MAKE) cov ) + ( cd CSparse && $(MAKE) cov ) + ( cd CHOLMOD && $(MAKE) cov ) + ( cd KLU && $(MAKE) cov ) + ( cd SPQR && $(MAKE) cov ) + ( cd UMFPACK && $(MAKE) cov ) +# ( cd PIRO_BAND && $(MAKE) cov ) +# ( cd SKYLINE_SVD && $(MAKE) cov ) + +# configure and compile METIS, placing the libmetis.* library in +# SuiteSparse/lib and the metis.h include file in SuiteSparse/include. +metis: include/metis.h + +# Install the shared version of METIS in SuiteSparse/lib. +# The SO_INSTALL_NAME commmand is only needed on the Mac, so *.dylib is +# hardcoded below. +include/metis.h: +ifeq (,$(MY_METIS_LIB)) + - ( cd metis-5.1.0 && $(MAKE) config shared=1 prefix=$(SUITESPARSE) ) + - ( cd metis-5.1.0 && $(MAKE) ) + - ( cd metis-5.1.0 && $(MAKE) install ) + - $(SO_INSTALL_NAME) $(SUITESPARSE)/lib/libmetis.dylib \ + $(SUITESPARSE)/lib/libmetis.dylib +else + @echo 'Using pre-installed METIS 5.1.0 library at ' '[$(MY_METIS_LIB)]' +endif + diff --git a/Patches/SuiteSparse/Patch.cmake b/Patches/SuiteSparse/Patch.cmake index be3623e9..2c413f7c 100644 --- a/Patches/SuiteSparse/Patch.cmake +++ b/Patches/SuiteSparse/Patch.cmake @@ -14,3 +14,10 @@ else() @ONLY ) endif() + +file( COPY ${SuiteSparse_patch}/CHOLMOD/Makefile + DESTINATION ${SuiteSparse_source}/CHOLMOD/Lib + ) +file( COPY ${SuiteSparse_patch}/Makefile + DESTINATION ${SuiteSparse_source} + ) diff --git a/Patches/SuiteSparse/SuiteSparse_config.mk b/Patches/SuiteSparse/SuiteSparse_config.mk index b1163325..dd53eb52 100644 --- a/Patches/SuiteSparse/SuiteSparse_config.mk +++ b/Patches/SuiteSparse/SuiteSparse_config.mk @@ -97,6 +97,12 @@ F77LIB = # For "make install" INSTALL_LIB = @fletch_BUILD_INSTALL_PREFIX@/lib INSTALL_INCLUDE = @fletch_BUILD_INSTALL_PREFIX@/include +INSTALL_DOC = @fletch_BUILD_INSTALL_PREFIX@/doc + +SO_TARGET = $(LIBRARY).so.$(VERSION) +SO_PLAIN = $(LIBRARY).so +SO_MAIN = $(LIBRARY).so.$(SO_VERSION) +SO_OPTS = -shared -Wl,-soname -Wl,$(SO_MAIN) # Which version of MAKE you are using (default is "make") # MAKE = make diff --git a/Patches/libjson/JSONChildren.cpp b/Patches/libjson/JSONChildren.cpp deleted file mode 100644 index 9e54518c..00000000 --- a/Patches/libjson/JSONChildren.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "JSONChildren.h" -#include "JSONNode.h" - -/* - * reserves a certain number of bytes, in memory saving mode it creates a special - * type of child container that will not autoshrink - */ -void jsonChildren::reserve2(jsonChildren *& mine, json_index_t amount) json_nothrow { - if (mine -> array != 0){ - if (mine -> mycapacity < amount){ - mine -> inc(amount - mine -> mycapacity); - #ifdef JSON_LESS_MEMORY - mine = jsonChildren_Reserved::newChildren_Reserved(mine, amount); - #endif - } - } else { - mine -> reserve(amount); - } -} - -void jsonChildren::inc(void) json_nothrow { - JSON_ASSERT(this != 0, JSON_TEXT("Children is null inc")); - if (json_unlikely(mysize == mycapacity)){ //it's full - if (json_unlikely(mycapacity == 0)){ //the array hasn't been created yet - JSON_ASSERT(!array, JSON_TEXT("Expanding a 0 capacity array, but not null")); - #ifdef JSON_LESS_MEMORY - array = json_malloc(1); - mycapacity = 1; - #else - array = json_malloc(8); //8 seems average for JSON, and it's only 64 bytes - mycapacity = 8; - #endif - } else { - #ifdef JSON_LESS_MEMORY - mycapacity += 1; //increment the size of the array - #else - mycapacity <<= 1; //double the size of the array - #endif - array = json_realloc(array, mycapacity); - } - } -} - - -void jsonChildren::inc(json_index_t amount) json_nothrow { - JSON_ASSERT(this != 0, JSON_TEXT("Children is null inc(amount)")); - if (json_unlikely(amount == 0)) return; - if (json_likely(mysize + amount >= mycapacity)){ //it's full - if (json_unlikely(mycapacity == 0)){ //the array hasn't been created yet - JSON_ASSERT(!array, JSON_TEXT("Expanding a 0 capacity array, but not null")); - #ifdef JSON_LESS_MEMORY - array = json_malloc(amount); - mycapacity = amount; - #else - array = json_malloc(amount > 8 ? amount : 8); //8 seems average for JSON, and it's only 64 bytes - mycapacity = amount > 8 ? amount : 8; - #endif - } else { - #ifdef JSON_LESS_MEMORY - mycapacity = mysize + amount; //increment the size of the array - #else - while(mysize + amount > mycapacity){ - mycapacity <<= 1; //double the size of the array - } - #endif - array = json_realloc(array, mycapacity); - } - } -} - -//actually deletes everything within the vector, this is safe to do on an empty or even a null array -void jsonChildren::deleteAll(void) json_nothrow { - JSON_ASSERT(this != 0, JSON_TEXT("Children is null deleteAll")); - json_foreach(this, runner){ - JSON_ASSERT(*runner != 0, JSON_TEXT("a null pointer within the children")); - JSONNode::deleteJSONNode(*runner); //this is why I can't do forward declaration - } -} - -void jsonChildren::doerase(JSONNode ** position, json_index_t number) json_nothrow { - JSON_ASSERT(this != 0, JSON_TEXT("Children is null doerase")); - JSON_ASSERT(array != 0, JSON_TEXT("erasing something from a null array 2")); - JSON_ASSERT(position >= array, JSON_TEXT("position is beneath the start of the array 2")); - JSON_ASSERT(position + number <= array + mysize, JSON_TEXT("erasing out of bounds 2")); - if (position + number >= array + mysize){ - mysize = (json_index_t)(position - array); - #ifndef JSON_ISO_STRICT - JSON_ASSERT((long long)position - (long long)array >= 0, JSON_TEXT("doing negative allocation")); - #endif - } else { - std::memmove(position, position + number, (mysize - (position - array) - number) * sizeof(JSONNode *)); - mysize -= number; - } -} diff --git a/Patches/libjson/Patch.cmake b/Patches/libjson/Patch.cmake deleted file mode 100644 index a878d3b5..00000000 --- a/Patches/libjson/Patch.cmake +++ /dev/null @@ -1,16 +0,0 @@ -#+ -# This file is called as CMake -P script for the patch step of -# External_libjson.cmake to cmake-ify libjson -#- - -# CMake-ify -file(COPY ${libjson_patch}/cmakeify/ DESTINATION ${libjson_source}) -file(REMOVE ${libjson_source}/JSONOptions.h) -file(GLOB_RECURSE junk_files ${libjson_source}/*/._*) -file(REMOVE ${junk_files}) - -file(COPY - ${libjson_patch}/JSONChildren.cpp - DESTINATION - ${libjson_source}/_internal/Source/ - ) diff --git a/Patches/libjson/cmakeify/CMakeLists.txt b/Patches/libjson/cmakeify/CMakeLists.txt deleted file mode 100644 index 3d901fda..00000000 --- a/Patches/libjson/cmakeify/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project(libjson) - -# Setup build directories -if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${libjson_BINARY_DIR}/lib) -endif() -if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${libjson_BINARY_DIR}/lib) -endif() -if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libjson_BINARY_DIR}/bin) -endif() - -set(libjson_VERSION_MAJOR 7) -set(libjson_VERSION_MINOR 6) -set(libjson_VERSION_PATCH 1) -set(libjson_VERSION "${libjson_VERSION_MAJOR}.${libjson_VERSION_MINOR}.${libjson_VERSION_PATCH}") - - -option(BUILD_SHARED_LIBS False "Build stared libraries instead of static") - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() - -set(JSON_LIBNAME "json" CACHE STRING "Name of the installation library") - -# Pre-load some compiler flags -include(${libjson_SOURCE_DIR}/CompilerFlags.cmake) - -# Configure the options header -include(${libjson_SOURCE_DIR}/JSONOptions.cmake) - -configure_file( - ${libjson_SOURCE_DIR}/JSONOptions.h.in - ${libjson_SOURCE_DIR}/JSONOptions.h -) -configure_file( - ${libjson_SOURCE_DIR}/libjson.h - ${libjson_BINARY_DIR}/${JSON_LIBNAME}.h - COPYONLY -) -install(FILES - ${libjson_BINARY_DIR}/${JSON_LIBNAME}.h - ${libjson_SOURCE_DIR}/JSONOptions.h - DESTINATION include/${JSON_LIBNAME} -) -install(DIRECTORY _internal/Dependencies DESTINATION include/${JSON_LIBNAME}) - -include_directories(${libjson_BINARY_DIR}) -add_subdirectory(_internal/Source) diff --git a/Patches/libjson/cmakeify/CompilerFlags.cmake b/Patches/libjson/cmakeify/CompilerFlags.cmake deleted file mode 100644 index b6ba959c..00000000 --- a/Patches/libjson/cmakeify/CompilerFlags.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) -endif() - -if(NOT DEFINED _DEFAULT_FLAGS_SET) - set(_DEFAULT_FLAGS_SET True CACHE INTERNAL "") - if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math -fexpensive-optimizations" CACHE STRING "" FORCE) - set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -ffast-math" CACHE STRING "" FORCE) - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math -fexpensive-optimizations" CACHE STRING "" FORCE) - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -ffast-math" CACHE STRING "" FORCE) - endif() -endif() diff --git a/Patches/libjson/cmakeify/JSONOptions.cmake b/Patches/libjson/cmakeify/JSONOptions.cmake deleted file mode 100644 index 50f760a8..00000000 --- a/Patches/libjson/cmakeify/JSONOptions.cmake +++ /dev/null @@ -1,125 +0,0 @@ -string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE) - -option(JSON_STRICT "" OFF) -mark_as_advanced(JSON_STRICT) - -if(CMAKE_BUILD_TYPE STREQUAL "debug") - option(JSON_DEBUG "" ON) -else() - option(JSON_DEBUG "" OFF) -endif() -mark_as_advanced(JSON_DEBUG) - -option(JSON_ISO_STRICT "" OFF) -mark_as_advanced(JSON_ISO_STRICT) - -option(JSON_SAFE "" ON) -mark_as_advanced(JSON_SAFE) - -option(JSON_STDERROR "" OFF) -mark_as_advanced(JSON_STDERROR) - -option(JSON_PREPARSE "" OFF) -mark_as_advanced(JSON_PREPARSE) - -if(CMAKE_BUILD_TYPE STREQUAL "minsizerel") - option(JSON_LESS_MEMORY "" ON) -else() - option(JSON_LESS_MEMORY "" OFF) -endif() -mark_as_advanced(JSON_LESS_MEMORY) - -option(JSON_UNICODE "" OFF) -mark_as_advanced(JSON_UNICODE) - -option(JSON_REF_COUNT "" ON) -mark_as_advanced(JSON_REF_COUNT) - -option(JSON_BINARY "" ON) -mark_as_advanced(JSON_BINARY) - -option(JSON_EXPOSE_BASE64 "" ON) -mark_as_advanced(JSON_EXPOSE_BASE64) - -option(JSON_ITERATORS "" ON) -mark_as_advanced(JSON_ITERATORS) - -option(JSON_STREAM "" ON) -mark_as_advanced(JSON_STREAM) - -option(JSON_MEMORY_CALLBACKS "" OFF) -mark_as_advanced(JSON_MEMORY_CALLBACKS) - -option(JSON_MEMORY_MANAGE "" OFF) -mark_as_advanced(JSON_MEMORY_MANAGE) - -option(JSON_MUTEX_CALLBACKS "" OFF) -mark_as_advanced(JSON_MUTEX_CALLBACKS) - -option(JSON_MUTEX_MANAGE "" OFF) -mark_as_advanced(JSON_MUTEX_MANAGE) - -option(JSON_NO_C_CONSTS "" OFF) -mark_as_advanced(JSON_NO_C_CONSTS) - -option(JSON_OCTAL "" OFF) -mark_as_advanced(JSON_OCTAL) - -set(JSON_WRITE_PRIORITY "MED" CACHE STRING "") -mark_as_advanced(JSON_WRITE_PRIORITY) - -set(JSON_READ_PRIORITY "HIGH" CACHE STRING "") -mark_as_advanced(JSON_READ_PRIORITY) - -if(WIN32) - set(JSON_NEWLINE "\\r\\n" CACHE STRING "") -else() - set(JSON_NEWLINE "\\n" CACHE STRING "") -endif() -mark_as_advanced(JSON_NEWLINE) - -option(JSON_ESCAPE_WRITES "" ON) -mark_as_advanced(JSON_ESCAPE_WRITES) - -option(JSON_COMMENTS "" ON) -mark_as_advanced(JSON_COMMENTS) - -option(JSON_WRITE_BASH_COMMENTS "" OFF) -mark_as_advanced(JSON_WRITE_BASH_COMMENTS) - -option(JSON_WRITE_SINGLE_LINE_COMMENTS "" OFF) -mark_as_advanced(JSON_WRITE_SINGLE_LINE_COMMENTS) - -option(JSON_VALIDATE "" ON) -mark_as_advanced(JSON_VALIDATE) - -option(JSON_CASE_INSENSITIVE_FUNCTIONS "" ON) -mark_as_advanced(JSON_CASE_INSENSITIVE_FUNCTIONS) - -set(JSON_INDEX_TYPE "unsigned int" CACHE STRING "") -mark_as_advanced(JSON_INDEX_TYPE) - -set(JSON_BOOL_TYPE "char" CACHE STRING "") -mark_as_advanced(JSON_BOOL_TYPE) - -set(JSON_NUMBER_TYPE "double" CACHE STRING "") -mark_as_advanced(JSON_NUMBER_TYPE) - -option(JSON_UNIT_TEST "" OFF) -mark_as_advanced(JSON_UNIT_TEST) - -option(JSON_NO_EXCEPTIONS "" OFF) -mark_as_advanced(JSON_NO_EXCEPTIONS) - -option(JSON_CASTABLE "" ON) -mark_as_advanced(JSON_CASTABLE) - -set(JSON_SECURITY_MAX_NEST_LEVEL "128" CACHE STRING "") -mark_as_advanced(JSON_SECURITY_MAX_NEST_LEVEL) - -set(JSON_SECURITY_MAX_STRING_LENGTH "33554432" CACHE STRING "") -mark_as_advanced(JSON_SECURITY_MAX_STRING_LENGTH) - -set(JSON_SECURITY_MAX_STREAM_OBJECTS "128" CACHE STRING "") -mark_as_advanced(JSON_SECURITY_MAX_STREAM_OBJECTS) - diff --git a/Patches/libjson/cmakeify/JSONOptions.h.in b/Patches/libjson/cmakeify/JSONOptions.h.in deleted file mode 100644 index 37be3717..00000000 --- a/Patches/libjson/cmakeify/JSONOptions.h.in +++ /dev/null @@ -1,326 +0,0 @@ -#ifndef JSON_OPTIONS_H -#define JSON_OPTIONS_H @JSON_OPTIONS_H@ - -/** - * This file holds all of the compiling options for easy access and so - * that you don't have to remember them, or look them up all the time - */ - - -/* - * JSON_LIBRARY must be declared if libjson is compiled as a static or dynamic - * library. This exposes a C-style interface, but none of the inner workings of libjson - */ -/* #define JSON_LIBRARY */ - - -/* - * JSON_STRICT removes all of libjson's extensions. Meaning no comments, no special numbers - */ -#cmakedefine JSON_STRICT - - -/* - * JSON_DEBUG is used to perform extra error checking. Because libjson usually - * does on the fly parsing, validation is impossible, so this option will allow - * you to register an error callback so that you can record what is going wrong - * before the library crashes. This option does not protect from these errors, - * it simply tells you about them, which is nice for debugging, but not preferable - * for release candidates - */ -#cmakedefine JSON_DEBUG - -/* - * Choosing debug mode is a compile time operation in Visual Studio (rather than a - * configure time option as it is with other CMake generators). Since JSON treats - * it as an error on all compilers other than __GNU_C (see JSONDefs.h) if NDEBUG - * and JSON_DEBUG are inconsistent, force them to be consistent. - */ -#ifdef _MSC_VER -#ifdef NDEBUG - #undef JSON_DEBUG -#else - #define JSON_DEBUG -#endif -#endif - - -/* - * JSON_ISO_STRICT turns off all code that uses non-standard C++. This removes all - * references to long long and long double as well as a few others - */ -#cmakedefine JSON_ISO_STRICT - - -/* - * JSON_SAFE performs similarly to JSON_DEBUG, except this option does protect - * from the errors that it encounters. This option is recommended for those who - * feel it's possible for their program to encounter invalid json. - */ -#cmakedefine JSON_SAFE - - -/* - * JSON_STDERROR routes error messages to cerr instead of a callback, this - * option hides the callback registering function. This will usually display - * messages in the console - */ -#cmakedefine JSON_STDERROR - - -/* - * JSON_PREPARSE causes all parsing to be done immediately. By default, libjson - * parses nodes on the fly as they are needed, this makes parsing much faster if - * your program gets a lot of information that it doesn't need. An example of - * this would be a client application communicating with a server if the server - * returns things like last modified date and other things that you don't use. - */ -#cmakedefine JSON_PREPARSE - - -/* - * JSON_LESS_MEMORY will force libjson to let go of memory as quickly as it can - * this is recommended for software that has to run on less than optimal machines. - * It will cut libjson's memory usage by about 20%, but also run slightly slower. - * It's recommended that you also compile using the -Os option, as this will also - * reduce the size of the library - */ -#cmakedefine JSON_LESS_MEMORY - - -/* - * JSON_UNICODE tells libjson to use wstrings instead of regular strings, this - * means that libjson supports the full array of unicode characters, but also takes - * much more memory and processing power. - */ -#cmakedefine JSON_UNICODE - - -/* - * JSON_REF_COUNT causes libjson to reference count JSONNodes, which makes copying - * and passing them around much faster. It is recommended that this stay on for - * most uses - */ -#cmakedefine JSON_REF_COUNT - - -/* - * JSON_BINARY is used to support binary, which is base64 encoded and decoded by libjson, - * if this option is not turned off, no base64 support is included - */ -#cmakedefine JSON_BINARY - - -/* - * JSON_EXPOSE_BASE64 is used to turn on the functionality of libjson's base64 encoding - * and decoding. This may be useful if you want to obfuscate your json, or send binary data over - * a network - */ -#cmakedefine JSON_EXPOSE_BASE64 - - -/* - * JSON_ITERATORS turns on all of libjson's iterating functionality. This would usually - * only be turned off while compiling for use with C - */ -#cmakedefine JSON_ITERATORS - - -/* - * JSON_STREAM turns on libjson's streaming functionality. This allows you to give parts of - * your json into a stream, which will automatically hit a callback when full nodes are - * completed - */ -#cmakedefine JSON_STREAM - - -/* - * JSON_MEMORY_CALLBACKS exposes functions to register callbacks for allocating, resizing, - * and freeing memory. Because libjson is designed for customizability, it is feasible - * that some users would like to further add speed by having the library utilize a memory - * pool. With this option turned on, the default behavior is still done internally unless - * a callback is registered. So you can have this option on and not use it. - */ -#cmakedefine JSON_MEMORY_CALLBACKS - - -/* - * JSON_MEMORY_MANAGE is used to create functionality to automatically track and clean - * up memory that has been allocated by the user. This includes strings, binary data, and - * nodes. It also exposes bulk delete functions. - */ -#cmakedefine JSON_MEMORY_MANAGE - - -/* - * JSON_MUTEX_CALLBACKS exposes functions to register callbacks to lock and unlock - * mutexs and functions to lock and unlock JSONNodes and all of it's children. This - * does not prevent other threads from accessing the node, but will prevent them from - * locking it. It is much easier for the end programmer to allow libjson to manage - * your mutexs because of reference counting and manipulating trees, libjson automatically - * tracks mutex controls for you, so you only ever lock what you need to - */ -#cmakedefine JSON_MUTEX_CALLBACKS - - -/* - * JSON_MUTEX_MANAGE lets you set mutexes and forget them, libjson will not only keep - * track of the mutex, but also keep a count of how many nodes are using it, and delete - * it when there are no more references - */ -#cmakedefine JSON_MUTEX_MANAGE - - -/* - * JSON_NO_C_CONSTS removes consts from the C interface. It still acts the same way, but - * this may be useful for using the header with languages or variants that don't have const - */ -#cmakedefine JSON_NO_C_CONSTS - - -/* - * JSON_OCTAL allows libjson to use octal values in numbers. - */ -#cmakedefine JSON_OCTAL - - -/* - * JSON_WRITE_PRIORITY turns on libjson's writing capabilties. Without this libjson can only - * read and parse json, this allows it to write back out. Changing the value of the writer - * changes how libjson compiles, and how fast it will go when writing - */ -#define JSON_WRITE_PRIORITY @JSON_WRITE_PRIORITY@ - - -/* - * JSON_READ_PRIORITY turns on libjson's reading capabilties. Changing the value of the reader - * changes how libjson compiles, and how fast it will go when writing - */ -#define JSON_READ_PRIORITY @JSON_READ_PRIORITY@ - - -/* - * JSON_NEWLINE affects how libjson writes. If this option is turned on, libjson - * will use whatever it's defined as for the newline signifier, otherwise, it will use - * standard unix \n. - */ -#define JSON_NEWLINE "@JSON_NEWLINE@" - - -/* - * JSON_ESCAPE_WRITES tells the libjson engine to escape special characters when it writes - * out. If this option is turned off, the json it outputs may not adhere to JSON standards - */ -#cmakedefine JSON_ESCAPE_WRITES - - -/* - * JSON_COMMENTS tells libjson to store and write comments. libjson always supports - * parsing json that has comments in it as it simply ignores them, but with this option - * it keeps the comments and allows you to insert further comments - */ -#cmakedefine JSON_COMMENTS - - -/* - * JSON_WRITE_BASH_COMMENTS will cause libjson to write all comments in bash (#) style - * if this option is not turned on, then it will use C-style comments. Bash comments are - * all single line - */ -#cmakedefine JSON_WRITE_BASH_COMMENTS - - -/* - * JSON_WRITE_SINGLE_LINE_COMMENTS will cause libjson to write all comments in using // - * notation, or (#) if that option is on. Some parsers do not support multiline C comments - * although, this option is not needed for bash comments, as they are all single line anyway - */ -#cmakedefine JSON_WRITE_SINGLE_LINE_COMMENTS - - - -/* - * JSON_VALIDATE turns on validation features of libjson. - */ -#cmakedefine JSON_VALIDATE - - -/* - * JSON_CASE_INSENSITIVE_FUNCTIONS turns on funtions for finding child nodes in a case- - * insenititve way - */ -#cmakedefine JSON_CASE_INSENSITIVE_FUNCTIONS - - -/* - * JSON_INDEX_TYPE allows you th change the size type for the children functions. If this - * option is not used then unsigned int is used. This option is useful for cutting down - * on memory, or using huge numbers of child nodes (over 4 billion) - */ -#define JSON_INDEX_TYPE @JSON_INDEX_TYPE@ - - -/* - * JSON_BOOL_TYPE lets you change the bool type for the C interface. Because before C99 there - * was no bool, and even then it's just a typedef, you may want to use something else. If this - * is not defined, it will revert to int - */ -#define JSON_BOOL_TYPE @JSON_BOOL_TYPE@ - - -/* - * JSON_NUMBER_TYPE lets you change the number type for as_float as well as the internal storage for the - * number. If you omit this option, the default double will be used for most cases and float for JSON_LESS_MEMORY - */ -#define JSON_NUMBER_TYPE @JSON_NUMBER_TYPE@ - - -/* - * JSON_UNIT_TEST is used to maintain and debug the libjson. It makes all private - * members and functions public so that tests can do checks of the inner workings - * of libjson. This should not be turned on by end users. - */ -#cmakedefine JSON_UNIT_TEST - - -/* - * JSON_NO_EXCEPTIONS turns off any exception throwing by the library. It may still use exceptions - * internally, but the interface will never throw anything. - */ -#cmakedefine JSON_NO_EXCEPTIONS - - -/* - * JSON_CASTABLE allows you to call as_bool on a number and have it do the 0 or not 0 check, - * it also allows you to ask for a string from a number, or boolean, and have it return the right thing. - * Without this option, those types of requests are undefined. It also exposes the as_array, as_node, and cast - * functions - */ -#cmakedefine JSON_CASTABLE - - -/* - * JSON_SECURITY_MAX_NEST_LEVEL is a security measure added to make prevent against DoS attacks - * This only affects validation, as if you are worried about security attacks, then you are - * most certainly validating json before sending it to be parsed. This option allows you to limitl how many - * levels deep a JSON Node can go. 128 is a good depth to start with - */ -#define JSON_SECURITY_MAX_NEST_LEVEL @JSON_SECURITY_MAX_NEST_LEVEL@ - - -/* - * JSON_SECURITY_MAX_STRING_LENGTH is another security measure, preventing DoS attacks with very long - * strings of JSON. 32MB is the default value for this, this allows large images to be embedded - */ -#define JSON_SECURITY_MAX_STRING_LENGTH @JSON_SECURITY_MAX_STRING_LENGTH@ - - -/* - * JSON_SECURITY_MAX_STREAM_OBJECTS is a security measure for streams. It prevents DoS attacks with - * large number of objects hitting the stream all at once. 128 is a lot of objects, but not out of - * the question for high speed systems. - */ -#define JSON_SECURITY_MAX_STREAM_OBJECTS @JSON_SECURITY_MAX_STREAM_OBJECTS@ - -#endif - diff --git a/Patches/libjson/cmakeify/_internal/Source/CMakeLists.txt b/Patches/libjson/cmakeify/_internal/Source/CMakeLists.txt deleted file mode 100644 index 2af5c859..00000000 --- a/Patches/libjson/cmakeify/_internal/Source/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -include_directories(JSONDefs) - -add_library(json - JSONAllocator.h JSONAllocator.cpp - JSONChildren.h JSONChildren.cpp - JSONDebug.h JSONDebug.cpp - JSONDefs.h - JSONGlobals.h - JSONIterators.cpp - JSONMemory.h JSONMemory.cpp - JSONMemoryPool.h - JSONNode.h JSONNode.cpp - JSONNode_Mutex.cpp - JSONPreparse.h JSONPreparse.cpp - JSONSharedString.h - JSONSingleton.h - JSONStream.h JSONStream.cpp - JSONValidator.h JSONValidator.cpp - JSONWorker.h JSONWorker.cpp - JSONWriter.cpp - JSON_Base64.h - NumberToString.h - - internalJSONNode.h internalJSONNode.cpp - - libjson.cpp -) -set_target_properties(json PROPERTIES - OUTPUT_NAME "${JSON_LIBNAME}" - VERSION "${libjson_VERSION}" - SOVERSION "${libjson_VERSION}" -) -install(TARGETS json - RUNTIME DESTINATION bin - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib -) -file(GLOB JSON_HEADERS *.h) -install(FILES ${JSON_HEADERS} DESTINATION include/${JSON_LIBNAME}/_internal/Source) -install(DIRECTORY JSONDefs DESTINATION include/${JSON_LIBNAME}/_internal/Source) -install(DIRECTORY ../Dependencies DESTINATION include/${JSON_LIBNAME}/_internal) diff --git a/Patches/libjson/cmakeify/_internal/Source/JSONDefs.h b/Patches/libjson/cmakeify/_internal/Source/JSONDefs.h deleted file mode 100644 index 68ce1588..00000000 --- a/Patches/libjson/cmakeify/_internal/Source/JSONDefs.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef JSONDEFS_H -#define JSONDEFS_H - -/* - Defines all of the types of functions and various other definitions - that are used in C applications, this is very useful if dynamically loading - the library instead of linking. -*/ - -#include "../../JSONOptions.h" -#include "JSONDefs/Unknown_C.h" -#include "JSONDefs/GNU_C.h" -#include "JSONDefs/Visual_C.h" -#include "JSONDefs/Strings_Defs.h" - -#define __LIBJSON_MAJOR__ 7 -#define __LIBJSON_MINOR__ 6 -#define __LIBJSON_PATCH__ 1 -#define __LIBJSON_VERSION__ (__LIBJSON_MAJOR__ * 10000 + __LIBJSON_MINOR__ * 100 + __LIBJSON_PATCH__) - -#define JSON_NULL '\0' -#define JSON_STRING '\1' -#define JSON_NUMBER '\2' -#define JSON_BOOL '\3' -#define JSON_ARRAY '\4' -#define JSON_NODE '\5' - -#ifdef __cplusplus - #if defined(JSON_MEMORY_CALLBACKS) || defined(JSON_MEMORY_POOL) - #include "JSONAllocator.h" - #else - #define json_allocator std::allocator - #endif - - #ifdef JSON_STRING_HEADER - #include JSON_STRING_HEADER - #else - typedef std::basic_string, json_allocator > json_string; - #endif -#endif -#define JSON_MAP(x, y) std::map, json_allocator > > - -#ifdef JSON_NO_EXCEPTIONS - #define json_throw(x) - #define json_try - #define json_catch(exception, code) -#else - #define json_throw(x) throw(x) - #define json_try try - #define json_catch(exception, code) catch(exception){ code } -#endif - -#ifdef JSON_STRICT - #ifndef JSON_UNICODE - #error, JSON_UNICODE is required for JSON_STRICT - #endif - #ifdef JSON_COMMENTS - #error, JSON_COMMENTS is required to be off for JSON_STRICT - #endif -#endif - - -#ifdef JSON_NUMBER_TYPE - typedef JSON_NUMBER_TYPE json_number; - #define JSON_FLOAT_THRESHHOLD 0.00001 -#else - #ifdef JSON_LESS_MEMORY - typedef float json_number; - #define JSON_FLOAT_THRESHHOLD 0.00001f - #else - typedef double json_number; - #define JSON_FLOAT_THRESHHOLD 0.00001 - #endif -#endif - - -#ifdef JSON_LESS_MEMORY - /* PACKED and BITS stored in compiler specific headers */ - #define START_MEM_SCOPE { - #define END_MEM_SCOPE } -#else - #define PACKED(x) - #define BITS(x) - #define START_MEM_SCOPE - #define END_MEM_SCOPE -#endif - -#if defined JSON_DEBUG || defined JSON_SAFE - #ifdef JSON_LIBRARY - typedef void (*json_error_callback_t)(const json_char *); - #else - typedef void (*json_error_callback_t)(const json_string &); - #endif -#endif - -#ifdef JSON_INDEX_TYPE - typedef JSON_INDEX_TYPE json_index_t; -#else - typedef unsigned int json_index_t; -#endif - -#ifdef JSON_BOOL_TYPE - typedef JSON_BOOL_TYPE json_bool_t; -#else - typedef int json_bool_t; -#endif - -#ifdef JSON_INT_TYPE - typedef JSON_INT_TYPE json_int_t; -#else - typedef long json_int_t; -#endif - -#define JSONSTREAM_SELF (void*)-1 -typedef void (*json_stream_e_callback_t)(void * identifier); - -typedef void (*json_mutex_callback_t)(void *); -typedef void (*json_free_t)(void *); -#ifndef JSON_LIBRARY - typedef void * (*json_malloc_t)(size_t); - typedef void * (*json_realloc_t)(void *, size_t); -#else - #define JSONNODE void /* so that JSONNODE* is void* */ - typedef JSONNODE** JSONNODE_ITERATOR; - #ifdef JSON_STREAM - #define JSONSTREAM void - typedef void (*json_stream_callback_t)(JSONNODE *, void * identifier); - #endif - typedef void * (*json_malloc_t)(unsigned long); - typedef void * (*json_realloc_t)(void *, unsigned long); -#endif - -/* -#ifdef JSON_DEBUG - #ifdef NDEBUG - #ifdef __GNUC__ - #warning, Have JSON_DEBUG on in a release build - #else - #error, Have JSON_DEBUG on in a release build - #endif - #endif -#else - #ifndef NDEBUG - #ifdef __GNUC__ - #warning, Release build of libjson, but NDEBUG is not on - #else - #error, Release build of libjson, but NDEBUG is not on - #endif - #endif -#endif -*/ - -#ifdef JSON_UNIT_TEST - #define JSON_PRIVATE public: - #define JSON_PROTECTED public: -#else - #define JSON_PRIVATE private: - #define JSON_PROTECTED protected: -#endif -#ifdef JSON_STREAM - #ifndef JSON_READ_PRIORITY - #error, JSON_STREAM also requires JSON_READ_PRIORITY - #endif -#endif -#ifdef JSON_VALIDATE - #ifndef JSON_READ_PRIORITY - #error, JSON_VALIDATE also requires JSON_READ_PRIORITY - #endif -#endif - -#define JSON_TEMP_COMMENT_IDENTIFIER JSON_TEXT('#') - -#endif diff --git a/Patches/libjson/cmakeify/_internal/Source/NumberToString.h b/Patches/libjson/cmakeify/_internal/Source/NumberToString.h deleted file mode 100644 index f3f6a3ed..00000000 --- a/Patches/libjson/cmakeify/_internal/Source/NumberToString.h +++ /dev/null @@ -1,455 +0,0 @@ -#ifndef NUMBERTOSTRING_H -#define NUMBERTOSTRING_H - -#include -#include "JSONDebug.h" -#ifdef JSON_LESS_MEMORY - #include "JSONMemory.h" -#endif -#include "JSONSharedString.h" -#include -#include -template -struct getLenSize{ - char tmp[GETLENSIZE == 16]; // compile time assertion - enum {GETLEN = 41}; -}; - -template<> -struct getLenSize<1>{ - enum {GETLEN = 5}; -}; - -template <> -struct getLenSize<2>{ - enum {GETLEN = 7}; -}; - -template <> -struct getLenSize<4>{ - enum {GETLEN = 12}; -}; - -template <> -struct getLenSize<8>{ - enum {GETLEN = 22}; -}; - -static inline bool _floatsAreEqual(const json_number & one, const json_number & two) json_pure; -static inline bool _floatsAreEqual(const json_number & one, const json_number & two) json_nothrow { - return (one > two) ? (one - two) < JSON_FLOAT_THRESHHOLD : (one - two) > -JSON_FLOAT_THRESHHOLD; -} - -#ifdef JSON_LESS_MEMORY - #define num_str_result s.ptr -#endif - -class NumberToString { -public: - template - static json_string _itoa(T val) json_nothrow { - #ifdef JSON_LESS_MEMORY - json_auto s(getLenSize::GETLEN); - #else - json_char num_str_result[getLenSize::GETLEN]; - #endif - num_str_result[getLenSize::GETLEN - 1] = JSON_TEXT('\0'); //null terminator - json_char * runner = &num_str_result[getLenSize::GETLEN - 2]; - bool negative; - - START_MEM_SCOPE - long value = (long)val; - //first thing, check if it's negative, if so, make it positive - if (value < 0){ - value = -value; - negative = true; - } else { - negative = false; - } - - //create the string - do { - *runner-- = (json_char)(value % 10) + JSON_TEXT('0'); - } while(value /= 10); - END_MEM_SCOPE - - //if it's negative, add the negation - if (negative){ - *runner = JSON_TEXT('-'); - return json_string(runner); - } - return json_string(runner + 1); - } - - #ifndef JSON_LIBRARY - template - static json_string _uitoa(T val) json_nothrow { - #ifdef JSON_LESS_MEMORY - json_auto s(getLenSize::GETLEN); - #else - json_char num_str_result[getLenSize::GETLEN]; - #endif - num_str_result[getLenSize::GETLEN - 1] = JSON_TEXT('\0'); //null terminator - json_char * runner = &num_str_result[getLenSize::GETLEN - 2]; - - //create the string - START_MEM_SCOPE - unsigned long value = (unsigned long)val; - do { - *runner-- = (json_char)(value % 10) + JSON_TEXT('0'); - } while(value /= 10); - END_MEM_SCOPE - - return json_string(runner + 1); - } - #endif - - #ifdef JSON_ISO_STRICT - #define EXTRA_LONG - #define FLOAT_STRING "%f" - #define LFLOAT_STRING L"%f" - #else - #define EXTRA_LONG long - #define FLOAT_STRING "%Lf" - #define LFLOAT_STRING L"%Lf" - #endif - - static json_string _ftoa(json_number value) json_nothrow { - #if _MSC_VER - if (json_unlikely(_isnan(value))){ - #else - if (json_unlikely(std::isnan(value))){ - #endif - return json_string("\"nan\""); - } - #ifndef JSON_LIBRARY - //ScopeCoverage(_ftoa_coverage, 6); - if (json_unlikely(value >= 0.0 && _floatsAreEqual(value, (json_number)((unsigned EXTRA_LONG long)value)))){ - return _uitoa((unsigned EXTRA_LONG long)value); - } else - #else - //ScopeCoverage(_ftoa_coverage, 5); - #endif - if (json_unlikely(_floatsAreEqual(value, (json_number)((long EXTRA_LONG)value)))){ - return _itoa((long EXTRA_LONG)value); - } - - #ifdef JSON_LESS_MEMORY - json_auto s(64); - #else - json_char num_str_result[64]; - #endif - #ifdef JSON_UNICODE - std::swprintf(num_str_result, 63, LFLOAT_STRING, (EXTRA_LONG double)value); - #else - //Thanks to Salvor Hardin for this Visual C++ fix - #ifdef _MSC_VER - _snprintf_s(num_str_result, 63, 63, FLOAT_STRING, (EXTRA_LONG double)value); //yes, 63 appears twice using _snprintf_s() - #else - std::snprintf(num_str_result, 63, FLOAT_STRING, (EXTRA_LONG double)value); - #endif - #endif - //strip the trailing zeros - for(json_char * pos = &num_str_result[0]; *pos; ++pos){ - if (json_unlikely(*pos == '.')){ //only care about after the decimal - for(json_char * runner = pos + 1; *runner; ++runner){ - if (json_likely(*runner != JSON_TEXT('0'))){ - pos = runner + 1; //have to go to the end 1.0001 - } - } - *pos = JSON_TEXT('\0'); - break; - } - } - return json_string(num_str_result); - } - - #if defined(JSON_SAFE) || defined(JSON_DEBUG) - static bool isNumeric(const json_string & str) json_nothrow { - const json_char * p = str.c_str(); - bool decimal = false; - bool scientific = false; - - #ifdef JSON_STRICT - bool leadingzero = false; - #endif - - //first letter is weird - switch(*p){ - case JSON_TEXT('\0'): - return false; - #ifndef JSON_STRICT - case JSON_TEXT('.'): - decimal = true; - break; - case JSON_TEXT('+'): - #endif - case JSON_TEXT('-'): - switch (*(p + 1)){ - case JSON_TEXT('.'): - case JSON_TEXT('e'): - case JSON_TEXT('E'): - case JSON_TEXT('\0'): - return false; - case JSON_TEXT('0'): - #ifdef JSON_STRICT - switch(*(p + 2)){ - case JSON_TEXT('.'): - case JSON_TEXT('e'): - case JSON_TEXT('E'): - leadingzero = false; - break; - case JSON_TEXT('\0'): - return true; - default: - leadingzero = true; - break; - } - #endif - ++p; - break; - default: - break; - } - break; - case JSON_TEXT('1'): - case JSON_TEXT('2'): - case JSON_TEXT('3'): - case JSON_TEXT('4'): - case JSON_TEXT('5'): - case JSON_TEXT('6'): - case JSON_TEXT('7'): - case JSON_TEXT('8'): - case JSON_TEXT('9'): - break; - case JSON_TEXT('0'): - ++p; - #ifdef JSON_STRICT - leadingzero = true; - #endif - switch(*p){ - case JSON_TEXT('.'): - decimal = true; - break; - case JSON_TEXT('e'): - case JSON_TEXT('E'): - #ifdef JSON_STRICT - leadingzero = false; //not leading, just a zero - #endif - scientific = true; - ++p; - switch(*p){ - case JSON_TEXT('\0'): - return false; - case JSON_TEXT('-'): - case JSON_TEXT('+'): - #ifndef JSON_STRICT - case JSON_TEXT('0'): //cant have a leading zero in scrict - #endif - case JSON_TEXT('1'): - case JSON_TEXT('2'): - case JSON_TEXT('3'): - case JSON_TEXT('4'): - case JSON_TEXT('5'): - case JSON_TEXT('6'): - case JSON_TEXT('7'): - case JSON_TEXT('8'): - case JSON_TEXT('9'): - break; - default: - return false; - } - break; - #ifndef JSON_STRICT - case JSON_TEXT('x'): - return (str.find_first_not_of(JSON_TEXT("0123456789ABCDEFabcdef"), 2) == json_string::npos); - case JSON_TEXT('1'): - case JSON_TEXT('2'): - case JSON_TEXT('3'): - case JSON_TEXT('4'): - case JSON_TEXT('5'): - case JSON_TEXT('6'): - case JSON_TEXT('7'): - return (str.find_first_not_of(JSON_TEXT("01234567"), 1) == json_string::npos); - #endif - case JSON_TEXT('\0'): //just 0 - return true; - default: - return false; - } - break; - default: - return false; - } - ++p; - - //next digits - while (*p){ - switch(*p){ - case JSON_TEXT('.'): - if (json_unlikely(decimal)){ - return false; //multiple decimals - } - - if (json_unlikely(scientific)){ - return false; - } - decimal = true; - break; - case JSON_TEXT('e'): - case JSON_TEXT('E'): - if (json_unlikely(scientific)){ - return false; - } - scientific = true; - ++p; - switch(*p){ - case JSON_TEXT('\0'): - return false; - case JSON_TEXT('-'): - case JSON_TEXT('+'): - if (!isdigit(*(p + 1))){ - return false; - } - - #ifdef JSON_STRICT - if (*(p + 1) == JSON_TEXT('0')){ //no leading zeros on scientific notations - return false; - } - #endif - break; - #ifndef JSON_STRICT - case JSON_TEXT('0'): //cant have a leading zero in scrict - #endif - case JSON_TEXT('1'): - case JSON_TEXT('2'): - case JSON_TEXT('3'): - case JSON_TEXT('4'): - case JSON_TEXT('5'): - case JSON_TEXT('6'): - case JSON_TEXT('7'): - case JSON_TEXT('8'): - case JSON_TEXT('9'): - break; - default: - return false; - } - break; - case JSON_TEXT('0'): - case JSON_TEXT('1'): - case JSON_TEXT('2'): - case JSON_TEXT('3'): - case JSON_TEXT('4'): - case JSON_TEXT('5'): - case JSON_TEXT('6'): - case JSON_TEXT('7'): - case JSON_TEXT('8'): - case JSON_TEXT('9'): - break; - default: - return false; - } - ++p; - } - #ifdef JSON_STRICT - if (leadingzero && !decimal){ - return false; - } - #endif - return true; - } - #endif - - #ifdef JSON_STRICT - //much faster because no octal or hex support - static json_number _atof (const json_char * num){ - json_number sign = (json_number)1.0; - - //sign - if (*num==JSON_TEXT('-')){ - sign = -1.0; - ++num; - } else { - } - - //skip leading zero if one - #if defined(JSON_SAFE) || defined(JSON_DEBUG) - bool _leadingzeros = *num == JSON_TEXT('0'); - bool _leadingdigits = false; - #endif - if (*num == JSON_TEXT('0')){ - ++num; - } - #ifdef JSON_STRICT - else if (json_likely(*num < JSON_TEXT('1') || *num > JSON_TEXT('9'))){ - return std::numeric_limits::signaling_NaN(); - } - #endif - - JSON_ASSERT_SAFE(*num != JSON_TEXT('0'), JSON_TEXT("multiple leading zeros"), return std::numeric_limits::signaling_NaN(); ); - - // Number - json_number n = (json_number)0.0; - if (json_likely(*num >= JSON_TEXT('1') && *num <= JSON_TEXT('9'))){ - #if defined(JSON_SAFE) || defined(JSON_DEBUG) - _leadingdigits = true; - #endif - do { - n = (n * 10.0) + (*num++ - JSON_TEXT('0')); - } while (*num >= JSON_TEXT('0') && *num <= JSON_TEXT('9')); - } else { - JSON_ASSERT_SAFE( - (*num) == JSON_TEXT('.') || //.xxx - (*num) == JSON_TEXT('e') || //0Exxx - (*num) == JSON_TEXT('E') || //0exxx - (*num) == JSON_TEXT('\0') //end of the number, just zero - , JSON_TEXT("first digit not a number, e, period, or terminator"), return std::numeric_limits::signaling_NaN(); ); - } - - // Fractional part - json_number scale = (json_number)0.0; - if (*num == JSON_TEXT('.')) { - JSON_ASSERT_SAFE(_leadingzeros || _leadingdigits, JSON_TEXT("period without leading anything"), return std::numeric_limits::signaling_NaN(); ); - ++num; - for(; *num >= JSON_TEXT('0') && *num <= JSON_TEXT('9');){ - n = (n * 10.0) + (*num++ - JSON_TEXT('0')); - --scale; - }; - } else { - JSON_ASSERT_SAFE(!_leadingzeros || n == 0, JSON_TEXT("leading zero on an int"), return std::numeric_limits::signaling_NaN(); ); - JSON_ASSERT_SAFE( - (*num) == JSON_TEXT('e') || //0Exxx - (*num) == JSON_TEXT('E') || //0exxx - (*num) == JSON_TEXT('\0') //end of the number, just zero - , JSON_TEXT("next char not an e or terminator"), return std::numeric_limits::signaling_NaN(); ); - } - - // Exponent - int subscale = 0, signsubscale = 1; - if (json_unlikely(*num == JSON_TEXT('e') || *num == JSON_TEXT('E'))){ - ++num; - switch(*num){ - case JSON_TEXT('+'): - ++num; - break; - case JSON_TEXT('-'): - signsubscale = -1; - ++num; - JSON_ASSERT_SAFE(*num != JSON_TEXT('0'), JSON_TEXT("negative cant be followed by leading zero even after E"), return std::numeric_limits::signaling_NaN(); ); - break; - default: - break; - } - JSON_ASSERT_SAFE(*num != JSON_TEXT('\0'), JSON_TEXT("no exponent for scientific notation"), return std::numeric_limits::signaling_NaN(); ); - while (*num >= JSON_TEXT('0') && *num <= JSON_TEXT('9')){ - subscale=(subscale * 10) + (*num++ - JSON_TEXT('0')); - } - } - - JSON_ASSERT_SAFE(*num == JSON_TEXT('\0'), JSON_TEXT("done with number, not at terminator"), return std::numeric_limits::signaling_NaN(); ); - return sign * n * pow((json_number)10.0, scale + subscale * signsubscale); // number = +/- number.fraction * 10^+/- exponent - } - #endif -}; - -#endif diff --git a/README.rst b/README.rst index 5c4f0a0f..2b6f9d6c 100644 --- a/README.rst +++ b/README.rst @@ -118,8 +118,8 @@ minimum required version of CMake is 3.3.0, but newer versions are strongly recommended. Currently, a compiler with at C++11 support is expected (e.g. GCC 4.8, Visual -Studio 2015) is required. KWIVER requires C++11; however, Fletch may compile -with older compilers. +Studio 2015) is required. KWIVER requires C++17 and some packages may require +C++17 as well. CMake Options ------------- @@ -137,7 +137,7 @@ want the C++ libraries built. ``fletch_ENABLE_ALL_PACKAGES`` Turn all packages on (you can turn some back off later) ``fletch_BUILD_WITH_PYTHON`` Build all the packages with Python support -``fletch_BUILD_CXX11`` Build using C++11 compiler options. +``fletch_BUILD_CXX17`` Build using C++17 compiler options. This is required for KWIVER. ``fletch_DOWNLOAD_DIR`` This is where Fletch will cache downloaded source source code tarballs (default is ``src/Downloads``)