Update all CMake to lowercase function name style. - Updated to new CMake style where function names are all lowercase, this will be backwards compatible as CMake function names are case insensitive. - Updated using Emacs' M-x unscreamify-cmake-buffer. Change-Id: If7219816f560270e59212813aeb021353a64a0e2
diff --git a/CMakeLists.txt b/CMakeLists.txt index b2cb280..20c3499 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -29,50 +29,50 @@ # Authors: keir@google.com (Keir Mierle) # alexs.mac@gmail.com (Alex Stewart) -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) -CMAKE_POLICY(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.0) +cmake_policy(VERSION 2.8) -CMAKE_POLICY(SET CMP0003 NEW) -IF (POLICY CMP0042) - CMAKE_POLICY(SET CMP0042 NEW) -ENDIF() +cmake_policy(SET CMP0003 NEW) +if (POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) +endif() -PROJECT(Ceres C CXX) +project(Ceres C CXX) # 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) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +include(UpdateCacheVariable) # Set up the git hook to make Gerrit Change-Id: lines in commit messages. -INCLUDE(AddGerritCommitHook) -ADD_GERRIT_COMMIT_HOOK() +include(AddGerritCommitHook) +add_gerrit_commit_hook() # On OS X, add the Homebrew prefix to the set of prefixes searched by # CMake in find_path & find_library. This should ensure that we can # still build Ceres even if Homebrew is installed in a non-standard # location (not /usr/local). -IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") - FIND_PROGRAM(HOMEBREW_EXECUTABLE brew) - MARK_AS_ADVANCED(FORCE HOMEBREW_EXECUTABLE) - IF (HOMEBREW_EXECUTABLE) +if (CMAKE_SYSTEM_NAME MATCHES "Darwin") + find_program(HOMEBREW_EXECUTABLE brew) + mark_as_advanced(FORCE HOMEBREW_EXECUTABLE) + if (HOMEBREW_EXECUTABLE) # Detected a Homebrew install, query for its install prefix. - EXECUTE_PROCESS(COMMAND ${HOMEBREW_EXECUTABLE} --prefix + execute_process(COMMAND ${HOMEBREW_EXECUTABLE} --prefix OUTPUT_VARIABLE HOMEBREW_INSTALL_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) - MESSAGE(STATUS "Detected Homebrew with install prefix: " + message(STATUS "Detected Homebrew with install prefix: " "${HOMEBREW_INSTALL_PREFIX}, adding to CMake search paths.") - LIST(APPEND CMAKE_PREFIX_PATH "${HOMEBREW_INSTALL_PREFIX}") - ENDIF() -ENDIF() + list(APPEND CMAKE_PREFIX_PATH "${HOMEBREW_INSTALL_PREFIX}") + endif() +endif() -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(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") +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 @@ -81,30 +81,30 @@ # # 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 +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) +set(CERES_ABI_VERSION 1.10.0) -ENABLE_TESTING() +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) +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 +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 +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 @@ -113,7 +113,7 @@ depends on the sparse QR factorization algorithm, which is licensed under the MPL." OFF) -IF (NOT WIN32) +if (NOT WIN32) # Ceres does not use C++11 internally, however it does use shared_ptr # (required) and unordered_map (if available), both of which were present in # previous iterations of what became C++11. GCC & Clang can have both TR1 & @@ -126,25 +126,25 @@ # # This option is not available on Windows, as there, any new (C++11 etc) # features available are on by default and there is no analogue to -std=c++11. - OPTION(CXX11 "Enable use of C++11 headers if available (requires client code use C++11)." OFF) -ENDIF(NOT WIN32) -OPTION(EXPORT_BUILD_DIR + option(CXX11 "Enable use of C++11 headers if available (requires client code use C++11)." OFF) +endif(NOT WIN32) +option(EXPORT_BUILD_DIR "Export build directory using CMake (enables external use without install)." 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 +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( + 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) + 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 # @@ -168,38 +168,38 @@ # # 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}") +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(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) + update_cache_variable(SUITESPARSE OFF) + update_cache_variable(CXSPARSE OFF) + update_cache_variable(GFLAGS OFF) + update_cache_variable(OPENMP OFF) # Apple claims that the BLAS call dsyrk_ is a private API, and will not allow # you to submit to the Apple Store if the symbol is present. - UPDATE_CACHE_VARIABLE(LAPACK OFF) + update_cache_variable(LAPACK OFF) - MESSAGE(STATUS "Building for iOS: SuiteSparse, CXSparse, LAPACK, gflags, " + message(STATUS "Building for iOS: SuiteSparse, CXSparse, LAPACK, gflags, " "and OpenMP are not available.") - UPDATE_CACHE_VARIABLE(BUILD_EXAMPLES OFF) - MESSAGE(STATUS "Building for iOS, will not build examples.") + 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}") + 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 + if (${IOS_PLATFORM} STREQUAL "SIMULATOR" OR ${IOS_PLATFORM} STREQUAL "SIMULATOR64") # By default, the minimum version is < 7.0, which causes problems with # detection of shared_ptr & unordered_map as pre-7.0 used libstdc++ # but 7.0+ uses libc++ (also LLVM-GCC was removed from Xcode 5). - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mios-simulator-version-min=7.0") - ENDIF() -ENDIF (IOS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mios-simulator-version-min=7.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 @@ -209,139 +209,139 @@ # CMake variables: <DEPENDENCY>_LIBRARIES & <DEPENDENCY>_INCLUDE_DIRS. In order # to ensure backwards compatibility, convert any legacy variables to # _directory_ hints for the FindPackage() scripts. -MACRO(HANDLE_LEGACY_INCLUDE_DEPENDENCY_HINT +macro(HANDLE_LEGACY_INCLUDE_DEPENDENCY_HINT LEGACY_VAR DIRECTORY_HINT_VAR) - IF (DEFINED ${LEGACY_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} " + 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://ceres-solver.org/building.html for more information.") - LIST(APPEND ${DIRECTORY_HINT_VAR} ${${LEGACY_VAR}}) - ENDIF (DEFINED ${LEGACY_VAR}) -ENDMACRO(HANDLE_LEGACY_INCLUDE_DEPENDENCY_HINT) + list(APPEND ${DIRECTORY_HINT_VAR} ${${LEGACY_VAR}}) + endif (DEFINED ${LEGACY_VAR}) +endmacro(HANDLE_LEGACY_INCLUDE_DEPENDENCY_HINT) -MACRO(HANDLE_LEGACY_LIBRARY_DEPENDENCY_HINT +macro(HANDLE_LEGACY_LIBRARY_DEPENDENCY_HINT LEGACY_VAR DIRECTORY_HINT_VAR) - IF (DEFINED ${LEGACY_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} " + 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://ceres-solver.org/building.html for more information.") - IF (EXISTS ${${LEGACY_VAR}} AND + 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 + 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) + list(APPEND ${DIRECTORY_HINT_VAR} ${${LEGACY_VAR}}) + endif() + endif (DEFINED ${LEGACY_VAR}) +endmacro(HANDLE_LEGACY_LIBRARY_DEPENDENCY_HINT) -UNSET(CERES_COMPILE_OPTIONS) +unset(CERES_COMPILE_OPTIONS) # Eigen. -HANDLE_LEGACY_INCLUDE_DEPENDENCY_HINT(EIGEN_INCLUDE EIGEN_INCLUDE_DIR_HINTS) -FIND_PACKAGE(Eigen REQUIRED) -IF (EIGEN_FOUND) - IF (EIGEN_VERSION VERSION_LESS 3.1.0) - MESSAGE(FATAL_ERROR "-- Ceres requires Eigen version >= 3.1.0 in order " +handle_legacy_include_dependency_hint(EIGEN_INCLUDE EIGEN_INCLUDE_DIR_HINTS) +find_package(Eigen REQUIRED) +if (EIGEN_FOUND) + if (EIGEN_VERSION VERSION_LESS 3.1.0) + message(FATAL_ERROR "-- Ceres requires Eigen version >= 3.1.0 in order " "that Eigen/SparseCore be available, detected version of Eigen is: " "${EIGEN_VERSION}") - ENDIF (EIGEN_VERSION VERSION_LESS 3.1.0) + endif (EIGEN_VERSION VERSION_LESS 3.1.0) - MESSAGE("-- Found Eigen version ${EIGEN_VERSION}: ${EIGEN_INCLUDE_DIRS}") + 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. ") + 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) + 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) + 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) +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) + 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) + 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 (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, " + 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) + 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) + 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 + 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 " + 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 " @@ -350,219 +350,219 @@ "(libsuitesparse-dev) and perform a source install of SuiteSparse " "(we recommend that you use the latest version), " "see http://ceres-solver.org/building.html for more information.") - ENDIF (BUILD_SHARED_LIBS AND + 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}, " + message("-- Found SuiteSparse ${SUITESPARSE_VERSION}, " "building with SuiteSparse.") - ELSE (SUITESPARSE_FOUND) + else (SUITESPARSE_FOUND) # Disable use of SuiteSparse if it cannot be found and continue. - MESSAGE("-- Did not find all SuiteSparse dependencies, disabling " + 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) + 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) +if (CXSPARSE) # Don't search with REQUIRED as we can continue without CXSparse. - FIND_PACKAGE(CXSparse) - IF (CXSPARSE_FOUND) + 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}, " + message("-- Found CXSparse version: ${CXSPARSE_VERSION}, " "building with CXSparse.") - ELSE (CXSPARSE_FOUND) + 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) + 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 + mark_as_advanced(FORCE CXSPARSE_INCLUDE_DIR CXSPARSE_LIBRARY) -ENDIF (CXSPARSE) +endif (CXSPARSE) # Ensure that the user understands they have disabled all sparse libraries. -IF (NOT SUITESPARSE AND NOT CXSPARSE AND NOT EIGENSPARSE) - MESSAGE(" ===============================================================") - MESSAGE(" Compiling without any sparse library: SuiteSparse, CXSparse ") - MESSAGE(" & Eigen (Sparse) are all disabled or unavailable. No sparse ") - MESSAGE(" linear solvers (SPARSE_NORMAL_CHOLESKY & SPARSE_SCHUR)") - MESSAGE(" will be available when Ceres is used.") - MESSAGE(" ===============================================================") -ENDIF(NOT SUITESPARSE AND NOT CXSPARSE AND NOT EIGENSPARSE) +if (NOT SUITESPARSE AND NOT CXSPARSE AND NOT EIGENSPARSE) + message(" ===============================================================") + message(" Compiling without any sparse library: SuiteSparse, CXSparse ") + message(" & Eigen (Sparse) are all disabled or unavailable. No sparse ") + message(" linear solvers (SPARSE_NORMAL_CHOLESKY & SPARSE_SCHUR)") + message(" will be available when Ceres is used.") + message(" ===============================================================") +endif(NOT SUITESPARSE AND NOT CXSPARSE AND NOT EIGENSPARSE) # 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) +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}, " + 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 " + 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!") + 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 + mark_as_advanced(FORCE GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY GFLAGS_NAMESPACE) -ENDIF (GFLAGS) +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}") +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 + 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) +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 & " + 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) + 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 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 (NOT CUSTOM_BLAS) + list(APPEND CERES_COMPILE_OPTIONS CERES_NO_CUSTOM_BLAS) + message("-- Disabling custom blas") +endif (NOT CUSTOM_BLAS) -IF (OPENMP) +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") + 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) + 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) + 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(CheckCXXCompilerFlag) -CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_HAS_CXX11_FLAG) -IF (CXX11 AND COMPILER_HAS_CXX11_FLAG) +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag("-std=c++11" COMPILER_HAS_CXX11_FLAG) +if (CXX11 AND COMPILER_HAS_CXX11_FLAG) # Update CMAKE_REQUIRED_FLAGS used by CheckCXXSourceCompiles to include # -std=c++11 s/t we will detect the C++11 versions of unordered_map & # shared_ptr if they exist. - SET(CMAKE_REQUIRED_FLAGS -std=c++11) -ENDIF (CXX11 AND COMPILER_HAS_CXX11_FLAG) + set(CMAKE_REQUIRED_FLAGS -std=c++11) +endif (CXX11 AND COMPILER_HAS_CXX11_FLAG) -INCLUDE(FindUnorderedMap) -FIND_UNORDERED_MAP() -IF (UNORDERED_MAP_FOUND) - IF (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_STD_UNORDERED_MAP) - ENDIF(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - IF (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) - ENDIF(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - IF (HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE) - LIST(APPEND CERES_COMPILE_OPTIONS CERES_TR1_UNORDERED_MAP) - ENDIF(HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE) -ELSE (UNORDERED_MAP_FOUND) - MESSAGE("-- Replacing unordered_map/set with map/set (warning: slower!), " +include(FindUnorderedMap) +find_unordered_map() +if (UNORDERED_MAP_FOUND) + if (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) + list(APPEND CERES_COMPILE_OPTIONS CERES_STD_UNORDERED_MAP) + endif(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) + if (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) + list(APPEND CERES_COMPILE_OPTIONS CERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) + endif(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) + if (HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE) + list(APPEND CERES_COMPILE_OPTIONS CERES_TR1_UNORDERED_MAP) + endif(HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE) +else (UNORDERED_MAP_FOUND) + message("-- Replacing unordered_map/set with map/set (warning: slower!), " "try enabling CXX11 option if you expect C++11 to be available.") - LIST(APPEND CERES_COMPILE_OPTIONS CERES_NO_UNORDERED_MAP) -ENDIF() + list(APPEND CERES_COMPILE_OPTIONS CERES_NO_UNORDERED_MAP) +endif() -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, try enabling CXX11 option " +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, try enabling CXX11 option " "if you expect C++11 to be available.") -ENDIF (SHARED_PTR_FOUND) +endif (SHARED_PTR_FOUND) # To ensure that CXX11 accurately reflects whether we are using C++11, # check if it is required given where the potentially C++11 features Ceres # uses were found, and disable it if C++11 is not being used. -IF (CXX11) - IF (NOT HAVE_SHARED_PTR_IN_STD_NAMESPACE AND +if (CXX11) + if (NOT HAVE_SHARED_PTR_IN_STD_NAMESPACE AND NOT HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - MESSAGE("-- Failed to find C++11 components in C++11 locations & " + message("-- Failed to find C++11 components in C++11 locations & " "namespaces, disabling CXX11.") - UPDATE_CACHE_VARIABLE(CXX11 OFF) - ELSE() - MESSAGE(" ==============================================================") - MESSAGE(" Compiling Ceres using C++11. This will result in a version ") - MESSAGE(" of Ceres that will require the use of C++11 in client code.") - MESSAGE(" ==============================================================") - LIST(APPEND CERES_COMPILE_OPTIONS CERES_USE_CXX11) - IF (COMPILER_HAS_CXX11_FLAG) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - ENDIF() - ENDIF() -ENDIF(CXX11) + update_cache_variable(CXX11 OFF) + else() + message(" ==============================================================") + message(" Compiling Ceres using C++11. This will result in a version ") + message(" of Ceres that will require the use of C++11 in client code.") + message(" ==============================================================") + list(APPEND CERES_COMPILE_OPTIONS CERES_USE_CXX11) + if (COMPILER_HAS_CXX11_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + endif() + endif() +endif(CXX11) -INCLUDE_DIRECTORIES( +include_directories( include internal internal/ceres @@ -577,200 +577,200 @@ # 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}) +include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS}) -IF (SUITESPARSE) - INCLUDE_DIRECTORIES(${SUITESPARSE_INCLUDE_DIRS}) -ENDIF (SUITESPARSE) +if (SUITESPARSE) + include_directories(${SUITESPARSE_INCLUDE_DIRS}) +endif (SUITESPARSE) -IF (CXSPARSE) - INCLUDE_DIRECTORIES(${CXSPARSE_INCLUDE_DIRS}) -ENDIF (CXSPARSE) +if (CXSPARSE) + include_directories(${CXSPARSE_INCLUDE_DIRS}) +endif (CXSPARSE) -IF (GFLAGS) - INCLUDE_DIRECTORIES(${GFLAGS_INCLUDE_DIRS}) -ENDIF (GFLAGS) +if (GFLAGS) + include_directories(${GFLAGS_INCLUDE_DIRS}) +endif (GFLAGS) -IF (BUILD_SHARED_LIBS) - MESSAGE("-- Building Ceres as a shared library.") +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) + 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 +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) +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) +set (CERES_CXX_FLAGS) -IF (CMAKE_BUILD_TYPE STREQUAL "Release") - IF (CMAKE_COMPILER_IS_GNUCXX) +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") + 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") + 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} + 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") + 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") + 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}") +set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CERES_CXX_FLAGS}") -IF (MINGW) +if (MINGW) # MinGW produces code that segfaults when performing matrix multiplications # in Eigen when compiled with -O3 (see [1]), as such force the use of -O2 # which works. # # [1] http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556 - MESSAGE("-- MinGW detected, forcing -O2 instead of -O3 in Release for Eigen due " + message("-- MinGW detected, forcing -O2 instead of -O3 in Release for Eigen due " "to a MinGW bug: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556") - STRING(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - UPDATE_CACHE_VARIABLE(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") -ENDIF (MINGW) + string(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + update_cache_variable(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") +endif (MINGW) # After the tweaks for the compile settings, disable some warnings on MSVC. -IF (MSVC) +if (MSVC) # Disable signed/unsigned int conversion warnings. - ADD_DEFINITIONS("/wd4018") + add_definitions("/wd4018") # Disable warning about using struct/class for the same symobl. - ADD_DEFINITIONS("/wd4099") + add_definitions("/wd4099") # Disable warning about the insecurity of using "std::copy". - ADD_DEFINITIONS("/wd4996") + add_definitions("/wd4996") # Disable performance warning about int-to-bool conversion. - ADD_DEFINITIONS("/wd4800") + add_definitions("/wd4800") # Disable performance warning about fopen insecurity. - ADD_DEFINITIONS("/wd4996") + 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") + 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") + 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") + 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 + 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) + 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) + 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() + 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) + add_definitions("-D_VARIADIC_MAX=10") +endif (MSVC) -IF (UNIX) +if (UNIX) # GCC is not strict enough by default, so enable most of the warnings. - SET(CMAKE_CXX_FLAGS + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=all -Werror=extra -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers") -ENDIF (UNIX) +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 +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" + 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 () + 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} +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 + 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 " + 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 + endif (CLANG_VERSION VERSION_GREATER 4.0 AND CLANG_VERSION VERSION_LESS 4.2) -ENDIF (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +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 @@ -778,57 +778,57 @@ # 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}" +list(REMOVE_DUPLICATES CERES_COMPILE_OPTIONS) +include(CreateCeresConfig) +create_ceres_config("${CERES_COMPILE_OPTIONS}" ${CMAKE_BINARY_DIR}/config/ceres/internal) # Force the location containing the configured config.h to the front of the # include_directories list (by default it is appended to the back) to ensure # that if the user has an installed version of Ceres in the same location as one # of the dependencies (e.g. /usr/local) that we find the config.h we just # configured, not the (older) installed config.h. -INCLUDE_DIRECTORIES(BEFORE ${CMAKE_BINARY_DIR}/config) +include_directories(BEFORE ${CMAKE_BINARY_DIR}/config) -ADD_SUBDIRECTORY(internal/ceres) +add_subdirectory(internal/ceres) -IF (BUILD_DOCUMENTATION) - FIND_PACKAGE(Sphinx QUIET) - IF (NOT SPHINX_FOUND) - MESSAGE("-- Failed to find Sphinx, disabling build of documentation.") - UPDATE_CACHE_VARIABLE(BUILD_DOCUMENTATION OFF) - ELSE() +if (BUILD_DOCUMENTATION) + find_package(Sphinx QUIET) + if (NOT SPHINX_FOUND) + message("-- Failed to find Sphinx, disabling build of documentation.") + update_cache_variable(BUILD_DOCUMENTATION OFF) + else() # Generate the User's Guide (html). # The corresponding target is ceres_docs, but is included in ALL. - MESSAGE("-- Build the HTML documentation.") - ADD_SUBDIRECTORY(docs) - ENDIF() -ENDIF (BUILD_DOCUMENTATION) + message("-- Build the HTML documentation.") + add_subdirectory(docs) + endif() +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) +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_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) +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_BINARY_DIR}/config/ceres/internal/config.h +install(FILES ${CMAKE_BINARY_DIR}/config/ceres/internal/config.h DESTINATION include/ceres/internal) -IF (MINIGLOG) +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 + install(FILES ${CMAKE_SOURCE_DIR}/internal/ceres/miniglog/glog/logging.h DESTINATION include/ceres/internal/miniglog/glog) -ENDIF (MINIGLOG) +endif (MINIGLOG) # Ceres supports two mechanisms by which it can be detected & imported into # client code which uses CMake via find_package(Ceres): @@ -853,31 +853,31 @@ # Create a CeresConfigVersion.cmake file containing the version information, # used by both export() & install(). -CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/CeresConfigVersion.cmake.in" +configure_file("${CMAKE_SOURCE_DIR}/cmake/CeresConfigVersion.cmake.in" "${CMAKE_BINARY_DIR}/CeresConfigVersion.cmake" @ONLY) # Install method #1: Put Ceres in CMAKE_INSTALL_PREFIX: /usr/local or equivalent. # Set the install path for the installed CeresConfig.cmake configuration file # relative to CMAKE_INSTALL_PREFIX. -IF (WIN32) - SET(RELATIVE_CMAKECONFIG_INSTALL_DIR CMake) -ELSE () - SET(RELATIVE_CMAKECONFIG_INSTALL_DIR share/Ceres) -ENDIF () +if (WIN32) + set(RELATIVE_CMAKECONFIG_INSTALL_DIR CMake) +else () + set(RELATIVE_CMAKECONFIG_INSTALL_DIR share/Ceres) +endif () # This "exports" for installation all targets which have been put into the # export set "CeresExport". This generates a CeresTargets.cmake file which, # when read in by a client project as part of find_package(Ceres) creates # imported library targets for Ceres (with dependency relations) which can be # used in target_link_libraries() calls in the client project to use Ceres. -INSTALL(EXPORT CeresExport +install(EXPORT CeresExport DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR} FILE CeresTargets.cmake) # Save the relative path from the installed CeresConfig.cmake file to the # install prefix. We do not save an absolute path in case the installed package # is subsequently relocated after installation (on Windows). -FILE(RELATIVE_PATH INSTALL_ROOT_REL_CONFIG_INSTALL_DIR +file(RELATIVE_PATH INSTALL_ROOT_REL_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${RELATIVE_CMAKECONFIG_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}) @@ -888,27 +888,27 @@ # the exported version, which must be named CeresConfig.cmake in # CMAKE_BINARY_DIR to be detected. The suffix is removed when # it is installed. -SET(SETUP_CERES_CONFIG_FOR_INSTALLATION TRUE) -CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/CeresConfig.cmake.in" +set(SETUP_CERES_CONFIG_FOR_INSTALLATION TRUE) +configure_file("${CMAKE_SOURCE_DIR}/cmake/CeresConfig.cmake.in" "${CMAKE_BINARY_DIR}/CeresConfig-install.cmake" @ONLY) # Install the configuration files into the same directory as the autogenerated # CeresTargets.cmake file. We include the find_package() 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_BINARY_DIR}/CeresConfig-install.cmake" +install(FILES "${CMAKE_BINARY_DIR}/CeresConfig-install.cmake" RENAME CeresConfig.cmake DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR}) -INSTALL(FILES "${CMAKE_BINARY_DIR}/CeresConfigVersion.cmake" +install(FILES "${CMAKE_BINARY_DIR}/CeresConfigVersion.cmake" "${CMAKE_SOURCE_DIR}/cmake/FindEigen.cmake" "${CMAKE_SOURCE_DIR}/cmake/FindGlog.cmake" DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR}) # Create an uninstall target to remove all installed files. -CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake.in" +configure_file("${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake.in" "${CMAKE_BINARY_DIR}/cmake/uninstall.cmake" @ONLY) -ADD_CUSTOM_TARGET(uninstall +add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake/uninstall.cmake) # Install method #2: Put Ceres build into local CMake registry. @@ -916,23 +916,23 @@ # Optionally export the Ceres build directory into the local CMake package # registry (~/.cmake/packages on *nix & OS X). This allows the detection & # use of Ceres without requiring that it be installed. -IF (EXPORT_BUILD_DIR) - MESSAGE("-- Export Ceres build directory to local CMake package registry.") +if (EXPORT_BUILD_DIR) + message("-- Export Ceres build directory to local CMake package registry.") # Save the relative path from the build directory to the source directory. - FILE(RELATIVE_PATH INSTALL_ROOT_REL_CONFIG_INSTALL_DIR + file(RELATIVE_PATH INSTALL_ROOT_REL_CONFIG_INSTALL_DIR ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) # Analogously to install(EXPORT ...), export the Ceres target from the build # directory as a package called Ceres into the local CMake package registry. - EXPORT(TARGETS ceres FILE ${CMAKE_BINARY_DIR}/CeresTargets.cmake) - EXPORT(PACKAGE ${CMAKE_PROJECT_NAME}) + export(TARGETS ceres FILE ${CMAKE_BINARY_DIR}/CeresTargets.cmake) + export(PACKAGE ${CMAKE_PROJECT_NAME}) # Configure a CeresConfig.cmake file for the export of the Ceres build # directory from the template, reflecting the current build options. - SET(SETUP_CERES_CONFIG_FOR_INSTALLATION FALSE) - CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/CeresConfig.cmake.in" + set(SETUP_CERES_CONFIG_FOR_INSTALLATION FALSE) + configure_file("${CMAKE_SOURCE_DIR}/cmake/CeresConfig.cmake.in" "${CMAKE_BINARY_DIR}/CeresConfig.cmake" @ONLY) -ENDIF (EXPORT_BUILD_DIR) +endif (EXPORT_BUILD_DIR)
diff --git a/cmake/AddGerritCommitHook.cmake b/cmake/AddGerritCommitHook.cmake index 36da67a..071e84a 100644 --- a/cmake/AddGerritCommitHook.cmake +++ b/cmake/AddGerritCommitHook.cmake
@@ -30,47 +30,47 @@ # alexs.mac@gmail.com (Alex Stewart) # Set up the git hook to make Gerrit Change-Id: lines in commit messages. -FUNCTION(ADD_GERRIT_COMMIT_HOOK) - UNSET (LOCAL_GIT_DIRECTORY) - IF (EXISTS ${CMAKE_SOURCE_DIR}/.git) - IF (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git) +function(ADD_GERRIT_COMMIT_HOOK) + unset (LOCAL_GIT_DIRECTORY) + if (EXISTS ${CMAKE_SOURCE_DIR}/.git) + if (IS_DIRECTORY ${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(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git) + set (LOCAL_GIT_DIRECTORY ${CMAKE_SOURCE_DIR}/.git) + else(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git) # .git is a file, this means Ceres is a git submodule of another project # and our .git file contains the path to the git directory which manages # Ceres, so we should add the gerrit hook there. - FILE(READ ${CMAKE_SOURCE_DIR}/.git GIT_SUBMODULE_FILE_CONTENTS) + file(READ ${CMAKE_SOURCE_DIR}/.git GIT_SUBMODULE_FILE_CONTENTS) # Strip any trailing newline characters, s/t we get a valid path. - STRING(REGEX REPLACE "gitdir:[ ]*([^$].*)[\n].*" "${CMAKE_SOURCE_DIR}/\\1" + string(REGEX REPLACE "gitdir:[ ]*([^$].*)[\n].*" "${CMAKE_SOURCE_DIR}/\\1" GIT_SUBMODULE_GIT_DIRECTORY_PATH "${GIT_SUBMODULE_FILE_CONTENTS}") - GET_FILENAME_COMPONENT(GIT_SUBMODULE_GIT_DIRECTORY_PATH + get_filename_component(GIT_SUBMODULE_GIT_DIRECTORY_PATH "${GIT_SUBMODULE_GIT_DIRECTORY_PATH}" ABSOLUTE) - IF (EXISTS ${GIT_SUBMODULE_GIT_DIRECTORY_PATH} + if (EXISTS ${GIT_SUBMODULE_GIT_DIRECTORY_PATH} AND IS_DIRECTORY ${GIT_SUBMODULE_GIT_DIRECTORY_PATH}) - SET(LOCAL_GIT_DIRECTORY "${GIT_SUBMODULE_GIT_DIRECTORY_PATH}") - ENDIF() - ENDIF() - ELSE (EXISTS ${CMAKE_SOURCE_DIR}/.git) + set(LOCAL_GIT_DIRECTORY "${GIT_SUBMODULE_GIT_DIRECTORY_PATH}") + endif() + endif() + else (EXISTS ${CMAKE_SOURCE_DIR}/.git) # TODO(keir) Add proper Windows support. - ENDIF (EXISTS ${CMAKE_SOURCE_DIR}/.git) + endif (EXISTS ${CMAKE_SOURCE_DIR}/.git) - IF (EXISTS ${LOCAL_GIT_DIRECTORY}) - IF (NOT EXISTS ${LOCAL_GIT_DIRECTORY}/hooks/commit-msg) - MESSAGE(STATUS "Detected Ceres being used as a git submodule, adding " + if (EXISTS ${LOCAL_GIT_DIRECTORY}) + if (NOT EXISTS ${LOCAL_GIT_DIRECTORY}/hooks/commit-msg) + message(STATUS "Detected Ceres being used as a git submodule, adding " "commit hook for Gerrit to: ${LOCAL_GIT_DIRECTORY}") # Download the hook only if it is not already present. - FILE(DOWNLOAD https://ceres-solver-review.googlesource.com/tools/hooks/commit-msg + 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 + 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}) -ENDFUNCTION() + endif (NOT EXISTS ${LOCAL_GIT_DIRECTORY}/hooks/commit-msg) + endif (EXISTS ${LOCAL_GIT_DIRECTORY}) +endfunction()
diff --git a/cmake/CeresConfig.cmake.in b/cmake/CeresConfig.cmake.in index 6b89e96..bcda9a7 100644 --- a/cmake/CeresConfig.cmake.in +++ b/cmake/CeresConfig.cmake.in
@@ -69,213 +69,213 @@ # Called if we failed to find Ceres or any of its required dependencies, # unsets all public (designed to be used externally) variables and reports # error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument. -MACRO(CERES_REPORT_NOT_FOUND REASON_MSG) +macro(CERES_REPORT_NOT_FOUND REASON_MSG) # FindPackage() only references Ceres_FOUND, and requires it to be # explicitly set FALSE to denote not found (not merely undefined). - SET(Ceres_FOUND FALSE) - SET(CERES_FOUND FALSE) - UNSET(CERES_INCLUDE_DIRS) - UNSET(CERES_LIBRARIES) + set(Ceres_FOUND FALSE) + set(CERES_FOUND FALSE) + unset(CERES_INCLUDE_DIRS) + unset(CERES_LIBRARIES) # Reset the CMake module path to its state when this script was called. - SET(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH}) + set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH}) # Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by # FindPackage() use the camelcase library name, not uppercase. - IF (Ceres_FIND_QUIETLY) - MESSAGE(STATUS "Failed to find Ceres - " ${REASON_MSG} ${ARGN}) - ELSE (Ceres_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Failed to find Ceres - " ${REASON_MSG} ${ARGN}) - ELSE() + if (Ceres_FIND_QUIETLY) + message(STATUS "Failed to find Ceres - " ${REASON_MSG} ${ARGN}) + else (Ceres_FIND_REQUIRED) + message(FATAL_ERROR "Failed to find Ceres - " ${REASON_MSG} ${ARGN}) + else() # Neither QUIETLY nor REQUIRED, use SEND_ERROR which emits an error # that prevents generation, but continues configuration. - MESSAGE(SEND_ERROR "Failed to find Ceres - " ${REASON_MSG} ${ARGN}) - ENDIF () - RETURN() -ENDMACRO(CERES_REPORT_NOT_FOUND) + message(SEND_ERROR "Failed to find Ceres - " ${REASON_MSG} ${ARGN}) + endif () + return() +endmacro(CERES_REPORT_NOT_FOUND) # If Ceres was not installed, then by definition it was exported # from a build directory. -SET(CERES_WAS_INSTALLED @SETUP_CERES_CONFIG_FOR_INSTALLATION@) +set(CERES_WAS_INSTALLED @SETUP_CERES_CONFIG_FOR_INSTALLATION@) # Record the state of the CMake module path when this script was # called so that we can ensure that we leave it in the same state on # exit as it was on entry, but modify it locally. -SET(CALLERS_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) +set(CALLERS_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) # Get the (current, i.e. installed) directory containing this file. -GET_FILENAME_COMPONENT(CERES_CURRENT_CONFIG_DIR +get_filename_component(CERES_CURRENT_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -IF (CERES_WAS_INSTALLED) +if (CERES_WAS_INSTALLED) # Reset CMake module path to the installation directory of this # script, thus we will use the FindPackage() scripts shipped with # Ceres to find Ceres' dependencies, even if the user has equivalently # named FindPackage() scripts in their project. - SET(CMAKE_MODULE_PATH ${CERES_CURRENT_CONFIG_DIR}) + set(CMAKE_MODULE_PATH ${CERES_CURRENT_CONFIG_DIR}) # Build the absolute root install directory as a relative path # (determined when Ceres was configured & built) from the current # install directory for this this file. This allows for the install # tree to be relocated, after Ceres was built, outside of CMake. - GET_FILENAME_COMPONENT(CURRENT_ROOT_INSTALL_DIR + get_filename_component(CURRENT_ROOT_INSTALL_DIR ${CERES_CURRENT_CONFIG_DIR}/@INSTALL_ROOT_REL_CONFIG_INSTALL_DIR@ ABSOLUTE) - IF (NOT EXISTS ${CURRENT_ROOT_INSTALL_DIR}) - CERES_REPORT_NOT_FOUND( + if (NOT EXISTS ${CURRENT_ROOT_INSTALL_DIR}) + ceres_report_not_found( "Ceres install root: ${CURRENT_ROOT_INSTALL_DIR}, " "determined from relative path from CeresConfig.cmake install location: " "${CERES_CURRENT_CONFIG_DIR}, does not exist. Either the install " "directory was deleted, or the install tree was only partially relocated " "outside of CMake after Ceres was built.") - ENDIF (NOT EXISTS ${CURRENT_ROOT_INSTALL_DIR}) + endif (NOT EXISTS ${CURRENT_ROOT_INSTALL_DIR}) # Set the include directories for Ceres (itself). - SET(CERES_INCLUDE_DIR "${CURRENT_ROOT_INSTALL_DIR}/include") - IF (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h) - CERES_REPORT_NOT_FOUND( + set(CERES_INCLUDE_DIR "${CURRENT_ROOT_INSTALL_DIR}/include") + if (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h) + ceres_report_not_found( "Ceres install root: ${CURRENT_ROOT_INSTALL_DIR}, " "determined from relative path from CeresConfig.cmake install location: " "${CERES_CURRENT_CONFIG_DIR}, does not contain Ceres headers. " "Either the install directory was deleted, or the install tree was only " "partially relocated outside of CMake after Ceres was built.") - ENDIF (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h) - LIST(APPEND CERES_INCLUDE_DIRS ${CERES_INCLUDE_DIR}) + endif (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h) + list(APPEND CERES_INCLUDE_DIRS ${CERES_INCLUDE_DIR}) -ELSE(CERES_WAS_INSTALLED) +else(CERES_WAS_INSTALLED) # Ceres was exported from the build tree. - SET(CERES_EXPORTED_BUILD_DIR ${CERES_CURRENT_CONFIG_DIR}) - GET_FILENAME_COMPONENT(CERES_EXPORTED_SOURCE_DIR + set(CERES_EXPORTED_BUILD_DIR ${CERES_CURRENT_CONFIG_DIR}) + get_filename_component(CERES_EXPORTED_SOURCE_DIR ${CERES_EXPORTED_BUILD_DIR}/@INSTALL_ROOT_REL_CONFIG_INSTALL_DIR@ ABSOLUTE) - IF (NOT EXISTS ${CERES_EXPORTED_SOURCE_DIR}) - CERES_REPORT_NOT_FOUND( + if (NOT EXISTS ${CERES_EXPORTED_SOURCE_DIR}) + ceres_report_not_found( "Ceres exported source directory: ${CERES_EXPORTED_SOURCE_DIR}, " "determined from relative path from CeresConfig.cmake exported build " "directory: ${CERES_EXPORTED_BUILD_DIR} does not exist.") - ENDIF() + endif() # Reset CMake module path to the cmake directory in the Ceres source # tree which was exported, thus we will use the FindPackage() scripts shipped # with Ceres to find Ceres' dependencies, even if the user has equivalently # named FindPackage() scripts in their project. - SET(CMAKE_MODULE_PATH ${CERES_EXPORTED_SOURCE_DIR}/cmake) + set(CMAKE_MODULE_PATH ${CERES_EXPORTED_SOURCE_DIR}/cmake) # Set the include directories for Ceres (itself). - SET(CERES_INCLUDE_DIR "${CERES_EXPORTED_SOURCE_DIR}/include") - IF (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h) - CERES_REPORT_NOT_FOUND( + set(CERES_INCLUDE_DIR "${CERES_EXPORTED_SOURCE_DIR}/include") + if (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h) + ceres_report_not_found( "Ceres exported source directory: ${CERES_EXPORTED_SOURCE_DIR}, " "determined from relative path from CeresConfig.cmake exported build " "directory: ${CERES_EXPORTED_BUILD_DIR}, does not contain Ceres headers.") - ENDIF (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h) - LIST(APPEND CERES_INCLUDE_DIRS ${CERES_INCLUDE_DIR}) + endif (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h) + list(APPEND CERES_INCLUDE_DIRS ${CERES_INCLUDE_DIR}) # Append the path to the configured config.h in the exported build directory # to the Ceres include directories. - SET(CERES_CONFIG_FILE + set(CERES_CONFIG_FILE ${CERES_EXPORTED_BUILD_DIR}/config/ceres/internal/config.h) - IF (NOT EXISTS ${CERES_CONFIG_FILE}) - CERES_REPORT_NOT_FOUND( + if (NOT EXISTS ${CERES_CONFIG_FILE}) + ceres_report_not_found( "Ceres exported build directory: ${CERES_EXPORTED_BUILD_DIR}, " "does not contain required configured Ceres config.h, it is not here: " "${CERES_CONFIG_FILE}.") - ENDIF (NOT EXISTS ${CERES_CONFIG_FILE}) - LIST(APPEND CERES_INCLUDE_DIRS ${CERES_EXPORTED_BUILD_DIR}/config) -ENDIF(CERES_WAS_INSTALLED) + endif (NOT EXISTS ${CERES_CONFIG_FILE}) + list(APPEND CERES_INCLUDE_DIRS ${CERES_EXPORTED_BUILD_DIR}/config) +endif(CERES_WAS_INSTALLED) # Set the version. -SET(CERES_VERSION @CERES_VERSION@ ) +set(CERES_VERSION @CERES_VERSION@ ) # Eigen. # Flag set during configuration and build of Ceres. -SET(CERES_EIGEN_VERSION @EIGEN_VERSION@) +set(CERES_EIGEN_VERSION @EIGEN_VERSION@) # Append the locations of Eigen when Ceres was built to the search path hints. -LIST(APPEND EIGEN_INCLUDE_DIR_HINTS @EIGEN_INCLUDE_DIR@) +list(APPEND EIGEN_INCLUDE_DIR_HINTS @EIGEN_INCLUDE_DIR@) # Search quietly to control the timing of the error message if not found. The # search should be for an exact match, but for usability reasons do a soft # match and reject with an explanation below. -FIND_PACKAGE(Eigen ${CERES_EIGEN_VERSION} QUIET) -IF (EIGEN_FOUND) - IF (NOT EIGEN_VERSION VERSION_EQUAL CERES_EIGEN_VERSION) +find_package(Eigen ${CERES_EIGEN_VERSION} QUIET) +if (EIGEN_FOUND) + if (NOT EIGEN_VERSION VERSION_EQUAL CERES_EIGEN_VERSION) # CMake's VERSION check in FIND_PACKAGE() will accept any version >= the # specified version. However, only version = is supported. Improve # usability by explaining why we don't accept non-exact version matching. - CERES_REPORT_NOT_FOUND("Found Eigen dependency, but the version of Eigen " + ceres_report_not_found("Found Eigen dependency, but the version of Eigen " "found (${EIGEN_VERSION}) does not exactly match the version of Eigen " "Ceres was compiled with (${CERES_EIGEN_VERSION}). This can cause subtle " "bugs by triggering violations of the One Definition Rule. See the " "Wikipedia article http://en.wikipedia.org/wiki/One_Definition_Rule " "for more details") - ENDIF () - MESSAGE(STATUS "Found required Ceres dependency: " + endif () + message(STATUS "Found required Ceres dependency: " "Eigen version ${CERES_EIGEN_VERSION} in ${EIGEN_INCLUDE_DIRS}") -ELSE (EIGEN_FOUND) - CERES_REPORT_NOT_FOUND("Missing required Ceres " +else (EIGEN_FOUND) + ceres_report_not_found("Missing required Ceres " "dependency: Eigen version ${CERES_EIGEN_VERSION}, please set " "EIGEN_INCLUDE_DIR.") -ENDIF (EIGEN_FOUND) -LIST(APPEND CERES_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS}) +endif (EIGEN_FOUND) +list(APPEND CERES_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS}) # Glog. # Flag set during configuration and build of Ceres. -SET(CERES_USES_MINIGLOG @MINIGLOG@) -IF (CERES_USES_MINIGLOG) - SET(MINIGLOG_INCLUDE_DIR ${CERES_INCLUDE_DIR}/ceres/internal/miniglog) - IF (NOT EXISTS ${MINIGLOG_INCLUDE_DIR}) - CERES_REPORT_NOT_FOUND( +set(CERES_USES_MINIGLOG @MINIGLOG@) +if (CERES_USES_MINIGLOG) + set(MINIGLOG_INCLUDE_DIR ${CERES_INCLUDE_DIR}/ceres/internal/miniglog) + if (NOT EXISTS ${MINIGLOG_INCLUDE_DIR}) + ceres_report_not_found( "Ceres include directory: " "${CERES_INCLUDE_DIR} does not include miniglog, but Ceres was " "compiled with MINIGLOG enabled (in place of Glog).") - ENDIF (NOT EXISTS ${MINIGLOG_INCLUDE_DIR}) - LIST(APPEND CERES_INCLUDE_DIRS ${MINIGLOG_INCLUDE_DIR}) + endif (NOT EXISTS ${MINIGLOG_INCLUDE_DIR}) + list(APPEND CERES_INCLUDE_DIRS ${MINIGLOG_INCLUDE_DIR}) # Output message at standard log level (not the lower STATUS) so that # the message is output in GUI during configuration to warn user. - MESSAGE("-- Found Ceres compiled with miniglog substitute " + message("-- Found Ceres compiled with miniglog substitute " "for glog, beware this will likely cause problems if glog is later linked.") -ELSE (CERES_USES_MINIGLOG) +else (CERES_USES_MINIGLOG) # Append the locations of glog when Ceres was built to the search path hints. - LIST(APPEND GLOG_INCLUDE_DIR_HINTS @GLOG_INCLUDE_DIR@) - GET_FILENAME_COMPONENT(CERES_BUILD_GLOG_LIBRARY_DIR @GLOG_LIBRARY@ PATH) - LIST(APPEND GLOG_LIBRARY_DIR_HINTS ${CERES_BUILD_GLOG_LIBRARY_DIR}) + list(APPEND GLOG_INCLUDE_DIR_HINTS @GLOG_INCLUDE_DIR@) + get_filename_component(CERES_BUILD_GLOG_LIBRARY_DIR @GLOG_LIBRARY@ PATH) + list(APPEND GLOG_LIBRARY_DIR_HINTS ${CERES_BUILD_GLOG_LIBRARY_DIR}) # Search quietly s/t we control the timing of the error message if not found. - FIND_PACKAGE(Glog QUIET) - IF (GLOG_FOUND) - MESSAGE(STATUS "Found required Ceres dependency: " + find_package(Glog QUIET) + if (GLOG_FOUND) + message(STATUS "Found required Ceres dependency: " "Glog in ${GLOG_INCLUDE_DIRS}") - ELSE (GLOG_FOUND) - CERES_REPORT_NOT_FOUND("Missing required Ceres " + else (GLOG_FOUND) + ceres_report_not_found("Missing required Ceres " "dependency: Glog, please set GLOG_INCLUDE_DIR.") - ENDIF (GLOG_FOUND) - LIST(APPEND CERES_INCLUDE_DIRS ${GLOG_INCLUDE_DIRS}) -ENDIF (CERES_USES_MINIGLOG) + endif (GLOG_FOUND) + list(APPEND CERES_INCLUDE_DIRS ${GLOG_INCLUDE_DIRS}) +endif (CERES_USES_MINIGLOG) # Import exported Ceres targets, if they have not already been imported. -IF (NOT TARGET ceres AND NOT Ceres_BINARY_DIR) - INCLUDE(${CERES_CURRENT_CONFIG_DIR}/CeresTargets.cmake) -ENDIF (NOT TARGET ceres AND NOT Ceres_BINARY_DIR) +if (NOT TARGET ceres AND NOT Ceres_BINARY_DIR) + include(${CERES_CURRENT_CONFIG_DIR}/CeresTargets.cmake) +endif (NOT TARGET ceres AND NOT Ceres_BINARY_DIR) # Set the expected XX_LIBRARIES variable for FindPackage(). -SET(CERES_LIBRARIES ceres) +set(CERES_LIBRARIES ceres) # Set legacy include directories variable for backwards compatibility. -SET(CERES_INCLUDES ${CERES_INCLUDE_DIRS}) +set(CERES_INCLUDES ${CERES_INCLUDE_DIRS}) # Reset CMake module path to its state when this script was called. -SET(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH}) +set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH}) # As we use CERES_REPORT_NOT_FOUND() to abort, if we reach this point we have # found Ceres and all required dependencies. -IF (CERES_WAS_INSTALLED) - MESSAGE(STATUS "Found Ceres version: ${CERES_VERSION} " +if (CERES_WAS_INSTALLED) + message(STATUS "Found Ceres version: ${CERES_VERSION} " "installed in: ${CURRENT_ROOT_INSTALL_DIR}") -ELSE (CERES_WAS_INSTALLED) - MESSAGE(STATUS "Found Ceres version: ${CERES_VERSION} " +else (CERES_WAS_INSTALLED) + message(STATUS "Found Ceres version: ${CERES_VERSION} " "exported from build directory: ${CERES_EXPORTED_BUILD_DIR}") -ENDIF() +endif() # Set CERES_FOUND to be equivalent to Ceres_FOUND, which is set to # TRUE by FindPackage() if this file is found and run, and after which # Ceres_FOUND is not (explicitly, i.e. undefined does not count) set # to FALSE. -SET(CERES_FOUND TRUE) +set(CERES_FOUND TRUE)
diff --git a/cmake/CeresConfigVersion.cmake.in b/cmake/CeresConfigVersion.cmake.in index f577f89..5ff36eb 100644 --- a/cmake/CeresConfigVersion.cmake.in +++ b/cmake/CeresConfigVersion.cmake.in
@@ -38,13 +38,13 @@ # version string are exactly the same and it sets PACKAGE_VERSION_COMPATIBLE # if the current version is >= requested version. -SET(PACKAGE_VERSION @CERES_VERSION@) +set(PACKAGE_VERSION @CERES_VERSION@) -IF ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") - SET(PACKAGE_VERSION_COMPATIBLE FALSE) -ELSE ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") - SET(PACKAGE_VERSION_COMPATIBLE TRUE) - IF ("${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") - SET(PACKAGE_VERSION_EXACT TRUE) - ENDIF ("${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") -ENDIF ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") +if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif ("${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") +endif ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
diff --git a/cmake/CreateCeresConfig.cmake b/cmake/CreateCeresConfig.cmake index ceedbfe..89db68c 100644 --- a/cmake/CreateCeresConfig.cmake +++ b/cmake/CreateCeresConfig.cmake
@@ -32,7 +32,7 @@ # we can determine where *this* file is, and thus the relative path to # config.h.in. Inside of CONFIGURE_CERES_CONFIG(), CMAKE_CURRENT_LIST_DIR # refers to the caller of CONFIGURE_CERES_CONFIG(), not this file. -SET(CERES_CONFIG_IN_FILE "${CMAKE_CURRENT_LIST_DIR}/config.h.in") +set(CERES_CONFIG_IN_FILE "${CMAKE_CURRENT_LIST_DIR}/config.h.in") # CreateCeresConfig.cmake - Create the config.h for Ceres. # @@ -55,61 +55,61 @@ # the configured config.h. Typically this # will be <src>/include/ceres/internal. -FUNCTION(CREATE_CERES_CONFIG CURRENT_CERES_COMPILE_OPTIONS CERES_CONFIG_OUTPUT_DIRECTORY) +function(CREATE_CERES_CONFIG CURRENT_CERES_COMPILE_OPTIONS CERES_CONFIG_OUTPUT_DIRECTORY) # Create the specified output directory if it does not exist. - IF (NOT EXISTS "${CERES_CONFIG_OUTPUT_DIRECTORY}") - MESSAGE(STATUS "Creating configured Ceres config.h output directory: " + if (NOT EXISTS "${CERES_CONFIG_OUTPUT_DIRECTORY}") + message(STATUS "Creating configured Ceres config.h output directory: " "${CERES_CONFIG_OUTPUT_DIRECTORY}") - FILE(MAKE_DIRECTORY "${CERES_CONFIG_OUTPUT_DIRECTORY}") - ENDIF() - IF (EXISTS "${CERES_CONFIG_OUTPUT_DIRECTORY}" AND + file(MAKE_DIRECTORY "${CERES_CONFIG_OUTPUT_DIRECTORY}") + endif() + if (EXISTS "${CERES_CONFIG_OUTPUT_DIRECTORY}" AND NOT IS_DIRECTORY "${CERES_CONFIG_OUTPUT_DIRECTORY}") - MESSAGE(FATAL_ERROR "Ceres Bug: Specified CERES_CONFIG_OUTPUT_DIRECTORY: " + message(FATAL_ERROR "Ceres Bug: Specified CERES_CONFIG_OUTPUT_DIRECTORY: " "${CERES_CONFIG_OUTPUT_DIRECTORY} exists, but is not a directory.") - ENDIF() + endif() # Read all possible configurable compile options from config.h.in, this avoids # us having to hard-code in this file what the valid options are. - FILE(READ ${CERES_CONFIG_IN_FILE} CERES_CONFIG_IN_CONTENTS) - STRING(REGEX MATCHALL "@[^@ $]+@" + file(READ ${CERES_CONFIG_IN_FILE} CERES_CONFIG_IN_CONTENTS) + string(REGEX MATCHALL "@[^@ $]+@" ALL_CONFIGURABLE_CERES_OPTIONS "${CERES_CONFIG_IN_CONTENTS}") # Removing @ symbols at beginning and end of each option. - STRING(REPLACE "@" "" + string(REPLACE "@" "" ALL_CONFIGURABLE_CERES_OPTIONS "${ALL_CONFIGURABLE_CERES_OPTIONS}") # Ensure that there are no repetitions in the current compile options. - LIST(REMOVE_DUPLICATES CURRENT_CERES_COMPILE_OPTIONS) + list(REMOVE_DUPLICATES CURRENT_CERES_COMPILE_OPTIONS) - FOREACH (CERES_OPTION ${ALL_CONFIGURABLE_CERES_OPTIONS}) + foreach (CERES_OPTION ${ALL_CONFIGURABLE_CERES_OPTIONS}) # Try and find the option in the list of current compile options, if it # is present, then the option is enabled, otherwise it is disabled. - LIST(FIND CURRENT_CERES_COMPILE_OPTIONS ${CERES_OPTION} OPTION_ENABLED) + list(FIND CURRENT_CERES_COMPILE_OPTIONS ${CERES_OPTION} OPTION_ENABLED) # list(FIND ..) returns -1 if the element was not in the list, but CMake # interprets if (VAR) to be true if VAR is any non-zero number, even # negative ones, hence we have to explicitly check for >= 0. - IF (OPTION_ENABLED GREATER -1) - MESSAGE(STATUS "Enabling ${CERES_OPTION} in Ceres config.h") - SET(${CERES_OPTION} "#define ${CERES_OPTION}") + if (OPTION_ENABLED GREATER -1) + message(STATUS "Enabling ${CERES_OPTION} in Ceres config.h") + set(${CERES_OPTION} "#define ${CERES_OPTION}") # Remove the item from the list of current options so that we can identify # any options that were in CURRENT_CERES_COMPILE_OPTIONS, but not in # ALL_CONFIGURABLE_CERES_OPTIONS (which is an error). - LIST(REMOVE_ITEM CURRENT_CERES_COMPILE_OPTIONS ${CERES_OPTION}) - ELSE() - SET(${CERES_OPTION} "// #define ${CERES_OPTION}") - ENDIF() - ENDFOREACH() + list(REMOVE_ITEM CURRENT_CERES_COMPILE_OPTIONS ${CERES_OPTION}) + else() + set(${CERES_OPTION} "// #define ${CERES_OPTION}") + endif() + endforeach() # CURRENT_CERES_COMPILE_OPTIONS should now be an empty list, any elements # remaining were not present in ALL_CONFIGURABLE_CERES_OPTIONS read from # config.h.in. - IF (CURRENT_CERES_COMPILE_OPTIONS) - MESSAGE(FATAL_ERROR "Ceres Bug: CURRENT_CERES_COMPILE_OPTIONS contained " + if (CURRENT_CERES_COMPILE_OPTIONS) + message(FATAL_ERROR "Ceres Bug: CURRENT_CERES_COMPILE_OPTIONS contained " "the following options which were not present in config.h.in: " "${CURRENT_CERES_COMPILE_OPTIONS}") - ENDIF() + endif() - CONFIGURE_FILE(${CERES_CONFIG_IN_FILE} + configure_file(${CERES_CONFIG_IN_FILE} "${CERES_CONFIG_OUTPUT_DIRECTORY}/config.h" @ONLY) -ENDFUNCTION() +endfunction()
diff --git a/cmake/FindCXSparse.cmake b/cmake/FindCXSparse.cmake index 5eef530..623eefb 100644 --- a/cmake/FindCXSparse.cmake +++ b/cmake/FindCXSparse.cmake
@@ -69,125 +69,125 @@ # Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when # FindCXSparse was invoked. -MACRO(CXSPARSE_RESET_FIND_LIBRARY_PREFIX) - IF (MSVC) - SET(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") - ENDIF (MSVC) -ENDMACRO(CXSPARSE_RESET_FIND_LIBRARY_PREFIX) +macro(CXSPARSE_RESET_FIND_LIBRARY_PREFIX) + if (MSVC) + set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") + endif (MSVC) +endmacro(CXSPARSE_RESET_FIND_LIBRARY_PREFIX) # Called if we failed to find CXSparse or any of it's required dependencies, # unsets all public (designed to be used externally) variables and reports # error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument. -MACRO(CXSPARSE_REPORT_NOT_FOUND REASON_MSG) - UNSET(CXSPARSE_FOUND) - UNSET(CXSPARSE_INCLUDE_DIRS) - UNSET(CXSPARSE_LIBRARIES) +macro(CXSPARSE_REPORT_NOT_FOUND REASON_MSG) + unset(CXSPARSE_FOUND) + unset(CXSPARSE_INCLUDE_DIRS) + unset(CXSPARSE_LIBRARIES) # Make results of search visible in the CMake GUI if CXSparse has not # been found so that user does not have to toggle to advanced view. - MARK_AS_ADVANCED(CLEAR CXSPARSE_INCLUDE_DIR + mark_as_advanced(CLEAR CXSPARSE_INCLUDE_DIR CXSPARSE_LIBRARY) - CXSPARSE_RESET_FIND_LIBRARY_PREFIX() + cxsparse_reset_find_library_prefix() # Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage() # use the camelcase library name, not uppercase. - IF (CXSparse_FIND_QUIETLY) - MESSAGE(STATUS "Failed to find CXSparse - " ${REASON_MSG} ${ARGN}) - ELSEIF (CXSparse_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Failed to find CXSparse - " ${REASON_MSG} ${ARGN}) - ELSE() + if (CXSparse_FIND_QUIETLY) + message(STATUS "Failed to find CXSparse - " ${REASON_MSG} ${ARGN}) + elseif (CXSparse_FIND_REQUIRED) + message(FATAL_ERROR "Failed to find CXSparse - " ${REASON_MSG} ${ARGN}) + else() # Neither QUIETLY nor REQUIRED, use no priority which emits a message # but continues configuration and allows generation. - MESSAGE("-- Failed to find CXSparse - " ${REASON_MSG} ${ARGN}) - ENDIF () -ENDMACRO(CXSPARSE_REPORT_NOT_FOUND) + message("-- Failed to find CXSparse - " ${REASON_MSG} ${ARGN}) + endif () +endmacro(CXSPARSE_REPORT_NOT_FOUND) # Handle possible presence of lib prefix for libraries on MSVC, see # also CXSPARSE_RESET_FIND_LIBRARY_PREFIX(). -IF (MSVC) +if (MSVC) # Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES # s/t we can set it back before returning. - SET(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") + set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") # The empty string in this list is important, it represents the case when # the libraries have no prefix (shared libraries / DLLs). - SET(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}") -ENDIF (MSVC) + set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}") +endif (MSVC) # Search user-installed locations first, so that we prefer user installs # to system installs where both exist. # # TODO: Add standard Windows search locations for CXSparse. -LIST(APPEND CXSPARSE_CHECK_INCLUDE_DIRS +list(APPEND CXSPARSE_CHECK_INCLUDE_DIRS /usr/local/include /usr/local/homebrew/include # Mac OS X /opt/local/var/macports/software # Mac OS X. /opt/local/include /usr/include) -LIST(APPEND CXSPARSE_CHECK_LIBRARY_DIRS +list(APPEND CXSPARSE_CHECK_LIBRARY_DIRS /usr/local/lib /usr/local/homebrew/lib # Mac OS X. /opt/local/lib /usr/lib) # Search supplied hint directories first if supplied. -FIND_PATH(CXSPARSE_INCLUDE_DIR +find_path(CXSPARSE_INCLUDE_DIR NAMES cs.h PATHS ${CXSPARSE_INCLUDE_DIR_HINTS} ${CXSPARSE_CHECK_INCLUDE_DIRS}) -IF (NOT CXSPARSE_INCLUDE_DIR OR +if (NOT CXSPARSE_INCLUDE_DIR OR NOT EXISTS ${CXSPARSE_INCLUDE_DIR}) - CXSPARSE_REPORT_NOT_FOUND( + cxsparse_report_not_found( "Could not find CXSparse include directory, set CXSPARSE_INCLUDE_DIR " "to directory containing cs.h") -ENDIF (NOT CXSPARSE_INCLUDE_DIR OR +endif (NOT CXSPARSE_INCLUDE_DIR OR NOT EXISTS ${CXSPARSE_INCLUDE_DIR}) -FIND_LIBRARY(CXSPARSE_LIBRARY NAMES cxsparse +find_library(CXSPARSE_LIBRARY NAMES cxsparse PATHS ${CXSPARSE_LIBRARY_DIR_HINTS} ${CXSPARSE_CHECK_LIBRARY_DIRS}) -IF (NOT CXSPARSE_LIBRARY OR +if (NOT CXSPARSE_LIBRARY OR NOT EXISTS ${CXSPARSE_LIBRARY}) - CXSPARSE_REPORT_NOT_FOUND( + cxsparse_report_not_found( "Could not find CXSparse library, set CXSPARSE_LIBRARY " "to full path to libcxsparse.") -ENDIF (NOT CXSPARSE_LIBRARY OR +endif (NOT CXSPARSE_LIBRARY OR NOT EXISTS ${CXSPARSE_LIBRARY}) # Mark internally as found, then verify. CXSPARSE_REPORT_NOT_FOUND() unsets # if called. -SET(CXSPARSE_FOUND TRUE) +set(CXSPARSE_FOUND TRUE) # Extract CXSparse version from cs.h -IF (CXSPARSE_INCLUDE_DIR) - SET(CXSPARSE_VERSION_FILE ${CXSPARSE_INCLUDE_DIR}/cs.h) - IF (NOT EXISTS ${CXSPARSE_VERSION_FILE}) - CXSPARSE_REPORT_NOT_FOUND( +if (CXSPARSE_INCLUDE_DIR) + set(CXSPARSE_VERSION_FILE ${CXSPARSE_INCLUDE_DIR}/cs.h) + if (NOT EXISTS ${CXSPARSE_VERSION_FILE}) + cxsparse_report_not_found( "Could not find file: ${CXSPARSE_VERSION_FILE} " "containing version information in CXSparse install located at: " "${CXSPARSE_INCLUDE_DIR}.") - ELSE (NOT EXISTS ${CXSPARSE_VERSION_FILE}) - FILE(READ ${CXSPARSE_INCLUDE_DIR}/cs.h CXSPARSE_VERSION_FILE_CONTENTS) + else (NOT EXISTS ${CXSPARSE_VERSION_FILE}) + file(READ ${CXSPARSE_INCLUDE_DIR}/cs.h CXSPARSE_VERSION_FILE_CONTENTS) - STRING(REGEX MATCH "#define CS_VER [0-9]+" + string(REGEX MATCH "#define CS_VER [0-9]+" CXSPARSE_MAIN_VERSION "${CXSPARSE_VERSION_FILE_CONTENTS}") - STRING(REGEX REPLACE "#define CS_VER ([0-9]+)" "\\1" + string(REGEX REPLACE "#define CS_VER ([0-9]+)" "\\1" CXSPARSE_MAIN_VERSION "${CXSPARSE_MAIN_VERSION}") - STRING(REGEX MATCH "#define CS_SUBVER [0-9]+" + string(REGEX MATCH "#define CS_SUBVER [0-9]+" CXSPARSE_SUB_VERSION "${CXSPARSE_VERSION_FILE_CONTENTS}") - STRING(REGEX REPLACE "#define CS_SUBVER ([0-9]+)" "\\1" + string(REGEX REPLACE "#define CS_SUBVER ([0-9]+)" "\\1" CXSPARSE_SUB_VERSION "${CXSPARSE_SUB_VERSION}") - STRING(REGEX MATCH "#define CS_SUBSUB [0-9]+" + string(REGEX MATCH "#define CS_SUBSUB [0-9]+" CXSPARSE_SUBSUB_VERSION "${CXSPARSE_VERSION_FILE_CONTENTS}") - STRING(REGEX REPLACE "#define CS_SUBSUB ([0-9]+)" "\\1" + string(REGEX REPLACE "#define CS_SUBSUB ([0-9]+)" "\\1" CXSPARSE_SUBSUB_VERSION "${CXSPARSE_SUBSUB_VERSION}") # This is on a single line s/t CMake does not interpret it as a list of # elements and insert ';' separators which would result in 3.;1.;2 nonsense. - SET(CXSPARSE_VERSION "${CXSPARSE_MAIN_VERSION}.${CXSPARSE_SUB_VERSION}.${CXSPARSE_SUBSUB_VERSION}") - ENDIF (NOT EXISTS ${CXSPARSE_VERSION_FILE}) -ENDIF (CXSPARSE_INCLUDE_DIR) + set(CXSPARSE_VERSION "${CXSPARSE_MAIN_VERSION}.${CXSPARSE_SUB_VERSION}.${CXSPARSE_SUBSUB_VERSION}") + endif (NOT EXISTS ${CXSPARSE_VERSION_FILE}) +endif (CXSPARSE_INCLUDE_DIR) # Catch the case when the caller has set CXSPARSE_LIBRARY in the cache / GUI and # thus FIND_LIBRARY was not called, but specified library is invalid, otherwise @@ -195,34 +195,34 @@ # TODO: This regex for CXSparse library is pretty primitive, we use lowercase # for comparison to handle Windows using CamelCase library names, could # this check be better? -STRING(TOLOWER "${CXSPARSE_LIBRARY}" LOWERCASE_CXSPARSE_LIBRARY) -IF (CXSPARSE_LIBRARY AND +string(TOLOWER "${CXSPARSE_LIBRARY}" LOWERCASE_CXSPARSE_LIBRARY) +if (CXSPARSE_LIBRARY AND EXISTS ${CXSPARSE_LIBRARY} AND NOT "${LOWERCASE_CXSPARSE_LIBRARY}" MATCHES ".*cxsparse[^/]*") - CXSPARSE_REPORT_NOT_FOUND( + cxsparse_report_not_found( "Caller defined CXSPARSE_LIBRARY: " "${CXSPARSE_LIBRARY} does not match CXSparse.") -ENDIF (CXSPARSE_LIBRARY AND +endif (CXSPARSE_LIBRARY AND EXISTS ${CXSPARSE_LIBRARY} AND NOT "${LOWERCASE_CXSPARSE_LIBRARY}" MATCHES ".*cxsparse[^/]*") # Set standard CMake FindPackage variables if found. -IF (CXSPARSE_FOUND) - SET(CXSPARSE_INCLUDE_DIRS ${CXSPARSE_INCLUDE_DIR}) - SET(CXSPARSE_LIBRARIES ${CXSPARSE_LIBRARY}) -ENDIF (CXSPARSE_FOUND) +if (CXSPARSE_FOUND) + set(CXSPARSE_INCLUDE_DIRS ${CXSPARSE_INCLUDE_DIR}) + set(CXSPARSE_LIBRARIES ${CXSPARSE_LIBRARY}) +endif (CXSPARSE_FOUND) -CXSPARSE_RESET_FIND_LIBRARY_PREFIX() +cxsparse_reset_find_library_prefix() # Handle REQUIRED / QUIET optional arguments and version. -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CXSparse +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CXSparse REQUIRED_VARS CXSPARSE_INCLUDE_DIRS CXSPARSE_LIBRARIES VERSION_VAR CXSPARSE_VERSION) # Only mark internal variables as advanced if we found CXSparse, otherwise # leave them visible in the standard GUI for the user to set manually. -IF (CXSPARSE_FOUND) - MARK_AS_ADVANCED(FORCE CXSPARSE_INCLUDE_DIR +if (CXSPARSE_FOUND) + mark_as_advanced(FORCE CXSPARSE_INCLUDE_DIR CXSPARSE_LIBRARY) -ENDIF (CXSPARSE_FOUND) +endif (CXSPARSE_FOUND)
diff --git a/cmake/FindEigen.cmake b/cmake/FindEigen.cmake index 8e7609e..6d86197 100644 --- a/cmake/FindEigen.cmake +++ b/cmake/FindEigen.cmake
@@ -63,104 +63,104 @@ # Called if we failed to find Eigen or any of it's required dependencies, # unsets all public (designed to be used externally) variables and reports # error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument. -MACRO(EIGEN_REPORT_NOT_FOUND REASON_MSG) - UNSET(EIGEN_FOUND) - UNSET(EIGEN_INCLUDE_DIRS) +macro(EIGEN_REPORT_NOT_FOUND REASON_MSG) + unset(EIGEN_FOUND) + unset(EIGEN_INCLUDE_DIRS) # Make results of search visible in the CMake GUI if Eigen has not # been found so that user does not have to toggle to advanced view. - MARK_AS_ADVANCED(CLEAR EIGEN_INCLUDE_DIR) + mark_as_advanced(CLEAR EIGEN_INCLUDE_DIR) # Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage() # use the camelcase library name, not uppercase. - IF (Eigen_FIND_QUIETLY) - MESSAGE(STATUS "Failed to find Eigen - " ${REASON_MSG} ${ARGN}) - ELSEIF (Eigen_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Failed to find Eigen - " ${REASON_MSG} ${ARGN}) - ELSE() + if (Eigen_FIND_QUIETLY) + message(STATUS "Failed to find Eigen - " ${REASON_MSG} ${ARGN}) + elseif (Eigen_FIND_REQUIRED) + message(FATAL_ERROR "Failed to find Eigen - " ${REASON_MSG} ${ARGN}) + else() # Neither QUIETLY nor REQUIRED, use no priority which emits a message # but continues configuration and allows generation. - MESSAGE("-- Failed to find Eigen - " ${REASON_MSG} ${ARGN}) - ENDIF () -ENDMACRO(EIGEN_REPORT_NOT_FOUND) + message("-- Failed to find Eigen - " ${REASON_MSG} ${ARGN}) + endif () +endmacro(EIGEN_REPORT_NOT_FOUND) # Search user-installed locations first, so that we prefer user installs # to system installs where both exist. # # TODO: Add standard Windows search locations for Eigen. -LIST(APPEND EIGEN_CHECK_INCLUDE_DIRS +list(APPEND EIGEN_CHECK_INCLUDE_DIRS /usr/local/include /usr/local/homebrew/include # Mac OS X /opt/local/var/macports/software # Mac OS X. /opt/local/include /usr/include) # Additional suffixes to try appending to each search path. -LIST(APPEND EIGEN_CHECK_PATH_SUFFIXES +list(APPEND EIGEN_CHECK_PATH_SUFFIXES eigen3 # Default root directory for Eigen. Eigen/include/eigen3 ) # Windows (for C:/Program Files prefix). # Search supplied hint directories first if supplied. -FIND_PATH(EIGEN_INCLUDE_DIR +find_path(EIGEN_INCLUDE_DIR NAMES Eigen/Core PATHS ${EIGEN_INCLUDE_DIR_HINTS} ${EIGEN_CHECK_INCLUDE_DIRS} PATH_SUFFIXES ${EIGEN_CHECK_PATH_SUFFIXES}) -IF (NOT EIGEN_INCLUDE_DIR OR +if (NOT EIGEN_INCLUDE_DIR OR NOT EXISTS ${EIGEN_INCLUDE_DIR}) - EIGEN_REPORT_NOT_FOUND( + eigen_report_not_found( "Could not find eigen3 include directory, set EIGEN_INCLUDE_DIR to " "path to eigen3 include directory, e.g. /usr/local/include/eigen3.") -ENDIF (NOT EIGEN_INCLUDE_DIR OR +endif (NOT EIGEN_INCLUDE_DIR OR NOT EXISTS ${EIGEN_INCLUDE_DIR}) # Mark internally as found, then verify. EIGEN_REPORT_NOT_FOUND() unsets # if called. -SET(EIGEN_FOUND TRUE) +set(EIGEN_FOUND TRUE) # Extract Eigen version from Eigen/src/Core/util/Macros.h -IF (EIGEN_INCLUDE_DIR) - SET(EIGEN_VERSION_FILE ${EIGEN_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h) - IF (NOT EXISTS ${EIGEN_VERSION_FILE}) - EIGEN_REPORT_NOT_FOUND( +if (EIGEN_INCLUDE_DIR) + set(EIGEN_VERSION_FILE ${EIGEN_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h) + if (NOT EXISTS ${EIGEN_VERSION_FILE}) + eigen_report_not_found( "Could not find file: ${EIGEN_VERSION_FILE} " "containing version information in Eigen install located at: " "${EIGEN_INCLUDE_DIR}.") - ELSE (NOT EXISTS ${EIGEN_VERSION_FILE}) - FILE(READ ${EIGEN_VERSION_FILE} EIGEN_VERSION_FILE_CONTENTS) + else (NOT EXISTS ${EIGEN_VERSION_FILE}) + file(READ ${EIGEN_VERSION_FILE} EIGEN_VERSION_FILE_CONTENTS) - STRING(REGEX MATCH "#define EIGEN_WORLD_VERSION [0-9]+" + string(REGEX MATCH "#define EIGEN_WORLD_VERSION [0-9]+" EIGEN_WORLD_VERSION "${EIGEN_VERSION_FILE_CONTENTS}") - STRING(REGEX REPLACE "#define EIGEN_WORLD_VERSION ([0-9]+)" "\\1" + string(REGEX REPLACE "#define EIGEN_WORLD_VERSION ([0-9]+)" "\\1" EIGEN_WORLD_VERSION "${EIGEN_WORLD_VERSION}") - STRING(REGEX MATCH "#define EIGEN_MAJOR_VERSION [0-9]+" + string(REGEX MATCH "#define EIGEN_MAJOR_VERSION [0-9]+" EIGEN_MAJOR_VERSION "${EIGEN_VERSION_FILE_CONTENTS}") - STRING(REGEX REPLACE "#define EIGEN_MAJOR_VERSION ([0-9]+)" "\\1" + string(REGEX REPLACE "#define EIGEN_MAJOR_VERSION ([0-9]+)" "\\1" EIGEN_MAJOR_VERSION "${EIGEN_MAJOR_VERSION}") - STRING(REGEX MATCH "#define EIGEN_MINOR_VERSION [0-9]+" + string(REGEX MATCH "#define EIGEN_MINOR_VERSION [0-9]+" EIGEN_MINOR_VERSION "${EIGEN_VERSION_FILE_CONTENTS}") - STRING(REGEX REPLACE "#define EIGEN_MINOR_VERSION ([0-9]+)" "\\1" + string(REGEX REPLACE "#define EIGEN_MINOR_VERSION ([0-9]+)" "\\1" EIGEN_MINOR_VERSION "${EIGEN_MINOR_VERSION}") # This is on a single line s/t CMake does not interpret it as a list of # elements and insert ';' separators which would result in 3.;2.;0 nonsense. - SET(EIGEN_VERSION "${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION}") - ENDIF (NOT EXISTS ${EIGEN_VERSION_FILE}) -ENDIF (EIGEN_INCLUDE_DIR) + set(EIGEN_VERSION "${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION}") + endif (NOT EXISTS ${EIGEN_VERSION_FILE}) +endif (EIGEN_INCLUDE_DIR) # Set standard CMake FindPackage variables if found. -IF (EIGEN_FOUND) - SET(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR}) -ENDIF (EIGEN_FOUND) +if (EIGEN_FOUND) + set(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR}) +endif (EIGEN_FOUND) # Handle REQUIRED / QUIET optional arguments and version. -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Eigen +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Eigen REQUIRED_VARS EIGEN_INCLUDE_DIRS VERSION_VAR EIGEN_VERSION) # Only mark internal variables as advanced if we found Eigen, otherwise # leave it visible in the standard GUI for the user to set manually. -IF (EIGEN_FOUND) - MARK_AS_ADVANCED(FORCE EIGEN_INCLUDE_DIR) -ENDIF (EIGEN_FOUND) +if (EIGEN_FOUND) + mark_as_advanced(FORCE EIGEN_INCLUDE_DIR) +endif (EIGEN_FOUND)
diff --git a/cmake/FindGflags.cmake b/cmake/FindGflags.cmake index 0eefd2f..a700367 100644 --- a/cmake/FindGflags.cmake +++ b/cmake/FindGflags.cmake
@@ -84,54 +84,54 @@ # Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when FindGflags was # invoked, necessary for MSVC. -MACRO(GFLAGS_RESET_FIND_LIBRARY_PREFIX) - IF (MSVC) - SET(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") - ENDIF (MSVC) -ENDMACRO(GFLAGS_RESET_FIND_LIBRARY_PREFIX) +macro(GFLAGS_RESET_FIND_LIBRARY_PREFIX) + if (MSVC) + set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") + endif (MSVC) +endmacro(GFLAGS_RESET_FIND_LIBRARY_PREFIX) # Called if we failed to find gflags or any of it's required dependencies, # unsets all public (designed to be used externally) variables and reports # error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument. -MACRO(GFLAGS_REPORT_NOT_FOUND REASON_MSG) - UNSET(GFLAGS_FOUND) - UNSET(GFLAGS_INCLUDE_DIRS) - UNSET(GFLAGS_LIBRARIES) +macro(GFLAGS_REPORT_NOT_FOUND REASON_MSG) + unset(GFLAGS_FOUND) + unset(GFLAGS_INCLUDE_DIRS) + unset(GFLAGS_LIBRARIES) # Do not use unset, as we want to keep GFLAGS_NAMESPACE in the cache, # but simply clear its value. - SET(GFLAGS_NAMESPACE "" CACHE STRING + set(GFLAGS_NAMESPACE "" CACHE STRING "gflags namespace (google or gflags)" FORCE) # Make results of search visible in the CMake GUI if gflags has not # been found so that user does not have to toggle to advanced view. - MARK_AS_ADVANCED(CLEAR GFLAGS_INCLUDE_DIR + mark_as_advanced(CLEAR GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY GFLAGS_NAMESPACE) - GFLAGS_RESET_FIND_LIBRARY_PREFIX() + gflags_reset_find_library_prefix() # Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage() # use the camelcase library name, not uppercase. - IF (Gflags_FIND_QUIETLY) - MESSAGE(STATUS "Failed to find gflags - " ${REASON_MSG} ${ARGN}) - ELSEIF (Gflags_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Failed to find gflags - " ${REASON_MSG} ${ARGN}) - ELSE() + if (Gflags_FIND_QUIETLY) + message(STATUS "Failed to find gflags - " ${REASON_MSG} ${ARGN}) + elseif (Gflags_FIND_REQUIRED) + message(FATAL_ERROR "Failed to find gflags - " ${REASON_MSG} ${ARGN}) + else() # Neither QUIETLY nor REQUIRED, use no priority which emits a message # but continues configuration and allows generation. - MESSAGE("-- Failed to find gflags - " ${REASON_MSG} ${ARGN}) - ENDIF () -ENDMACRO(GFLAGS_REPORT_NOT_FOUND) + message("-- Failed to find gflags - " ${REASON_MSG} ${ARGN}) + endif () +endmacro(GFLAGS_REPORT_NOT_FOUND) # Verify that all variable names passed as arguments are defined (can be empty # but must be defined) or raise a fatal error. -MACRO(GFLAGS_CHECK_VARS_DEFINED) - FOREACH(CHECK_VAR ${ARGN}) - IF (NOT DEFINED ${CHECK_VAR}) - MESSAGE(FATAL_ERROR "Ceres Bug: ${CHECK_VAR} is not defined.") - ENDIF() - ENDFOREACH() -ENDMACRO(GFLAGS_CHECK_VARS_DEFINED) +macro(GFLAGS_CHECK_VARS_DEFINED) + foreach(CHECK_VAR ${ARGN}) + if (NOT DEFINED ${CHECK_VAR}) + message(FATAL_ERROR "Ceres Bug: ${CHECK_VAR} is not defined.") + endif() + endforeach() +endmacro(GFLAGS_CHECK_VARS_DEFINED) # Use check_cxx_source_compiles() to compile trivial test programs to determine # the gflags namespace. This works on all OSs except Windows. If using Visual @@ -143,50 +143,50 @@ # Defines: GFLAGS_NAMESPACE in the caller's scope with the detected namespace, # which is blank (empty string, will test FALSE is CMake conditionals) # if detection failed. -FUNCTION(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_TRY_COMPILE) +function(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_TRY_COMPILE) # Verify that all required variables are defined. - GFLAGS_CHECK_VARS_DEFINED( + gflags_check_vars_defined( GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY) # Ensure that GFLAGS_NAMESPACE is always unset on completion unless # we explicitly set if after having the correct namespace. - SET(GFLAGS_NAMESPACE "" PARENT_SCOPE) + set(GFLAGS_NAMESPACE "" PARENT_SCOPE) - INCLUDE(CheckCXXSourceCompiles) + include(CheckCXXSourceCompiles) # Setup include path & link library for gflags for CHECK_CXX_SOURCE_COMPILES. - SET(CMAKE_REQUIRED_INCLUDES ${GFLAGS_INCLUDE_DIR}) - SET(CMAKE_REQUIRED_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES ${GFLAGS_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES}) # First try the (older) google namespace. Note that the output variable # MUST be unique to the build type as otherwise the test is not repeated as # it is assumed to have already been performed. - CHECK_CXX_SOURCE_COMPILES( + check_cxx_source_compiles( "#include <gflags/gflags.h> int main(int argc, char * argv[]) { google::ParseCommandLineFlags(&argc, &argv, true); return 0; }" GFLAGS_IN_GOOGLE_NAMESPACE) - IF (GFLAGS_IN_GOOGLE_NAMESPACE) - SET(GFLAGS_NAMESPACE google PARENT_SCOPE) - RETURN() - ENDIF() + if (GFLAGS_IN_GOOGLE_NAMESPACE) + set(GFLAGS_NAMESPACE google PARENT_SCOPE) + return() + endif() # Try (newer) gflags namespace instead. Note that the output variable # MUST be unique to the build type as otherwise the test is not repeated as # it is assumed to have already been performed. - SET(CMAKE_REQUIRED_INCLUDES ${GFLAGS_INCLUDE_DIR}) - SET(CMAKE_REQUIRED_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES}) - CHECK_CXX_SOURCE_COMPILES( + set(CMAKE_REQUIRED_INCLUDES ${GFLAGS_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES}) + check_cxx_source_compiles( "#include <gflags/gflags.h> int main(int argc, char * argv[]) { gflags::ParseCommandLineFlags(&argc, &argv, true); return 0; }" GFLAGS_IN_GFLAGS_NAMESPACE) - IF (GFLAGS_IN_GFLAGS_NAMESPACE) - SET(GFLAGS_NAMESPACE gflags PARENT_SCOPE) - RETURN() - ENDIF (GFLAGS_IN_GFLAGS_NAMESPACE) -ENDFUNCTION(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_TRY_COMPILE) + if (GFLAGS_IN_GFLAGS_NAMESPACE) + set(GFLAGS_NAMESPACE gflags PARENT_SCOPE) + return() + endif (GFLAGS_IN_GFLAGS_NAMESPACE) +endfunction(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_TRY_COMPILE) # Use regex on the gflags headers to attempt to determine the gflags namespace. # Checks both gflags.h (contained namespace on versions < 2.1.2) and @@ -198,91 +198,91 @@ # Defines: GFLAGS_NAMESPACE in the caller's scope with the detected namespace, # which is blank (empty string, will test FALSE is CMake conditionals) # if detection failed. -FUNCTION(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_REGEX) +function(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_REGEX) # Verify that all required variables are defined. - GFLAGS_CHECK_VARS_DEFINED(GFLAGS_INCLUDE_DIR) + gflags_check_vars_defined(GFLAGS_INCLUDE_DIR) # Ensure that GFLAGS_NAMESPACE is always undefined on completion unless # we explicitly set if after having the correct namespace. - SET(GFLAGS_NAMESPACE "" PARENT_SCOPE) + set(GFLAGS_NAMESPACE "" PARENT_SCOPE) # Scan gflags.h to identify what namespace gflags was built with. On # versions of gflags < 2.1.2, gflags.h was configured with the namespace # directly, on >= 2.1.2, gflags.h uses the GFLAGS_NAMESPACE #define which # is defined in gflags_declare.h, we try each location in turn. - SET(GFLAGS_HEADER_FILE ${GFLAGS_INCLUDE_DIR}/gflags/gflags.h) - IF (NOT EXISTS ${GFLAGS_HEADER_FILE}) - GFLAGS_REPORT_NOT_FOUND( + set(GFLAGS_HEADER_FILE ${GFLAGS_INCLUDE_DIR}/gflags/gflags.h) + if (NOT EXISTS ${GFLAGS_HEADER_FILE}) + gflags_report_not_found( "Could not find file: ${GFLAGS_HEADER_FILE} " "containing namespace information in gflags install located at: " "${GFLAGS_INCLUDE_DIR}.") - ENDIF() - FILE(READ ${GFLAGS_HEADER_FILE} GFLAGS_HEADER_FILE_CONTENTS) + endif() + file(READ ${GFLAGS_HEADER_FILE} GFLAGS_HEADER_FILE_CONTENTS) - STRING(REGEX MATCH "namespace [A-Za-z]+" + string(REGEX MATCH "namespace [A-Za-z]+" GFLAGS_NAMESPACE "${GFLAGS_HEADER_FILE_CONTENTS}") - STRING(REGEX REPLACE "namespace ([A-Za-z]+)" "\\1" + string(REGEX REPLACE "namespace ([A-Za-z]+)" "\\1" GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}") - IF (NOT GFLAGS_NAMESPACE) - GFLAGS_REPORT_NOT_FOUND( + if (NOT GFLAGS_NAMESPACE) + gflags_report_not_found( "Failed to extract gflags namespace from header file: " "${GFLAGS_HEADER_FILE}.") - ENDIF (NOT GFLAGS_NAMESPACE) + endif (NOT GFLAGS_NAMESPACE) - IF (GFLAGS_NAMESPACE STREQUAL "google" OR + if (GFLAGS_NAMESPACE STREQUAL "google" OR GFLAGS_NAMESPACE STREQUAL "gflags") # Found valid gflags namespace from gflags.h. - SET(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" PARENT_SCOPE) - RETURN() - ENDIF() + set(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" PARENT_SCOPE) + return() + endif() # Failed to find gflags namespace from gflags.h, gflags is likely a new # version, check gflags_declare.h, which in newer versions (>= 2.1.2) contains # the GFLAGS_NAMESPACE #define, which is then referenced in gflags.h. - SET(GFLAGS_DECLARE_FILE ${GFLAGS_INCLUDE_DIR}/gflags/gflags_declare.h) - IF (NOT EXISTS ${GFLAGS_DECLARE_FILE}) - GFLAGS_REPORT_NOT_FOUND( + set(GFLAGS_DECLARE_FILE ${GFLAGS_INCLUDE_DIR}/gflags/gflags_declare.h) + if (NOT EXISTS ${GFLAGS_DECLARE_FILE}) + gflags_report_not_found( "Could not find file: ${GFLAGS_DECLARE_FILE} " "containing namespace information in gflags install located at: " "${GFLAGS_INCLUDE_DIR}.") - ENDIF() - FILE(READ ${GFLAGS_DECLARE_FILE} GFLAGS_DECLARE_FILE_CONTENTS) + endif() + file(READ ${GFLAGS_DECLARE_FILE} GFLAGS_DECLARE_FILE_CONTENTS) - STRING(REGEX MATCH "#define GFLAGS_NAMESPACE [A-Za-z]+" + string(REGEX MATCH "#define GFLAGS_NAMESPACE [A-Za-z]+" GFLAGS_NAMESPACE "${GFLAGS_DECLARE_FILE_CONTENTS}") - STRING(REGEX REPLACE "#define GFLAGS_NAMESPACE ([A-Za-z]+)" "\\1" + string(REGEX REPLACE "#define GFLAGS_NAMESPACE ([A-Za-z]+)" "\\1" GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}") - IF (NOT GFLAGS_NAMESPACE) - GFLAGS_REPORT_NOT_FOUND( + if (NOT GFLAGS_NAMESPACE) + gflags_report_not_found( "Failed to extract gflags namespace from declare file: " "${GFLAGS_DECLARE_FILE}.") - ENDIF (NOT GFLAGS_NAMESPACE) + endif (NOT GFLAGS_NAMESPACE) - IF (GFLAGS_NAMESPACE STREQUAL "google" OR + if (GFLAGS_NAMESPACE STREQUAL "google" OR GFLAGS_NAMESPACE STREQUAL "gflags") # Found valid gflags namespace from gflags.h. - SET(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" PARENT_SCOPE) - RETURN() - ENDIF() -ENDFUNCTION(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_REGEX) + set(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" PARENT_SCOPE) + return() + endif() +endfunction(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_REGEX) # ----------------------------------------------------------------- # By default, if the user has expressed no preference for using an exported # gflags CMake configuration over performing a search for the installed # components, and has not specified any hints for the search locations, then # prefer a gflags exported configuration if available. -IF (NOT DEFINED GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION +if (NOT DEFINED GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION AND NOT GFLAGS_INCLUDE_DIR_HINTS AND NOT GFLAGS_LIBRARY_DIR_HINTS) - MESSAGE(STATUS "No preference for use of exported gflags CMake configuration " + message(STATUS "No preference for use of exported gflags CMake configuration " "set, and no hints for include/library directories provided. " "Defaulting to preferring an installed/exported gflags CMake configuration " "if available.") - SET(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION TRUE) -ENDIF() + set(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION TRUE) +endif() -IF (GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION) +if (GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION) # Try to find an exported CMake configuration for gflags, as generated by # gflags versions >= 2.1. # @@ -314,28 +314,28 @@ # version if available. # # [1] http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:find_package - FIND_PACKAGE(gflags QUIET + find_package(gflags QUIET NO_MODULE NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_BUILDS_PATH) - IF (gflags_FOUND) - MESSAGE(STATUS "Found installed version of gflags: ${gflags_DIR}") - ELSE(gflags_FOUND) + if (gflags_FOUND) + message(STATUS "Found installed version of gflags: ${gflags_DIR}") + else(gflags_FOUND) # Failed to find an installed version of gflags, repeat search allowing # exported build directories. - MESSAGE(STATUS "Failed to find installed version of gflags, searching for " + message(STATUS "Failed to find installed version of gflags, searching for " "gflags build directories exported with CMake.") # Again pass NO_CMAKE_BUILDS_PATH, as we know that gflags is exported and # do not want to treat projects built with the CMake GUI preferentially. - FIND_PACKAGE(gflags QUIET + find_package(gflags QUIET NO_MODULE NO_CMAKE_BUILDS_PATH) - IF (gflags_FOUND) - MESSAGE(STATUS "Found exported gflags build directory: ${gflags_DIR}") - ENDIF(gflags_FOUND) - ENDIF(gflags_FOUND) + if (gflags_FOUND) + message(STATUS "Found exported gflags build directory: ${gflags_DIR}") + endif(gflags_FOUND) + endif(gflags_FOUND) - SET(FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION ${gflags_FOUND}) + set(FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION ${gflags_FOUND}) # gflags v2.1 - 2.1.2 shipped with a bug in their gflags-config.cmake [1] # whereby gflags_LIBRARIES = "gflags", but there was no imported target @@ -345,43 +345,43 @@ # fix it. # # [1] https://github.com/gflags/gflags/issues/110 - IF (gflags_FOUND AND + if (gflags_FOUND AND ${gflags_VERSION} VERSION_LESS 2.1.3 AND NOT TARGET ${gflags_LIBRARIES}) - MESSAGE(STATUS "Detected broken gflags install in: ${gflags_DIR}, " + message(STATUS "Detected broken gflags install in: ${gflags_DIR}, " "version: ${gflags_VERSION} <= 2.1.2 which defines gflags_LIBRARIES = " "${gflags_LIBRARIES} which is not an imported CMake target, see: " "https://github.com/gflags/gflags/issues/110. Attempting to fix by " "detecting correct gflags target.") # Ordering here expresses preference for detection, specifically we do not # want to use the _nothreads variants if the full library is available. - LIST(APPEND CHECK_GFLAGS_IMPORTED_TARGET_NAMES + list(APPEND CHECK_GFLAGS_IMPORTED_TARGET_NAMES gflags-shared gflags-static gflags_nothreads-shared gflags_nothreads-static) - FOREACH(CHECK_GFLAGS_TARGET ${CHECK_GFLAGS_IMPORTED_TARGET_NAMES}) - IF (TARGET ${CHECK_GFLAGS_TARGET}) - MESSAGE(STATUS "Found valid gflags target: ${CHECK_GFLAGS_TARGET}, " + foreach(CHECK_GFLAGS_TARGET ${CHECK_GFLAGS_IMPORTED_TARGET_NAMES}) + if (TARGET ${CHECK_GFLAGS_TARGET}) + message(STATUS "Found valid gflags target: ${CHECK_GFLAGS_TARGET}, " "updating gflags_LIBRARIES.") - SET(gflags_LIBRARIES ${CHECK_GFLAGS_TARGET}) - BREAK() - ENDIF() - ENDFOREACH() - IF (NOT TARGET ${gflags_LIBRARIES}) - MESSAGE(STATUS "Failed to fix detected broken gflags install in: " + set(gflags_LIBRARIES ${CHECK_GFLAGS_TARGET}) + break() + endif() + endforeach() + if (NOT TARGET ${gflags_LIBRARIES}) + message(STATUS "Failed to fix detected broken gflags install in: " "${gflags_DIR}, version: ${gflags_VERSION} <= 2.1.2, none of the " "imported targets for gflags: ${CHECK_GFLAGS_IMPORTED_TARGET_NAMES} " "are defined. Will continue with a manual search for gflags " "components. We recommend you build/install a version of gflags > " "2.1.2 (or master).") - SET(FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION FALSE) - ENDIF() - ENDIF() + set(FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION FALSE) + endif() + endif() - IF (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION) - MESSAGE(STATUS "Detected gflags version: ${gflags_VERSION}") - SET(GFLAGS_FOUND ${gflags_FOUND}) - SET(GFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIR}) - SET(GFLAGS_LIBRARY ${gflags_LIBRARIES}) + if (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION) + message(STATUS "Detected gflags version: ${gflags_VERSION}") + set(GFLAGS_FOUND ${gflags_FOUND}) + set(GFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIR}) + set(GFLAGS_LIBRARY ${gflags_LIBRARIES}) # gflags does not export the namespace in their CMake configuration, so # use our function to determine what it should be, as it can be either @@ -390,102 +390,102 @@ # NOTE: We use the regex method to determine the namespace here, as # check_cxx_source_compiles() will not use imported targets, which # is what gflags will be in this case. - GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_REGEX() + gflags_check_gflags_namespace_using_regex() - IF (NOT GFLAGS_NAMESPACE) - GFLAGS_REPORT_NOT_FOUND( + if (NOT GFLAGS_NAMESPACE) + gflags_report_not_found( "Failed to determine gflags namespace using regex for gflags " "version: ${gflags_VERSION} exported here: ${gflags_DIR} using CMake.") - ENDIF (NOT GFLAGS_NAMESPACE) - ELSE (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION) - MESSAGE(STATUS "Failed to find an installed/exported CMake configuration " + endif (NOT GFLAGS_NAMESPACE) + else (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION) + message(STATUS "Failed to find an installed/exported CMake configuration " "for gflags, will perform search for installed gflags components.") - ENDIF (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION) -ENDIF(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION) + endif (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION) +endif(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION) -IF (NOT GFLAGS_FOUND) +if (NOT GFLAGS_FOUND) # Either failed to find an exported gflags CMake configuration, or user # told us not to use one. Perform a manual search for all gflags components. # Handle possible presence of lib prefix for libraries on MSVC, see # also GFLAGS_RESET_FIND_LIBRARY_PREFIX(). - IF (MSVC) + if (MSVC) # Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES # s/t we can set it back before returning. - SET(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") + set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") # The empty string in this list is important, it represents the case when # the libraries have no prefix (shared libraries / DLLs). - SET(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}") - ENDIF (MSVC) + set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}") + endif (MSVC) # Search user-installed locations first, so that we prefer user installs # to system installs where both exist. - LIST(APPEND GFLAGS_CHECK_INCLUDE_DIRS + list(APPEND GFLAGS_CHECK_INCLUDE_DIRS /usr/local/include /usr/local/homebrew/include # Mac OS X /opt/local/var/macports/software # Mac OS X. /opt/local/include /usr/include) - LIST(APPEND GFLAGS_CHECK_PATH_SUFFIXES + list(APPEND GFLAGS_CHECK_PATH_SUFFIXES gflags/include # Windows (for C:/Program Files prefix). gflags/Include ) # Windows (for C:/Program Files prefix). - LIST(APPEND GFLAGS_CHECK_LIBRARY_DIRS + list(APPEND GFLAGS_CHECK_LIBRARY_DIRS /usr/local/lib /usr/local/homebrew/lib # Mac OS X. /opt/local/lib /usr/lib) - LIST(APPEND GFLAGS_CHECK_LIBRARY_SUFFIXES + list(APPEND GFLAGS_CHECK_LIBRARY_SUFFIXES gflags/lib # Windows (for C:/Program Files prefix). gflags/Lib ) # Windows (for C:/Program Files prefix). # Search supplied hint directories first if supplied. - FIND_PATH(GFLAGS_INCLUDE_DIR + find_path(GFLAGS_INCLUDE_DIR NAMES gflags/gflags.h PATHS ${GFLAGS_INCLUDE_DIR_HINTS} ${GFLAGS_CHECK_INCLUDE_DIRS} PATH_SUFFIXES ${GFLAGS_CHECK_PATH_SUFFIXES}) - IF (NOT GFLAGS_INCLUDE_DIR OR + if (NOT GFLAGS_INCLUDE_DIR OR NOT EXISTS ${GFLAGS_INCLUDE_DIR}) - GFLAGS_REPORT_NOT_FOUND( + gflags_report_not_found( "Could not find gflags include directory, set GFLAGS_INCLUDE_DIR " "to directory containing gflags/gflags.h") - ENDIF (NOT GFLAGS_INCLUDE_DIR OR + endif (NOT GFLAGS_INCLUDE_DIR OR NOT EXISTS ${GFLAGS_INCLUDE_DIR}) - FIND_LIBRARY(GFLAGS_LIBRARY NAMES gflags + find_library(GFLAGS_LIBRARY NAMES gflags PATHS ${GFLAGS_LIBRARY_DIR_HINTS} ${GFLAGS_CHECK_LIBRARY_DIRS} PATH_SUFFIXES ${GFLAGS_CHECK_LIBRARY_SUFFIXES}) - IF (NOT GFLAGS_LIBRARY OR + if (NOT GFLAGS_LIBRARY OR NOT EXISTS ${GFLAGS_LIBRARY}) - GFLAGS_REPORT_NOT_FOUND( + gflags_report_not_found( "Could not find gflags library, set GFLAGS_LIBRARY " "to full path to libgflags.") - ENDIF (NOT GFLAGS_LIBRARY OR + endif (NOT GFLAGS_LIBRARY OR NOT EXISTS ${GFLAGS_LIBRARY}) # gflags typically requires a threading library (which is OS dependent), note # that this defines the CMAKE_THREAD_LIBS_INIT variable. If we are able to # detect threads, we assume that gflags requires it. - FIND_PACKAGE(Threads QUIET) - SET(GFLAGS_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + find_package(Threads QUIET) + set(GFLAGS_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) # On Windows (including MinGW), the Shlwapi library is used by gflags if # available. - IF (WIN32) - INCLUDE(CheckIncludeFileCXX) - CHECK_INCLUDE_FILE_CXX("shlwapi.h" HAVE_SHLWAPI) - IF (HAVE_SHLWAPI) - LIST(APPEND GFLAGS_LINK_LIBRARIES shlwapi.lib) - ENDIF(HAVE_SHLWAPI) - ENDIF (WIN32) + if (WIN32) + include(CheckIncludeFileCXX) + check_include_file_cxx("shlwapi.h" HAVE_SHLWAPI) + if (HAVE_SHLWAPI) + list(APPEND GFLAGS_LINK_LIBRARIES shlwapi.lib) + endif(HAVE_SHLWAPI) + endif (WIN32) # Mark internally as found, then verify. GFLAGS_REPORT_NOT_FOUND() unsets # if called. - SET(GFLAGS_FOUND TRUE) + set(GFLAGS_FOUND TRUE) # Identify what namespace gflags was built with. - IF (GFLAGS_INCLUDE_DIR AND NOT GFLAGS_NAMESPACE) + if (GFLAGS_INCLUDE_DIR AND NOT GFLAGS_NAMESPACE) # To handle Windows peculiarities / CMake bugs on MSVC we try two approaches # to detect the gflags namespace: # @@ -495,27 +495,27 @@ # 2) [In the event 1) fails] Use regex on the gflags headers to try to # determine the gflags namespace. Whilst this is less robust than 1), # it does avoid any interaction with msbuild. - GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_TRY_COMPILE() + gflags_check_gflags_namespace_using_try_compile() - IF (NOT GFLAGS_NAMESPACE) + if (NOT GFLAGS_NAMESPACE) # Failed to determine gflags namespace using check_cxx_source_compiles() # method, try and obtain it using regex on the gflags headers instead. - MESSAGE(STATUS "Failed to find gflags namespace using using " + message(STATUS "Failed to find gflags namespace using using " "check_cxx_source_compiles(), trying namespace regex instead, " "this is expected on Windows.") - GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_REGEX() + gflags_check_gflags_namespace_using_regex() - IF (NOT GFLAGS_NAMESPACE) - GFLAGS_REPORT_NOT_FOUND( + if (NOT GFLAGS_NAMESPACE) + gflags_report_not_found( "Failed to determine gflags namespace either by " "check_cxx_source_compiles(), or namespace regex.") - ENDIF (NOT GFLAGS_NAMESPACE) - ENDIF (NOT GFLAGS_NAMESPACE) - ENDIF (GFLAGS_INCLUDE_DIR AND NOT GFLAGS_NAMESPACE) + endif (NOT GFLAGS_NAMESPACE) + endif (NOT GFLAGS_NAMESPACE) + endif (GFLAGS_INCLUDE_DIR AND NOT GFLAGS_NAMESPACE) # Make the GFLAGS_NAMESPACE a cache variable s/t the user can view it, and could # overwrite it in the CMake GUI. - SET(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" CACHE STRING + set(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" CACHE STRING "gflags namespace (google or gflags)" FORCE) # gflags does not seem to provide any record of the version in its @@ -523,55 +523,55 @@ # Catch case when caller has set GFLAGS_NAMESPACE in the cache / GUI # with an invalid value. - IF (GFLAGS_NAMESPACE AND + if (GFLAGS_NAMESPACE AND NOT GFLAGS_NAMESPACE STREQUAL "google" AND NOT GFLAGS_NAMESPACE STREQUAL "gflags") - GFLAGS_REPORT_NOT_FOUND( + gflags_report_not_found( "Caller defined GFLAGS_NAMESPACE:" " ${GFLAGS_NAMESPACE} is not valid, not google or gflags.") - ENDIF () + endif () # Catch case when caller has set GFLAGS_INCLUDE_DIR in the cache / GUI and # thus FIND_[PATH/LIBRARY] are not called, but specified locations are # invalid, otherwise we would report the library as found. - IF (GFLAGS_INCLUDE_DIR AND + if (GFLAGS_INCLUDE_DIR AND NOT EXISTS ${GFLAGS_INCLUDE_DIR}/gflags/gflags.h) - GFLAGS_REPORT_NOT_FOUND( + gflags_report_not_found( "Caller defined GFLAGS_INCLUDE_DIR:" " ${GFLAGS_INCLUDE_DIR} does not contain gflags/gflags.h header.") - ENDIF (GFLAGS_INCLUDE_DIR AND + endif (GFLAGS_INCLUDE_DIR AND NOT EXISTS ${GFLAGS_INCLUDE_DIR}/gflags/gflags.h) # TODO: This regex for gflags library is pretty primitive, we use lowercase # for comparison to handle Windows using CamelCase library names, could # this check be better? - STRING(TOLOWER "${GFLAGS_LIBRARY}" LOWERCASE_GFLAGS_LIBRARY) - IF (GFLAGS_LIBRARY AND + string(TOLOWER "${GFLAGS_LIBRARY}" LOWERCASE_GFLAGS_LIBRARY) + if (GFLAGS_LIBRARY AND NOT "${LOWERCASE_GFLAGS_LIBRARY}" MATCHES ".*gflags[^/]*") - GFLAGS_REPORT_NOT_FOUND( + gflags_report_not_found( "Caller defined GFLAGS_LIBRARY: " "${GFLAGS_LIBRARY} does not match gflags.") - ENDIF (GFLAGS_LIBRARY AND + endif (GFLAGS_LIBRARY AND NOT "${LOWERCASE_GFLAGS_LIBRARY}" MATCHES ".*gflags[^/]*") - GFLAGS_RESET_FIND_LIBRARY_PREFIX() + gflags_reset_find_library_prefix() -ENDIF(NOT GFLAGS_FOUND) +endif(NOT GFLAGS_FOUND) # Set standard CMake FindPackage variables if found. -IF (GFLAGS_FOUND) - SET(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR}) - SET(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES}) -ENDIF (GFLAGS_FOUND) +if (GFLAGS_FOUND) + set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR}) + set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES}) +endif (GFLAGS_FOUND) # Handle REQUIRED / QUIET optional arguments. -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gflags DEFAULT_MSG +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Gflags DEFAULT_MSG GFLAGS_INCLUDE_DIRS GFLAGS_LIBRARIES GFLAGS_NAMESPACE) # Only mark internal variables as advanced if we found gflags, otherwise # leave them visible in the standard GUI for the user to set manually. -IF (GFLAGS_FOUND) - MARK_AS_ADVANCED(FORCE GFLAGS_INCLUDE_DIR +if (GFLAGS_FOUND) + mark_as_advanced(FORCE GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY GFLAGS_NAMESPACE gflags_DIR) # Autogenerated by find_package(gflags) -ENDIF (GFLAGS_FOUND) +endif (GFLAGS_FOUND)
diff --git a/cmake/FindGlog.cmake b/cmake/FindGlog.cmake index 4f5a6b5..9ec157a 100644 --- a/cmake/FindGlog.cmake +++ b/cmake/FindGlog.cmake
@@ -62,106 +62,106 @@ # Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when # FindGlog was invoked. -MACRO(GLOG_RESET_FIND_LIBRARY_PREFIX) - IF (MSVC) - SET(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") - ENDIF (MSVC) -ENDMACRO(GLOG_RESET_FIND_LIBRARY_PREFIX) +macro(GLOG_RESET_FIND_LIBRARY_PREFIX) + if (MSVC) + set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") + endif (MSVC) +endmacro(GLOG_RESET_FIND_LIBRARY_PREFIX) # Called if we failed to find glog or any of it's required dependencies, # unsets all public (designed to be used externally) variables and reports # error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument. -MACRO(GLOG_REPORT_NOT_FOUND REASON_MSG) - UNSET(GLOG_FOUND) - UNSET(GLOG_INCLUDE_DIRS) - UNSET(GLOG_LIBRARIES) +macro(GLOG_REPORT_NOT_FOUND REASON_MSG) + unset(GLOG_FOUND) + unset(GLOG_INCLUDE_DIRS) + unset(GLOG_LIBRARIES) # Make results of search visible in the CMake GUI if glog has not # been found so that user does not have to toggle to advanced view. - MARK_AS_ADVANCED(CLEAR GLOG_INCLUDE_DIR + mark_as_advanced(CLEAR GLOG_INCLUDE_DIR GLOG_LIBRARY) - GLOG_RESET_FIND_LIBRARY_PREFIX() + glog_reset_find_library_prefix() # Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage() # use the camelcase library name, not uppercase. - IF (Glog_FIND_QUIETLY) - MESSAGE(STATUS "Failed to find glog - " ${REASON_MSG} ${ARGN}) - ELSEIF (Glog_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Failed to find glog - " ${REASON_MSG} ${ARGN}) - ELSE() + if (Glog_FIND_QUIETLY) + message(STATUS "Failed to find glog - " ${REASON_MSG} ${ARGN}) + elseif (Glog_FIND_REQUIRED) + message(FATAL_ERROR "Failed to find glog - " ${REASON_MSG} ${ARGN}) + else() # Neither QUIETLY nor REQUIRED, use no priority which emits a message # but continues configuration and allows generation. - MESSAGE("-- Failed to find glog - " ${REASON_MSG} ${ARGN}) - ENDIF () -ENDMACRO(GLOG_REPORT_NOT_FOUND) + message("-- Failed to find glog - " ${REASON_MSG} ${ARGN}) + endif () +endmacro(GLOG_REPORT_NOT_FOUND) # Handle possible presence of lib prefix for libraries on MSVC, see # also GLOG_RESET_FIND_LIBRARY_PREFIX(). -IF (MSVC) +if (MSVC) # Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES # s/t we can set it back before returning. - SET(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") + set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") # The empty string in this list is important, it represents the case when # the libraries have no prefix (shared libraries / DLLs). - SET(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}") -ENDIF (MSVC) + set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}") +endif (MSVC) # Search user-installed locations first, so that we prefer user installs # to system installs where both exist. -LIST(APPEND GLOG_CHECK_INCLUDE_DIRS +list(APPEND GLOG_CHECK_INCLUDE_DIRS /usr/local/include /usr/local/homebrew/include # Mac OS X /opt/local/var/macports/software # Mac OS X. /opt/local/include /usr/include) # Windows (for C:/Program Files prefix). -LIST(APPEND GLOG_CHECK_PATH_SUFFIXES +list(APPEND GLOG_CHECK_PATH_SUFFIXES glog/include glog/Include Glog/include Glog/Include) -LIST(APPEND GLOG_CHECK_LIBRARY_DIRS +list(APPEND GLOG_CHECK_LIBRARY_DIRS /usr/local/lib /usr/local/homebrew/lib # Mac OS X. /opt/local/lib /usr/lib) # Windows (for C:/Program Files prefix). -LIST(APPEND GLOG_CHECK_LIBRARY_SUFFIXES +list(APPEND GLOG_CHECK_LIBRARY_SUFFIXES glog/lib glog/Lib Glog/lib Glog/Lib) # Search supplied hint directories first if supplied. -FIND_PATH(GLOG_INCLUDE_DIR +find_path(GLOG_INCLUDE_DIR NAMES glog/logging.h PATHS ${GLOG_INCLUDE_DIR_HINTS} ${GLOG_CHECK_INCLUDE_DIRS} PATH_SUFFIXES ${GLOG_CHECK_PATH_SUFFIXES}) -IF (NOT GLOG_INCLUDE_DIR OR +if (NOT GLOG_INCLUDE_DIR OR NOT EXISTS ${GLOG_INCLUDE_DIR}) - GLOG_REPORT_NOT_FOUND( + glog_report_not_found( "Could not find glog include directory, set GLOG_INCLUDE_DIR " "to directory containing glog/logging.h") -ENDIF (NOT GLOG_INCLUDE_DIR OR +endif (NOT GLOG_INCLUDE_DIR OR NOT EXISTS ${GLOG_INCLUDE_DIR}) -FIND_LIBRARY(GLOG_LIBRARY NAMES glog +find_library(GLOG_LIBRARY NAMES glog PATHS ${GLOG_LIBRARY_DIR_HINTS} ${GLOG_CHECK_LIBRARY_DIRS} PATH_SUFFIXES ${GLOG_CHECK_LIBRARY_SUFFIXES}) -IF (NOT GLOG_LIBRARY OR +if (NOT GLOG_LIBRARY OR NOT EXISTS ${GLOG_LIBRARY}) - GLOG_REPORT_NOT_FOUND( + glog_report_not_found( "Could not find glog library, set GLOG_LIBRARY " "to full path to libglog.") -ENDIF (NOT GLOG_LIBRARY OR +endif (NOT GLOG_LIBRARY OR NOT EXISTS ${GLOG_LIBRARY}) # Mark internally as found, then verify. GLOG_REPORT_NOT_FOUND() unsets # if called. -SET(GLOG_FOUND TRUE) +set(GLOG_FOUND TRUE) # Glog does not seem to provide any record of the version in its # source tree, thus cannot extract version. @@ -169,41 +169,41 @@ # Catch case when caller has set GLOG_INCLUDE_DIR in the cache / GUI and # thus FIND_[PATH/LIBRARY] are not called, but specified locations are # invalid, otherwise we would report the library as found. -IF (GLOG_INCLUDE_DIR AND +if (GLOG_INCLUDE_DIR AND NOT EXISTS ${GLOG_INCLUDE_DIR}/glog/logging.h) - GLOG_REPORT_NOT_FOUND( + glog_report_not_found( "Caller defined GLOG_INCLUDE_DIR:" " ${GLOG_INCLUDE_DIR} does not contain glog/logging.h header.") -ENDIF (GLOG_INCLUDE_DIR AND +endif (GLOG_INCLUDE_DIR AND NOT EXISTS ${GLOG_INCLUDE_DIR}/glog/logging.h) # TODO: This regex for glog library is pretty primitive, we use lowercase # for comparison to handle Windows using CamelCase library names, could # this check be better? -STRING(TOLOWER "${GLOG_LIBRARY}" LOWERCASE_GLOG_LIBRARY) -IF (GLOG_LIBRARY AND +string(TOLOWER "${GLOG_LIBRARY}" LOWERCASE_GLOG_LIBRARY) +if (GLOG_LIBRARY AND NOT "${LOWERCASE_GLOG_LIBRARY}" MATCHES ".*glog[^/]*") - GLOG_REPORT_NOT_FOUND( + glog_report_not_found( "Caller defined GLOG_LIBRARY: " "${GLOG_LIBRARY} does not match glog.") -ENDIF (GLOG_LIBRARY AND +endif (GLOG_LIBRARY AND NOT "${LOWERCASE_GLOG_LIBRARY}" MATCHES ".*glog[^/]*") # Set standard CMake FindPackage variables if found. -IF (GLOG_FOUND) - SET(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR}) - SET(GLOG_LIBRARIES ${GLOG_LIBRARY}) -ENDIF (GLOG_FOUND) +if (GLOG_FOUND) + set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR}) + set(GLOG_LIBRARIES ${GLOG_LIBRARY}) +endif (GLOG_FOUND) -GLOG_RESET_FIND_LIBRARY_PREFIX() +glog_reset_find_library_prefix() # Handle REQUIRED / QUIET optional arguments. -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Glog DEFAULT_MSG +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Glog DEFAULT_MSG GLOG_INCLUDE_DIRS GLOG_LIBRARIES) # Only mark internal variables as advanced if we found glog, otherwise # leave them visible in the standard GUI for the user to set manually. -IF (GLOG_FOUND) - MARK_AS_ADVANCED(FORCE GLOG_INCLUDE_DIR +if (GLOG_FOUND) + mark_as_advanced(FORCE GLOG_INCLUDE_DIR GLOG_LIBRARY) -ENDIF (GLOG_FOUND) +endif (GLOG_FOUND)
diff --git a/cmake/FindSharedPtr.cmake b/cmake/FindSharedPtr.cmake index 3135dd5..e37c969 100644 --- a/cmake/FindSharedPtr.cmake +++ b/cmake/FindSharedPtr.cmake
@@ -39,70 +39,70 @@ # SHARED_PTR_TR1_NAMESPACE: TRUE if shared_ptr is defined in std::tr1 namespace, # otherwise it's assumed to be defined in std namespace. -MACRO(FIND_SHARED_PTR) +macro(FIND_SHARED_PTR) # To support CXX11 option, clear the results of all check_xxx() functions # s/t we always perform the checks each time, otherwise CMake fails to # detect that the tests should be performed again after CXX11 is toggled. - UNSET(HAVE_STD_MEMORY_HEADER CACHE) - UNSET(HAVE_SHARED_PTR_IN_STD_NAMESPACE CACHE) - UNSET(HAVE_SHARED_PTR_IN_TR1_NAMESPACE CACHE) - UNSET(HAVE_TR1_MEMORY_HEADER CACHE) - UNSET(HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER CACHE) + unset(HAVE_STD_MEMORY_HEADER CACHE) + unset(HAVE_SHARED_PTR_IN_STD_NAMESPACE CACHE) + unset(HAVE_SHARED_PTR_IN_TR1_NAMESPACE CACHE) + unset(HAVE_TR1_MEMORY_HEADER CACHE) + unset(HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER CACHE) - SET(SHARED_PTR_FOUND FALSE) - CHECK_INCLUDE_FILE_CXX(memory HAVE_STD_MEMORY_HEADER) - IF (HAVE_STD_MEMORY_HEADER) + set(SHARED_PTR_FOUND FALSE) + check_include_file_cxx(memory HAVE_STD_MEMORY_HEADER) + if (HAVE_STD_MEMORY_HEADER) # Finding the memory header doesn't mean that shared_ptr is in std # namespace. # # In particular, MSVC 2008 has shared_ptr 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 <memory> + include(CheckCXXSourceCompiles) + check_cxx_source_compiles("#include <memory> int main() { std::shared_ptr<int> int_ptr; return 0; }" HAVE_SHARED_PTR_IN_STD_NAMESPACE) - IF (HAVE_SHARED_PTR_IN_STD_NAMESPACE) - MESSAGE("-- Found shared_ptr in std namespace using <memory> header.") - SET(SHARED_PTR_FOUND TRUE) - ELSE (HAVE_SHARED_PTR_IN_STD_NAMESPACE) - CHECK_CXX_SOURCE_COMPILES("#include <memory> + if (HAVE_SHARED_PTR_IN_STD_NAMESPACE) + message("-- Found shared_ptr in std namespace using <memory> header.") + set(SHARED_PTR_FOUND TRUE) + else (HAVE_SHARED_PTR_IN_STD_NAMESPACE) + check_cxx_source_compiles("#include <memory> int main() { std::tr1::shared_ptr<int> int_ptr; return 0; }" HAVE_SHARED_PTR_IN_TR1_NAMESPACE) - IF (HAVE_SHARED_PTR_IN_TR1_NAMESPACE) - MESSAGE("-- Found shared_ptr in std::tr1 namespace using <memory> header.") - SET(SHARED_PTR_TR1_NAMESPACE TRUE) - SET(SHARED_PTR_FOUND TRUE) - ENDIF (HAVE_SHARED_PTR_IN_TR1_NAMESPACE) - ENDIF (HAVE_SHARED_PTR_IN_STD_NAMESPACE) - ENDIF (HAVE_STD_MEMORY_HEADER) + if (HAVE_SHARED_PTR_IN_TR1_NAMESPACE) + message("-- Found shared_ptr in std::tr1 namespace using <memory> header.") + set(SHARED_PTR_TR1_NAMESPACE TRUE) + set(SHARED_PTR_FOUND TRUE) + endif (HAVE_SHARED_PTR_IN_TR1_NAMESPACE) + endif (HAVE_SHARED_PTR_IN_STD_NAMESPACE) + endif (HAVE_STD_MEMORY_HEADER) - IF (NOT SHARED_PTR_FOUND) + if (NOT SHARED_PTR_FOUND) # Further, gcc defines shared_ptr in std::tr1 namespace and # <tr1/memory> is to be included for this. And what makes things # even more tricky is that gcc does have <memory> header, so # all the checks above wouldn't find shared_ptr. - CHECK_INCLUDE_FILE_CXX("tr1/memory" HAVE_TR1_MEMORY_HEADER) - IF (HAVE_TR1_MEMORY_HEADER) - CHECK_CXX_SOURCE_COMPILES("#include <tr1/memory> + check_include_file_cxx("tr1/memory" HAVE_TR1_MEMORY_HEADER) + if (HAVE_TR1_MEMORY_HEADER) + check_cxx_source_compiles("#include <tr1/memory> int main() { std::tr1::shared_ptr<int> int_ptr; return 0; }" HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER) - IF (HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER) - MESSAGE("-- Found shared_ptr in std::tr1 namespace using <tr1/memory> header.") - SET(SHARED_PTR_TR1_MEMORY_HEADER TRUE) - SET(SHARED_PTR_TR1_NAMESPACE TRUE) - SET(SHARED_PTR_FOUND TRUE) - ENDIF (HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER) - ENDIF (HAVE_TR1_MEMORY_HEADER) - ENDIF (NOT SHARED_PTR_FOUND) -ENDMACRO(FIND_SHARED_PTR) + if (HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER) + message("-- Found shared_ptr in std::tr1 namespace using <tr1/memory> header.") + set(SHARED_PTR_TR1_MEMORY_HEADER TRUE) + set(SHARED_PTR_TR1_NAMESPACE TRUE) + set(SHARED_PTR_FOUND TRUE) + endif (HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER) + endif (HAVE_TR1_MEMORY_HEADER) + endif (NOT SHARED_PTR_FOUND) +endmacro(FIND_SHARED_PTR)
diff --git a/cmake/FindSphinx.cmake b/cmake/FindSphinx.cmake index aebf615..220108d 100644 --- a/cmake/FindSphinx.cmake +++ b/cmake/FindSphinx.cmake
@@ -35,7 +35,7 @@ # SPHINX_EXECUTABLE # SPHINX_FOUND -FIND_PROGRAM(SPHINX_EXECUTABLE +find_program(SPHINX_EXECUTABLE NAMES sphinx-build PATHS /usr/bin @@ -43,24 +43,24 @@ /opt/local/bin DOC "Sphinx documentation generator") -IF (NOT SPHINX_EXECUTABLE) - SET(_Python_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) +if (NOT SPHINX_EXECUTABLE) + set(_Python_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) - FOREACH (_version ${_Python_VERSIONS}) - SET(_sphinx_NAMES sphinx-build-${_version}) + foreach (_version ${_Python_VERSIONS}) + set(_sphinx_NAMES sphinx-build-${_version}) - FIND_PROGRAM(SPHINX_EXECUTABLE + find_program(SPHINX_EXECUTABLE NAMES ${_sphinx_NAMES} PATHS /usr/bin /usr/local/bin /opt/local/bin DOC "Sphinx documentation generator") - ENDFOREACH () -ENDIF () + endforeach () +endif () -INCLUDE(FindPackageHandleStandardArgs) +include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE) +find_package_handle_standard_args(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE) -MARK_AS_ADVANCED(SPHINX_EXECUTABLE) +mark_as_advanced(SPHINX_EXECUTABLE)
diff --git a/cmake/FindSuiteSparse.cmake b/cmake/FindSuiteSparse.cmake index 3b5e814..1086a9c 100644 --- a/cmake/FindSuiteSparse.cmake +++ b/cmake/FindSuiteSparse.cmake
@@ -112,60 +112,60 @@ # Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when # FindSuiteSparse was invoked. -MACRO(SUITESPARSE_RESET_FIND_LIBRARY_PREFIX) - IF (MSVC) - SET(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") - ENDIF (MSVC) -ENDMACRO(SUITESPARSE_RESET_FIND_LIBRARY_PREFIX) +macro(SUITESPARSE_RESET_FIND_LIBRARY_PREFIX) + if (MSVC) + set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") + endif (MSVC) +endmacro(SUITESPARSE_RESET_FIND_LIBRARY_PREFIX) # Called if we failed to find SuiteSparse or any of it's required dependencies, # unsets all public (designed to be used externally) variables and reports # error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument. -MACRO(SUITESPARSE_REPORT_NOT_FOUND REASON_MSG) - UNSET(SUITESPARSE_FOUND) - UNSET(SUITESPARSE_INCLUDE_DIRS) - UNSET(SUITESPARSE_LIBRARIES) - UNSET(SUITESPARSE_VERSION) - UNSET(SUITESPARSE_MAIN_VERSION) - UNSET(SUITESPARSE_SUB_VERSION) - UNSET(SUITESPARSE_SUBSUB_VERSION) +macro(SUITESPARSE_REPORT_NOT_FOUND REASON_MSG) + unset(SUITESPARSE_FOUND) + unset(SUITESPARSE_INCLUDE_DIRS) + unset(SUITESPARSE_LIBRARIES) + unset(SUITESPARSE_VERSION) + unset(SUITESPARSE_MAIN_VERSION) + unset(SUITESPARSE_SUB_VERSION) + unset(SUITESPARSE_SUBSUB_VERSION) # Do NOT unset SUITESPARSE_FOUND_REQUIRED_VARS here, as it is used by # FindPackageHandleStandardArgs() to generate the automatic error message on # failure which highlights which components are missing. - SUITESPARSE_RESET_FIND_LIBRARY_PREFIX() + suitesparse_reset_find_library_prefix() # Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage() # use the camelcase library name, not uppercase. - IF (SuiteSparse_FIND_QUIETLY) - MESSAGE(STATUS "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) - ELSEIF (SuiteSparse_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) - ELSE() + if (SuiteSparse_FIND_QUIETLY) + message(STATUS "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) + elseif (SuiteSparse_FIND_REQUIRED) + message(FATAL_ERROR "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) + else() # Neither QUIETLY nor REQUIRED, use no priority which emits a message # but continues configuration and allows generation. - MESSAGE("-- Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) - ENDIF (SuiteSparse_FIND_QUIETLY) + message("-- Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) + endif (SuiteSparse_FIND_QUIETLY) # Do not call RETURN(), s/t we keep processing if not called with REQUIRED. -ENDMACRO(SUITESPARSE_REPORT_NOT_FOUND) +endmacro(SUITESPARSE_REPORT_NOT_FOUND) # Handle possible presence of lib prefix for libraries on MSVC, see # also SUITESPARSE_RESET_FIND_LIBRARY_PREFIX(). -IF (MSVC) +if (MSVC) # Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES # s/t we can set it back before returning. - SET(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") + set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") # The empty string in this list is important, it represents the case when # the libraries have no prefix (shared libraries / DLLs). - SET(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}") -ENDIF (MSVC) + set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}") +endif (MSVC) # Specify search directories for include files and libraries (this is the union # of the search directories for all OSs). Search user-specified hint # directories first if supplied, and search user-installed locations first # so that we prefer user installs to system installs where both exist. -LIST(APPEND SUITESPARSE_CHECK_INCLUDE_DIRS +list(APPEND SUITESPARSE_CHECK_INCLUDE_DIRS ${SUITESPARSE_INCLUDE_DIR_HINTS} /opt/local/include /opt/local/include/ufsparse # Mac OS X @@ -174,7 +174,7 @@ /usr/local/include/suitesparse /usr/include/suitesparse # Ubuntu /usr/include) -LIST(APPEND SUITESPARSE_CHECK_LIBRARY_DIRS +list(APPEND SUITESPARSE_CHECK_LIBRARY_DIRS ${SUITESPARSE_LIBRARY_DIR_HINTS} /opt/local/lib /opt/local/lib/ufsparse # Mac OS X @@ -188,380 +188,380 @@ # automatic failure message generated by FindPackageHandleStandardArgs() # when not all required components are found is helpful, we maintain a list # of all variables that must be defined for SuiteSparse to be considered found. -UNSET(SUITESPARSE_FOUND_REQUIRED_VARS) +unset(SUITESPARSE_FOUND_REQUIRED_VARS) # BLAS. -FIND_PACKAGE(BLAS QUIET) -IF (NOT BLAS_FOUND) - SUITESPARSE_REPORT_NOT_FOUND( +find_package(BLAS QUIET) +if (NOT BLAS_FOUND) + suitesparse_report_not_found( "Did not find BLAS library (required for SuiteSparse).") -ENDIF (NOT BLAS_FOUND) -LIST(APPEND SUITESPARSE_FOUND_REQUIRED_VARS BLAS_FOUND) +endif (NOT BLAS_FOUND) +list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS BLAS_FOUND) # LAPACK. -FIND_PACKAGE(LAPACK QUIET) -IF (NOT LAPACK_FOUND) - SUITESPARSE_REPORT_NOT_FOUND( +find_package(LAPACK QUIET) +if (NOT LAPACK_FOUND) + suitesparse_report_not_found( "Did not find LAPACK library (required for SuiteSparse).") -ENDIF (NOT LAPACK_FOUND) -LIST(APPEND SUITESPARSE_FOUND_REQUIRED_VARS LAPACK_FOUND) +endif (NOT LAPACK_FOUND) +list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS LAPACK_FOUND) # AMD. -SET(AMD_FOUND TRUE) -LIST(APPEND SUITESPARSE_FOUND_REQUIRED_VARS AMD_FOUND) -FIND_LIBRARY(AMD_LIBRARY NAMES amd +set(AMD_FOUND TRUE) +list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS AMD_FOUND) +find_library(AMD_LIBRARY NAMES amd PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}) -IF (EXISTS ${AMD_LIBRARY}) - MESSAGE(STATUS "Found AMD library: ${AMD_LIBRARY}") -ELSE (EXISTS ${AMD_LIBRARY}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${AMD_LIBRARY}) + message(STATUS "Found AMD library: ${AMD_LIBRARY}") +else (EXISTS ${AMD_LIBRARY}) + suitesparse_report_not_found( "Did not find AMD library (required SuiteSparse component).") - SET(AMD_FOUND FALSE) -ENDIF (EXISTS ${AMD_LIBRARY}) -MARK_AS_ADVANCED(AMD_LIBRARY) + set(AMD_FOUND FALSE) +endif (EXISTS ${AMD_LIBRARY}) +mark_as_advanced(AMD_LIBRARY) -FIND_PATH(AMD_INCLUDE_DIR NAMES amd.h +find_path(AMD_INCLUDE_DIR NAMES amd.h PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}) -IF (EXISTS ${AMD_INCLUDE_DIR}) - MESSAGE(STATUS "Found AMD header in: ${AMD_INCLUDE_DIR}") -ELSE (EXISTS ${AMD_INCLUDE_DIR}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${AMD_INCLUDE_DIR}) + message(STATUS "Found AMD header in: ${AMD_INCLUDE_DIR}") +else (EXISTS ${AMD_INCLUDE_DIR}) + suitesparse_report_not_found( "Did not find AMD header (required SuiteSparse component).") - SET(AMD_FOUND FALSE) -ENDIF (EXISTS ${AMD_INCLUDE_DIR}) -MARK_AS_ADVANCED(AMD_INCLUDE_DIR) + set(AMD_FOUND FALSE) +endif (EXISTS ${AMD_INCLUDE_DIR}) +mark_as_advanced(AMD_INCLUDE_DIR) # CAMD. -SET(CAMD_FOUND TRUE) -LIST(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CAMD_FOUND) -FIND_LIBRARY(CAMD_LIBRARY NAMES camd +set(CAMD_FOUND TRUE) +list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CAMD_FOUND) +find_library(CAMD_LIBRARY NAMES camd PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}) -IF (EXISTS ${CAMD_LIBRARY}) - MESSAGE(STATUS "Found CAMD library: ${CAMD_LIBRARY}") -ELSE (EXISTS ${CAMD_LIBRARY}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${CAMD_LIBRARY}) + message(STATUS "Found CAMD library: ${CAMD_LIBRARY}") +else (EXISTS ${CAMD_LIBRARY}) + suitesparse_report_not_found( "Did not find CAMD library (required SuiteSparse component).") - SET(CAMD_FOUND FALSE) -ENDIF (EXISTS ${CAMD_LIBRARY}) -MARK_AS_ADVANCED(CAMD_LIBRARY) + set(CAMD_FOUND FALSE) +endif (EXISTS ${CAMD_LIBRARY}) +mark_as_advanced(CAMD_LIBRARY) -FIND_PATH(CAMD_INCLUDE_DIR NAMES camd.h +find_path(CAMD_INCLUDE_DIR NAMES camd.h PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}) -IF (EXISTS ${CAMD_INCLUDE_DIR}) - MESSAGE(STATUS "Found CAMD header in: ${CAMD_INCLUDE_DIR}") -ELSE (EXISTS ${CAMD_INCLUDE_DIR}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${CAMD_INCLUDE_DIR}) + message(STATUS "Found CAMD header in: ${CAMD_INCLUDE_DIR}") +else (EXISTS ${CAMD_INCLUDE_DIR}) + suitesparse_report_not_found( "Did not find CAMD header (required SuiteSparse component).") - SET(CAMD_FOUND FALSE) -ENDIF (EXISTS ${CAMD_INCLUDE_DIR}) -MARK_AS_ADVANCED(CAMD_INCLUDE_DIR) + set(CAMD_FOUND FALSE) +endif (EXISTS ${CAMD_INCLUDE_DIR}) +mark_as_advanced(CAMD_INCLUDE_DIR) # COLAMD. -SET(COLAMD_FOUND TRUE) -LIST(APPEND SUITESPARSE_FOUND_REQUIRED_VARS COLAMD_FOUND) -FIND_LIBRARY(COLAMD_LIBRARY NAMES colamd +set(COLAMD_FOUND TRUE) +list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS COLAMD_FOUND) +find_library(COLAMD_LIBRARY NAMES colamd PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}) -IF (EXISTS ${COLAMD_LIBRARY}) - MESSAGE(STATUS "Found COLAMD library: ${COLAMD_LIBRARY}") -ELSE (EXISTS ${COLAMD_LIBRARY}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${COLAMD_LIBRARY}) + message(STATUS "Found COLAMD library: ${COLAMD_LIBRARY}") +else (EXISTS ${COLAMD_LIBRARY}) + suitesparse_report_not_found( "Did not find COLAMD library (required SuiteSparse component).") - SET(COLAMD_FOUND FALSE) -ENDIF (EXISTS ${COLAMD_LIBRARY}) -MARK_AS_ADVANCED(COLAMD_LIBRARY) + set(COLAMD_FOUND FALSE) +endif (EXISTS ${COLAMD_LIBRARY}) +mark_as_advanced(COLAMD_LIBRARY) -FIND_PATH(COLAMD_INCLUDE_DIR NAMES colamd.h +find_path(COLAMD_INCLUDE_DIR NAMES colamd.h PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}) -IF (EXISTS ${COLAMD_INCLUDE_DIR}) - MESSAGE(STATUS "Found COLAMD header in: ${COLAMD_INCLUDE_DIR}") -ELSE (EXISTS ${COLAMD_INCLUDE_DIR}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${COLAMD_INCLUDE_DIR}) + message(STATUS "Found COLAMD header in: ${COLAMD_INCLUDE_DIR}") +else (EXISTS ${COLAMD_INCLUDE_DIR}) + suitesparse_report_not_found( "Did not find COLAMD header (required SuiteSparse component).") - SET(COLAMD_FOUND FALSE) -ENDIF (EXISTS ${COLAMD_INCLUDE_DIR}) -MARK_AS_ADVANCED(COLAMD_INCLUDE_DIR) + set(COLAMD_FOUND FALSE) +endif (EXISTS ${COLAMD_INCLUDE_DIR}) +mark_as_advanced(COLAMD_INCLUDE_DIR) # CCOLAMD. -SET(CCOLAMD_FOUND TRUE) -LIST(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CCOLAMD_FOUND) -FIND_LIBRARY(CCOLAMD_LIBRARY NAMES ccolamd +set(CCOLAMD_FOUND TRUE) +list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CCOLAMD_FOUND) +find_library(CCOLAMD_LIBRARY NAMES ccolamd PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}) -IF (EXISTS ${CCOLAMD_LIBRARY}) - MESSAGE(STATUS "Found CCOLAMD library: ${CCOLAMD_LIBRARY}") -ELSE (EXISTS ${CCOLAMD_LIBRARY}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${CCOLAMD_LIBRARY}) + message(STATUS "Found CCOLAMD library: ${CCOLAMD_LIBRARY}") +else (EXISTS ${CCOLAMD_LIBRARY}) + suitesparse_report_not_found( "Did not find CCOLAMD library (required SuiteSparse component).") - SET(CCOLAMD_FOUND FALSE) -ENDIF (EXISTS ${CCOLAMD_LIBRARY}) -MARK_AS_ADVANCED(CCOLAMD_LIBRARY) + set(CCOLAMD_FOUND FALSE) +endif (EXISTS ${CCOLAMD_LIBRARY}) +mark_as_advanced(CCOLAMD_LIBRARY) -FIND_PATH(CCOLAMD_INCLUDE_DIR NAMES ccolamd.h +find_path(CCOLAMD_INCLUDE_DIR NAMES ccolamd.h PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}) -IF (EXISTS ${CCOLAMD_INCLUDE_DIR}) - MESSAGE(STATUS "Found CCOLAMD header in: ${CCOLAMD_INCLUDE_DIR}") -ELSE (EXISTS ${CCOLAMD_INCLUDE_DIR}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${CCOLAMD_INCLUDE_DIR}) + message(STATUS "Found CCOLAMD header in: ${CCOLAMD_INCLUDE_DIR}") +else (EXISTS ${CCOLAMD_INCLUDE_DIR}) + suitesparse_report_not_found( "Did not find CCOLAMD header (required SuiteSparse component).") - SET(CCOLAMD_FOUND FALSE) -ENDIF (EXISTS ${CCOLAMD_INCLUDE_DIR}) -MARK_AS_ADVANCED(CCOLAMD_INCLUDE_DIR) + set(CCOLAMD_FOUND FALSE) +endif (EXISTS ${CCOLAMD_INCLUDE_DIR}) +mark_as_advanced(CCOLAMD_INCLUDE_DIR) # CHOLMOD. -SET(CHOLMOD_FOUND TRUE) -LIST(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CHOLMOD_FOUND) -FIND_LIBRARY(CHOLMOD_LIBRARY NAMES cholmod +set(CHOLMOD_FOUND TRUE) +list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CHOLMOD_FOUND) +find_library(CHOLMOD_LIBRARY NAMES cholmod PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}) -IF (EXISTS ${CHOLMOD_LIBRARY}) - MESSAGE(STATUS "Found CHOLMOD library: ${CHOLMOD_LIBRARY}") -ELSE (EXISTS ${CHOLMOD_LIBRARY}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${CHOLMOD_LIBRARY}) + message(STATUS "Found CHOLMOD library: ${CHOLMOD_LIBRARY}") +else (EXISTS ${CHOLMOD_LIBRARY}) + suitesparse_report_not_found( "Did not find CHOLMOD library (required SuiteSparse component).") - SET(CHOLMOD_FOUND FALSE) -ENDIF (EXISTS ${CHOLMOD_LIBRARY}) -MARK_AS_ADVANCED(CHOLMOD_LIBRARY) + set(CHOLMOD_FOUND FALSE) +endif (EXISTS ${CHOLMOD_LIBRARY}) +mark_as_advanced(CHOLMOD_LIBRARY) -FIND_PATH(CHOLMOD_INCLUDE_DIR NAMES cholmod.h +find_path(CHOLMOD_INCLUDE_DIR NAMES cholmod.h PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}) -IF (EXISTS ${CHOLMOD_INCLUDE_DIR}) - MESSAGE(STATUS "Found CHOLMOD header in: ${CHOLMOD_INCLUDE_DIR}") -ELSE (EXISTS ${CHOLMOD_INCLUDE_DIR}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${CHOLMOD_INCLUDE_DIR}) + message(STATUS "Found CHOLMOD header in: ${CHOLMOD_INCLUDE_DIR}") +else (EXISTS ${CHOLMOD_INCLUDE_DIR}) + suitesparse_report_not_found( "Did not find CHOLMOD header (required SuiteSparse component).") - SET(CHOLMOD_FOUND FALSE) -ENDIF (EXISTS ${CHOLMOD_INCLUDE_DIR}) -MARK_AS_ADVANCED(CHOLMOD_INCLUDE_DIR) + set(CHOLMOD_FOUND FALSE) +endif (EXISTS ${CHOLMOD_INCLUDE_DIR}) +mark_as_advanced(CHOLMOD_INCLUDE_DIR) # SuiteSparseQR. -SET(SUITESPARSEQR_FOUND TRUE) -LIST(APPEND SUITESPARSE_FOUND_REQUIRED_VARS SUITESPARSEQR_FOUND) -FIND_LIBRARY(SUITESPARSEQR_LIBRARY NAMES spqr +set(SUITESPARSEQR_FOUND TRUE) +list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS SUITESPARSEQR_FOUND) +find_library(SUITESPARSEQR_LIBRARY NAMES spqr PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}) -IF (EXISTS ${SUITESPARSEQR_LIBRARY}) - MESSAGE(STATUS "Found SuiteSparseQR library: ${SUITESPARSEQR_LIBRARY}") -ELSE (EXISTS ${SUITESPARSEQR_LIBRARY}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${SUITESPARSEQR_LIBRARY}) + message(STATUS "Found SuiteSparseQR library: ${SUITESPARSEQR_LIBRARY}") +else (EXISTS ${SUITESPARSEQR_LIBRARY}) + suitesparse_report_not_found( "Did not find SuiteSparseQR library (required SuiteSparse component).") - SET(SUITESPARSEQR_FOUND FALSE) -ENDIF (EXISTS ${SUITESPARSEQR_LIBRARY}) -MARK_AS_ADVANCED(SUITESPARSEQR_LIBRARY) + set(SUITESPARSEQR_FOUND FALSE) +endif (EXISTS ${SUITESPARSEQR_LIBRARY}) +mark_as_advanced(SUITESPARSEQR_LIBRARY) -FIND_PATH(SUITESPARSEQR_INCLUDE_DIR NAMES SuiteSparseQR.hpp +find_path(SUITESPARSEQR_INCLUDE_DIR NAMES SuiteSparseQR.hpp PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}) -IF (EXISTS ${SUITESPARSEQR_INCLUDE_DIR}) - MESSAGE(STATUS "Found SuiteSparseQR header in: ${SUITESPARSEQR_INCLUDE_DIR}") -ELSE (EXISTS ${SUITESPARSEQR_INCLUDE_DIR}) - SUITESPARSE_REPORT_NOT_FOUND( +if (EXISTS ${SUITESPARSEQR_INCLUDE_DIR}) + message(STATUS "Found SuiteSparseQR header in: ${SUITESPARSEQR_INCLUDE_DIR}") +else (EXISTS ${SUITESPARSEQR_INCLUDE_DIR}) + suitesparse_report_not_found( "Did not find SUITESPARSEQR header (required SuiteSparse component).") - SET(SUITESPARSEQR_FOUND FALSE) -ENDIF (EXISTS ${SUITESPARSEQR_INCLUDE_DIR}) -MARK_AS_ADVANCED(SUITESPARSEQR_INCLUDE_DIR) + set(SUITESPARSEQR_FOUND FALSE) +endif (EXISTS ${SUITESPARSEQR_INCLUDE_DIR}) +mark_as_advanced(SUITESPARSEQR_INCLUDE_DIR) -IF (SUITESPARSEQR_FOUND) +if (SUITESPARSEQR_FOUND) # SuiteSparseQR may be compiled with Intel Threading Building Blocks, # we assume that if TBB is installed, SuiteSparseQR was compiled with # support for it, this will do no harm if it wasn't. - SET(TBB_FOUND TRUE) - FIND_LIBRARY(TBB_LIBRARIES NAMES tbb + set(TBB_FOUND TRUE) + find_library(TBB_LIBRARIES NAMES tbb PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}) - IF (EXISTS ${TBB_LIBRARIES}) - MESSAGE(STATUS "Found Intel Thread Building Blocks (TBB) library: " + if (EXISTS ${TBB_LIBRARIES}) + message(STATUS "Found Intel Thread Building Blocks (TBB) library: " "${TBB_LIBRARIES}, assuming SuiteSparseQR was compiled with TBB.") - ELSE (EXISTS ${TBB_LIBRARIES}) - MESSAGE(STATUS "Did not find Intel TBB library, assuming SuiteSparseQR was " + else (EXISTS ${TBB_LIBRARIES}) + message(STATUS "Did not find Intel TBB library, assuming SuiteSparseQR was " "not compiled with TBB.") - SET(TBB_FOUND FALSE) - ENDIF (EXISTS ${TBB_LIBRARIES}) - MARK_AS_ADVANCED(TBB_LIBRARIES) + set(TBB_FOUND FALSE) + endif (EXISTS ${TBB_LIBRARIES}) + mark_as_advanced(TBB_LIBRARIES) - IF (TBB_FOUND) - FIND_LIBRARY(TBB_MALLOC_LIB NAMES tbbmalloc + if (TBB_FOUND) + find_library(TBB_MALLOC_LIB NAMES tbbmalloc PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}) - IF (EXISTS ${TBB_MALLOC_LIB}) - MESSAGE(STATUS "Found Intel Thread Building Blocks (TBB) Malloc library: " + if (EXISTS ${TBB_MALLOC_LIB}) + message(STATUS "Found Intel Thread Building Blocks (TBB) Malloc library: " "${TBB_MALLOC_LIB}") # Append TBB malloc library to TBB libraries list whilst retaining # any CMake generated help string (cache variable). - LIST(APPEND TBB_LIBRARIES ${TBB_MALLOC_LIB}) - GET_PROPERTY(HELP_STRING CACHE TBB_LIBRARIES PROPERTY HELPSTRING) - SET(TBB_LIBRARIES "${TBB_LIBRARIES}" CACHE STRING "${HELP_STRING}") + list(APPEND TBB_LIBRARIES ${TBB_MALLOC_LIB}) + get_property(HELP_STRING CACHE TBB_LIBRARIES PROPERTY HELPSTRING) + set(TBB_LIBRARIES "${TBB_LIBRARIES}" CACHE STRING "${HELP_STRING}") # Add the TBB libraries to the SuiteSparseQR libraries (the only # libraries to optionally depend on TBB). - LIST(APPEND SUITESPARSEQR_LIBRARY ${TBB_LIBRARIES}) + list(APPEND SUITESPARSEQR_LIBRARY ${TBB_LIBRARIES}) - ELSE (EXISTS ${TBB_MALLOC_LIB}) + else (EXISTS ${TBB_MALLOC_LIB}) # If we cannot find all required TBB components do not include it as # a dependency. - MESSAGE(STATUS "Did not find Intel Thread Building Blocks (TBB) Malloc " + message(STATUS "Did not find Intel Thread Building Blocks (TBB) Malloc " "Library, discarding TBB as a dependency.") - SET(TBB_FOUND FALSE) - ENDIF (EXISTS ${TBB_MALLOC_LIB}) - MARK_AS_ADVANCED(TBB_MALLOC_LIB) - ENDIF (TBB_FOUND) -ENDIF(SUITESPARSEQR_FOUND) + set(TBB_FOUND FALSE) + endif (EXISTS ${TBB_MALLOC_LIB}) + mark_as_advanced(TBB_MALLOC_LIB) + endif (TBB_FOUND) +endif(SUITESPARSEQR_FOUND) # UFconfig / SuiteSparse_config. # # If SuiteSparse version is >= 4 then SuiteSparse_config is required. # For SuiteSparse 3, UFconfig.h is required. -FIND_LIBRARY(SUITESPARSE_CONFIG_LIBRARY NAMES suitesparseconfig +find_library(SUITESPARSE_CONFIG_LIBRARY NAMES suitesparseconfig PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}) -IF (EXISTS ${SUITESPARSE_CONFIG_LIBRARY}) - MESSAGE(STATUS "Found SuiteSparse_config library: " +if (EXISTS ${SUITESPARSE_CONFIG_LIBRARY}) + message(STATUS "Found SuiteSparse_config library: " "${SUITESPARSE_CONFIG_LIBRARY}") -ENDIF (EXISTS ${SUITESPARSE_CONFIG_LIBRARY}) -MARK_AS_ADVANCED(SUITESPARSE_CONFIG_LIBRARY) +endif (EXISTS ${SUITESPARSE_CONFIG_LIBRARY}) +mark_as_advanced(SUITESPARSE_CONFIG_LIBRARY) -FIND_PATH(SUITESPARSE_CONFIG_INCLUDE_DIR NAMES SuiteSparse_config.h +find_path(SUITESPARSE_CONFIG_INCLUDE_DIR NAMES SuiteSparse_config.h PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}) -IF (EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR}) - MESSAGE(STATUS "Found SuiteSparse_config header in: " +if (EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR}) + message(STATUS "Found SuiteSparse_config header in: " "${SUITESPARSE_CONFIG_INCLUDE_DIR}") -ENDIF (EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR}) -MARK_AS_ADVANCED(SUITESPARSE_CONFIG_INCLUDE_DIR) +endif (EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR}) +mark_as_advanced(SUITESPARSE_CONFIG_INCLUDE_DIR) -SET(SUITESPARSE_CONFIG_FOUND FALSE) -SET(UFCONFIG_FOUND FALSE) +set(SUITESPARSE_CONFIG_FOUND FALSE) +set(UFCONFIG_FOUND FALSE) -IF (EXISTS ${SUITESPARSE_CONFIG_LIBRARY} AND +if (EXISTS ${SUITESPARSE_CONFIG_LIBRARY} AND EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR}) - SET(SUITESPARSE_CONFIG_FOUND TRUE) + set(SUITESPARSE_CONFIG_FOUND TRUE) # SuiteSparse_config (SuiteSparse version >= 4) requires librt library for # timing by default when compiled on Linux or Unix, but not on OSX (which # does not have librt). - IF (CMAKE_SYSTEM_NAME MATCHES "Linux" OR UNIX AND NOT APPLE) - FIND_LIBRARY(LIBRT_LIBRARY NAMES rt + if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR UNIX AND NOT APPLE) + find_library(LIBRT_LIBRARY NAMES rt PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}) - IF (LIBRT_LIBRARY) - MESSAGE(STATUS "Adding librt: ${LIBRT_LIBRARY} to " + if (LIBRT_LIBRARY) + message(STATUS "Adding librt: ${LIBRT_LIBRARY} to " "SuiteSparse_config libraries (required on Linux & Unix [not OSX] if " "SuiteSparse is compiled with timing).") - ELSE (LIBRT_LIBRARY) - MESSAGE(STATUS "Could not find librt, but found SuiteSparse_config, " + else (LIBRT_LIBRARY) + message(STATUS "Could not find librt, but found SuiteSparse_config, " "assuming that SuiteSparse was compiled without timing.") - ENDIF (LIBRT_LIBRARY) - MARK_AS_ADVANCED(LIBRT_LIBRARY) - LIST(APPEND SUITESPARSE_CONFIG_LIBRARY ${LIBRT_LIBRARY}) - ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux" OR UNIX AND NOT APPLE) + endif (LIBRT_LIBRARY) + mark_as_advanced(LIBRT_LIBRARY) + list(APPEND SUITESPARSE_CONFIG_LIBRARY ${LIBRT_LIBRARY}) + endif (CMAKE_SYSTEM_NAME MATCHES "Linux" OR UNIX AND NOT APPLE) -ELSE (EXISTS ${SUITESPARSE_CONFIG_LIBRARY} AND +else (EXISTS ${SUITESPARSE_CONFIG_LIBRARY} AND EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR}) # Failed to find SuiteSparse_config (>= v4 installs), instead look for # UFconfig header which should be present in < v4 installs. - SET(SUITESPARSE_CONFIG_FOUND FALSE) - FIND_PATH(UFCONFIG_INCLUDE_DIR NAMES UFconfig.h + set(SUITESPARSE_CONFIG_FOUND FALSE) + find_path(UFCONFIG_INCLUDE_DIR NAMES UFconfig.h PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}) - IF (EXISTS ${UFCONFIG_INCLUDE_DIR}) - MESSAGE(STATUS "Found UFconfig header in: ${UFCONFIG_INCLUDE_DIR}") - SET(UFCONFIG_FOUND TRUE) - ENDIF (EXISTS ${UFCONFIG_INCLUDE_DIR}) - MARK_AS_ADVANCED(UFCONFIG_INCLUDE_DIR) -ENDIF (EXISTS ${SUITESPARSE_CONFIG_LIBRARY} AND + if (EXISTS ${UFCONFIG_INCLUDE_DIR}) + message(STATUS "Found UFconfig header in: ${UFCONFIG_INCLUDE_DIR}") + set(UFCONFIG_FOUND TRUE) + endif (EXISTS ${UFCONFIG_INCLUDE_DIR}) + mark_as_advanced(UFCONFIG_INCLUDE_DIR) +endif (EXISTS ${SUITESPARSE_CONFIG_LIBRARY} AND EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR}) -IF (NOT SUITESPARSE_CONFIG_FOUND AND +if (NOT SUITESPARSE_CONFIG_FOUND AND NOT UFCONFIG_FOUND) - SUITESPARSE_REPORT_NOT_FOUND( + suitesparse_report_not_found( "Failed to find either: SuiteSparse_config header & library (should be " "present in all SuiteSparse >= v4 installs), or UFconfig header (should " "be present in all SuiteSparse < v4 installs).") -ENDIF (NOT SUITESPARSE_CONFIG_FOUND AND +endif (NOT SUITESPARSE_CONFIG_FOUND AND NOT UFCONFIG_FOUND) # Extract the SuiteSparse version from the appropriate header (UFconfig.h for # <= v3, SuiteSparse_config.h for >= v4). -LIST(APPEND SUITESPARSE_FOUND_REQUIRED_VARS SUITESPARSE_VERSION) +list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS SUITESPARSE_VERSION) -IF (UFCONFIG_FOUND) +if (UFCONFIG_FOUND) # SuiteSparse version <= 3. - SET(SUITESPARSE_VERSION_FILE ${UFCONFIG_INCLUDE_DIR}/UFconfig.h) - IF (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) - SUITESPARSE_REPORT_NOT_FOUND( + set(SUITESPARSE_VERSION_FILE ${UFCONFIG_INCLUDE_DIR}/UFconfig.h) + if (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) + suitesparse_report_not_found( "Could not find file: ${SUITESPARSE_VERSION_FILE} containing version " "information for <= v3 SuiteSparse installs, but UFconfig was found " "(only present in <= v3 installs).") - ELSE (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) - FILE(READ ${SUITESPARSE_VERSION_FILE} UFCONFIG_CONTENTS) + else (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) + file(READ ${SUITESPARSE_VERSION_FILE} UFCONFIG_CONTENTS) - STRING(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION [0-9]+" + string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION [0-9]+" SUITESPARSE_MAIN_VERSION "${UFCONFIG_CONTENTS}") - STRING(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION ([0-9]+)" "\\1" + string(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION ([0-9]+)" "\\1" SUITESPARSE_MAIN_VERSION "${SUITESPARSE_MAIN_VERSION}") - STRING(REGEX MATCH "#define SUITESPARSE_SUB_VERSION [0-9]+" + string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION [0-9]+" SUITESPARSE_SUB_VERSION "${UFCONFIG_CONTENTS}") - STRING(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION ([0-9]+)" "\\1" + string(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION ([0-9]+)" "\\1" SUITESPARSE_SUB_VERSION "${SUITESPARSE_SUB_VERSION}") - STRING(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION [0-9]+" + string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION [0-9]+" SUITESPARSE_SUBSUB_VERSION "${UFCONFIG_CONTENTS}") - STRING(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION ([0-9]+)" "\\1" + string(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION ([0-9]+)" "\\1" SUITESPARSE_SUBSUB_VERSION "${SUITESPARSE_SUBSUB_VERSION}") # This is on a single line s/t CMake does not interpret it as a list of # elements and insert ';' separators which would result in 4.;2.;1 nonsense. - SET(SUITESPARSE_VERSION + set(SUITESPARSE_VERSION "${SUITESPARSE_MAIN_VERSION}.${SUITESPARSE_SUB_VERSION}.${SUITESPARSE_SUBSUB_VERSION}") - ENDIF (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) -ENDIF (UFCONFIG_FOUND) + endif (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) +endif (UFCONFIG_FOUND) -IF (SUITESPARSE_CONFIG_FOUND) +if (SUITESPARSE_CONFIG_FOUND) # SuiteSparse version >= 4. - SET(SUITESPARSE_VERSION_FILE + set(SUITESPARSE_VERSION_FILE ${SUITESPARSE_CONFIG_INCLUDE_DIR}/SuiteSparse_config.h) - IF (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) - SUITESPARSE_REPORT_NOT_FOUND( + if (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) + suitesparse_report_not_found( "Could not find file: ${SUITESPARSE_VERSION_FILE} containing version " "information for >= v4 SuiteSparse installs, but SuiteSparse_config was " "found (only present in >= v4 installs).") - ELSE (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) - FILE(READ ${SUITESPARSE_VERSION_FILE} SUITESPARSE_CONFIG_CONTENTS) + else (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) + file(READ ${SUITESPARSE_VERSION_FILE} SUITESPARSE_CONFIG_CONTENTS) - STRING(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION [0-9]+" + string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION [0-9]+" SUITESPARSE_MAIN_VERSION "${SUITESPARSE_CONFIG_CONTENTS}") - STRING(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION ([0-9]+)" "\\1" + string(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION ([0-9]+)" "\\1" SUITESPARSE_MAIN_VERSION "${SUITESPARSE_MAIN_VERSION}") - STRING(REGEX MATCH "#define SUITESPARSE_SUB_VERSION [0-9]+" + string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION [0-9]+" SUITESPARSE_SUB_VERSION "${SUITESPARSE_CONFIG_CONTENTS}") - STRING(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION ([0-9]+)" "\\1" + string(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION ([0-9]+)" "\\1" SUITESPARSE_SUB_VERSION "${SUITESPARSE_SUB_VERSION}") - STRING(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION [0-9]+" + string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION [0-9]+" SUITESPARSE_SUBSUB_VERSION "${SUITESPARSE_CONFIG_CONTENTS}") - STRING(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION ([0-9]+)" "\\1" + string(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION ([0-9]+)" "\\1" SUITESPARSE_SUBSUB_VERSION "${SUITESPARSE_SUBSUB_VERSION}") # This is on a single line s/t CMake does not interpret it as a list of # elements and insert ';' separators which would result in 4.;2.;1 nonsense. - SET(SUITESPARSE_VERSION + set(SUITESPARSE_VERSION "${SUITESPARSE_MAIN_VERSION}.${SUITESPARSE_SUB_VERSION}.${SUITESPARSE_SUBSUB_VERSION}") - ENDIF (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) -ENDIF (SUITESPARSE_CONFIG_FOUND) + endif (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) +endif (SUITESPARSE_CONFIG_FOUND) # METIS (Optional dependency). -FIND_LIBRARY(METIS_LIBRARY NAMES metis +find_library(METIS_LIBRARY NAMES metis PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}) -IF (EXISTS ${METIS_LIBRARY}) - MESSAGE(STATUS "Found METIS library: ${METIS_LIBRARY}.") +if (EXISTS ${METIS_LIBRARY}) + message(STATUS "Found METIS library: ${METIS_LIBRARY}.") set(METIS_FOUND TRUE) -ELSE (EXISTS ${METIS_LIBRARY}) - MESSAGE(STATUS "Did not find METIS library (optional SuiteSparse dependency)") +else (EXISTS ${METIS_LIBRARY}) + message(STATUS "Did not find METIS library (optional SuiteSparse dependency)") set(METIS_FOUND FALSE) -ENDIF (EXISTS ${METIS_LIBRARY}) -MARK_AS_ADVANCED(METIS_LIBRARY) +endif (EXISTS ${METIS_LIBRARY}) +mark_as_advanced(METIS_LIBRARY) # Only mark SuiteSparse as found if all required components and dependencies # have been found. -SET(SUITESPARSE_FOUND TRUE) -FOREACH(REQUIRED_VAR ${SUITESPARSE_FOUND_REQUIRED_VARS}) - IF (NOT ${REQUIRED_VAR}) - SET(SUITESPARSE_FOUND FALSE) - ENDIF (NOT ${REQUIRED_VAR}) -ENDFOREACH(REQUIRED_VAR ${SUITESPARSE_FOUND_REQUIRED_VARS}) +set(SUITESPARSE_FOUND TRUE) +foreach(REQUIRED_VAR ${SUITESPARSE_FOUND_REQUIRED_VARS}) + if (NOT ${REQUIRED_VAR}) + set(SUITESPARSE_FOUND FALSE) + endif (NOT ${REQUIRED_VAR}) +endforeach(REQUIRED_VAR ${SUITESPARSE_FOUND_REQUIRED_VARS}) -IF (SUITESPARSE_FOUND) - LIST(APPEND SUITESPARSE_INCLUDE_DIRS +if (SUITESPARSE_FOUND) + list(APPEND SUITESPARSE_INCLUDE_DIRS ${AMD_INCLUDE_DIR} ${CAMD_INCLUDE_DIR} ${COLAMD_INCLUDE_DIR} @@ -570,21 +570,21 @@ ${SUITESPARSEQR_INCLUDE_DIR}) # Handle config separately, as otherwise at least one of them will be set # to NOTFOUND which would cause any check on SUITESPARSE_INCLUDE_DIRS to fail. - IF (SUITESPARSE_CONFIG_FOUND) - LIST(APPEND SUITESPARSE_INCLUDE_DIRS + if (SUITESPARSE_CONFIG_FOUND) + list(APPEND SUITESPARSE_INCLUDE_DIRS ${SUITESPARSE_CONFIG_INCLUDE_DIR}) - ENDIF (SUITESPARSE_CONFIG_FOUND) - IF (UFCONFIG_FOUND) - LIST(APPEND SUITESPARSE_INCLUDE_DIRS + endif (SUITESPARSE_CONFIG_FOUND) + if (UFCONFIG_FOUND) + list(APPEND SUITESPARSE_INCLUDE_DIRS ${UFCONFIG_INCLUDE_DIR}) - ENDIF (UFCONFIG_FOUND) + endif (UFCONFIG_FOUND) # As SuiteSparse includes are often all in the same directory, remove any # repetitions. - LIST(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIRS) + list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIRS) # Important: The ordering of these libraries is *NOT* arbitrary, as these # could potentially be static libraries their link ordering is important. - LIST(APPEND SUITESPARSE_LIBRARIES + list(APPEND SUITESPARSE_LIBRARIES ${SUITESPARSEQR_LIBRARY} ${CHOLMOD_LIBRARY} ${CCOLAMD_LIBRARY} @@ -593,59 +593,59 @@ ${AMD_LIBRARY} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) - IF (SUITESPARSE_CONFIG_FOUND) - LIST(APPEND SUITESPARSE_LIBRARIES + if (SUITESPARSE_CONFIG_FOUND) + list(APPEND SUITESPARSE_LIBRARIES ${SUITESPARSE_CONFIG_LIBRARY}) - ENDIF (SUITESPARSE_CONFIG_FOUND) - IF (METIS_FOUND) - LIST(APPEND SUITESPARSE_LIBRARIES + endif (SUITESPARSE_CONFIG_FOUND) + if (METIS_FOUND) + list(APPEND SUITESPARSE_LIBRARIES ${METIS_LIBRARY}) - ENDIF (METIS_FOUND) -ENDIF() + endif (METIS_FOUND) +endif() # Determine if we are running on Ubuntu with the package install of SuiteSparse # which is broken and does not support linking a shared library. -SET(SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION FALSE) -IF (CMAKE_SYSTEM_NAME MATCHES "Linux" AND +set(SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION FALSE) +if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND SUITESPARSE_VERSION VERSION_EQUAL 3.4.0) - FIND_PROGRAM(LSB_RELEASE_EXECUTABLE lsb_release) - IF (LSB_RELEASE_EXECUTABLE) + find_program(LSB_RELEASE_EXECUTABLE lsb_release) + if (LSB_RELEASE_EXECUTABLE) # Any even moderately recent Ubuntu release (likely to be affected by # this bug) should have lsb_release, if it isn't present we are likely # on a different Linux distribution (should be fine). - EXECUTE_PROCESS(COMMAND ${LSB_RELEASE_EXECUTABLE} -si + execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -si OUTPUT_VARIABLE LSB_DISTRIBUTOR_ID OUTPUT_STRIP_TRAILING_WHITESPACE) - IF (LSB_DISTRIBUTOR_ID MATCHES "Ubuntu" AND + if (LSB_DISTRIBUTOR_ID MATCHES "Ubuntu" AND SUITESPARSE_LIBRARIES MATCHES "/usr/lib/libamd") # We are on Ubuntu, and the SuiteSparse version matches the broken # system install version and is a system install. - SET(SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION TRUE) - MESSAGE(STATUS "Found system install of SuiteSparse " + set(SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION TRUE) + message(STATUS "Found system install of SuiteSparse " "${SUITESPARSE_VERSION} running on Ubuntu, which has a known bug " "preventing linking of shared libraries (static linking unaffected).") - ENDIF (LSB_DISTRIBUTOR_ID MATCHES "Ubuntu" AND + endif (LSB_DISTRIBUTOR_ID MATCHES "Ubuntu" AND SUITESPARSE_LIBRARIES MATCHES "/usr/lib/libamd") - ENDIF (LSB_RELEASE_EXECUTABLE) -ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux" AND + endif (LSB_RELEASE_EXECUTABLE) +endif (CMAKE_SYSTEM_NAME MATCHES "Linux" AND SUITESPARSE_VERSION VERSION_EQUAL 3.4.0) -SUITESPARSE_RESET_FIND_LIBRARY_PREFIX() +suitesparse_reset_find_library_prefix() # Handle REQUIRED and QUIET arguments to FIND_PACKAGE -INCLUDE(FindPackageHandleStandardArgs) -IF (SUITESPARSE_FOUND) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(SuiteSparse +include(FindPackageHandleStandardArgs) +if (SUITESPARSE_FOUND) + find_package_handle_standard_args(SuiteSparse REQUIRED_VARS ${SUITESPARSE_FOUND_REQUIRED_VARS} VERSION_VAR SUITESPARSE_VERSION FAIL_MESSAGE "Failed to find some/all required components of SuiteSparse.") -ELSE (SUITESPARSE_FOUND) +else (SUITESPARSE_FOUND) # Do not pass VERSION_VAR to FindPackageHandleStandardArgs() if we failed to # find SuiteSparse to avoid a confusing autogenerated failure message # that states 'not found (missing: FOO) (found version: x.y.z)'. - FIND_PACKAGE_HANDLE_STANDARD_ARGS(SuiteSparse + find_package_handle_standard_args(SuiteSparse REQUIRED_VARS ${SUITESPARSE_FOUND_REQUIRED_VARS} FAIL_MESSAGE "Failed to find some/all required components of SuiteSparse.") -ENDIF (SUITESPARSE_FOUND) +endif (SUITESPARSE_FOUND)
diff --git a/cmake/FindUnorderedMap.cmake b/cmake/FindUnorderedMap.cmake index 6aec18a..6ba07fd 100644 --- a/cmake/FindUnorderedMap.cmake +++ b/cmake/FindUnorderedMap.cmake
@@ -37,58 +37,58 @@ # HAVE_UNORDERED_MAP_IN_STD_NAMESPACE: Use <unordered_map> & std. # HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE: Use <unordered_map> & std::tr1. # HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE: <tr1/unordered_map> & std::tr1. -MACRO(FIND_UNORDERED_MAP) +macro(FIND_UNORDERED_MAP) # To support CXX11 option, clear the results of all check_xxx() functions # s/t we always perform the checks each time, otherwise CMake fails to # detect that the tests should be performed again after CXX11 is toggled. - UNSET(HAVE_STD_UNORDERED_MAP_HEADER CACHE) - UNSET(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE CACHE) - UNSET(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE CACHE) - UNSET(HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE CACHE) + unset(HAVE_STD_UNORDERED_MAP_HEADER CACHE) + unset(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE CACHE) + unset(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE CACHE) + unset(HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE CACHE) - SET(UNORDERED_MAP_FOUND FALSE) - INCLUDE(CheckIncludeFileCXX) - CHECK_INCLUDE_FILE_CXX(unordered_map HAVE_STD_UNORDERED_MAP_HEADER) - IF (HAVE_STD_UNORDERED_MAP_HEADER) + set(UNORDERED_MAP_FOUND FALSE) + 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 <unordered_map> + include(CheckCXXSourceCompiles) + check_cxx_source_compiles("#include <unordered_map> int main() { std::unordered_map<int, int> map; return 0; }" HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - IF (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - SET(UNORDERED_MAP_FOUND TRUE) - MESSAGE("-- Found unordered_map/set in std namespace.") - ELSE (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - CHECK_CXX_SOURCE_COMPILES("#include <unordered_map> + if (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) + set(UNORDERED_MAP_FOUND TRUE) + message("-- Found unordered_map/set in std namespace.") + else (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) + check_cxx_source_compiles("#include <unordered_map> int main() { std::tr1::unordered_map<int, int> map; return 0; }" HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - IF (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - SET(UNORDERED_MAP_FOUND TRUE) - MESSAGE("-- Found unordered_map/set in std::tr1 namespace.") - ELSE (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - MESSAGE("-- Found <unordered_map> but cannot find either " + if (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) + set(UNORDERED_MAP_FOUND TRUE) + message("-- Found unordered_map/set in std::tr1 namespace.") + else (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) + message("-- Found <unordered_map> but cannot find either " "std::unordered_map or std::tr1::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" + 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_IN_TR1_NAMESPACE) - IF (HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE) - SET(UNORDERED_MAP_FOUND TRUE) - MESSAGE("-- Found tr1/unordered_map/set in std::tr1 namespace.") - ELSE (HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE) - MESSAGE("-- Unable to find <unordered_map> or <tr1/unordered_map>.") - ENDIF (HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE) - ENDIF (HAVE_STD_UNORDERED_MAP_HEADER) -ENDMACRO(FIND_UNORDERED_MAP) + if (HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE) + set(UNORDERED_MAP_FOUND TRUE) + message("-- Found tr1/unordered_map/set in std::tr1 namespace.") + else (HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE) + message("-- Unable to find <unordered_map> or <tr1/unordered_map>.") + endif (HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE) + endif (HAVE_STD_UNORDERED_MAP_HEADER) +endmacro(FIND_UNORDERED_MAP)
diff --git a/cmake/UpdateCacheVariable.cmake b/cmake/UpdateCacheVariable.cmake index 350aba6..5995a87 100644 --- a/cmake/UpdateCacheVariable.cmake +++ b/cmake/UpdateCacheVariable.cmake
@@ -36,8 +36,8 @@ # This function automates this process by getting the current help string # for the cache variable to update, then reinitialising it with the new # value, but with the original help string. -FUNCTION(UPDATE_CACHE_VARIABLE VAR_NAME VALUE) - GET_PROPERTY(HELP_STRING CACHE ${VAR_NAME} PROPERTY HELPSTRING) - GET_PROPERTY(VAR_TYPE CACHE ${VAR_NAME} PROPERTY TYPE) - SET(${VAR_NAME} ${VALUE} CACHE ${VAR_TYPE} "${HELP_STRING}" FORCE) -ENDFUNCTION() +function(UPDATE_CACHE_VARIABLE VAR_NAME VALUE) + get_property(HELP_STRING CACHE ${VAR_NAME} PROPERTY HELPSTRING) + get_property(VAR_TYPE CACHE ${VAR_NAME} PROPERTY TYPE) + set(${VAR_NAME} ${VALUE} CACHE ${VAR_TYPE} "${HELP_STRING}" FORCE) +endfunction()
diff --git a/cmake/uninstall.cmake.in b/cmake/uninstall.cmake.in index 6ccb672..06cac80 100644 --- a/cmake/uninstall.cmake.in +++ b/cmake/uninstall.cmake.in
@@ -29,69 +29,69 @@ # Author: arnaudgelas@gmail.com (Arnaud Gelas) # alexs.mac@gmail.com (Alex Stewart) -IF (COMMAND cmake_policy) +if (COMMAND cmake_policy) # Ignore empty elements in LIST() commands. - CMAKE_POLICY(SET CMP0007 OLD) -ENDIF (COMMAND cmake_policy) + cmake_policy(SET CMP0007 OLD) +endif (COMMAND cmake_policy) -IF (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - MESSAGE(FATAL_ERROR "Cannot find install manifest: " +if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: " "\"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") -ENDIF (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +endif (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") -FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" INSTALL_MANIFEST) -STRING(REGEX REPLACE "\n" ";" INSTALL_MANIFEST "${INSTALL_MANIFEST}") -LIST(REVERSE INSTALL_MANIFEST) +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" INSTALL_MANIFEST) +string(REGEX REPLACE "\n" ";" INSTALL_MANIFEST "${INSTALL_MANIFEST}") +list(REVERSE INSTALL_MANIFEST) -FOREACH (INSTALLED_FILE ${INSTALL_MANIFEST}) +foreach (INSTALLED_FILE ${INSTALL_MANIFEST}) # Save the root ceres include install directory, e.g. /usr/local/include/ceres # so that we can remove it at the end. - IF (NOT CERES_INCLUDE_INSTALL_ROOT) - GET_FILENAME_COMPONENT(FILE_NAME ${INSTALLED_FILE} NAME) - IF (FILE_NAME STREQUAL ceres.h) + if (NOT CERES_INCLUDE_INSTALL_ROOT) + get_filename_component(FILE_NAME ${INSTALLED_FILE} NAME) + if (FILE_NAME STREQUAL ceres.h) # Ensure that the directory is nested as we expect, as we are going to # remove it, and we do not want to remove files pertaining to anyone else. - GET_FILENAME_COMPONENT(PARENT_DIR ${INSTALLED_FILE} PATH) - GET_FILENAME_COMPONENT(PARENT_DIR_NAME ${PARENT_DIR} NAME) - IF (PARENT_DIR_NAME STREQUAL ceres AND IS_DIRECTORY ${PARENT_DIR}) - SET(CERES_INCLUDE_INSTALL_ROOT ${PARENT_DIR}) - ENDIF (PARENT_DIR_NAME STREQUAL ceres AND IS_DIRECTORY ${PARENT_DIR}) - ENDIF (FILE_NAME STREQUAL ceres.h) - ENDIF (NOT CERES_INCLUDE_INSTALL_ROOT) + get_filename_component(PARENT_DIR ${INSTALLED_FILE} PATH) + get_filename_component(PARENT_DIR_NAME ${PARENT_DIR} NAME) + if (PARENT_DIR_NAME STREQUAL ceres AND IS_DIRECTORY ${PARENT_DIR}) + set(CERES_INCLUDE_INSTALL_ROOT ${PARENT_DIR}) + endif (PARENT_DIR_NAME STREQUAL ceres AND IS_DIRECTORY ${PARENT_DIR}) + endif (FILE_NAME STREQUAL ceres.h) + endif (NOT CERES_INCLUDE_INSTALL_ROOT) - MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${INSTALLED_FILE}\"") - IF (EXISTS "$ENV{DESTDIR}${INSTALLED_FILE}") - EXECUTE_PROCESS(COMMAND @CMAKE_COMMAND@ + message(STATUS "Uninstalling \"$ENV{DESTDIR}${INSTALLED_FILE}\"") + if (EXISTS "$ENV{DESTDIR}${INSTALLED_FILE}") + execute_process(COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${INSTALLED_FILE}" OUTPUT_VARIABLE RM_OUT RESULT_VARIABLE RM_RETVAL) - IF (NOT ${RM_RETVAL} EQUAL 0) - MESSAGE(FATAL_ERROR + if (NOT ${RM_RETVAL} EQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${INSTALLED_FILE}\"") - ENDIF (NOT ${RM_RETVAL} EQUAL 0) - ELSE (EXISTS "$ENV{DESTDIR}${INSTALLED_FILE}") - MESSAGE(STATUS "File \"$ENV{DESTDIR}${INSTALLED_FILE}\" does not exist.") - ENDIF (EXISTS "$ENV{DESTDIR}${INSTALLED_FILE}") -ENDFOREACH(INSTALLED_FILE) + endif (NOT ${RM_RETVAL} EQUAL 0) + else (EXISTS "$ENV{DESTDIR}${INSTALLED_FILE}") + message(STATUS "File \"$ENV{DESTDIR}${INSTALLED_FILE}\" does not exist.") + endif (EXISTS "$ENV{DESTDIR}${INSTALLED_FILE}") +endforeach(INSTALLED_FILE) # Removing Ceres include install directory. -IF (CERES_INCLUDE_INSTALL_ROOT AND +if (CERES_INCLUDE_INSTALL_ROOT AND EXISTS ${CERES_INCLUDE_INSTALL_ROOT}) - MESSAGE(STATUS "Removing Ceres include install directory: " + message(STATUS "Removing Ceres include install directory: " "\"$ENV{DESTDIR}${CERES_INCLUDE_INSTALL_ROOT}\"") - EXECUTE_PROCESS(COMMAND @CMAKE_COMMAND@ + execute_process(COMMAND @CMAKE_COMMAND@ -E remove_directory "$ENV{DESTDIR}${CERES_INCLUDE_INSTALL_ROOT}" OUTPUT_VARIABLE RM_OUT RESULT_VARIABLE RM_RETVAL) - IF (NOT ${RM_RETVAL} EQUAL 0) - MESSAGE(FATAL_ERROR + if (NOT ${RM_RETVAL} EQUAL 0) + message(FATAL_ERROR "Failed to remove: \"$ENV{DESTDIR}${CERES_INCLUDE_INSTALL_ROOT\"") - ENDIF (NOT ${RM_RETVAL} EQUAL 0) -ELSE (CERES_INCLUDE_INSTALL_ROOT AND + endif (NOT ${RM_RETVAL} EQUAL 0) +else (CERES_INCLUDE_INSTALL_ROOT AND EXISTS ${CERES_INCLUDE_INSTALL_ROOT}) - MESSAGE(FATAL_ERROR "Failed to find Ceres installed include directory " + message(FATAL_ERROR "Failed to find Ceres installed include directory " "(e.g. /usr/local/include/ceres), candidate: " "\"$ENV{DESTDIR}${CERES_INCLUDE_INSTALL_ROOT}\"") -ENDIF (CERES_INCLUDE_INSTALL_ROOT AND +endif (CERES_INCLUDE_INSTALL_ROOT AND EXISTS ${CERES_INCLUDE_INSTALL_ROOT})
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 7bcc758..cfdd910 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt
@@ -26,4 +26,4 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -ADD_SUBDIRECTORY(source) +add_subdirectory(source)
diff --git a/docs/source/CMakeLists.txt b/docs/source/CMakeLists.txt index 91b76df..dd3ddcb 100644 --- a/docs/source/CMakeLists.txt +++ b/docs/source/CMakeLists.txt
@@ -1,16 +1,16 @@ -FIND_PACKAGE(Sphinx REQUIRED) +find_package(Sphinx REQUIRED) # HTML output directory -SET(SPHINX_HTML_DIR "${CMAKE_BINARY_DIR}/docs/html") +set(SPHINX_HTML_DIR "${CMAKE_BINARY_DIR}/docs/html") # Install documentation -INSTALL(DIRECTORY ${SPHINX_HTML_DIR} +install(DIRECTORY ${SPHINX_HTML_DIR} DESTINATION share/doc/ceres COMPONENT Doc PATTERN "${SPHINX_HTML_DIR}/*") # Building using 'make_docs.py' python script -ADD_CUSTOM_TARGET(ceres_docs ALL +add_custom_target(ceres_docs ALL python "${CMAKE_SOURCE_DIR}/scripts/make_docs.py" "${CMAKE_SOURCE_DIR}"
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index fc1a70b..40040f9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt
@@ -31,88 +31,88 @@ # Only Ceres itself should be compiled with CERES_BUILDING_SHARED_LIBRARY # defined, any users of Ceres will have CERES_USING_SHARED_LIBRARY defined # for them in Ceres' config.h if appropriate. -IF (BUILD_SHARED_LIBS) - REMOVE_DEFINITIONS(-DCERES_BUILDING_SHARED_LIBRARY) -ENDIF() +if (BUILD_SHARED_LIBS) + remove_definitions(-DCERES_BUILDING_SHARED_LIBRARY) +endif() -ADD_EXECUTABLE(helloworld helloworld.cc) -TARGET_LINK_LIBRARIES(helloworld ceres) +add_executable(helloworld helloworld.cc) +target_link_libraries(helloworld ceres) -ADD_EXECUTABLE(helloworld_numeric_diff helloworld_numeric_diff.cc) -TARGET_LINK_LIBRARIES(helloworld_numeric_diff ceres) +add_executable(helloworld_numeric_diff helloworld_numeric_diff.cc) +target_link_libraries(helloworld_numeric_diff ceres) -ADD_EXECUTABLE(helloworld_analytic_diff helloworld_analytic_diff.cc) -TARGET_LINK_LIBRARIES(helloworld_analytic_diff ceres) +add_executable(helloworld_analytic_diff helloworld_analytic_diff.cc) +target_link_libraries(helloworld_analytic_diff ceres) -ADD_EXECUTABLE(curve_fitting curve_fitting.cc) -TARGET_LINK_LIBRARIES(curve_fitting ceres) +add_executable(curve_fitting curve_fitting.cc) +target_link_libraries(curve_fitting ceres) -ADD_EXECUTABLE(rosenbrock rosenbrock.cc) -TARGET_LINK_LIBRARIES(rosenbrock ceres) +add_executable(rosenbrock rosenbrock.cc) +target_link_libraries(rosenbrock ceres) -ADD_EXECUTABLE(curve_fitting_c curve_fitting.c) -TARGET_LINK_LIBRARIES(curve_fitting_c ceres) +add_executable(curve_fitting_c curve_fitting.c) +target_link_libraries(curve_fitting_c ceres) # Force CMake to link curve_fitting_c using the C linker, this is important # when Ceres was compiled using C++11 to ensure that -std=c++11 is not passed # through. -SET_TARGET_PROPERTIES(curve_fitting_c PROPERTIES LINKER_LANGUAGE C) +set_target_properties(curve_fitting_c PROPERTIES LINKER_LANGUAGE C) # As this is a C file #including <math.h> we have to explicitly add the math # library (libm). Although some compilers (dependent upon options) will accept # the indirect link to libm via Ceres, at least GCC 4.8 on pure Debian won't. -IF (NOT MSVC) - TARGET_LINK_LIBRARIES(curve_fitting_c m) -ENDIF (NOT MSVC) +if (NOT MSVC) + target_link_libraries(curve_fitting_c m) +endif (NOT MSVC) -ADD_EXECUTABLE(ellipse_approximation ellipse_approximation.cc) -TARGET_LINK_LIBRARIES(ellipse_approximation ceres) +add_executable(ellipse_approximation ellipse_approximation.cc) +target_link_libraries(ellipse_approximation ceres) -ADD_EXECUTABLE(robust_curve_fitting robust_curve_fitting.cc) -TARGET_LINK_LIBRARIES(robust_curve_fitting ceres) +add_executable(robust_curve_fitting robust_curve_fitting.cc) +target_link_libraries(robust_curve_fitting ceres) -ADD_EXECUTABLE(simple_bundle_adjuster simple_bundle_adjuster.cc) -TARGET_LINK_LIBRARIES(simple_bundle_adjuster ceres) +add_executable(simple_bundle_adjuster simple_bundle_adjuster.cc) +target_link_libraries(simple_bundle_adjuster ceres) -ADD_EXECUTABLE(sampled_function sampled_function.cc) -TARGET_LINK_LIBRARIES(sampled_function ceres) +add_executable(sampled_function sampled_function.cc) +target_link_libraries(sampled_function ceres) -IF (GFLAGS) +if (GFLAGS) # The CERES_GFLAGS_NAMESPACE compile definition is NOT stored in # CERES_COMPILE_OPTIONS (and thus config.h) as Ceres itself does not # require gflags, only the tests and examples do. - ADD_DEFINITIONS(-DCERES_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE}) + add_definitions(-DCERES_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE}) - ADD_EXECUTABLE(powell powell.cc) - TARGET_LINK_LIBRARIES(powell ceres ${GFLAGS_LIBRARIES}) + add_executable(powell powell.cc) + target_link_libraries(powell ceres ${GFLAGS_LIBRARIES}) - ADD_EXECUTABLE(nist nist.cc) - TARGET_LINK_LIBRARIES(nist ceres ${GFLAGS_LIBRARIES}) + add_executable(nist nist.cc) + target_link_libraries(nist ceres ${GFLAGS_LIBRARIES}) - ADD_EXECUTABLE(more_garbow_hillstrom more_garbow_hillstrom.cc) - TARGET_LINK_LIBRARIES(more_garbow_hillstrom ceres ${GFLAGS_LIBRARIES}) + add_executable(more_garbow_hillstrom more_garbow_hillstrom.cc) + target_link_libraries(more_garbow_hillstrom ceres ${GFLAGS_LIBRARIES}) - ADD_EXECUTABLE(circle_fit circle_fit.cc) - TARGET_LINK_LIBRARIES(circle_fit ceres ${GFLAGS_LIBRARIES}) + add_executable(circle_fit circle_fit.cc) + target_link_libraries(circle_fit ceres ${GFLAGS_LIBRARIES}) - ADD_EXECUTABLE(bundle_adjuster + add_executable(bundle_adjuster bundle_adjuster.cc bal_problem.cc) - TARGET_LINK_LIBRARIES(bundle_adjuster ceres ${GFLAGS_LIBRARIES}) + target_link_libraries(bundle_adjuster ceres ${GFLAGS_LIBRARIES}) - ADD_EXECUTABLE(libmv_bundle_adjuster + add_executable(libmv_bundle_adjuster libmv_bundle_adjuster.cc) - TARGET_LINK_LIBRARIES(libmv_bundle_adjuster ceres ${GFLAGS_LIBRARIES}) + target_link_libraries(libmv_bundle_adjuster ceres ${GFLAGS_LIBRARIES}) - ADD_EXECUTABLE(libmv_homography + add_executable(libmv_homography libmv_homography.cc) - TARGET_LINK_LIBRARIES(libmv_homography ceres ${GFLAGS_LIBRARIES}) + target_link_libraries(libmv_homography ceres ${GFLAGS_LIBRARIES}) - ADD_EXECUTABLE(denoising + add_executable(denoising denoising.cc fields_of_experts.cc) - TARGET_LINK_LIBRARIES(denoising ceres ${GFLAGS_LIBRARIES}) + target_link_libraries(denoising ceres ${GFLAGS_LIBRARIES}) - ADD_EXECUTABLE(robot_pose_mle + add_executable(robot_pose_mle robot_pose_mle.cc) - TARGET_LINK_LIBRARIES(robot_pose_mle ceres ${GFLAGS_LIBRARIES}) + target_link_libraries(robot_pose_mle ceres ${GFLAGS_LIBRARIES}) -ENDIF (GFLAGS) +endif (GFLAGS)
diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt index 2d217c2..118f2e0 100644 --- a/internal/ceres/CMakeLists.txt +++ b/internal/ceres/CMakeLists.txt
@@ -28,7 +28,7 @@ # # Author: keir@google.com (Keir Mierle) -SET(CERES_INTERNAL_SRC +set(CERES_INTERNAL_SRC array_utils.cc blas.cc block_evaluate_preparer.cc @@ -119,216 +119,216 @@ # install native libraries to lib64 rather than lib. Most distros seem to # follow this convention with a couple notable exceptions (Debian-based and # Arch-based distros) which we try to detect here. -IF (CMAKE_SYSTEM_NAME MATCHES "Linux" AND +if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT DEFINED LIB_SUFFIX AND NOT CMAKE_CROSSCOMPILING AND CMAKE_SIZEOF_VOID_P EQUAL "8" AND NOT EXISTS "/etc/debian_version" AND NOT EXISTS "/etc/arch-release") - SET(LIB_SUFFIX "64") -ENDIF () + set(LIB_SUFFIX "64") +endif () # Also depend on the header files so that they appear in IDEs. -FILE(GLOB CERES_INTERNAL_HDRS *.h) +file(GLOB CERES_INTERNAL_HDRS *.h) # Include the specialized schur solvers. -IF (SCHUR_SPECIALIZATIONS) - FILE(GLOB CERES_INTERNAL_SCHUR_FILES generated/*.cc) -ELSE (SCHUR_SPECIALIZATIONS) +if (SCHUR_SPECIALIZATIONS) + file(GLOB CERES_INTERNAL_SCHUR_FILES generated/*.cc) +else (SCHUR_SPECIALIZATIONS) # Only the fully dynamic solver. The build is much faster this way. - FILE(GLOB CERES_INTERNAL_SCHUR_FILES generated/*_d_d_d.cc) -ENDIF (SCHUR_SPECIALIZATIONS) + file(GLOB CERES_INTERNAL_SCHUR_FILES generated/*_d_d_d.cc) +endif (SCHUR_SPECIALIZATIONS) # Build the list of dependencies for Ceres based on the current configuration. -IF (NOT MINIGLOG AND GLOG_FOUND) - LIST(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES ${GLOG_LIBRARIES}) -ENDIF (NOT MINIGLOG AND GLOG_FOUND) +if (NOT MINIGLOG AND GLOG_FOUND) + list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES ${GLOG_LIBRARIES}) +endif (NOT MINIGLOG AND GLOG_FOUND) -IF (SUITESPARSE AND SUITESPARSE_FOUND) +if (SUITESPARSE AND SUITESPARSE_FOUND) # Define version information for use in Solver::FullReport. - ADD_DEFINITIONS(-DCERES_SUITESPARSE_VERSION="${SUITESPARSE_VERSION}") - LIST(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${SUITESPARSE_LIBRARIES}) -ENDIF (SUITESPARSE AND SUITESPARSE_FOUND) + add_definitions(-DCERES_SUITESPARSE_VERSION="${SUITESPARSE_VERSION}") + list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${SUITESPARSE_LIBRARIES}) +endif (SUITESPARSE AND SUITESPARSE_FOUND) -IF (CXSPARSE AND CXSPARSE_FOUND) +if (CXSPARSE AND CXSPARSE_FOUND) # Define version information for use in Solver::FullReport. - ADD_DEFINITIONS(-DCERES_CXSPARSE_VERSION="${CXSPARSE_VERSION}") - LIST(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${CXSPARSE_LIBRARIES}) -ENDIF (CXSPARSE AND CXSPARSE_FOUND) + add_definitions(-DCERES_CXSPARSE_VERSION="${CXSPARSE_VERSION}") + list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${CXSPARSE_LIBRARIES}) +endif (CXSPARSE AND CXSPARSE_FOUND) -IF (BLAS_FOUND AND LAPACK_FOUND) - LIST(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${LAPACK_LIBRARIES}) - LIST(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${BLAS_LIBRARIES}) -ENDIF (BLAS_FOUND AND LAPACK_FOUND) +if (BLAS_FOUND AND LAPACK_FOUND) + list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${LAPACK_LIBRARIES}) + list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${BLAS_LIBRARIES}) +endif (BLAS_FOUND AND LAPACK_FOUND) -IF (OPENMP_FOUND) - IF (NOT MSVC) - LIST(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES gomp) - LIST(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${CMAKE_THREAD_LIBS_INIT}) - ENDIF (NOT MSVC) -ENDIF (OPENMP_FOUND) +if (OPENMP_FOUND) + if (NOT MSVC) + list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES gomp) + list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${CMAKE_THREAD_LIBS_INIT}) + endif (NOT MSVC) +endif (OPENMP_FOUND) -SET(CERES_LIBRARY_SOURCE +set(CERES_LIBRARY_SOURCE ${CERES_INTERNAL_SRC} ${CERES_INTERNAL_HDRS} ${CERES_INTERNAL_SCHUR_FILES}) # Primarily for Android, but optionally for others, compile the minimal # glog implementation into Ceres. -IF (MINIGLOG) - LIST(APPEND CERES_LIBRARY_SOURCE miniglog/glog/logging.cc) -ENDIF (MINIGLOG) +if (MINIGLOG) + list(APPEND CERES_LIBRARY_SOURCE miniglog/glog/logging.cc) +endif (MINIGLOG) -ADD_LIBRARY(ceres ${CERES_LIBRARY_SOURCE}) -SET_TARGET_PROPERTIES(ceres PROPERTIES +add_library(ceres ${CERES_LIBRARY_SOURCE}) +set_target_properties(ceres PROPERTIES VERSION ${CERES_VERSION} SOVERSION ${CERES_VERSION_MAJOR} ) -IF (CXX11 AND COMPILER_HAS_CXX11_FLAG) - IF (CMAKE_VERSION VERSION_LESS "2.8.12") - MESSAGE("-- Warning: detected CMake version: ${CMAKE_VERSION} < 2.8.12, " +if (CXX11 AND COMPILER_HAS_CXX11_FLAG) + if (CMAKE_VERSION VERSION_LESS "2.8.12") + message("-- Warning: detected CMake version: ${CMAKE_VERSION} < 2.8.12, " "which is the minimum required for compile options to be included in an " "exported CMake target, but CERES_USE_CXX11 is enabled and the detected. " "compiler requires -std=c++11. The client is responsible for adding " "-std=c++11 when using Ceres.") - ELSE () + else () # If Ceres is compiled using C++11, and the compiler requires -std=c++11 # to be set, then ensure that this requirement is rolled into the exported # CMake target, s/t client code which uses Ceres will inherit it (if the # CMake version supports it), iff they are NOT compiling for C. We check # for not C, rather than C++ as LINKER_LANGUAGE is often NOTFOUND and then # uses the default (C++). - TARGET_COMPILE_OPTIONS(ceres PUBLIC + target_compile_options(ceres PUBLIC $<$<NOT:$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>>:-std=c++11>) - ENDIF() -ENDIF() + endif() +endif() -IF (BUILD_SHARED_LIBS) +if (BUILD_SHARED_LIBS) # When building a shared library, mark all external libraries as # PRIVATE so they don't show up as a dependency. - TARGET_LINK_LIBRARIES(ceres + target_link_libraries(ceres LINK_PUBLIC ${CERES_LIBRARY_PUBLIC_DEPENDENCIES} LINK_PRIVATE ${CERES_LIBRARY_PRIVATE_DEPENDENCIES}) -ELSE (BUILD_SHARED_LIBS) +else (BUILD_SHARED_LIBS) # When building a static library, all external libraries are # PUBLIC(default) since the user needs to link to them. # They will be listed in CeresTargets.cmake. - SET(CERES_LIBRARY_DEPENDENCIES + set(CERES_LIBRARY_DEPENDENCIES ${CERES_LIBRARY_PUBLIC_DEPENDENCIES} ${CERES_LIBRARY_PRIVATE_DEPENDENCIES}) - TARGET_LINK_LIBRARIES(ceres ${CERES_LIBRARY_DEPENDENCIES}) -ENDIF (BUILD_SHARED_LIBS) + target_link_libraries(ceres ${CERES_LIBRARY_DEPENDENCIES}) +endif (BUILD_SHARED_LIBS) -INSTALL(TARGETS ceres +install(TARGETS ceres EXPORT CeresExport RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) -IF (BUILD_TESTING AND GFLAGS) +if (BUILD_TESTING AND GFLAGS) # The CERES_GFLAGS_NAMESPACE compile definition is NOT stored in # CERES_COMPILE_OPTIONS (and thus config.h) as Ceres itself does not # require gflags, only the tests and examples do. - ADD_DEFINITIONS(-DCERES_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE}) + add_definitions(-DCERES_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE}) - ADD_LIBRARY(gtest gmock_gtest_all.cc gmock_main.cc) - ADD_LIBRARY(test_util + add_library(gtest gmock_gtest_all.cc gmock_main.cc) + add_library(test_util evaluator_test_utils.cc numeric_diff_test_utils.cc test_util.cc) - IF (MINIGLOG) + if (MINIGLOG) # When using miniglog, it is compiled into Ceres, thus Ceres becomes # the library against which other libraries should link for logging. - TARGET_LINK_LIBRARIES(gtest ${GFLAGS_LIBRARIES} ceres) - TARGET_LINK_LIBRARIES(test_util ceres gtest) - ELSE (MINIGLOG) - TARGET_LINK_LIBRARIES(gtest ${GFLAGS_LIBRARIES} ${GLOG_LIBRARIES}) - TARGET_LINK_LIBRARIES(test_util ceres gtest ${GLOG_LIBRARIES}) - ENDIF (MINIGLOG) + target_link_libraries(gtest ${GFLAGS_LIBRARIES} ceres) + target_link_libraries(test_util ceres gtest) + else (MINIGLOG) + target_link_libraries(gtest ${GFLAGS_LIBRARIES} ${GLOG_LIBRARIES}) + target_link_libraries(test_util ceres gtest ${GLOG_LIBRARIES}) + endif (MINIGLOG) - MACRO (CERES_TEST NAME) - ADD_EXECUTABLE(${NAME}_test ${NAME}_test.cc) - TARGET_LINK_LIBRARIES(${NAME}_test test_util ceres gtest) - ADD_TEST(NAME ${NAME}_test + macro (CERES_TEST NAME) + add_executable(${NAME}_test ${NAME}_test.cc) + target_link_libraries(${NAME}_test test_util ceres gtest) + add_test(NAME ${NAME}_test COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${NAME}_test --test_srcdir ${CMAKE_SOURCE_DIR}/data) - ENDMACRO (CERES_TEST) + endmacro (CERES_TEST) - CERES_TEST(array_utils) - CERES_TEST(autodiff) - CERES_TEST(autodiff_cost_function) - CERES_TEST(autodiff_local_parameterization) - CERES_TEST(block_jacobi_preconditioner) - CERES_TEST(block_random_access_dense_matrix) - CERES_TEST(block_random_access_diagonal_matrix) - CERES_TEST(block_random_access_sparse_matrix) - CERES_TEST(block_sparse_matrix) - CERES_TEST(c_api) - CERES_TEST(canonical_views_clustering) - CERES_TEST(compressed_row_sparse_matrix) - CERES_TEST(conditioned_cost_function) - CERES_TEST(corrector) - CERES_TEST(cost_function_to_functor) - CERES_TEST(covariance) - CERES_TEST(cubic_interpolation) - CERES_TEST(dense_sparse_matrix) - CERES_TEST(dynamic_autodiff_cost_function) - CERES_TEST(dynamic_compressed_row_sparse_matrix) - CERES_TEST(dynamic_numeric_diff_cost_function) - CERES_TEST(evaluator) - CERES_TEST(gradient_checker) - CERES_TEST(gradient_checking_cost_function) - CERES_TEST(gradient_problem) - CERES_TEST(gradient_problem_solver) - CERES_TEST(graph) - CERES_TEST(graph_algorithms) - CERES_TEST(householder_vector) - CERES_TEST(implicit_schur_complement) - CERES_TEST(iterative_schur_complement_solver) - CERES_TEST(jet) - CERES_TEST(levenberg_marquardt_strategy) - CERES_TEST(dogleg_strategy) - CERES_TEST(line_search_preprocessor) - CERES_TEST(local_parameterization) - CERES_TEST(loss_function) - CERES_TEST(minimizer) - CERES_TEST(normal_prior) - CERES_TEST(numeric_diff_cost_function) - CERES_TEST(ordered_groups) - CERES_TEST(parameter_block) - CERES_TEST(parameter_block_ordering) - CERES_TEST(partitioned_matrix_view) - CERES_TEST(polynomial) - CERES_TEST(problem) - CERES_TEST(program) - CERES_TEST(reorder_program) - CERES_TEST(residual_block) - CERES_TEST(residual_block_utils) - CERES_TEST(rotation) - CERES_TEST(schur_complement_solver) - CERES_TEST(schur_eliminator) - CERES_TEST(single_linkage_clustering) - CERES_TEST(small_blas) - CERES_TEST(solver) + ceres_test(array_utils) + ceres_test(autodiff) + ceres_test(autodiff_cost_function) + ceres_test(autodiff_local_parameterization) + ceres_test(block_jacobi_preconditioner) + ceres_test(block_random_access_dense_matrix) + ceres_test(block_random_access_diagonal_matrix) + ceres_test(block_random_access_sparse_matrix) + ceres_test(block_sparse_matrix) + ceres_test(c_api) + ceres_test(canonical_views_clustering) + ceres_test(compressed_row_sparse_matrix) + ceres_test(conditioned_cost_function) + ceres_test(corrector) + ceres_test(cost_function_to_functor) + ceres_test(covariance) + ceres_test(cubic_interpolation) + ceres_test(dense_sparse_matrix) + ceres_test(dynamic_autodiff_cost_function) + ceres_test(dynamic_compressed_row_sparse_matrix) + ceres_test(dynamic_numeric_diff_cost_function) + ceres_test(evaluator) + ceres_test(gradient_checker) + ceres_test(gradient_checking_cost_function) + ceres_test(gradient_problem) + ceres_test(gradient_problem_solver) + ceres_test(graph) + ceres_test(graph_algorithms) + ceres_test(householder_vector) + ceres_test(implicit_schur_complement) + ceres_test(iterative_schur_complement_solver) + ceres_test(jet) + ceres_test(levenberg_marquardt_strategy) + ceres_test(dogleg_strategy) + ceres_test(line_search_preprocessor) + ceres_test(local_parameterization) + ceres_test(loss_function) + ceres_test(minimizer) + ceres_test(normal_prior) + ceres_test(numeric_diff_cost_function) + ceres_test(ordered_groups) + ceres_test(parameter_block) + ceres_test(parameter_block_ordering) + ceres_test(partitioned_matrix_view) + ceres_test(polynomial) + ceres_test(problem) + ceres_test(program) + ceres_test(reorder_program) + ceres_test(residual_block) + ceres_test(residual_block_utils) + ceres_test(rotation) + ceres_test(schur_complement_solver) + ceres_test(schur_eliminator) + ceres_test(single_linkage_clustering) + ceres_test(small_blas) + ceres_test(solver) # TODO(sameeragarwal): This test should ultimately be made # independent of SuiteSparse. - IF (SUITESPARSE AND SUITESPARSE_FOUND) - CERES_TEST(compressed_col_sparse_matrix_utils) - TARGET_LINK_LIBRARIES(compressed_col_sparse_matrix_utils_test + if (SUITESPARSE AND SUITESPARSE_FOUND) + ceres_test(compressed_col_sparse_matrix_utils) + target_link_libraries(compressed_col_sparse_matrix_utils_test ${SUITESPARSE_LIBRARIES}) - ENDIF (SUITESPARSE AND SUITESPARSE_FOUND) + endif (SUITESPARSE AND SUITESPARSE_FOUND) - CERES_TEST(symmetric_linear_solver) - CERES_TEST(triplet_sparse_matrix) - CERES_TEST(trust_region_minimizer) - CERES_TEST(trust_region_preprocessor) - CERES_TEST(unsymmetric_linear_solver) - CERES_TEST(visibility) - CERES_TEST(visibility_based_preconditioner) + ceres_test(symmetric_linear_solver) + ceres_test(triplet_sparse_matrix) + ceres_test(trust_region_minimizer) + ceres_test(trust_region_preprocessor) + ceres_test(unsymmetric_linear_solver) + ceres_test(visibility) + ceres_test(visibility_based_preconditioner) # Put the large end to end test last. - CERES_TEST(system) -ENDIF (BUILD_TESTING AND GFLAGS) + ceres_test(system) +endif (BUILD_TESTING AND GFLAGS)