123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777 |
- cmake_minimum_required(VERSION 3.16...3.27)
- if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
- find_program(HOMEBREW_EXECUTABLE brew)
- mark_as_advanced(FORCE HOMEBREW_EXECUTABLE)
- if (HOMEBREW_EXECUTABLE)
-
- execute_process(COMMAND ${HOMEBREW_EXECUTABLE} --prefix
- OUTPUT_VARIABLE HOMEBREW_INSTALL_PREFIX
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- 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()
- project(Ceres C CXX)
- set(CMAKE_POSITION_INDEPENDENT_CODE ON)
- set(CMAKE_C_VISIBILITY_PRESET hidden)
- set(CMAKE_CXX_VISIBILITY_PRESET hidden)
- set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
- list(APPEND CMAKE_MODULE_PATH "${Ceres_SOURCE_DIR}/cmake")
- include(AddCompileFlagsIfSupported)
- include(CheckCXXCompilerFlag)
- include(CheckLibraryExists)
- include(GNUInstallDirs)
- include(UpdateCacheVariable)
- check_cxx_compiler_flag(/bigobj HAVE_BIGOBJ)
- check_library_exists(m pow "" HAVE_LIBM)
- include(DetectBrokenStackCheckMacOSXcodePairing)
- detect_broken_stack_check_macos_xcode_pairing()
- include(AddGerritCommitHook)
- add_gerrit_commit_hook(${Ceres_SOURCE_DIR} ${Ceres_BINARY_DIR})
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Ceres_BINARY_DIR}/bin)
- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Ceres_BINARY_DIR}/lib)
- set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Ceres_BINARY_DIR}/lib)
- set(CMAKE_RELEASE_POSTFIX "")
- set(CMAKE_DEBUG_POSTFIX "-debug")
- include(ReadCeresVersionFromSource)
- read_ceres_version_from_source(${Ceres_SOURCE_DIR})
- enable_testing()
- include(CMakeDependentOption)
- include(PrettyPrintCMakeList)
- option(MINIGLOG "Use a stripped down version of glog." OFF)
- option(GFLAGS "Enable Google Flags." ON)
- option(SUITESPARSE "Enable SuiteSparse." ON)
- if (APPLE)
- option(ACCELERATESPARSE
- "Enable use of sparse solvers in Apple's Accelerate framework." ON)
- option(ENABLE_BITCODE
- "Enable bitcode for iOS builds (disables inline optimizations for Eigen)." OFF)
- endif()
- option(USE_CUDA "Enable use of CUDA linear algebra solvers." ON)
- option(LAPACK "Enable use of LAPACK directly within Ceres." ON)
- option(SCHUR_SPECIALIZATIONS "Enable fixed-size schur specializations." ON)
- option(CUSTOM_BLAS
- "Use handcoded BLAS routines (usually faster) instead of Eigen."
- ON)
- option(EIGENSPARSE "Enable Eigen as a sparse linear algebra library." ON)
- cmake_dependent_option(EIGENMETIS "Enable Eigen METIS support." ON EIGENSPARSE OFF)
- 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_BENCHMARKS "Build Ceres benchmarking suite" ON)
- option(BUILD_SHARED_LIBS "Build Ceres as a shared library." OFF)
- option(PROVIDE_UNINSTALL_TARGET "Add a custom target to ease removal of installed targets" ON)
- set(SANITIZERS "" CACHE STRING "Semicolon-separated list of sanitizers to use (e.g address, memory, thread)")
- include(EnableSanitizer)
- enable_sanitizer(${SANITIZERS})
- if (ANDROID)
- option(ANDROID_STRIP_DEBUG_SYMBOLS "Strip debug symbols from Android builds (reduces file sizes)" ON)
- endif()
- if (IOS)
- message(STATUS "Building Ceres for iOS platform: ${IOS_PLATFORM}")
-
- if (IOS_DEPLOYMENT_TARGET VERSION_LESS 7.0)
- message(FATAL_ERROR "Unsupported iOS version: ${IOS_DEPLOYMENT_TARGET}, Ceres "
- "requires at least iOS version 7.0")
- endif()
- update_cache_variable(MINIGLOG ON)
- message(STATUS "Building for iOS: Forcing use of miniglog instead of glog.")
-
-
- update_cache_variable(LAPACK OFF)
- message(STATUS "Building for iOS: SuiteSparse, LAPACK, gflags "
- "are not available.")
- update_cache_variable(BUILD_EXAMPLES OFF)
- message(STATUS "Building for iOS: Will not build examples.")
- endif (IOS)
- unset(CERES_COMPILE_OPTIONS)
- find_package(Eigen3 3.3 REQUIRED)
- if (Eigen3_FOUND)
- message("-- Found Eigen version ${Eigen3_VERSION}: ${Eigen3_DIR}")
- if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)" AND
- Eigen3_VERSION VERSION_LESS 3.3.4)
-
-
- message(FATAL_ERROR "-- Ceres requires Eigen version >= 3.3.4 on aarch64. "
- "Detected version of Eigen is: ${Eigen3_VERSION}.")
- endif()
- if (EIGENSPARSE)
- message("-- Enabling use of Eigen as a sparse linear algebra library.")
- list(APPEND CERES_COMPILE_OPTIONS CERES_USE_EIGEN_SPARSE)
- else (EIGENSPARSE)
- message("-- Disabling 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)
- endif (Eigen3_FOUND)
- if (USE_CUDA)
- if (CMAKE_VERSION VERSION_LESS 3.17)
-
-
-
-
-
- find_package(CUDA QUIET)
- if (CUDA_FOUND)
- message("-- Found CUDA version ${CUDA_VERSION} installed in: "
- "${CUDA_TOOLKIT_ROOT_DIR} via legacy (< 3.17) CMake module. "
- "Using the legacy CMake module means that any installation of "
- "Ceres will require that the CUDA libraries be installed in a "
- "location included in the LD_LIBRARY_PATH.")
- enable_language(CUDA)
- macro(DECLARE_IMPORTED_CUDA_TARGET COMPONENT)
- add_library(CUDA::${COMPONENT} INTERFACE IMPORTED)
- target_include_directories(
- CUDA::${COMPONENT} INTERFACE ${CUDA_INCLUDE_DIRS})
- target_link_libraries(
- CUDA::${COMPONENT} INTERFACE ${CUDA_${COMPONENT}_LIBRARY} ${ARGN})
- endmacro()
- declare_imported_cuda_target(cublas)
- declare_imported_cuda_target(cusolver)
- declare_imported_cuda_target(cusparse)
- declare_imported_cuda_target(cudart ${CUDA_LIBRARIES})
- set(CUDAToolkit_BIN_DIR ${CUDA_TOOLKIT_ROOT_DIR}/bin)
- else (CUDA_FOUND)
- message("-- Did not find CUDA, disabling CUDA support.")
- update_cache_variable(USE_CUDA OFF)
- endif (CUDA_FOUND)
- else (CMAKE_VERSION VERSION_LESS 3.17)
- find_package(CUDAToolkit QUIET)
- if (CUDAToolkit_FOUND)
- message("-- Found CUDA version ${CUDAToolkit_VERSION} installed in: "
- "${CUDAToolkit_TARGET_DIR}")
- set(CUDAToolkit_DEPENDENCY
- "find_dependency(CUDAToolkit ${CUDAToolkit_VERSION})")
- enable_language(CUDA)
- if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
-
- set(CMAKE_CUDA_ARCHITECTURES "50;60;70;80")
- message("-- Setting CUDA Architecture to ${CMAKE_CUDA_ARCHITECTURES}")
- endif()
- list(APPEND CERES_CUDA_LIBRARIES
- CUDA::cublas
- CUDA::cudart
- CUDA::cusolver
- CUDA::cusparse)
- set(CMAKE_CUDA_RUNTIME_LIBRARY NONE)
- else (CUDAToolkit_FOUND)
- message("-- Did not find CUDA, disabling CUDA support.")
- update_cache_variable(USE_CUDA OFF)
- endif (CUDAToolkit_FOUND)
- endif (CMAKE_VERSION VERSION_LESS 3.17)
- endif (USE_CUDA)
- if (NOT USE_CUDA)
- message("-- Building without CUDA.")
- list(APPEND CERES_COMPILE_OPTIONS CERES_NO_CUDA)
- endif (NOT USE_CUDA)
- 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.")
- update_cache_variable(LAPACK OFF)
- list(APPEND CERES_COMPILE_OPTIONS CERES_NO_LAPACK)
- endif (LAPACK_FOUND)
- else (LAPACK)
- message("-- Building without LAPACK.")
- list(APPEND CERES_COMPILE_OPTIONS CERES_NO_LAPACK)
- endif (LAPACK)
- set(RELATIVE_CMAKECONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/Ceres)
- if (SUITESPARSE)
-
-
-
- find_package(SuiteSparse 4.5.6 COMPONENTS CHOLMOD SPQR
- OPTIONAL_COMPONENTS Partition)
- if (SuiteSparse_FOUND)
- set(SuiteSparse_DEPENDENCY "find_dependency(SuiteSparse ${SuiteSparse_VERSION})")
-
-
- message("-- Found SuiteSparse ${SuiteSparse_VERSION}, "
- "building with SuiteSparse.")
- if (SuiteSparse_NO_CMAKE OR NOT SuiteSparse_DIR)
- install(FILES ${Ceres_SOURCE_DIR}/cmake/FindSuiteSparse.cmake
- ${Ceres_SOURCE_DIR}/cmake/FindMETIS.cmake
- DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR})
- endif (SuiteSparse_NO_CMAKE OR NOT SuiteSparse_DIR)
- else (SuiteSparse_FOUND)
-
- 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)
- if (NOT SuiteSparse_Partition_FOUND)
- list (APPEND CERES_COMPILE_OPTIONS CERES_NO_CHOLMOD_PARTITION)
- endif (NOT SuiteSparse_Partition_FOUND)
- if (EIGENMETIS)
- find_package (METIS)
- if (METIS_FOUND)
-
-
-
-
- set(METIS_DEPENDENCY "find_dependency(METIS ${METIS_VERSION})")
-
- if (NOT METIS_DIR)
- install(FILES ${Ceres_SOURCE_DIR}/cmake/FindMETIS.cmake
- DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR})
- endif (NOT METIS_DIR)
- else (METIS_FOUND)
- message("-- Did not find METIS, disabling Eigen METIS support.")
- update_cache_variable(EIGENMETIS OFF)
- list (APPEND CERES_COMPILE_OPTIONS CERES_NO_EIGEN_METIS)
- endif (METIS_FOUND)
- else (EIGENMETIS)
- message("-- Building without Eigen METIS support.")
- list (APPEND CERES_COMPILE_OPTIONS CERES_NO_EIGEN_METIS)
- endif (EIGENMETIS)
- if (ACCELERATESPARSE)
- find_package(AccelerateSparse)
- if (AccelerateSparse_FOUND)
- message("-- Found Apple's Accelerate framework with sparse solvers, "
- "building with Accelerate sparse support.")
- else()
- message("-- Failed to find Apple's Accelerate framework with sparse solvers, "
- "building without Accelerate sparse support.")
- update_cache_variable(ACCELERATESPARSE OFF)
- list(APPEND CERES_COMPILE_OPTIONS CERES_NO_ACCELERATE_SPARSE)
- endif()
- else()
- message("-- Building without Apple's Accelerate sparse support.")
- list(APPEND CERES_COMPILE_OPTIONS CERES_NO_ACCELERATE_SPARSE)
- mark_as_advanced(FORCE AccelerateSparse_INCLUDE_DIR
- AccelerateSparse_LIBRARY)
- endif()
- if (NOT SUITESPARSE AND NOT EIGENSPARSE AND NOT ACCELERATESPARSE)
- message(" ===============================================================")
- message(" Compiling without any sparse library: SuiteSparse, ")
- message(" EigenSparse & Apple's Accelerate are all disabled or unavailable. ")
- message(" No sparse linear solvers (SPARSE_NORMAL_CHOLESKY & SPARSE_SCHUR)")
- message(" will be available when Ceres is used.")
- message(" ===============================================================")
- endif()
- if (ANDROID)
- message(" ================================================================")
- if (ANDROID_STRIP_DEBUG_SYMBOLS)
-
- set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s" )
- set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s" )
- message(" Stripping debug information from Android build of Ceres library ")
- message(" to avoid +200MB library files.")
- else()
- message(" Warning: not stripping debug information from Android build of ")
- message(" Ceres library. This will result in a large (+200MB) library.")
- endif()
- message("")
- message(" You can control whether debug information is stripped via the ")
- message(" ANDROID_STRIP_DEBUG_SYMBOLS CMake option when configuring Ceres.")
- message(" ================================================================")
- endif()
- if (GFLAGS)
-
- find_package(gflags 2.2.0)
- if (gflags_FOUND)
- if (TARGET gflags)
- message("-- Found Google Flags (gflags) version ${gflags_VERSION}: ${gflags_DIR}")
- else()
- message("-- Detected version of gflags: ${gflags_VERSION} does not define "
- "expected gflags CMake target which should be exported by gflags 2.2+. "
- "Building without gflags.")
- update_cache_variable(GFLAGS OFF)
- endif()
- else (gflags_FOUND)
- message("-- Did not find Google Flags (gflags), Building without gflags.")
- update_cache_variable(GFLAGS OFF)
- endif (gflags_FOUND)
- endif()
- if (NOT GFLAGS)
- message("-- Use of gflags disabled - no tests or tools will be built!")
- endif()
- if (MINIGLOG)
- message("-- Compiling minimal glog substitute into Ceres.")
- set(GLOG_INCLUDE_DIRS internal/ceres/miniglog)
- set(MINIGLOG_MAX_LOG_LEVEL 2 CACHE STRING "The maximum message severity level to be logged")
- add_definitions("-DMAX_LOG_LEVEL=${MINIGLOG_MAX_LOG_LEVEL}")
- message("-- Using minimal glog substitute (include): ${GLOG_INCLUDE_DIRS}")
- message("-- Max log level for minimal glog substitute: ${MINIGLOG_MAX_LOG_LEVEL}")
-
-
-
-
- mark_as_advanced(FORCE GLOG_INCLUDE_DIR
- GLOG_LIBRARY)
- else (MINIGLOG)
- unset(MINIGLOG_MAX_LOG_LEVEL CACHE)
-
-
- find_package(Glog)
- if (NOT GLOG_FOUND)
- message(FATAL_ERROR "Can't find Google Log (glog). Please set either: "
- "glog_DIR (newer CMake built versions of glog) or GLOG_INCLUDE_DIR & "
- "GLOG_LIBRARY or enable MINIGLOG option to use minimal glog "
- "implementation.")
- endif(NOT GLOG_FOUND)
-
- set(GLOG_GFLAGS_DEPENDENCY_MESSAGE
- " Assuming glog was built with gflags support as gflags was found. "
- "This will make gflags a public dependency of Ceres.")
- if (NOT gflags_FOUND)
- set(GLOG_GFLAGS_DEPENDENCY_MESSAGE
- " Assuming glog was NOT built with gflags support as gflags was "
- "not found. If glog was built with gflags, please set the "
- "gflags search locations such that it can be found by Ceres. "
- "Otherwise, Ceres may fail to link due to missing gflags symbols.")
- endif(NOT gflags_FOUND)
- message("-- Found Google Log (glog)." ${GLOG_GFLAGS_DEPENDENCY_MESSAGE})
- endif (MINIGLOG)
- if (NOT SCHUR_SPECIALIZATIONS)
- list(APPEND CERES_COMPILE_OPTIONS CERES_RESTRICT_SCHUR_SPECIALIZATION)
- message("-- Disabling Schur specializations (faster compiles)")
- endif (NOT SCHUR_SPECIALIZATIONS)
- if (NOT CUSTOM_BLAS)
- list(APPEND CERES_COMPILE_OPTIONS CERES_NO_CUSTOM_BLAS)
- message("-- Disabling custom blas")
- endif (NOT CUSTOM_BLAS)
- if (BUILD_BENCHMARKS)
-
- find_package(benchmark 1.3 QUIET)
- if (benchmark_FOUND)
- message("-- Found Google benchmark library. Building Ceres benchmarks.")
- else()
- message("-- Failed to find Google benchmark library, disabling build of benchmarks.")
- update_cache_variable(BUILD_BENCHMARKS OFF)
- endif()
- mark_as_advanced(benchmark_DIR)
- endif()
- if (BUILD_SHARED_LIBS)
- message("-- Building Ceres as a shared library.")
- else (BUILD_SHARED_LIBS)
- message("-- Building Ceres as a static library.")
- endif (BUILD_SHARED_LIBS)
- 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)
- if (MINGW)
-
-
-
-
-
- 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)
- if (MSVC)
-
- add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
-
- add_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:_SILENCE_CXX23_DENORM_DEPRECATION_WARNING>)
-
- add_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:_SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING>)
-
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/wd4018>)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/wd4267>)
-
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/wd4099>)
-
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/wd4800>)
-
-
-
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/wd4244>)
-
-
-
-
-
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/wd4251>)
-
-
-
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/bigobj>)
-
-
-
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4049")
-
- add_definitions("-D_VARIADIC_MAX=10")
- endif (MSVC)
- if (UNIX)
-
-
- add_cxx_compiler_flag_if_supported(CERES_STRICT_CXX_FLAGS
- -Wmissing-declarations)
-
- add_cxx_compiler_flag_if_supported(CERES_STRICT_CXX_FLAGS
- -Wno-unknown-pragmas)
- add_cxx_compiler_flag_if_supported(CERES_STRICT_CXX_FLAGS
- -Wno-sign-compare)
- add_cxx_compiler_flag_if_supported(CERES_STRICT_CXX_FLAGS
- -Wno-unused-parameter)
- add_cxx_compiler_flag_if_supported(CERES_STRICT_CXX_FLAGS
- -Wno-missing-field-initializers)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CERES_STRICT_CXX_FLAGS}")
- endif (UNIX)
- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-
-
- if (ENABLE_BITCODE)
- set(CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} -fembed-bitcode")
- else ()
-
-
-
-
- set(CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} -Qunused-arguments -mllvm -inline-threshold=600")
- endif ()
-
-
- 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 ()
- add_compile_definitions($<$<BOOL:${WIN32}>:NOMINMAX>)
- list(REMOVE_DUPLICATES CERES_COMPILE_OPTIONS)
- include(CreateCeresConfig)
- create_ceres_config("${CERES_COMPILE_OPTIONS}"
- ${Ceres_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/ceres/internal)
- add_subdirectory(internal/ceres)
- if (BUILD_DOCUMENTATION)
- find_package (Sphinx REQUIRED COMPONENTS sphinx_rtd_theme)
- if (NOT Sphinx_FOUND)
- message("-- Failed to find Sphinx and/or its dependencies, disabling build of documentation.")
- update_cache_variable(BUILD_DOCUMENTATION OFF)
- else()
-
-
- 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)
- file(GLOB CERES_HDRS ${Ceres_SOURCE_DIR}/include/ceres/*.h)
- install(FILES ${CERES_HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ceres)
- file(GLOB CERES_PUBLIC_INTERNAL_HDRS ${Ceres_SOURCE_DIR}/include/ceres/internal/*.h)
- install(FILES ${CERES_PUBLIC_INTERNAL_HDRS} DESTINATION
- ${CMAKE_INSTALL_INCLUDEDIR}/ceres/internal)
- install(DIRECTORY ${Ceres_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
- if (MINIGLOG)
-
-
- install(FILES ${Ceres_SOURCE_DIR}/internal/ceres/miniglog/glog/logging.h
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ceres/internal/miniglog/glog)
- endif (MINIGLOG)
- include(CeresCompileOptionsToComponents)
- ceres_compile_options_to_components("${CERES_COMPILE_OPTIONS}"
- CERES_COMPILED_COMPONENTS)
- include(CMakePackageConfigHelpers)
- write_basic_package_version_file("${Ceres_BINARY_DIR}/CeresConfigVersion.cmake"
- VERSION ${CERES_VERSION}
- COMPATIBILITY SameMajorVersion)
- install(EXPORT CeresExport
- NAMESPACE Ceres::
- DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR} FILE CeresTargets.cmake)
- file(RELATIVE_PATH INSTALL_ROOT_REL_CONFIG_INSTALL_DIR
- ${CMAKE_INSTALL_PREFIX}/${RELATIVE_CMAKECONFIG_INSTALL_DIR}
- ${CMAKE_INSTALL_PREFIX})
- set(SETUP_CERES_CONFIG_FOR_INSTALLATION TRUE)
- configure_file("${Ceres_SOURCE_DIR}/cmake/CeresConfig.cmake.in"
- "${Ceres_BINARY_DIR}/CeresConfig-install.cmake" @ONLY)
- install(FILES "${Ceres_BINARY_DIR}/CeresConfig-install.cmake"
- RENAME CeresConfig.cmake
- DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR})
- install(FILES "${Ceres_BINARY_DIR}/CeresConfigVersion.cmake"
- DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR})
- if (GLOG_FOUND AND NOT FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION)
-
-
- install(FILES "${Ceres_SOURCE_DIR}/cmake/FindGlog.cmake"
- DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR})
- endif()
- if (PROVIDE_UNINSTALL_TARGET)
-
- configure_file("${Ceres_SOURCE_DIR}/cmake/uninstall.cmake.in"
- "${Ceres_BINARY_DIR}/cmake/uninstall.cmake"
- @ONLY)
- add_custom_target(uninstall
- COMMAND ${CMAKE_COMMAND} -P ${Ceres_BINARY_DIR}/cmake/uninstall.cmake)
- endif()
- if (EXPORT_BUILD_DIR)
- message("-- Export Ceres build directory to local CMake package registry.")
-
- file(RELATIVE_PATH INSTALL_ROOT_REL_CONFIG_INSTALL_DIR
- ${Ceres_BINARY_DIR}
- ${Ceres_SOURCE_DIR})
- set (Ceres_EXPORT_TARGETS ceres)
- if (TARGET ceres_cuda_kernels)
-
-
- list (APPEND Ceres_EXPORT_TARGETS ceres_cuda_kernels)
- endif (TARGET ceres_cuda_kernels)
-
-
- export(TARGETS ${Ceres_EXPORT_TARGETS}
- NAMESPACE Ceres::
- FILE ${Ceres_BINARY_DIR}/CeresTargets.cmake)
- export(PACKAGE ${CMAKE_PROJECT_NAME})
- unset (Ceres_EXPORT_TARGETS)
-
-
- set(SETUP_CERES_CONFIG_FOR_INSTALLATION FALSE)
- configure_file("${Ceres_SOURCE_DIR}/cmake/CeresConfig.cmake.in"
- "${Ceres_BINARY_DIR}/CeresConfig.cmake" @ONLY)
- endif (EXPORT_BUILD_DIR)
|