diff --git a/CMakeLists.txt b/CMakeLists.txt index b247c7172..48ba201ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -501,12 +501,6 @@ endif() 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 - # symbol import/export support. - 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) @@ -672,7 +666,7 @@ add_compile_options( list(REMOVE_DUPLICATES CERES_COMPILE_OPTIONS) include(CreateCeresConfig) create_ceres_config("${CERES_COMPILE_OPTIONS}" - ${Ceres_BINARY_DIR}/config/ceres/internal) + ${Ceres_BINARY_DIR}/include/ceres/internal) add_subdirectory(internal/ceres) @@ -707,9 +701,9 @@ file(GLOB CERES_PUBLIC_INTERNAL_HDRS ${Ceres_SOURCE_DIR}/include/ceres/internal/ 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 ${Ceres_BINARY_DIR}/config/ceres/internal/config.h - DESTINATION include/ceres/internal) +# build options and export.h into the installed headers directory. +install(DIRECTORY ${Ceres_BINARY_DIR}/include/ + DESTINATION include) if (MINIGLOG) # Install miniglog header if being used as logging #includes appear in diff --git a/cmake/CreateCeresConfig.cmake b/cmake/CreateCeresConfig.cmake index 89db68cc9..5e84db6ec 100644 --- a/cmake/CreateCeresConfig.cmake +++ b/cmake/CreateCeresConfig.cmake @@ -1,5 +1,5 @@ # Ceres Solver - A fast non-linear least squares minimizer -# Copyright 2015 Google Inc. All rights reserved. +# Copyright 2022 Google Inc. All rights reserved. # http://ceres-solver.org/ # # Redistribution and use in source and binary forms, with or without diff --git a/cmake/config.h.in b/cmake/config.h.in index 7022f6764..028b62ec9 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -1,5 +1,5 @@ // Ceres Solver - A fast non-linear least squares minimizer -// Copyright 2015 Google Inc. All rights reserved. +// Copyright 2022 Google Inc. All rights reserved. // http://ceres-solver.org/ // // Redistribution and use in source and binary forms, with or without @@ -81,12 +81,43 @@ // If defined Ceres was compiled with modern C++ multithreading. @CERES_USE_CXX_THREADS@ -// If defined, Ceres was built as a shared library. -@CERES_USING_SHARED_LIBRARY@ - // If defined, Ceres was compiled with a version MSVC >= 2005 which // deprecated the standard POSIX names for bessel functions, replacing them // with underscore prefixed versions (e.g. j0() -> _j0()). @CERES_MSVC_USE_UNDERSCORE_PREFIXED_BESSEL_FUNCTIONS@ +#if defined(CERES_USE_OPENMP) +#if defined(CERES_USE_CXX_THREADS) || defined(CERES_NO_THREADS) +#error CERES_USE_OPENMP is mutually exclusive to CERES_USE_CXX_THREADS and CERES_NO_THREADS +#endif +#elif defined(CERES_USE_CXX_THREADS) +#if defined(CERES_USE_OPENMP) || defined(CERES_NO_THREADS) +#error CERES_USE_CXX_THREADS is mutually exclusive to CERES_USE_OPENMP, CERES_USE_CXX_THREADS and CERES_NO_THREADS +#endif +#elif defined(CERES_NO_THREADS) +#if defined(CERES_USE_OPENMP) || defined(CERES_USE_CXX_THREADS) +#error CERES_NO_THREADS is mutually exclusive to CERES_USE_OPENMP and CERES_USE_CXX_THREADS +#endif +#else +# error One of CERES_USE_OPENMP, CERES_USE_CXX_THREADS or CERES_NO_THREADS must be defined. +#endif + +// CERES_NO_SPARSE should be automatically defined by config.h if Ceres was +// compiled without any sparse back-end. Verify that it has not subsequently +// been inconsistently redefined. +#if defined(CERES_NO_SPARSE) +#if !defined(CERES_NO_SUITESPARSE) +#error CERES_NO_SPARSE requires CERES_NO_SUITESPARSE. +#endif +#if !defined(CERES_NO_CXSPARSE) +#error CERES_NO_SPARSE requires CERES_NO_CXSPARSE +#endif +#if !defined(CERES_NO_ACCELERATE_SPARSE) +#error CERES_NO_SPARSE requires CERES_NO_ACCELERATE_SPARSE +#endif +#if defined(CERES_USE_EIGEN_SPARSE) +#error CERES_NO_SPARSE requires !CERES_USE_EIGEN_SPARSE +#endif +#endif + #endif // CERES_PUBLIC_INTERNAL_CONFIG_H_ diff --git a/include/ceres/c_api.h b/include/ceres/c_api.h index 91b82bf99..1be8ca2e0 100644 --- a/include/ceres/c_api.h +++ b/include/ceres/c_api.h @@ -39,7 +39,7 @@ #define CERES_PUBLIC_C_API_H_ // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/internal/disable_warnings.h" // clang-format on diff --git a/include/ceres/context.h b/include/ceres/context.h index ab42bfe49..87fba0f29 100644 --- a/include/ceres/context.h +++ b/include/ceres/context.h @@ -31,7 +31,7 @@ #ifndef CERES_PUBLIC_CONTEXT_H_ #define CERES_PUBLIC_CONTEXT_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { @@ -41,7 +41,7 @@ namespace ceres { // Problems, either serially or in parallel. When using it with multiple // Problems at the same time, they may end up contending for resources // (e.g. threads) managed by the Context. -class CERES_EXPORT_INTERNAL Context { +class CERES_NO_EXPORT Context { public: Context(); Context(const Context&) = delete; diff --git a/include/ceres/cost_function.h b/include/ceres/cost_function.h index 1bf687ca3..fef972b75 100644 --- a/include/ceres/cost_function.h +++ b/include/ceres/cost_function.h @@ -48,7 +48,7 @@ #include #include "ceres/internal/disable_warnings.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { diff --git a/include/ceres/cost_function_to_functor.h b/include/ceres/cost_function_to_functor.h index b3aea30dd..08a8050c5 100644 --- a/include/ceres/cost_function_to_functor.h +++ b/include/ceres/cost_function_to_functor.h @@ -94,9 +94,9 @@ #include "ceres/cost_function.h" #include "ceres/dynamic_cost_function_to_functor.h" +#include "ceres/internal/export.h" #include "ceres/internal/fixed_array.h" #include "ceres/internal/parameter_dims.h" -#include "ceres/internal/port.h" #include "ceres/types.h" #include "glog/logging.h" diff --git a/include/ceres/covariance.h b/include/ceres/covariance.h index eba61a1ea..f20870bf1 100644 --- a/include/ceres/covariance.h +++ b/include/ceres/covariance.h @@ -36,7 +36,7 @@ #include #include "ceres/internal/disable_warnings.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/types.h" namespace ceres { diff --git a/include/ceres/crs_matrix.h b/include/ceres/crs_matrix.h index bc618fa09..286733c59 100644 --- a/include/ceres/crs_matrix.h +++ b/include/ceres/crs_matrix.h @@ -34,7 +34,7 @@ #include #include "ceres/internal/disable_warnings.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { diff --git a/include/ceres/cubic_interpolation.h b/include/ceres/cubic_interpolation.h index fb2f9986d..f84417e8d 100644 --- a/include/ceres/cubic_interpolation.h +++ b/include/ceres/cubic_interpolation.h @@ -32,7 +32,7 @@ #define CERES_PUBLIC_CUBIC_INTERPOLATION_H_ #include "Eigen/Core" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "glog/logging.h" namespace ceres { diff --git a/include/ceres/dynamic_cost_function.h b/include/ceres/dynamic_cost_function.h index 069ad5981..d635b888d 100644 --- a/include/ceres/dynamic_cost_function.h +++ b/include/ceres/dynamic_cost_function.h @@ -32,6 +32,7 @@ #define CERES_PUBLIC_DYNAMIC_COST_FUNCTION_H_ #include "ceres/cost_function.h" +#include "ceres/internal/disable_warnings.h" namespace ceres { @@ -52,4 +53,6 @@ class CERES_EXPORT DynamicCostFunction : public CostFunction { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_DYNAMIC_COST_FUNCTION_H_ diff --git a/include/ceres/dynamic_cost_function_to_functor.h b/include/ceres/dynamic_cost_function_to_functor.h index 2d28f976a..5b5feaaf5 100644 --- a/include/ceres/dynamic_cost_function_to_functor.h +++ b/include/ceres/dynamic_cost_function_to_functor.h @@ -37,8 +37,9 @@ #include #include "ceres/dynamic_cost_function.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/internal/fixed_array.h" -#include "ceres/internal/port.h" #include "glog/logging.h" namespace ceres { @@ -101,7 +102,7 @@ namespace ceres { // private: // DynamicCostFunctionToFunctor intrinsic_projection_; // }; -class DynamicCostFunctionToFunctor { +class CERES_EXPORT DynamicCostFunctionToFunctor { public: // Takes ownership of cost_function. explicit DynamicCostFunctionToFunctor(CostFunction* cost_function) @@ -188,4 +189,6 @@ class DynamicCostFunctionToFunctor { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_DYNAMIC_COST_FUNCTION_TO_FUNCTOR_H_ diff --git a/include/ceres/evaluation_callback.h b/include/ceres/evaluation_callback.h index b7c52cfcd..495d56504 100644 --- a/include/ceres/evaluation_callback.h +++ b/include/ceres/evaluation_callback.h @@ -31,7 +31,7 @@ #ifndef CERES_PUBLIC_EVALUATION_CALLBACK_H_ #define CERES_PUBLIC_EVALUATION_CALLBACK_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { diff --git a/include/ceres/first_order_function.h b/include/ceres/first_order_function.h index 7b92cd094..d718b6679 100644 --- a/include/ceres/first_order_function.h +++ b/include/ceres/first_order_function.h @@ -31,7 +31,7 @@ #ifndef CERES_PUBLIC_FIRST_ORDER_FUNCTION_H_ #define CERES_PUBLIC_FIRST_ORDER_FUNCTION_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { diff --git a/include/ceres/gradient_checker.h b/include/ceres/gradient_checker.h index 8e4d06c4e..178fa2b0d 100644 --- a/include/ceres/gradient_checker.h +++ b/include/ceres/gradient_checker.h @@ -40,7 +40,9 @@ #include "ceres/cost_function.h" #include "ceres/dynamic_numeric_diff_cost_function.h" +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" +#include "ceres/internal/export.h" #include "ceres/internal/fixed_array.h" #include "ceres/local_parameterization.h" #include "ceres/manifold.h" @@ -182,4 +184,6 @@ class CERES_EXPORT GradientChecker { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_GRADIENT_CHECKER_H_ diff --git a/include/ceres/gradient_problem.h b/include/ceres/gradient_problem.h index b22d91a01..b6a8b8674 100644 --- a/include/ceres/gradient_problem.h +++ b/include/ceres/gradient_problem.h @@ -34,7 +34,8 @@ #include #include "ceres/first_order_function.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/local_parameterization.h" #include "ceres/manifold.h" @@ -179,4 +180,6 @@ class CERES_EXPORT GradientProblem { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_GRADIENT_PROBLEM_H_ diff --git a/include/ceres/gradient_problem_solver.h b/include/ceres/gradient_problem_solver.h index 322f1f3c7..b6290c80c 100644 --- a/include/ceres/gradient_problem_solver.h +++ b/include/ceres/gradient_problem_solver.h @@ -36,6 +36,7 @@ #include #include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/internal/port.h" #include "ceres/iteration_callback.h" #include "ceres/types.h" diff --git a/include/ceres/internal/autodiff.h b/include/ceres/internal/autodiff.h index 4a0c982e9..4ceb56ee5 100644 --- a/include/ceres/internal/autodiff.h +++ b/include/ceres/internal/autodiff.h @@ -140,9 +140,8 @@ #ifndef CERES_PUBLIC_INTERNAL_AUTODIFF_H_ #define CERES_PUBLIC_INTERNAL_AUTODIFF_H_ -#include - #include +#include #include #include "ceres/internal/array_selector.h" diff --git a/include/ceres/internal/port.h b/include/ceres/internal/port.h index a8a74096d..2bc44f465 100644 --- a/include/ceres/internal/port.h +++ b/include/ceres/internal/port.h @@ -1,5 +1,5 @@ // Ceres Solver - A fast non-linear least squares minimizer -// Copyright 2015 Google Inc. All rights reserved. +// Copyright 2022 Google Inc. All rights reserved. // http://ceres-solver.org/ // // Redistribution and use in source and binary forms, with or without @@ -31,43 +31,6 @@ #ifndef CERES_PUBLIC_INTERNAL_PORT_H_ #define CERES_PUBLIC_INTERNAL_PORT_H_ -// This file needs to compile as c code. -#include "ceres/internal/config.h" - -#if defined(CERES_USE_OPENMP) -#if defined(CERES_USE_CXX_THREADS) || defined(CERES_NO_THREADS) -#error CERES_USE_OPENMP is mutually exclusive to CERES_USE_CXX_THREADS and CERES_NO_THREADS -#endif -#elif defined(CERES_USE_CXX_THREADS) -#if defined(CERES_USE_OPENMP) || defined(CERES_NO_THREADS) -#error CERES_USE_CXX_THREADS is mutually exclusive to CERES_USE_OPENMP, CERES_USE_CXX_THREADS and CERES_NO_THREADS -#endif -#elif defined(CERES_NO_THREADS) -#if defined(CERES_USE_OPENMP) || defined(CERES_USE_CXX_THREADS) -#error CERES_NO_THREADS is mutually exclusive to CERES_USE_OPENMP and CERES_USE_CXX_THREADS -#endif -#else -# error One of CERES_USE_OPENMP, CERES_USE_CXX_THREADS or CERES_NO_THREADS must be defined. -#endif - -// CERES_NO_SPARSE should be automatically defined by config.h if Ceres was -// compiled without any sparse back-end. Verify that it has not subsequently -// been inconsistently redefined. -#if defined(CERES_NO_SPARSE) -#if !defined(CERES_NO_SUITESPARSE) -#error CERES_NO_SPARSE requires CERES_NO_SUITESPARSE. -#endif -#if !defined(CERES_NO_CXSPARSE) -#error CERES_NO_SPARSE requires CERES_NO_CXSPARSE -#endif -#if !defined(CERES_NO_ACCELERATE_SPARSE) -#error CERES_NO_SPARSE requires CERES_NO_ACCELERATE_SPARSE -#endif -#if defined(CERES_USE_EIGEN_SPARSE) -#error CERES_NO_SPARSE requires !CERES_USE_EIGEN_SPARSE -#endif -#endif - // A macro to mark a function/variable/class as deprecated. // We use compiler specific attributes rather than the c++ // attribute because they do not mix well with each other. @@ -77,46 +40,7 @@ #define CERES_DEPRECATED_WITH_MSG(message) __attribute__((deprecated(message))) #else // In the worst case fall back to c++ attribute. -#define CERES_DEPRECATED(message) [[deprecated(message)]] -#endif - -// A macro to signal which functions and classes are exported when -// building a shared library. -#if defined(_MSC_VER) -#define CERES_API_SHARED_IMPORT __declspec(dllimport) -#define CERES_API_SHARED_EXPORT __declspec(dllexport) -#elif defined(__GNUC__) -#define CERES_API_SHARED_IMPORT __attribute__((visibility("default"))) -#define CERES_API_SHARED_EXPORT __attribute__((visibility("default"))) -#else -#define CERES_API_SHARED_IMPORT -#define CERES_API_SHARED_EXPORT -#endif - -// CERES_BUILDING_SHARED_LIBRARY is only defined locally when Ceres itself is -// compiled as a shared library, it is never exported to users. In order that -// we do not have to configure config.h separately when building Ceres as either -// a static or dynamic library, we define both CERES_USING_SHARED_LIBRARY and -// CERES_BUILDING_SHARED_LIBRARY when building as a shared library. -#if defined(CERES_USING_SHARED_LIBRARY) -#if defined(CERES_BUILDING_SHARED_LIBRARY) -// Compiling Ceres itself as a shared library. -#define CERES_EXPORT CERES_API_SHARED_EXPORT -#else -// Using Ceres as a shared library. -#define CERES_EXPORT CERES_API_SHARED_IMPORT -#endif -#else -// Ceres was compiled as a static library, export everything. -#define CERES_EXPORT -#endif - -// Unit tests reach in and test internal functionality so we need a way to make -// those symbols visible -#ifdef CERES_EXPORT_INTERNAL_SYMBOLS -#define CERES_EXPORT_INTERNAL CERES_EXPORT -#else -#define CERES_EXPORT_INTERNAL +#define CERES_DEPRECATED_WITH_MSG(message) [[deprecated(message)]] #endif #ifndef CERES_GET_FLAG diff --git a/include/ceres/internal/variadic_evaluate.h b/include/ceres/internal/variadic_evaluate.h index 47ff6b18f..b8408237c 100644 --- a/include/ceres/internal/variadic_evaluate.h +++ b/include/ceres/internal/variadic_evaluate.h @@ -33,8 +33,7 @@ #ifndef CERES_PUBLIC_INTERNAL_VARIADIC_EVALUATE_H_ #define CERES_PUBLIC_INTERNAL_VARIADIC_EVALUATE_H_ -#include - +#include #include #include diff --git a/include/ceres/iteration_callback.h b/include/ceres/iteration_callback.h index 488c0151e..3d7e8e94f 100644 --- a/include/ceres/iteration_callback.h +++ b/include/ceres/iteration_callback.h @@ -36,6 +36,7 @@ #define CERES_PUBLIC_ITERATION_CALLBACK_H_ #include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/types.h" namespace ceres { diff --git a/include/ceres/local_parameterization.h b/include/ceres/local_parameterization.h index b18d6c64d..07093d25a 100644 --- a/include/ceres/local_parameterization.h +++ b/include/ceres/local_parameterization.h @@ -37,6 +37,7 @@ #include #include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/internal/port.h" namespace ceres { @@ -366,6 +367,8 @@ class CERES_DEPRECATED_WITH_MSG("Use ProductManifold instead.") // clang-format off #include "ceres/internal/reenable_warnings.h" +// clang-format on + #include "ceres/internal/line_parameterization.h" #endif // CERES_PUBLIC_LOCAL_PARAMETERIZATION_H_ diff --git a/include/ceres/loss_function.h b/include/ceres/loss_function.h index 06c8baeec..fc6f358b0 100644 --- a/include/ceres/loss_function.h +++ b/include/ceres/loss_function.h @@ -78,6 +78,7 @@ #include #include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/types.h" #include "glog/logging.h" diff --git a/include/ceres/manifold.h b/include/ceres/manifold.h index 98e27c5b7..a3ec9df30 100644 --- a/include/ceres/manifold.h +++ b/include/ceres/manifold.h @@ -37,7 +37,7 @@ #include #include "ceres/internal/disable_warnings.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/types.h" namespace ceres { diff --git a/include/ceres/numeric_diff_options.h b/include/ceres/numeric_diff_options.h index 64919ed5a..b025b51d9 100644 --- a/include/ceres/numeric_diff_options.h +++ b/include/ceres/numeric_diff_options.h @@ -32,7 +32,8 @@ #ifndef CERES_PUBLIC_NUMERIC_DIFF_OPTIONS_H_ #define CERES_PUBLIC_NUMERIC_DIFF_OPTIONS_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { @@ -70,4 +71,6 @@ struct CERES_EXPORT NumericDiffOptions { } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_NUMERIC_DIFF_OPTIONS_H_ diff --git a/include/ceres/ordered_groups.h b/include/ceres/ordered_groups.h index 954663c97..76a1c8ecb 100644 --- a/include/ceres/ordered_groups.h +++ b/include/ceres/ordered_groups.h @@ -36,7 +36,7 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "glog/logging.h" namespace ceres { diff --git a/include/ceres/problem.h b/include/ceres/problem.h index 1bec60afb..88bff7433 100644 --- a/include/ceres/problem.h +++ b/include/ceres/problem.h @@ -43,6 +43,7 @@ #include "ceres/context.h" #include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/internal/port.h" #include "ceres/types.h" #include "glog/logging.h" diff --git a/include/ceres/solver.h b/include/ceres/solver.h index fb362be7c..35644c40e 100644 --- a/include/ceres/solver.h +++ b/include/ceres/solver.h @@ -38,8 +38,9 @@ #include #include "ceres/crs_matrix.h" +#include "ceres/internal/config.h" #include "ceres/internal/disable_warnings.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/iteration_callback.h" #include "ceres/ordered_groups.h" #include "ceres/problem.h" diff --git a/include/ceres/types.h b/include/ceres/types.h index 3a38805c7..e52242381 100644 --- a/include/ceres/types.h +++ b/include/ceres/types.h @@ -40,7 +40,7 @@ #include #include "ceres/internal/disable_warnings.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt index 4852ce523..166eb195d 100644 --- a/internal/ceres/CMakeLists.txt +++ b/internal/ceres/CMakeLists.txt @@ -1,5 +1,5 @@ # Ceres Solver - A fast non-linear least squares minimizer -# Copyright 2015 Google Inc. All rights reserved. +# Copyright 2022 Google Inc. All rights reserved. # http://ceres-solver.org/ # # Redistribution and use in source and binary forms, with or without @@ -28,6 +28,17 @@ # # Author: keir@google.com (Keir Mierle) +# Always build position-independent code (PIC), even when building Ceres as a +# static library so that shared libraries can link against it, not just +# executables (PIC does not apply on Windows). Global variable can be overridden +# by the user whereas target properties can be not. +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +# Set the default symbol visibility to hidden to unify the behavior among +# the various compilers and to get smaller binaries +set(CMAKE_C_VISIBILITY_PRESET hidden) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) + # Avoid 'xxx.cc has no symbols' warnings from source files which are 'empty' # when their enclosing #ifdefs are disabled. if (CERES_THREADING_MODEL STREQUAL "CXX_THREADS") @@ -42,114 +53,20 @@ elseif (CERES_THREADING_MODEL STREQUAL "NO_THREADS") set(CERES_PARALLEL_FOR_SRC parallel_for_nothreads.cc) endif() -set(CERES_INTERNAL_SRC - ${CERES_PARALLEL_FOR_SRC} - accelerate_sparse.cc - array_utils.cc - block_evaluate_preparer.cc - block_jacobi_preconditioner.cc - block_jacobian_writer.cc - block_random_access_dense_matrix.cc - block_random_access_diagonal_matrix.cc - block_random_access_matrix.cc - block_random_access_sparse_matrix.cc - block_sparse_matrix.cc - block_structure.cc +# Source files that contain public symbols and live in the ceres namespaces. +# Such symbols are expected to be marked with CERES_EXPORT and the files below +# sorted in lexicographical order. +set(CERES_EXPORTED_SRCS c_api.cc - callbacks.cc - canonical_views_clustering.cc - cgnr_solver.cc - compressed_col_sparse_matrix_utils.cc - compressed_row_jacobian_writer.cc - compressed_row_sparse_matrix.cc - conditioned_cost_function.cc - conjugate_gradients_solver.cc - context.cc - context_impl.cc - coordinate_descent_minimizer.cc - corrector.cc - cost_function.cc - covariance.cc - covariance_impl.cc - cxsparse.cc - dense_cholesky.cc - dense_normal_cholesky_solver.cc - dense_qr.cc - dense_qr_solver.cc - dense_sparse_matrix.cc - detect_structure.cc - dogleg_strategy.cc - dynamic_compressed_row_jacobian_writer.cc - dynamic_compressed_row_sparse_matrix.cc - dynamic_sparse_normal_cholesky_solver.cc - eigensparse.cc - evaluation_callback.cc - evaluator.cc - file.cc - first_order_function.cc - float_cxsparse.cc - float_suitesparse.cc - function_sample.cc gradient_checker.cc - gradient_checking_cost_function.cc gradient_problem.cc - gradient_problem_solver.cc - implicit_schur_complement.cc - inner_product_computer.cc - is_close.cc - iteration_callback.cc - iterative_refiner.cc - iterative_schur_complement_solver.cc - levenberg_marquardt_strategy.cc - line_search.cc - line_search_direction.cc - line_search_minimizer.cc - line_search_preprocessor.cc - linear_least_squares_problems.cc - linear_operator.cc - linear_solver.cc local_parameterization.cc loss_function.cc - low_rank_inverse_hessian.cc manifold.cc - minimizer.cc normal_prior.cc - parallel_utils.cc - parameter_block_ordering.cc - partitioned_matrix_view.cc - polynomial.cc - preconditioner.cc - preprocessor.cc problem.cc - problem_impl.cc - program.cc - reorder_program.cc - residual_block.cc - residual_block_utils.cc - schur_complement_solver.cc - schur_eliminator.cc - schur_jacobi_preconditioner.cc - schur_templates.cc - scratch_evaluate_preparer.cc - single_linkage_clustering.cc solver.cc - solver_utils.cc - sparse_cholesky.cc - sparse_matrix.cc - sparse_normal_cholesky_solver.cc - stringprintf.cc - subset_preconditioner.cc - suitesparse.cc - thread_token_provider.cc - triplet_sparse_matrix.cc - trust_region_minimizer.cc - trust_region_preprocessor.cc - trust_region_step_evaluator.cc - trust_region_strategy.cc types.cc - visibility.cc - visibility_based_preconditioner.cc - wall_time.cc ) # Also depend on the header files so that they appear in IDEs. @@ -165,6 +82,7 @@ endif() # Depend also on public headers so they appear in IDEs. file(GLOB CERES_PUBLIC_HDRS ${Ceres_SOURCE_DIR}/include/ceres/*.h) file(GLOB CERES_PUBLIC_INTERNAL_HDRS ${Ceres_SOURCE_DIR}/include/ceres/internal/*.h) +file(GLOB CERES_PUBLIC_INTERNAL_HDRS ${Ceres_BINARY_DIR}/include/ceres/internal/*.h) # Include the specialized schur solvers. if (SCHUR_SPECIALIZATIONS) @@ -233,12 +151,116 @@ if (LAPACK_FOUND) list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${LAPACK_LIBRARIES}) endif () +# Source files that contain private symbols and live in the ceres::internal +# namespace. The corresponding symbols (classes, functions, etc.) are expected +# to be marked with CERES_NO_EXPORT and the files below sorted in +# lexicographical order. +add_library(ceres_internal OBJECT + ${CERES_INTERNAL_SCHUR_FILES} + ${CERES_PARALLEL_FOR_SRC} + accelerate_sparse.cc + array_utils.cc + block_evaluate_preparer.cc + block_jacobi_preconditioner.cc + block_jacobian_writer.cc + block_random_access_dense_matrix.cc + block_random_access_diagonal_matrix.cc + block_random_access_matrix.cc + block_random_access_sparse_matrix.cc + block_sparse_matrix.cc + block_structure.cc + callbacks.cc + canonical_views_clustering.cc + cgnr_solver.cc + compressed_col_sparse_matrix_utils.cc + compressed_row_jacobian_writer.cc + compressed_row_sparse_matrix.cc + conditioned_cost_function.cc + conjugate_gradients_solver.cc + context.cc + context_impl.cc + coordinate_descent_minimizer.cc + corrector.cc + cost_function.cc + covariance.cc + covariance_impl.cc + cxsparse.cc + dense_cholesky.cc + dense_normal_cholesky_solver.cc + dense_qr.cc + dense_qr_solver.cc + dense_sparse_matrix.cc + detect_structure.cc + dogleg_strategy.cc + dynamic_compressed_row_jacobian_writer.cc + dynamic_compressed_row_sparse_matrix.cc + dynamic_sparse_normal_cholesky_solver.cc + eigensparse.cc + evaluation_callback.cc + evaluator.cc + file.cc + first_order_function.cc + float_cxsparse.cc + float_suitesparse.cc + function_sample.cc + gradient_checking_cost_function.cc + gradient_problem_solver.cc + implicit_schur_complement.cc + inner_product_computer.cc + is_close.cc + iteration_callback.cc + iterative_refiner.cc + iterative_schur_complement_solver.cc + levenberg_marquardt_strategy.cc + line_search.cc + line_search_direction.cc + line_search_minimizer.cc + line_search_preprocessor.cc + linear_least_squares_problems.cc + linear_operator.cc + linear_solver.cc + low_rank_inverse_hessian.cc + minimizer.cc + parallel_utils.cc + parameter_block_ordering.cc + partitioned_matrix_view.cc + polynomial.cc + preconditioner.cc + preprocessor.cc + problem_impl.cc + program.cc + reorder_program.cc + residual_block.cc + residual_block_utils.cc + schur_complement_solver.cc + schur_eliminator.cc + schur_jacobi_preconditioner.cc + schur_templates.cc + scratch_evaluate_preparer.cc + single_linkage_clustering.cc + solver_utils.cc + sparse_cholesky.cc + sparse_matrix.cc + sparse_normal_cholesky_solver.cc + stringprintf.cc + subset_preconditioner.cc + suitesparse.cc + thread_token_provider.cc + triplet_sparse_matrix.cc + trust_region_minimizer.cc + trust_region_preprocessor.cc + trust_region_step_evaluator.cc + trust_region_strategy.cc + visibility.cc + visibility_based_preconditioner.cc + wall_time.cc +) + set(CERES_LIBRARY_SOURCE - ${CERES_INTERNAL_SRC} + ${CERES_EXPORTED_SRCS} ${CERES_INTERNAL_HDRS} ${CERES_PUBLIC_HDRS} - ${CERES_PUBLIC_INTERNAL_HDRS} - ${CERES_INTERNAL_SCHUR_FILES}) + ${CERES_PUBLIC_INTERNAL_HDRS}) # Primarily for Android, but optionally for others, compile the minimal # glog implementation into Ceres. @@ -256,28 +278,40 @@ if (CHECK_CXX_FLAG_Wno_missing_declarations) APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-missing-declarations") endif() -add_library(ceres ${CERES_LIBRARY_SOURCE}) -set_target_properties(ceres PROPERTIES - VERSION ${CERES_VERSION} - SOVERSION ${CERES_VERSION_MAJOR}) +add_library(ceres $ ${CERES_LIBRARY_SOURCE}) -if (BUILD_SHARED_LIBS) - set_target_properties(ceres PROPERTIES - # Set the default symbol visibility to hidden to unify the behavior among - # the various compilers and to get smaller binaries - C_VISIBILITY_PRESET hidden - CXX_VISIBILITY_PRESET hidden) +if(BUILD_SHARED_LIBS) + # While building shared libraries, we additionally require a static variant to + # be able to access internal symbols which are not intended for general use. + # Therefore, create a static library from object files and apply all the + # compiler options from the main library to the static one. + add_library(ceres_static STATIC $ ${CERES_LIBRARY_SOURCE}) + target_include_directories(ceres_static PUBLIC $) + target_compile_definitions(ceres_static PUBLIC $) + target_compile_options(ceres_static PUBLIC $) + target_link_libraries(ceres_static + INTERFACE $ + PRIVATE ${CERES_LIBRARY_PRIVATE_DEPENDENCIES}) + # CERES_STATIC_DEFINE is generated by the GenerateExportHeader CMake module + # used to autogerate export.h. The macro should not be renamed without + # updating the corresponding generate_export_header invocation. + target_compile_definitions(ceres_static PRIVATE CERES_STATIC_DEFINE) +else() + # In a static library build, not additional access layer is necessary as all + # symbols are visible. + add_library(ceres_static ALIAS ceres) endif() -# When building as a shared libarary with testing enabled, we need to export -# internal symbols needed by the unit tests -if (BUILD_TESTING) - target_compile_definitions(ceres - PUBLIC - CERES_EXPORT_INTERNAL_SYMBOLS - ) -endif() +# Create a local alias target that matches the expected installed target. +add_library(Ceres::ceres ALIAS ceres) +# Apply all compiler options from the main Ceres target. Compiler options should +# be generally defined on the main target referenced by the ceres_target CMake +# variable. +target_include_directories(ceres_internal PUBLIC $) +target_compile_definitions(ceres_internal PUBLIC $) +target_compile_options(ceres_internal PUBLIC $) +target_compile_definitions(ceres_internal PRIVATE ceres_EXPORTS) # The ability to specify a minimum language version via cxx_std_[11,14,17] # requires CMake >= 3.8. Prior to that we have to specify the compiler features @@ -291,31 +325,13 @@ else() endif() target_compile_features(ceres PUBLIC ${REQUIRED_PUBLIC_CXX_FEATURES}) -include(AppendTargetProperty) -# Always build position-independent code (PIC), even when building Ceres as a -# static library so that shared libraries can link against it, not just -# executables (PIC does not apply on Windows). -if (NOT WIN32 AND NOT BUILD_SHARED_LIBS) - # Use set_target_properties() not append_target_property() here as - # POSITION_INDEPENDENT_CODE is a binary ON/OFF switch. - set_target_properties(ceres PROPERTIES POSITION_INDEPENDENT_CODE ON) -endif() +set_target_properties(ceres PROPERTIES + VERSION ${CERES_VERSION} + SOVERSION 3) -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 - PUBLIC ${CERES_LIBRARY_PUBLIC_DEPENDENCIES} - PRIVATE ${CERES_LIBRARY_PRIVATE_DEPENDENCIES}) -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 - ${CERES_LIBRARY_PUBLIC_DEPENDENCIES} - ${CERES_LIBRARY_PRIVATE_DEPENDENCIES}) - target_link_libraries(ceres PUBLIC ${CERES_LIBRARY_DEPENDENCIES}) -endif (BUILD_SHARED_LIBS) +target_link_libraries(ceres + PUBLIC ${CERES_LIBRARY_PUBLIC_DEPENDENCIES} + PRIVATE ${CERES_LIBRARY_PRIVATE_DEPENDENCIES}) # Add the Ceres headers to its target. # @@ -324,16 +340,15 @@ endif (BUILD_SHARED_LIBS) # 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. -target_include_directories(ceres BEFORE PUBLIC - $) -target_include_directories(ceres PRIVATE ${Ceres_SOURCE_DIR}/internal) -target_include_directories(ceres PUBLIC - $ - $) +target_include_directories(ceres + BEFORE PUBLIC $ + PRIVATE ${Ceres_SOURCE_DIR}/internal + PUBLIC $ + $) # Eigen SparseQR generates various compiler warnings related to unused and # uninitialised local variables. To avoid having to individually suppress these -# warnings around the #include statments for Eigen headers across all GCC/Clang +# warnings around the #include statements for Eigen headers across all GCC/Clang # versions, we tell CMake to treat Eigen headers as system headers. This # results in all compiler warnings from them being suppressed. target_link_libraries(ceres PUBLIC Eigen3::Eigen) @@ -381,13 +396,13 @@ endif() # Add include locations for optional dependencies to the Ceres target without # duplication. list(REMOVE_DUPLICATES CERES_LIBRARY_PRIVATE_DEPENDENCIES_INCLUDE_DIRS) -foreach(INC_DIR ${CERES_LIBRARY_PRIVATE_DEPENDENCIES_INCLUDE_DIRS}) - target_include_directories(ceres PRIVATE ${INC_DIR}) -endforeach() +target_include_directories(ceres PRIVATE ${CERES_LIBRARY_PRIVATE_DEPENDENCIES_INCLUDE_DIRS}) list(REMOVE_DUPLICATES CERES_LIBRARY_PUBLIC_DEPENDENCIES_INCLUDE_DIRS) -foreach(INC_DIR ${CERES_LIBRARY_PUBLIC_DEPENDENCIES_INCLUDE_DIRS}) - target_include_directories(ceres PUBLIC ${INC_DIR}) -endforeach() +target_include_directories(ceres PUBLIC ${CERES_LIBRARY_PUBLIC_DEPENDENCIES_INCLUDE_DIRS}) + +# Generate an export header for annotating symbols visibility +include(GenerateExportHeader) +generate_export_header(ceres EXPORT_FILE_NAME ${Ceres_BINARY_DIR}/include/ceres/internal/export.h) install(TARGETS ceres EXPORT CeresExport @@ -395,33 +410,29 @@ install(TARGETS ceres LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) -# Create a local alias target that matches the expected installed target. -add_library(Ceres::ceres ALIAS ceres) +if (BUILD_TESTING OR benchmark_FOUND) + add_library(test_util STATIC + evaluator_test_utils.cc + numeric_diff_test_utils.cc + test_util.cc) + + target_include_directories(test_util PUBLIC ${Ceres_SOURCE_DIR}/internal) + target_link_libraries (test_util PUBLIC ceres_static) +endif (BUILD_TESTING OR benchmark_FOUND) if (BUILD_TESTING AND GFLAGS) + include(AppendTargetProperty) + add_library(gtest gmock_gtest_all.cc gmock_main.cc) - target_include_directories(gtest PUBLIC ${Ceres_SOURCE_DIR}/internal/ceres) if (BUILD_SHARED_LIBS) # Define gtest-specific shared library flags for compilation. append_target_property(gtest COMPILE_DEFINITIONS GTEST_CREATE_SHARED_LIBRARY) endif() + set_target_properties (gtest PROPERTIES CXX_VISIBILITY_PRESET default) - add_library(test_util - evaluator_test_utils.cc - numeric_diff_test_utils.cc - test_util.cc) - target_include_directories(test_util PUBLIC ${Ceres_SOURCE_DIR}/internal) - - 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 PUBLIC gflags Ceres::ceres) - target_link_libraries(test_util PUBLIC Ceres::ceres gtest) - else (MINIGLOG) - target_link_libraries(gtest PUBLIC gflags ${GLOG_LIBRARIES}) - target_link_libraries(test_util PUBLIC Ceres::ceres gtest ${GLOG_LIBRARIES}) - endif (MINIGLOG) + target_include_directories(gtest PRIVATE ${Ceres_SOURCE_DIR}/internal/ceres) + target_link_libraries(gtest PRIVATE Ceres::ceres) macro (CERES_TEST NAME) add_executable(${NAME}_test ${NAME}_test.cc) @@ -430,12 +441,9 @@ if (BUILD_TESTING AND GFLAGS) # may be referenced without the 'ceres' path prefix and all private # dependencies that may be directly referenced. target_include_directories(${NAME}_test - PUBLIC ${CMAKE_CURRENT_LIST_DIR} - ${Ceres_SOURCE_DIR}/internal/ceres - ${CERES_LIBRARY_PRIVATE_DEPENDENCIES_INCLUDE_DIRS}) - - - target_link_libraries(${NAME}_test PUBLIC test_util Ceres::ceres gtest) + PRIVATE ${Ceres_SOURCE_DIR}/internal/ceres + ${CERES_LIBRARY_PRIVATE_DEPENDENCIES_INCLUDE_DIRS}) + target_link_libraries(${NAME}_test PRIVATE gtest test_util ceres_static) if (BUILD_SHARED_LIBS) # Define gtest-specific shared library flags for linking. append_target_property(${NAME}_test COMPILE_DEFINITIONS @@ -549,11 +557,7 @@ if (BUILD_TESTING AND GFLAGS) endif (BUILD_TESTING AND GFLAGS) macro(add_dependencies_to_benchmark BENCHMARK_TARGET) - target_link_libraries(${BENCHMARK_TARGET} PUBLIC Ceres::ceres benchmark::benchmark) - target_include_directories(${BENCHMARK_TARGET} PUBLIC - ${Ceres_SOURCE_DIR}/internal - ${Ceres_SOURCE_DIR}/internal/ceres - ${CERES_LIBRARY_PRIVATE_DEPENDENCIES_INCLUDE_DIRS}) + target_link_libraries(${BENCHMARK_TARGET} PRIVATE benchmark::benchmark test_util) endmacro() if (BUILD_BENCHMARKS) diff --git a/internal/ceres/accelerate_sparse.cc b/internal/ceres/accelerate_sparse.cc index 15e66455b..74adfaf9a 100644 --- a/internal/ceres/accelerate_sparse.cc +++ b/internal/ceres/accelerate_sparse.cc @@ -29,7 +29,7 @@ // Author: alexs.mac@gmail.com (Alex Stewart) // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_NO_ACCELERATE_SPARSE diff --git a/internal/ceres/accelerate_sparse.h b/internal/ceres/accelerate_sparse.h index e53758dfa..7d5229409 100644 --- a/internal/ceres/accelerate_sparse.h +++ b/internal/ceres/accelerate_sparse.h @@ -32,7 +32,7 @@ #define CERES_INTERNAL_ACCELERATE_SPARSE_H_ // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_NO_ACCELERATE_SPARSE diff --git a/internal/ceres/array_utils.h b/internal/ceres/array_utils.h index 5264ee64b..d2fc7914e 100644 --- a/internal/ceres/array_utils.h +++ b/internal/ceres/array_utils.h @@ -45,29 +45,30 @@ #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { // Fill the array x with an impossible value that the user code is // never expected to compute. -CERES_EXPORT_INTERNAL void InvalidateArray(int size, double* x); +CERES_NO_EXPORT void InvalidateArray(int size, double* x); // Check if all the entries of the array x are valid, i.e. all the // values in the array should be finite and none of them should be // equal to the "impossible" value used by InvalidateArray. -CERES_EXPORT_INTERNAL bool IsArrayValid(int size, const double* x); +CERES_NO_EXPORT bool IsArrayValid(int size, const double* x); // If the array contains an invalid value, return the index for it, // otherwise return size. -CERES_EXPORT_INTERNAL int FindInvalidValue(const int size, const double* x); +CERES_NO_EXPORT int FindInvalidValue(const int size, const double* x); // Utility routine to print an array of doubles to a string. If the // array pointer is nullptr, it is treated as an array of zeros. -CERES_EXPORT_INTERNAL void AppendArrayToString(const int size, - const double* x, - std::string* result); +CERES_NO_EXPORT void AppendArrayToString(const int size, + const double* x, + std::string* result); // This routine takes an array of integer values, sorts and uniques // them and then maps each value in the array to its position in the @@ -82,9 +83,11 @@ CERES_EXPORT_INTERNAL void AppendArrayToString(const int size, // gets mapped to // // [1 0 2 3 0 1 3] -CERES_EXPORT_INTERNAL void MapValuesToContiguousRange(int size, int* array); +CERES_NO_EXPORT void MapValuesToContiguousRange(int size, int* array); } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_ARRAY_UTILS_H_ diff --git a/internal/ceres/block_evaluate_preparer.h b/internal/ceres/block_evaluate_preparer.h index 437868972..d72e41ba3 100644 --- a/internal/ceres/block_evaluate_preparer.h +++ b/internal/ceres/block_evaluate_preparer.h @@ -36,6 +36,7 @@ #ifndef CERES_INTERNAL_BLOCK_EVALUATE_PREPARER_H_ #define CERES_INTERNAL_BLOCK_EVALUATE_PREPARER_H_ +#include "ceres/internal/export.h" #include "ceres/scratch_evaluate_preparer.h" namespace ceres { @@ -44,7 +45,7 @@ namespace internal { class ResidualBlock; class SparseMatrix; -class BlockEvaluatePreparer { +class CERES_NO_EXPORT BlockEvaluatePreparer { public: // Using Init() instead of a constructor allows for allocating this structure // with new[]. This is because C++ doesn't allow passing arguments to objects diff --git a/internal/ceres/block_jacobi_preconditioner.h b/internal/ceres/block_jacobi_preconditioner.h index 4f4a49328..e0a512a14 100644 --- a/internal/ceres/block_jacobi_preconditioner.h +++ b/internal/ceres/block_jacobi_preconditioner.h @@ -34,7 +34,8 @@ #include #include "ceres/block_random_access_diagonal_matrix.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/preconditioner.h" namespace ceres { @@ -53,7 +54,7 @@ struct CompressedRowBlockStructure; // update the matrix by running Update(A, D). The values of the matrix A are // inspected to construct the preconditioner. The vector D is applied as the // D^TD diagonal term. -class CERES_EXPORT_INTERNAL BlockJacobiPreconditioner +class CERES_NO_EXPORT BlockJacobiPreconditioner : public BlockSparseMatrixPreconditioner { public: // A must remain valid while the BlockJacobiPreconditioner is. @@ -78,4 +79,6 @@ class CERES_EXPORT_INTERNAL BlockJacobiPreconditioner } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_BLOCK_JACOBI_PRECONDITIONER_H_ diff --git a/internal/ceres/block_jacobian_writer.cc b/internal/ceres/block_jacobian_writer.cc index 253baf8e0..e0f6ec01e 100644 --- a/internal/ceres/block_jacobian_writer.cc +++ b/internal/ceres/block_jacobian_writer.cc @@ -36,7 +36,7 @@ #include "ceres/block_evaluate_preparer.h" #include "ceres/block_sparse_matrix.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/parameter_block.h" #include "ceres/program.h" #include "ceres/residual_block.h" diff --git a/internal/ceres/block_jacobian_writer.h b/internal/ceres/block_jacobian_writer.h index 7723b4f68..b2d0aaa3b 100644 --- a/internal/ceres/block_jacobian_writer.h +++ b/internal/ceres/block_jacobian_writer.h @@ -42,7 +42,7 @@ #include #include "ceres/evaluator.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -52,7 +52,7 @@ class Program; class SparseMatrix; // TODO(sameeragarwal): This class needs documemtation. -class BlockJacobianWriter { +class CERES_NO_EXPORT BlockJacobianWriter { public: BlockJacobianWriter(const Evaluator::Options& options, Program* program); diff --git a/internal/ceres/block_random_access_dense_matrix.h b/internal/ceres/block_random_access_dense_matrix.h index aef252e48..171a6d694 100644 --- a/internal/ceres/block_random_access_dense_matrix.h +++ b/internal/ceres/block_random_access_dense_matrix.h @@ -35,7 +35,8 @@ #include #include "ceres/block_random_access_matrix.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -50,7 +51,7 @@ namespace internal { // pair. // // ReturnCell is a nop. -class CERES_EXPORT_INTERNAL BlockRandomAccessDenseMatrix +class CERES_NO_EXPORT BlockRandomAccessDenseMatrix : public BlockRandomAccessMatrix { public: // blocks is a vector of block sizes. The resulting matrix has @@ -94,4 +95,6 @@ class CERES_EXPORT_INTERNAL BlockRandomAccessDenseMatrix } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_BLOCK_RANDOM_ACCESS_DENSE_MATRIX_H_ diff --git a/internal/ceres/block_random_access_diagonal_matrix.cc b/internal/ceres/block_random_access_diagonal_matrix.cc index 1b021557e..af372ad57 100644 --- a/internal/ceres/block_random_access_diagonal_matrix.cc +++ b/internal/ceres/block_random_access_diagonal_matrix.cc @@ -37,7 +37,7 @@ #include #include "Eigen/Dense" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/stl_util.h" #include "ceres/triplet_sparse_matrix.h" #include "ceres/types.h" diff --git a/internal/ceres/block_random_access_diagonal_matrix.h b/internal/ceres/block_random_access_diagonal_matrix.h index 31e8b0b7e..3d36c3783 100644 --- a/internal/ceres/block_random_access_diagonal_matrix.h +++ b/internal/ceres/block_random_access_diagonal_matrix.h @@ -37,7 +37,8 @@ #include #include "ceres/block_random_access_matrix.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/triplet_sparse_matrix.h" #include "ceres/types.h" @@ -46,7 +47,7 @@ namespace internal { // A thread safe block diagonal matrix implementation of // BlockRandomAccessMatrix. -class CERES_EXPORT_INTERNAL BlockRandomAccessDiagonalMatrix +class CERES_NO_EXPORT BlockRandomAccessDiagonalMatrix : public BlockRandomAccessMatrix { public: // blocks is an array of block sizes. @@ -98,4 +99,6 @@ class CERES_EXPORT_INTERNAL BlockRandomAccessDiagonalMatrix } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_BLOCK_RANDOM_ACCESS_DIAGONAL_MATRIX_H_ diff --git a/internal/ceres/block_random_access_matrix.h b/internal/ceres/block_random_access_matrix.h index 7f01763ca..ec2c9e1cf 100644 --- a/internal/ceres/block_random_access_matrix.h +++ b/internal/ceres/block_random_access_matrix.h @@ -35,7 +35,7 @@ #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -85,7 +85,7 @@ namespace internal { // Structure to carry a pointer to the array containing a cell and the // mutex guarding it. -struct CellInfo { +struct CERES_NO_EXPORT CellInfo { CellInfo() : values(nullptr) {} explicit CellInfo(double* values) : values(values) {} @@ -93,7 +93,7 @@ struct CellInfo { std::mutex m; }; -class CERES_EXPORT_INTERNAL BlockRandomAccessMatrix { +class CERES_NO_EXPORT BlockRandomAccessMatrix { public: virtual ~BlockRandomAccessMatrix(); diff --git a/internal/ceres/block_random_access_sparse_matrix.cc b/internal/ceres/block_random_access_sparse_matrix.cc index 1b2f5e7b3..0bedf3c58 100644 --- a/internal/ceres/block_random_access_sparse_matrix.cc +++ b/internal/ceres/block_random_access_sparse_matrix.cc @@ -36,7 +36,7 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/triplet_sparse_matrix.h" #include "ceres/types.h" #include "glog/logging.h" diff --git a/internal/ceres/block_random_access_sparse_matrix.h b/internal/ceres/block_random_access_sparse_matrix.h index 67041b813..43886bd9a 100644 --- a/internal/ceres/block_random_access_sparse_matrix.h +++ b/internal/ceres/block_random_access_sparse_matrix.h @@ -39,7 +39,8 @@ #include #include "ceres/block_random_access_matrix.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/small_blas.h" #include "ceres/triplet_sparse_matrix.h" #include "ceres/types.h" @@ -51,7 +52,7 @@ namespace internal { // BlockRandomAccessMatrix. Internally a TripletSparseMatrix is used // for doing the actual storage. This class augments this matrix with // an unordered_map that allows random read/write access. -class CERES_EXPORT_INTERNAL BlockRandomAccessSparseMatrix +class CERES_NO_EXPORT BlockRandomAccessSparseMatrix : public BlockRandomAccessMatrix { public: // blocks is an array of block sizes. block_pairs is a set of @@ -127,4 +128,6 @@ class CERES_EXPORT_INTERNAL BlockRandomAccessSparseMatrix } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_BLOCK_RANDOM_ACCESS_SPARSE_MATRIX_H_ diff --git a/internal/ceres/block_sparse_matrix.h b/internal/ceres/block_sparse_matrix.h index 448282ca9..df8382d3f 100644 --- a/internal/ceres/block_sparse_matrix.h +++ b/internal/ceres/block_sparse_matrix.h @@ -37,8 +37,9 @@ #include #include "ceres/block_structure.h" +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/sparse_matrix.h" namespace ceres { @@ -54,7 +55,7 @@ class TripletSparseMatrix; // // internal/ceres/block_structure.h // -class CERES_EXPORT_INTERNAL BlockSparseMatrix : public SparseMatrix { +class CERES_NO_EXPORT BlockSparseMatrix : public SparseMatrix { public: // Construct a block sparse matrix with a fully initialized // CompressedRowBlockStructure objected. The matrix takes over @@ -138,7 +139,7 @@ class CERES_EXPORT_INTERNAL BlockSparseMatrix : public SparseMatrix { // // BlockSparseDataMatrix a struct that carries these two bits of // information -class BlockSparseMatrixData { +class CERES_NO_EXPORT BlockSparseMatrixData { public: BlockSparseMatrixData(const BlockSparseMatrix& m) : block_structure_(m.block_structure()), values_(m.values()){}; @@ -160,4 +161,6 @@ class BlockSparseMatrixData { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_BLOCK_SPARSE_MATRIX_H_ diff --git a/internal/ceres/block_structure.h b/internal/ceres/block_structure.h index 39f85a20a..203966457 100644 --- a/internal/ceres/block_structure.h +++ b/internal/ceres/block_structure.h @@ -41,14 +41,14 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { typedef int32_t BlockSize; -struct Block { +struct CERES_NO_EXPORT Block { Block() : size(-1), position(-1) {} Block(int size_, int position_) : size(size_), position(position_) {} @@ -56,7 +56,7 @@ struct Block { int position; // Position along the row/column. }; -struct Cell { +struct CERES_NO_EXPORT Cell { Cell() : block_id(-1), position(-1) {} Cell(int block_id_, int position_) : block_id(block_id_), position(position_) {} @@ -68,9 +68,9 @@ struct Cell { }; // Order cell by their block_id; -bool CellLessThan(const Cell& lhs, const Cell& rhs); +CERES_NO_EXPORT bool CellLessThan(const Cell& lhs, const Cell& rhs); -struct CompressedList { +struct CERES_NO_EXPORT CompressedList { CompressedList() = default; // Construct a CompressedList with the cells containing num_cells @@ -83,12 +83,12 @@ struct CompressedList { typedef CompressedList CompressedRow; typedef CompressedList CompressedColumn; -struct CompressedRowBlockStructure { +struct CERES_NO_EXPORT CompressedRowBlockStructure { std::vector cols; std::vector rows; }; -struct CompressedColumnBlockStructure { +struct CERES_NO_EXPORT CompressedColumnBlockStructure { std::vector rows; std::vector cols; }; diff --git a/internal/ceres/bundle_adjustment_test_util.h b/internal/ceres/bundle_adjustment_test_util.h index 8af935d0e..fe874055d 100644 --- a/internal/ceres/bundle_adjustment_test_util.h +++ b/internal/ceres/bundle_adjustment_test_util.h @@ -38,7 +38,7 @@ #include #include "ceres/autodiff_cost_function.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/ordered_groups.h" #include "ceres/problem.h" #include "ceres/rotation.h" diff --git a/internal/ceres/c_api.cc b/internal/ceres/c_api.cc index a96af8d3e..9a0fd9c4a 100644 --- a/internal/ceres/c_api.cc +++ b/internal/ceres/c_api.cc @@ -1,5 +1,5 @@ // Ceres Solver - A fast non-linear least squares minimizer -// Copyright 2015 Google Inc. All rights reserved. +// Copyright 2022 Google Inc. All rights reserved. // http://ceres-solver.org/ // // Redistribution and use in source and binary forms, with or without @@ -65,7 +65,7 @@ void ceres_free_problem(ceres_problem_t* problem) { // This cost function wraps a C-level function pointer from the user, to bridge // between C and C++. -class CallbackCostFunction : public ceres::CostFunction { +class CERES_NO_EXPORT CallbackCostFunction : public ceres::CostFunction { public: CallbackCostFunction(ceres_cost_function_t cost_function, void* user_data, @@ -79,8 +79,6 @@ class CallbackCostFunction : public ceres::CostFunction { } } - ~CallbackCostFunction() override = default; - bool Evaluate(double const* const* parameters, double* residuals, double** jacobians) const final { diff --git a/internal/ceres/callbacks.h b/internal/ceres/callbacks.h index 967628793..883de059b 100644 --- a/internal/ceres/callbacks.h +++ b/internal/ceres/callbacks.h @@ -33,7 +33,7 @@ #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/iteration_callback.h" namespace ceres { @@ -43,7 +43,7 @@ class Program; // Callback for updating the externally visible state of parameter // blocks. -class StateUpdatingCallback : public IterationCallback { +class CERES_NO_EXPORT StateUpdatingCallback : public IterationCallback { public: StateUpdatingCallback(Program* program, double* parameters); ~StateUpdatingCallback() override; @@ -56,7 +56,8 @@ class StateUpdatingCallback : public IterationCallback { // Callback for updating the externally visible state of the // parameters vector for GradientProblemSolver. -class GradientProblemSolverStateUpdatingCallback : public IterationCallback { +class CERES_NO_EXPORT GradientProblemSolverStateUpdatingCallback + : public IterationCallback { public: GradientProblemSolverStateUpdatingCallback(int num_parameters, const double* internal_parameters, @@ -72,7 +73,7 @@ class GradientProblemSolverStateUpdatingCallback : public IterationCallback { // Callback for logging the state of the minimizer to STDERR or // STDOUT depending on the user's preferences and logging level. -class LoggingCallback : public IterationCallback { +class CERES_NO_EXPORT LoggingCallback : public IterationCallback { public: LoggingCallback(MinimizerType minimizer_type, bool log_to_stdout); ~LoggingCallback() override; diff --git a/internal/ceres/canonical_views_clustering.cc b/internal/ceres/canonical_views_clustering.cc index 0dd77a0bb..68998fa22 100644 --- a/internal/ceres/canonical_views_clustering.cc +++ b/internal/ceres/canonical_views_clustering.cc @@ -35,6 +35,7 @@ #include #include "ceres/graph.h" +#include "ceres/internal/export.h" #include "ceres/map_util.h" #include "glog/logging.h" @@ -46,7 +47,7 @@ using std::vector; typedef std::unordered_map IntMap; typedef std::unordered_set IntSet; -class CanonicalViewsClustering { +class CERES_NO_EXPORT CanonicalViewsClustering { public: // Compute the canonical views clustering of the vertices of the diff --git a/internal/ceres/canonical_views_clustering.h b/internal/ceres/canonical_views_clustering.h index 465233ddf..00a6a739d 100644 --- a/internal/ceres/canonical_views_clustering.h +++ b/internal/ceres/canonical_views_clustering.h @@ -45,7 +45,8 @@ #include #include "ceres/graph.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -95,13 +96,13 @@ struct CanonicalViewsClusteringOptions; // It is possible depending on the configuration of the clustering // algorithm that some of the vertices may not be assigned to any // cluster. In this case they are assigned to a cluster with id = -1; -CERES_EXPORT_INTERNAL void ComputeCanonicalViewsClustering( +CERES_NO_EXPORT void ComputeCanonicalViewsClustering( const CanonicalViewsClusteringOptions& options, const WeightedGraph& graph, std::vector* centers, std::unordered_map* membership); -struct CERES_EXPORT_INTERNAL CanonicalViewsClusteringOptions { +struct CERES_NO_EXPORT CanonicalViewsClusteringOptions { // The minimum number of canonical views to compute. int min_views = 3; @@ -122,4 +123,6 @@ struct CERES_EXPORT_INTERNAL CanonicalViewsClusteringOptions { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_CANONICAL_VIEWS_CLUSTERING_H_ diff --git a/internal/ceres/cgnr_linear_operator.h b/internal/ceres/cgnr_linear_operator.h index 995e53148..f4e8b7ebf 100644 --- a/internal/ceres/cgnr_linear_operator.h +++ b/internal/ceres/cgnr_linear_operator.h @@ -34,7 +34,9 @@ #include #include +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" +#include "ceres/internal/export.h" #include "ceres/linear_operator.h" namespace ceres { @@ -78,7 +80,7 @@ class SparseMatrix; // and z = A^T b // // Note: This class is not thread safe, since it uses some temporary storage. -class CgnrLinearOperator : public LinearOperator { +class CERES_NO_EXPORT CgnrLinearOperator : public LinearOperator { public: CgnrLinearOperator(const LinearOperator& A, const double* D) : A_(A), D_(D), z_(new double[A.num_rows()]) {} @@ -116,4 +118,6 @@ class CgnrLinearOperator : public LinearOperator { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_CGNR_LINEAR_OPERATOR_H_ diff --git a/internal/ceres/cgnr_solver.h b/internal/ceres/cgnr_solver.h index 99f3cd7f0..e7c2f7426 100644 --- a/internal/ceres/cgnr_solver.h +++ b/internal/ceres/cgnr_solver.h @@ -33,6 +33,7 @@ #include +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" namespace ceres { @@ -49,7 +50,7 @@ class BlockJacobiPreconditioner; // // as required for solving for x in the least squares sense. Currently only // block diagonal preconditioning is supported. -class CgnrSolver : public BlockSparseMatrixSolver { +class CERES_NO_EXPORT CgnrSolver : public BlockSparseMatrixSolver { public: explicit CgnrSolver(const LinearSolver::Options& options); CgnrSolver(const CgnrSolver&) = delete; diff --git a/internal/ceres/compressed_col_sparse_matrix_utils.cc b/internal/ceres/compressed_col_sparse_matrix_utils.cc index e1f6bb8ff..94e7e9aa4 100644 --- a/internal/ceres/compressed_col_sparse_matrix_utils.cc +++ b/internal/ceres/compressed_col_sparse_matrix_utils.cc @@ -33,7 +33,7 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "glog/logging.h" namespace ceres { diff --git a/internal/ceres/compressed_col_sparse_matrix_utils.h b/internal/ceres/compressed_col_sparse_matrix_utils.h index d442e1a9b..fceb76448 100644 --- a/internal/ceres/compressed_col_sparse_matrix_utils.h +++ b/internal/ceres/compressed_col_sparse_matrix_utils.h @@ -33,7 +33,8 @@ #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -48,7 +49,7 @@ namespace internal { // and column block j, then it is expected that A contains at least // one non-zero entry corresponding to the top left entry of c_ij, // as that entry is used to detect the presence of a non-zero c_ij. -CERES_EXPORT_INTERNAL void CompressedColumnScalarMatrixToBlockMatrix( +CERES_NO_EXPORT void CompressedColumnScalarMatrixToBlockMatrix( const int* scalar_rows, const int* scalar_cols, const std::vector& row_blocks, @@ -59,7 +60,7 @@ CERES_EXPORT_INTERNAL void CompressedColumnScalarMatrixToBlockMatrix( // Given a set of blocks and a permutation of these blocks, compute // the corresponding "scalar" ordering, where the scalar ordering of // size sum(blocks). -CERES_EXPORT_INTERNAL void BlockOrderingToScalarOrdering( +CERES_NO_EXPORT void BlockOrderingToScalarOrdering( const std::vector& blocks, const std::vector& block_ordering, std::vector* scalar_ordering); @@ -142,4 +143,6 @@ void SolveRTRWithSparseRHS(IntegerType num_cols, } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_COMPRESSED_COL_SPARSE_MATRIX_UTILS_H_ diff --git a/internal/ceres/compressed_col_sparse_matrix_utils_test.cc b/internal/ceres/compressed_col_sparse_matrix_utils_test.cc index 3c71a81d4..3b7f9de07 100644 --- a/internal/ceres/compressed_col_sparse_matrix_utils_test.cc +++ b/internal/ceres/compressed_col_sparse_matrix_utils_test.cc @@ -34,7 +34,7 @@ #include #include "Eigen/SparseCore" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/triplet_sparse_matrix.h" #include "glog/logging.h" #include "gtest/gtest.h" diff --git a/internal/ceres/compressed_row_jacobian_writer.h b/internal/ceres/compressed_row_jacobian_writer.h index a73d0c6f3..7badab71b 100644 --- a/internal/ceres/compressed_row_jacobian_writer.h +++ b/internal/ceres/compressed_row_jacobian_writer.h @@ -38,6 +38,7 @@ #include #include "ceres/evaluator.h" +#include "ceres/internal/export.h" #include "ceres/scratch_evaluate_preparer.h" namespace ceres { @@ -47,7 +48,7 @@ class CompressedRowSparseMatrix; class Program; class SparseMatrix; -class CompressedRowJacobianWriter { +class CERES_NO_EXPORT CompressedRowJacobianWriter { public: CompressedRowJacobianWriter(Evaluator::Options /* ignored */, Program* program) diff --git a/internal/ceres/compressed_row_sparse_matrix.cc b/internal/ceres/compressed_row_sparse_matrix.cc index 92aabcecd..d8743cbd4 100644 --- a/internal/ceres/compressed_row_sparse_matrix.cc +++ b/internal/ceres/compressed_row_sparse_matrix.cc @@ -36,7 +36,7 @@ #include #include "ceres/crs_matrix.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/random.h" #include "ceres/triplet_sparse_matrix.h" #include "glog/logging.h" diff --git a/internal/ceres/compressed_row_sparse_matrix.h b/internal/ceres/compressed_row_sparse_matrix.h index c1766b78a..3d7d385b1 100644 --- a/internal/ceres/compressed_row_sparse_matrix.h +++ b/internal/ceres/compressed_row_sparse_matrix.h @@ -34,7 +34,8 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/sparse_matrix.h" #include "ceres/types.h" #include "glog/logging.h" @@ -47,7 +48,7 @@ namespace internal { class TripletSparseMatrix; -class CERES_EXPORT_INTERNAL CompressedRowSparseMatrix : public SparseMatrix { +class CERES_NO_EXPORT CompressedRowSparseMatrix : public SparseMatrix { public: enum StorageType { UNSYMMETRIC, @@ -219,4 +220,6 @@ class CERES_EXPORT_INTERNAL CompressedRowSparseMatrix : public SparseMatrix { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_COMPRESSED_ROW_SPARSE_MATRIX_H_ diff --git a/internal/ceres/concurrent_queue_test.cc b/internal/ceres/concurrent_queue_test.cc index 430111a6d..99be5f2ea 100644 --- a/internal/ceres/concurrent_queue_test.cc +++ b/internal/ceres/concurrent_queue_test.cc @@ -29,7 +29,7 @@ // Author: vitus@google.com (Michael Vitus) // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifdef CERES_USE_CXX_THREADS diff --git a/internal/ceres/conjugate_gradients_solver.h b/internal/ceres/conjugate_gradients_solver.h index f79ca4965..eb954e6c6 100644 --- a/internal/ceres/conjugate_gradients_solver.h +++ b/internal/ceres/conjugate_gradients_solver.h @@ -34,7 +34,8 @@ #ifndef CERES_INTERNAL_CONJUGATE_GRADIENTS_SOLVER_H_ #define CERES_INTERNAL_CONJUGATE_GRADIENTS_SOLVER_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" namespace ceres { @@ -55,7 +56,7 @@ class LinearOperator; // For more details see the documentation for // LinearSolver::PerSolveOptions::r_tolerance and // LinearSolver::PerSolveOptions::q_tolerance in linear_solver.h. -class CERES_EXPORT_INTERNAL ConjugateGradientsSolver : public LinearSolver { +class CERES_NO_EXPORT ConjugateGradientsSolver : public LinearSolver { public: explicit ConjugateGradientsSolver(const LinearSolver::Options& options); Summary Solve(LinearOperator* A, @@ -70,4 +71,6 @@ class CERES_EXPORT_INTERNAL ConjugateGradientsSolver : public LinearSolver { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_CONJUGATE_GRADIENTS_SOLVER_H_ diff --git a/internal/ceres/context_impl.h b/internal/ceres/context_impl.h index 2f9f74a46..7d1e6d30b 100644 --- a/internal/ceres/context_impl.h +++ b/internal/ceres/context_impl.h @@ -33,10 +33,12 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clanf-format on #include "ceres/context.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #ifdef CERES_USE_CXX_THREADS #include "ceres/thread_pool.h" @@ -45,7 +47,7 @@ namespace ceres { namespace internal { -class CERES_EXPORT_INTERNAL ContextImpl : public Context { +class CERES_NO_EXPORT ContextImpl : public Context { public: ContextImpl(); ContextImpl(const ContextImpl&) = delete; @@ -65,4 +67,6 @@ class CERES_EXPORT_INTERNAL ContextImpl : public Context { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_CONTEXT_IMPL_H_ diff --git a/internal/ceres/coordinate_descent_minimizer.h b/internal/ceres/coordinate_descent_minimizer.h index d46e6a85a..d781491bb 100644 --- a/internal/ceres/coordinate_descent_minimizer.h +++ b/internal/ceres/coordinate_descent_minimizer.h @@ -56,7 +56,7 @@ class LinearSolver; // // The minimizer assumes that none of the parameter blocks in the // program are constant. -class CoordinateDescentMinimizer : public Minimizer { +class CERES_NO_EXPORT CoordinateDescentMinimizer : public Minimizer { public: explicit CoordinateDescentMinimizer(ContextImpl* context); diff --git a/internal/ceres/corrector.h b/internal/ceres/corrector.h index 3e11cdce1..44379a3ea 100644 --- a/internal/ceres/corrector.h +++ b/internal/ceres/corrector.h @@ -35,7 +35,8 @@ #ifndef CERES_INTERNAL_CORRECTOR_H_ #define CERES_INTERNAL_CORRECTOR_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -48,7 +49,7 @@ namespace internal { // gauss newton approximation and then take its square root to get the // corresponding corrections to the residual and jacobian. For the // full expressions see Eq. 10 and 11 in BANS by Triggs et al. -class CERES_EXPORT_INTERNAL Corrector { +class CERES_NO_EXPORT Corrector { public: // The constructor takes the squared norm, the value, the first and // second derivatives of the LossFunction. It precalculates some of @@ -89,4 +90,6 @@ class CERES_EXPORT_INTERNAL Corrector { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_CORRECTOR_H_ diff --git a/internal/ceres/covariance_impl.h b/internal/ceres/covariance_impl.h index 394a04bbc..fc029ce25 100644 --- a/internal/ceres/covariance_impl.h +++ b/internal/ceres/covariance_impl.h @@ -38,7 +38,8 @@ #include #include "ceres/covariance.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/problem_impl.h" #include "ceres/suitesparse.h" @@ -47,7 +48,7 @@ namespace internal { class CompressedRowSparseMatrix; -class CERES_EXPORT_INTERNAL CovarianceImpl { +class CERES_NO_EXPORT CovarianceImpl { public: explicit CovarianceImpl(const Covariance::Options& options); ~CovarianceImpl(); @@ -98,4 +99,6 @@ class CERES_EXPORT_INTERNAL CovarianceImpl { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_COVARIANCE_IMPL_H_ diff --git a/internal/ceres/cxsparse.cc b/internal/ceres/cxsparse.cc index cde682a1b..7aa39fa03 100644 --- a/internal/ceres/cxsparse.cc +++ b/internal/ceres/cxsparse.cc @@ -29,7 +29,7 @@ // Author: strandmark@google.com (Petter Strandmark) // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_NO_CXSPARSE diff --git a/internal/ceres/cxsparse.h b/internal/ceres/cxsparse.h index 63dddb598..8968bba4f 100644 --- a/internal/ceres/cxsparse.h +++ b/internal/ceres/cxsparse.h @@ -32,7 +32,7 @@ #define CERES_INTERNAL_CXSPARSE_H_ // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_NO_CXSPARSE @@ -40,6 +40,7 @@ #include #include +#include "ceres/internal/disable_warnings.h" #include "ceres/linear_solver.h" #include "ceres/sparse_cholesky.h" #include "cs.h" @@ -54,7 +55,7 @@ class TripletSparseMatrix; // factorization with a known symbolic factorization. This features does not // explicitly exist in CXSparse. The methods in the class are nonstatic because // the class manages internal scratch space. -class CXSparse { +class CERES_NO_EXPORT CXSparse { public: CXSparse(); ~CXSparse(); @@ -138,7 +139,7 @@ class CXSparse { // An implementation of SparseCholesky interface using the CXSparse // library. -class CXSparseCholesky : public SparseCholesky { +class CERES_NO_EXPORT CXSparseCholesky : public SparseCholesky { public: // Factory static std::unique_ptr Create(OrderingType ordering_type); @@ -166,6 +167,8 @@ class CXSparseCholesky : public SparseCholesky { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #else typedef void cs_dis; diff --git a/internal/ceres/dense_cholesky.h b/internal/ceres/dense_cholesky.h index a7bb80a1a..f7e48d409 100644 --- a/internal/ceres/dense_cholesky.h +++ b/internal/ceres/dense_cholesky.h @@ -33,7 +33,7 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clang-format on #include @@ -54,7 +54,7 @@ namespace internal { // An interface that abstracts away the internal details of various dense linear // algebra libraries and offers a simple API for solving dense symmetric // positive definite linear systems using a Cholesky factorization. -class CERES_EXPORT_INTERNAL DenseCholesky { +class CERES_NO_EXPORT DenseCholesky { public: static std::unique_ptr Create( const LinearSolver::Options& options); @@ -100,7 +100,7 @@ class CERES_EXPORT_INTERNAL DenseCholesky { std::string* message); }; -class CERES_EXPORT_INTERNAL EigenDenseCholesky : public DenseCholesky { +class CERES_NO_EXPORT EigenDenseCholesky : public DenseCholesky { public: LinearSolverTerminationType Factorize(int num_cols, @@ -116,7 +116,7 @@ class CERES_EXPORT_INTERNAL EigenDenseCholesky : public DenseCholesky { }; #ifndef CERES_NO_LAPACK -class CERES_EXPORT_INTERNAL LAPACKDenseCholesky : public DenseCholesky { +class CERES_NO_EXPORT LAPACKDenseCholesky : public DenseCholesky { public: LinearSolverTerminationType Factorize(int num_cols, @@ -136,7 +136,7 @@ class CERES_EXPORT_INTERNAL LAPACKDenseCholesky : public DenseCholesky { #ifndef CERES_NO_CUDA // Implementation of DenseCholesky using the cuSolver library v.11.0 or older, // using the legacy cuSolverDn interface. -class CERES_EXPORT_INTERNAL CUDADenseCholesky32Bit : public DenseCholesky { +class CERES_NO_EXPORT CUDADenseCholesky32Bit : public DenseCholesky { public: static std::unique_ptr Create( const LinearSolver::Options& options); @@ -181,7 +181,7 @@ class CERES_EXPORT_INTERNAL CUDADenseCholesky32Bit : public DenseCholesky { // Implementation of DenseCholesky using the cuSolver library v.11.1 or newer, // using the 64-bit cuSolverDn interface. -class CERES_EXPORT_INTERNAL CUDADenseCholesky64Bit : public DenseCholesky { +class CERES_NO_EXPORT CUDADenseCholesky64Bit : public DenseCholesky { public: static std::unique_ptr Create( const LinearSolver::Options& options); diff --git a/internal/ceres/dense_jacobian_writer.h b/internal/ceres/dense_jacobian_writer.h index 26f171543..002093712 100644 --- a/internal/ceres/dense_jacobian_writer.h +++ b/internal/ceres/dense_jacobian_writer.h @@ -37,7 +37,9 @@ #include "ceres/casts.h" #include "ceres/dense_sparse_matrix.h" +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" +#include "ceres/internal/export.h" #include "ceres/parameter_block.h" #include "ceres/program.h" #include "ceres/residual_block.h" @@ -46,7 +48,7 @@ namespace ceres { namespace internal { -class DenseJacobianWriter { +class CERES_NO_EXPORT DenseJacobianWriter { public: DenseJacobianWriter(Evaluator::Options /* ignored */, Program* program) : program_(program) {} @@ -104,4 +106,6 @@ class DenseJacobianWriter { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_DENSE_JACOBIAN_WRITER_H_ diff --git a/internal/ceres/dense_normal_cholesky_solver.h b/internal/ceres/dense_normal_cholesky_solver.h index 2a07e3bae..395943606 100644 --- a/internal/ceres/dense_normal_cholesky_solver.h +++ b/internal/ceres/dense_normal_cholesky_solver.h @@ -37,6 +37,8 @@ #include #include "ceres/dense_cholesky.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" namespace ceres { @@ -76,7 +78,8 @@ class DenseSparseMatrix; // library. This solver always returns a solution, it is the user's // responsibility to judge if the solution is good enough for their // purposes. -class DenseNormalCholeskySolver : public DenseSparseMatrixSolver { +class CERES_NO_EXPORT DenseNormalCholeskySolver + : public DenseSparseMatrixSolver { public: explicit DenseNormalCholeskySolver(const LinearSolver::Options& options); @@ -94,4 +97,6 @@ class DenseNormalCholeskySolver : public DenseSparseMatrixSolver { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_DENSE_NORMAL_CHOLESKY_SOLVER_H_ diff --git a/internal/ceres/dense_qr.h b/internal/ceres/dense_qr.h index 302fd4a3a..aafb067be 100644 --- a/internal/ceres/dense_qr.h +++ b/internal/ceres/dense_qr.h @@ -33,14 +33,16 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clang-format on #include #include #include "Eigen/Dense" +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" #include "glog/logging.h" @@ -50,7 +52,7 @@ namespace internal { // An interface that abstracts away the internal details of various dense linear // algebra libraries and offers a simple API for solving dense linear systems // using a QR factorization. -class CERES_EXPORT_INTERNAL DenseQR { +class CERES_NO_EXPORT DenseQR { public: static std::unique_ptr Create(const LinearSolver::Options& options); @@ -96,7 +98,7 @@ class CERES_EXPORT_INTERNAL DenseQR { std::string* message); }; -class CERES_EXPORT_INTERNAL EigenDenseQR : public DenseQR { +class CERES_NO_EXPORT EigenDenseQR : public DenseQR { public: LinearSolverTerminationType Factorize(int num_rows, @@ -113,7 +115,7 @@ class CERES_EXPORT_INTERNAL EigenDenseQR : public DenseQR { }; #ifndef CERES_NO_LAPACK -class CERES_EXPORT_INTERNAL LAPACKDenseQR : public DenseQR { +class CERES_NO_EXPORT LAPACKDenseQR : public DenseQR { public: LinearSolverTerminationType Factorize(int num_rows, @@ -138,4 +140,6 @@ class CERES_EXPORT_INTERNAL LAPACKDenseQR : public DenseQR { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_DENSE_QR_H_ diff --git a/internal/ceres/dense_qr_solver.h b/internal/ceres/dense_qr_solver.h index 927dc32b1..0dd91c17b 100644 --- a/internal/ceres/dense_qr_solver.h +++ b/internal/ceres/dense_qr_solver.h @@ -35,8 +35,9 @@ #include #include "ceres/dense_qr.h" +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" namespace ceres { @@ -82,7 +83,7 @@ class DenseSparseMatrix; // library. This solver always returns a solution, it is the user's // responsibility to judge if the solution is good enough for their // purposes. -class CERES_EXPORT_INTERNAL DenseQRSolver : public DenseSparseMatrixSolver { +class CERES_NO_EXPORT DenseQRSolver : public DenseSparseMatrixSolver { public: explicit DenseQRSolver(const LinearSolver::Options& options); @@ -114,4 +115,6 @@ class CERES_EXPORT_INTERNAL DenseQRSolver : public DenseSparseMatrixSolver { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_DENSE_QR_SOLVER_H_ diff --git a/internal/ceres/dense_sparse_matrix.cc b/internal/ceres/dense_sparse_matrix.cc index 80ea6585d..9e6979d6f 100644 --- a/internal/ceres/dense_sparse_matrix.cc +++ b/internal/ceres/dense_sparse_matrix.cc @@ -33,7 +33,7 @@ #include #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/triplet_sparse_matrix.h" #include "glog/logging.h" diff --git a/internal/ceres/dense_sparse_matrix.h b/internal/ceres/dense_sparse_matrix.h index 1a612960c..606c38c66 100644 --- a/internal/ceres/dense_sparse_matrix.h +++ b/internal/ceres/dense_sparse_matrix.h @@ -33,8 +33,9 @@ #ifndef CERES_INTERNAL_DENSE_SPARSE_MATRIX_H_ #define CERES_INTERNAL_DENSE_SPARSE_MATRIX_H_ +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/sparse_matrix.h" #include "ceres/types.h" @@ -43,7 +44,7 @@ namespace internal { class TripletSparseMatrix; -class CERES_EXPORT_INTERNAL DenseSparseMatrix : public SparseMatrix { +class CERES_NO_EXPORT DenseSparseMatrix : public SparseMatrix { public: // Build a matrix with the same content as the TripletSparseMatrix // m. This assumes that m does not have any repeated entries. @@ -76,4 +77,6 @@ class CERES_EXPORT_INTERNAL DenseSparseMatrix : public SparseMatrix { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_DENSE_SPARSE_MATRIX_H_ diff --git a/internal/ceres/detect_structure.h b/internal/ceres/detect_structure.h index 06242307c..6151c0422 100644 --- a/internal/ceres/detect_structure.h +++ b/internal/ceres/detect_structure.h @@ -32,7 +32,8 @@ #define CERES_INTERNAL_DETECT_STRUCTURE_H_ #include "ceres/block_structure.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -56,13 +57,15 @@ namespace internal { // Note: The structure of rows without any e-blocks has no effect on // the values returned by this function. It is entirely possible that // the f_block_size and row_blocks_size is not constant in such rows. -void CERES_EXPORT DetectStructure(const CompressedRowBlockStructure& bs, - const int num_eliminate_blocks, - int* row_block_size, - int* e_block_size, - int* f_block_size); +void CERES_NO_EXPORT DetectStructure(const CompressedRowBlockStructure& bs, + const int num_eliminate_blocks, + int* row_block_size, + int* e_block_size, + int* f_block_size); } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_DETECT_STRUCTURE_H_ diff --git a/internal/ceres/dogleg_strategy.h b/internal/ceres/dogleg_strategy.h index 3ebf8bb6f..2d04a4932 100644 --- a/internal/ceres/dogleg_strategy.h +++ b/internal/ceres/dogleg_strategy.h @@ -31,7 +31,8 @@ #ifndef CERES_INTERNAL_DOGLEG_STRATEGY_H_ #define CERES_INTERNAL_DOGLEG_STRATEGY_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" #include "ceres/trust_region_strategy.h" @@ -53,7 +54,7 @@ namespace internal { // DoglegStrategy follows the approach by Shultz, Schnabel, Byrd. // This finds the exact optimum over the two-dimensional subspace // spanned by the two Dogleg vectors. -class CERES_EXPORT_INTERNAL DoglegStrategy : public TrustRegionStrategy { +class CERES_NO_EXPORT DoglegStrategy : public TrustRegionStrategy { public: explicit DoglegStrategy(const TrustRegionStrategy::Options& options); @@ -161,4 +162,6 @@ class CERES_EXPORT_INTERNAL DoglegStrategy : public TrustRegionStrategy { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_DOGLEG_STRATEGY_H_ diff --git a/internal/ceres/dynamic_compressed_row_finalizer.h b/internal/ceres/dynamic_compressed_row_finalizer.h index 30c98d86b..1645ece59 100644 --- a/internal/ceres/dynamic_compressed_row_finalizer.h +++ b/internal/ceres/dynamic_compressed_row_finalizer.h @@ -33,11 +33,12 @@ #include "ceres/casts.h" #include "ceres/dynamic_compressed_row_sparse_matrix.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { -struct DynamicCompressedRowJacobianFinalizer { +struct CERES_NO_EXPORT DynamicCompressedRowJacobianFinalizer { void operator()(SparseMatrix* base_jacobian, int num_parameters) { DynamicCompressedRowSparseMatrix* jacobian = down_cast(base_jacobian); diff --git a/internal/ceres/dynamic_compressed_row_jacobian_writer.h b/internal/ceres/dynamic_compressed_row_jacobian_writer.h index e87e7fd90..794a9b4c1 100644 --- a/internal/ceres/dynamic_compressed_row_jacobian_writer.h +++ b/internal/ceres/dynamic_compressed_row_jacobian_writer.h @@ -37,6 +37,7 @@ #include #include "ceres/evaluator.h" +#include "ceres/internal/export.h" #include "ceres/scratch_evaluate_preparer.h" namespace ceres { @@ -45,7 +46,7 @@ namespace internal { class Program; class SparseMatrix; -class DynamicCompressedRowJacobianWriter { +class CERES_NO_EXPORT DynamicCompressedRowJacobianWriter { public: DynamicCompressedRowJacobianWriter(Evaluator::Options /* ignored */, Program* program) diff --git a/internal/ceres/dynamic_compressed_row_sparse_matrix.h b/internal/ceres/dynamic_compressed_row_sparse_matrix.h index d06c36ebb..11f78c7b9 100644 --- a/internal/ceres/dynamic_compressed_row_sparse_matrix.h +++ b/internal/ceres/dynamic_compressed_row_sparse_matrix.h @@ -44,12 +44,13 @@ #include #include "ceres/compressed_row_sparse_matrix.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { -class CERES_EXPORT_INTERNAL DynamicCompressedRowSparseMatrix +class CERES_NO_EXPORT DynamicCompressedRowSparseMatrix : public CompressedRowSparseMatrix { public: // Set the number of rows and columns for the underlyig @@ -100,4 +101,6 @@ class CERES_EXPORT_INTERNAL DynamicCompressedRowSparseMatrix } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_DYNAMIC_COMPRESSED_ROW_SPARSE_MATRIX_H_ diff --git a/internal/ceres/dynamic_sparse_normal_cholesky_solver.h b/internal/ceres/dynamic_sparse_normal_cholesky_solver.h index a6203c91a..9ab212463 100644 --- a/internal/ceres/dynamic_sparse_normal_cholesky_solver.h +++ b/internal/ceres/dynamic_sparse_normal_cholesky_solver.h @@ -36,9 +36,10 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clang-format on +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" namespace ceres { @@ -53,7 +54,7 @@ class CompressedRowSparseMatrix; // // TODO(alex): Add support for Accelerate sparse solvers: // https://github.com/ceres-solver/ceres-solver/issues/397 -class DynamicSparseNormalCholeskySolver +class CERES_NO_EXPORT DynamicSparseNormalCholeskySolver : public CompressedRowSparseMatrixSolver { public: explicit DynamicSparseNormalCholeskySolver( diff --git a/internal/ceres/eigensparse.h b/internal/ceres/eigensparse.h index a196723a7..c4a4142e5 100644 --- a/internal/ceres/eigensparse.h +++ b/internal/ceres/eigensparse.h @@ -34,7 +34,7 @@ #define CERES_INTERNAL_EIGENSPARSE_H_ // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifdef CERES_USE_EIGEN_SPARSE @@ -42,13 +42,14 @@ #include #include "Eigen/SparseCore" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" #include "ceres/sparse_cholesky.h" namespace ceres { namespace internal { -class EigenSparseCholesky : public SparseCholesky { +class CERES_NO_EXPORT EigenSparseCholesky : public SparseCholesky { public: // Factory static std::unique_ptr Create( @@ -66,7 +67,7 @@ class EigenSparseCholesky : public SparseCholesky { // Even though the input is double precision linear system, this class // solves it by computing a single precision Cholesky factorization. -class FloatEigenSparseCholesky : public SparseCholesky { +class CERES_NO_EXPORT FloatEigenSparseCholesky : public SparseCholesky { public: // Factory static std::unique_ptr Create( diff --git a/internal/ceres/evaluator.cc b/internal/ceres/evaluator.cc index 60c1a6d02..52d0f09e5 100644 --- a/internal/ceres/evaluator.cc +++ b/internal/ceres/evaluator.cc @@ -41,7 +41,7 @@ #include "ceres/dense_jacobian_writer.h" #include "ceres/dynamic_compressed_row_finalizer.h" #include "ceres/dynamic_compressed_row_jacobian_writer.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/program_evaluator.h" #include "ceres/scratch_evaluate_preparer.h" #include "glog/logging.h" diff --git a/internal/ceres/evaluator.h b/internal/ceres/evaluator.h index 54ee63a08..28e8ce21f 100644 --- a/internal/ceres/evaluator.h +++ b/internal/ceres/evaluator.h @@ -39,7 +39,8 @@ #include "ceres/context_impl.h" #include "ceres/execution_summary.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/types.h" namespace ceres { @@ -56,7 +57,7 @@ class SparseMatrix; // function that is useful for an optimizer that wants to minimize the least // squares objective. This insulates the optimizer from issues like Jacobian // storage, manifolds, etc. -class CERES_EXPORT_INTERNAL Evaluator { +class CERES_NO_EXPORT Evaluator { public: virtual ~Evaluator(); @@ -166,4 +167,6 @@ class CERES_EXPORT_INTERNAL Evaluator { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_EVALUATOR_H_ diff --git a/internal/ceres/evaluator_test_utils.h b/internal/ceres/evaluator_test_utils.h index d47b6fab4..c9661f1b6 100644 --- a/internal/ceres/evaluator_test_utils.h +++ b/internal/ceres/evaluator_test_utils.h @@ -31,13 +31,13 @@ // // Test utils used for evaluation testing. -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { // Fixed sized struct for storing an evaluation. -struct ExpectedEvaluation { +struct CERES_NO_EXPORT ExpectedEvaluation { int num_rows; int num_cols; double cost; @@ -47,16 +47,16 @@ struct ExpectedEvaluation { }; // Compare two evaluations. -CERES_EXPORT_INTERNAL void CompareEvaluations(int expected_num_rows, - int expected_num_cols, - double expected_cost, - const double* expected_residuals, - const double* expected_gradient, - const double* expected_jacobian, - const double actual_cost, - const double* actual_residuals, - const double* actual_gradient, - const double* actual_jacobian); +CERES_NO_EXPORT void CompareEvaluations(int expected_num_rows, + int expected_num_cols, + double expected_cost, + const double* expected_residuals, + const double* expected_gradient, + const double* expected_jacobian, + const double actual_cost, + const double* actual_residuals, + const double* actual_gradient, + const double* actual_jacobian); } // namespace internal } // namespace ceres diff --git a/internal/ceres/execution_summary.h b/internal/ceres/execution_summary.h index 17fd882af..aac7ad6ad 100644 --- a/internal/ceres/execution_summary.h +++ b/internal/ceres/execution_summary.h @@ -35,7 +35,7 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/wall_time.h" namespace ceres { diff --git a/internal/ceres/file.h b/internal/ceres/file.h index c0015df60..bd13128ae 100644 --- a/internal/ceres/file.h +++ b/internal/ceres/file.h @@ -35,21 +35,26 @@ #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { +CERES_NO_EXPORT void WriteStringToFileOrDie(const std::string& data, const std::string& filename); +CERES_NO_EXPORT void ReadFileToStringOrDie(const std::string& filename, std::string* data); // Join two path components, adding a slash if necessary. If basename is an // absolute path then JoinPath ignores dirname and simply returns basename. -CERES_EXPORT_INTERNAL std::string JoinPath(const std::string& dirname, - const std::string& basename); +CERES_NO_EXPORT +std::string JoinPath(const std::string& dirname, const std::string& basename); } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_FILE_H_ diff --git a/internal/ceres/float_cxsparse.h b/internal/ceres/float_cxsparse.h index 9a274c236..8b4514acb 100644 --- a/internal/ceres/float_cxsparse.h +++ b/internal/ceres/float_cxsparse.h @@ -32,12 +32,13 @@ #define CERES_INTERNAL_FLOAT_CXSPARSE_H_ // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #if !defined(CERES_NO_CXSPARSE) #include +#include "ceres/internal/export.h" #include "ceres/sparse_cholesky.h" namespace ceres { @@ -45,7 +46,7 @@ namespace internal { // Fake implementation of a single precision Sparse Cholesky using // CXSparse. -class FloatCXSparseCholesky : public SparseCholesky { +class CERES_NO_EXPORT FloatCXSparseCholesky : public SparseCholesky { public: static std::unique_ptr Create(OrderingType ordering_type); }; diff --git a/internal/ceres/float_suitesparse.h b/internal/ceres/float_suitesparse.h index c436da43f..7e76799e2 100644 --- a/internal/ceres/float_suitesparse.h +++ b/internal/ceres/float_suitesparse.h @@ -33,11 +33,12 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clang-format on #include +#include "ceres/internal/export.h" #include "ceres/sparse_cholesky.h" #if !defined(CERES_NO_SUITESPARSE) @@ -47,7 +48,7 @@ namespace internal { // Fake implementation of a single precision Sparse Cholesky using // SuiteSparse. -class FloatSuiteSparseCholesky : public SparseCholesky { +class CERES_NO_EXPORT FloatSuiteSparseCholesky : public SparseCholesky { public: static std::unique_ptr Create(OrderingType ordering_type); }; diff --git a/internal/ceres/function_sample.h b/internal/ceres/function_sample.h index 3bcea1bc5..63ffc8ff8 100644 --- a/internal/ceres/function_sample.h +++ b/internal/ceres/function_sample.h @@ -33,8 +33,9 @@ #include +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -47,7 +48,7 @@ namespace internal { // line/direction. FunctionSample contains the information in two // ways. Information in the ambient space and information along the // direction of search. -struct CERES_EXPORT_INTERNAL FunctionSample { +struct CERES_NO_EXPORT FunctionSample { FunctionSample(); FunctionSample(double x, double value); FunctionSample(double x, double value, double gradient); @@ -90,4 +91,6 @@ struct CERES_EXPORT_INTERNAL FunctionSample { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_FUNCTION_SAMPLE_H_ diff --git a/internal/ceres/generated/partitioned_matrix_view_2_2_2.cc b/internal/ceres/generated/partitioned_matrix_view_2_2_2.cc index f5753bef5..7b4ed167d 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_2_2.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_2_2.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_2_3.cc b/internal/ceres/generated/partitioned_matrix_view_2_2_3.cc index a7a9b5231..0f012515a 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_2_3.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_2_3.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_2_4.cc b/internal/ceres/generated/partitioned_matrix_view_2_2_4.cc index faf6c4a75..bdbe91c43 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_2_4.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_2_4.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_2_d.cc b/internal/ceres/generated/partitioned_matrix_view_2_2_d.cc index 92fd4cddf..71f293b55 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_2_d.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_2_d.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_3_3.cc b/internal/ceres/generated/partitioned_matrix_view_2_3_3.cc index 2df314f13..a6ea7761c 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_3_3.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_3_3.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_3_4.cc b/internal/ceres/generated/partitioned_matrix_view_2_3_4.cc index ff1ca3e7f..e712678a2 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_3_4.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_3_4.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_3_6.cc b/internal/ceres/generated/partitioned_matrix_view_2_3_6.cc index 5041df915..3aff26e65 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_3_6.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_3_6.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_3_9.cc b/internal/ceres/generated/partitioned_matrix_view_2_3_9.cc index c0b72fec8..6cd239bfd 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_3_9.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_3_9.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_3_d.cc b/internal/ceres/generated/partitioned_matrix_view_2_3_d.cc index 8a3c162ab..68c50552d 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_3_d.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_3_d.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_4_3.cc b/internal/ceres/generated/partitioned_matrix_view_2_4_3.cc index 0e69ca640..88c5e29c6 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_4_3.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_4_3.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_4_4.cc b/internal/ceres/generated/partitioned_matrix_view_2_4_4.cc index ba9bb6152..b94878344 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_4_4.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_4_4.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_4_6.cc b/internal/ceres/generated/partitioned_matrix_view_2_4_6.cc index 1acdb9b21..7f044ef62 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_4_6.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_4_6.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_4_8.cc b/internal/ceres/generated/partitioned_matrix_view_2_4_8.cc index 888ff9955..7394e7998 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_4_8.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_4_8.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_4_9.cc b/internal/ceres/generated/partitioned_matrix_view_2_4_9.cc index bd4dde3d2..263f1fb36 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_4_9.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_4_9.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_4_d.cc b/internal/ceres/generated/partitioned_matrix_view_2_4_d.cc index 6d3516fc6..d47634e0f 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_4_d.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_4_d.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_2_d_d.cc b/internal/ceres/generated/partitioned_matrix_view_2_d_d.cc index 77d22ed6b..0944cdcbf 100644 --- a/internal/ceres/generated/partitioned_matrix_view_2_d_d.cc +++ b/internal/ceres/generated/partitioned_matrix_view_2_d_d.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_3_3_3.cc b/internal/ceres/generated/partitioned_matrix_view_3_3_3.cc index aeb456c6e..23674031b 100644 --- a/internal/ceres/generated/partitioned_matrix_view_3_3_3.cc +++ b/internal/ceres/generated/partitioned_matrix_view_3_3_3.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_4_4_2.cc b/internal/ceres/generated/partitioned_matrix_view_4_4_2.cc index bb240b9e3..d5268cac4 100644 --- a/internal/ceres/generated/partitioned_matrix_view_4_4_2.cc +++ b/internal/ceres/generated/partitioned_matrix_view_4_4_2.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_4_4_3.cc b/internal/ceres/generated/partitioned_matrix_view_4_4_3.cc index 5d4754364..67e098fc6 100644 --- a/internal/ceres/generated/partitioned_matrix_view_4_4_3.cc +++ b/internal/ceres/generated/partitioned_matrix_view_4_4_3.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_4_4_4.cc b/internal/ceres/generated/partitioned_matrix_view_4_4_4.cc index e14f98093..5fe28caee 100644 --- a/internal/ceres/generated/partitioned_matrix_view_4_4_4.cc +++ b/internal/ceres/generated/partitioned_matrix_view_4_4_4.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/partitioned_matrix_view_4_4_d.cc b/internal/ceres/generated/partitioned_matrix_view_4_4_d.cc index 9ec50563a..d87c76d0a 100644 --- a/internal/ceres/generated/partitioned_matrix_view_4_4_d.cc +++ b/internal/ceres/generated/partitioned_matrix_view_4_4_d.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_2_2.cc b/internal/ceres/generated/schur_eliminator_2_2_2.cc index 289a809ac..dc47a2e6d 100644 --- a/internal/ceres/generated/schur_eliminator_2_2_2.cc +++ b/internal/ceres/generated/schur_eliminator_2_2_2.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_2_3.cc b/internal/ceres/generated/schur_eliminator_2_2_3.cc index 20311ba84..e2df6f63d 100644 --- a/internal/ceres/generated/schur_eliminator_2_2_3.cc +++ b/internal/ceres/generated/schur_eliminator_2_2_3.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_2_4.cc b/internal/ceres/generated/schur_eliminator_2_2_4.cc index 1f6a8ae4a..0b1ae949a 100644 --- a/internal/ceres/generated/schur_eliminator_2_2_4.cc +++ b/internal/ceres/generated/schur_eliminator_2_2_4.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_2_d.cc b/internal/ceres/generated/schur_eliminator_2_2_d.cc index 08b18d357..0f7b6d78c 100644 --- a/internal/ceres/generated/schur_eliminator_2_2_d.cc +++ b/internal/ceres/generated/schur_eliminator_2_2_d.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_3_3.cc b/internal/ceres/generated/schur_eliminator_2_3_3.cc index 115b4c8cc..e4ab8eb19 100644 --- a/internal/ceres/generated/schur_eliminator_2_3_3.cc +++ b/internal/ceres/generated/schur_eliminator_2_3_3.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_3_4.cc b/internal/ceres/generated/schur_eliminator_2_3_4.cc index c70353704..d73d466b0 100644 --- a/internal/ceres/generated/schur_eliminator_2_3_4.cc +++ b/internal/ceres/generated/schur_eliminator_2_3_4.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_3_6.cc b/internal/ceres/generated/schur_eliminator_2_3_6.cc index edb9afea9..800ee536b 100644 --- a/internal/ceres/generated/schur_eliminator_2_3_6.cc +++ b/internal/ceres/generated/schur_eliminator_2_3_6.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_3_9.cc b/internal/ceres/generated/schur_eliminator_2_3_9.cc index faa5c19f5..d38cd5660 100644 --- a/internal/ceres/generated/schur_eliminator_2_3_9.cc +++ b/internal/ceres/generated/schur_eliminator_2_3_9.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_3_d.cc b/internal/ceres/generated/schur_eliminator_2_3_d.cc index 81b6f975e..4ac4b8ac8 100644 --- a/internal/ceres/generated/schur_eliminator_2_3_d.cc +++ b/internal/ceres/generated/schur_eliminator_2_3_d.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_4_3.cc b/internal/ceres/generated/schur_eliminator_2_4_3.cc index 2cb2d15ac..d5f5dbea4 100644 --- a/internal/ceres/generated/schur_eliminator_2_4_3.cc +++ b/internal/ceres/generated/schur_eliminator_2_4_3.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_4_4.cc b/internal/ceres/generated/schur_eliminator_2_4_4.cc index a78eff3aa..d50a6d400 100644 --- a/internal/ceres/generated/schur_eliminator_2_4_4.cc +++ b/internal/ceres/generated/schur_eliminator_2_4_4.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_4_6.cc b/internal/ceres/generated/schur_eliminator_2_4_6.cc index e2534f235..f79fa4dd2 100644 --- a/internal/ceres/generated/schur_eliminator_2_4_6.cc +++ b/internal/ceres/generated/schur_eliminator_2_4_6.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_4_8.cc b/internal/ceres/generated/schur_eliminator_2_4_8.cc index 296a46273..972b000f1 100644 --- a/internal/ceres/generated/schur_eliminator_2_4_8.cc +++ b/internal/ceres/generated/schur_eliminator_2_4_8.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_4_9.cc b/internal/ceres/generated/schur_eliminator_2_4_9.cc index 0d0b04e68..aa33e479b 100644 --- a/internal/ceres/generated/schur_eliminator_2_4_9.cc +++ b/internal/ceres/generated/schur_eliminator_2_4_9.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_4_d.cc b/internal/ceres/generated/schur_eliminator_2_4_d.cc index 797992660..a28ef15a5 100644 --- a/internal/ceres/generated/schur_eliminator_2_4_d.cc +++ b/internal/ceres/generated/schur_eliminator_2_4_d.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_2_d_d.cc b/internal/ceres/generated/schur_eliminator_2_d_d.cc index 189be043a..43924279a 100644 --- a/internal/ceres/generated/schur_eliminator_2_d_d.cc +++ b/internal/ceres/generated/schur_eliminator_2_d_d.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_3_3_3.cc b/internal/ceres/generated/schur_eliminator_3_3_3.cc index 35c14a8f4..7ff2a6234 100644 --- a/internal/ceres/generated/schur_eliminator_3_3_3.cc +++ b/internal/ceres/generated/schur_eliminator_3_3_3.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_4_4_2.cc b/internal/ceres/generated/schur_eliminator_4_4_2.cc index 878500a21..9008b8168 100644 --- a/internal/ceres/generated/schur_eliminator_4_4_2.cc +++ b/internal/ceres/generated/schur_eliminator_4_4_2.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_4_4_3.cc b/internal/ceres/generated/schur_eliminator_4_4_3.cc index c4b0959db..8e37df51b 100644 --- a/internal/ceres/generated/schur_eliminator_4_4_3.cc +++ b/internal/ceres/generated/schur_eliminator_4_4_3.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_4_4_4.cc b/internal/ceres/generated/schur_eliminator_4_4_4.cc index 20df53433..09d50813a 100644 --- a/internal/ceres/generated/schur_eliminator_4_4_4.cc +++ b/internal/ceres/generated/schur_eliminator_4_4_4.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/generated/schur_eliminator_4_4_d.cc b/internal/ceres/generated/schur_eliminator_4_4_d.cc index 17368dca4..089df2d7e 100644 --- a/internal/ceres/generated/schur_eliminator_4_4_d.cc +++ b/internal/ceres/generated/schur_eliminator_4_4_d.cc @@ -40,7 +40,7 @@ // This file is generated using generate_template_specializations.py. // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/gradient_checking_cost_function.h b/internal/ceres/gradient_checking_cost_function.h index 786b29f27..0caafafa8 100644 --- a/internal/ceres/gradient_checking_cost_function.h +++ b/internal/ceres/gradient_checking_cost_function.h @@ -37,7 +37,8 @@ #include #include "ceres/cost_function.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/iteration_callback.h" #include "ceres/manifold.h" @@ -48,7 +49,7 @@ class ProblemImpl; // Callback that collects information about gradient checking errors, and // will abort the solve as soon as an error occurs. -class CERES_EXPORT_INTERNAL GradientCheckingIterationCallback +class CERES_NO_EXPORT GradientCheckingIterationCallback : public IterationCallback { public: GradientCheckingIterationCallback(); @@ -74,7 +75,7 @@ class CERES_EXPORT_INTERNAL GradientCheckingIterationCallback // with finite differences. This API is only intended for unit tests that intend // to check the functionality of the GradientCheckingCostFunction // implementation directly. -CERES_EXPORT_INTERNAL std::unique_ptr +CERES_NO_EXPORT std::unique_ptr CreateGradientCheckingCostFunction( const CostFunction* cost_function, const std::vector* manifolds, @@ -102,13 +103,15 @@ CreateGradientCheckingCostFunction( // jacobians obtained by numerically differentiating them. See the // documentation of 'numeric_derivative_relative_step_size' in solver.h for a // better explanation. -CERES_EXPORT_INTERNAL std::unique_ptr -CreateGradientCheckingProblemImpl(ProblemImpl* problem_impl, - double relative_step_size, - double relative_precision, - GradientCheckingIterationCallback* callback); +CERES_NO_EXPORT std::unique_ptr CreateGradientCheckingProblemImpl( + ProblemImpl* problem_impl, + double relative_step_size, + double relative_precision, + GradientCheckingIterationCallback* callback); } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_GRADIENT_CHECKING_COST_FUNCTION_H_ diff --git a/internal/ceres/gradient_problem_evaluator.h b/internal/ceres/gradient_problem_evaluator.h index 86611d059..70b794f55 100644 --- a/internal/ceres/gradient_problem_evaluator.h +++ b/internal/ceres/gradient_problem_evaluator.h @@ -38,14 +38,15 @@ #include "ceres/evaluator.h" #include "ceres/execution_summary.h" #include "ceres/gradient_problem.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/sparse_matrix.h" #include "ceres/wall_time.h" namespace ceres { namespace internal { -class GradientProblemEvaluator : public Evaluator { +class CERES_NO_EXPORT GradientProblemEvaluator : public Evaluator { public: explicit GradientProblemEvaluator(const GradientProblem& problem) : problem_(problem) {} @@ -100,4 +101,6 @@ class GradientProblemEvaluator : public Evaluator { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_GRADIENT_PROBLEM_EVALUATOR_H_ diff --git a/internal/ceres/gradient_problem_solver.cc b/internal/ceres/gradient_problem_solver.cc index 582895da9..9382556d2 100644 --- a/internal/ceres/gradient_problem_solver.cc +++ b/internal/ceres/gradient_problem_solver.cc @@ -36,7 +36,7 @@ #include "ceres/gradient_problem.h" #include "ceres/gradient_problem_evaluator.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/map_util.h" #include "ceres/minimizer.h" #include "ceres/solver.h" diff --git a/internal/ceres/graph.h b/internal/ceres/graph.h index 685b267d3..313474f8a 100644 --- a/internal/ceres/graph.h +++ b/internal/ceres/graph.h @@ -36,6 +36,7 @@ #include #include +#include "ceres/internal/export.h" #include "ceres/map_util.h" #include "ceres/pair_hash.h" #include "ceres/types.h" @@ -47,7 +48,7 @@ namespace internal { // A unweighted undirected graph templated over the vertex ids. Vertex // should be hashable. template -class Graph { +class CERES_NO_EXPORT Graph { public: // Add a vertex. diff --git a/internal/ceres/graph_algorithms.h b/internal/ceres/graph_algorithms.h index 0580a3361..5299f80d9 100644 --- a/internal/ceres/graph_algorithms.h +++ b/internal/ceres/graph_algorithms.h @@ -41,6 +41,7 @@ #include #include "ceres/graph.h" +#include "ceres/internal/export.h" #include "ceres/wall_time.h" #include "glog/logging.h" @@ -50,7 +51,7 @@ namespace internal { // Compare two vertices of a graph by their degrees, if the degrees // are equal then order them by their ids. template -class VertexTotalOrdering { +class CERES_NO_EXPORT VertexTotalOrdering { public: explicit VertexTotalOrdering(const Graph& graph) : graph_(graph) {} diff --git a/internal/ceres/graph_algorithms_test.cc b/internal/ceres/graph_algorithms_test.cc index d5dd02eb8..59232db60 100644 --- a/internal/ceres/graph_algorithms_test.cc +++ b/internal/ceres/graph_algorithms_test.cc @@ -35,7 +35,7 @@ #include #include "ceres/graph.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "gtest/gtest.h" namespace ceres { diff --git a/internal/ceres/implicit_schur_complement.h b/internal/ceres/implicit_schur_complement.h index b0737061f..83e15fe2b 100644 --- a/internal/ceres/implicit_schur_complement.h +++ b/internal/ceres/implicit_schur_complement.h @@ -36,8 +36,9 @@ #include +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/linear_operator.h" #include "ceres/linear_solver.h" #include "ceres/partitioned_matrix_view.h" @@ -88,7 +89,7 @@ class BlockSparseMatrix; // RightMultiply (and the LeftMultiply) methods are not thread safe as // they depend on mutable arrays used for the temporaries needed to // compute the product y += Sx; -class CERES_EXPORT_INTERNAL ImplicitSchurComplement : public LinearOperator { +class CERES_NO_EXPORT ImplicitSchurComplement : public LinearOperator { public: // num_eliminate_blocks is the number of E blocks in the matrix // A. @@ -165,4 +166,6 @@ class CERES_EXPORT_INTERNAL ImplicitSchurComplement : public LinearOperator { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_IMPLICIT_SCHUR_COMPLEMENT_H_ diff --git a/internal/ceres/inner_product_computer.h b/internal/ceres/inner_product_computer.h index abf81be35..c6ed0b23e 100644 --- a/internal/ceres/inner_product_computer.h +++ b/internal/ceres/inner_product_computer.h @@ -36,7 +36,8 @@ #include "ceres/block_sparse_matrix.h" #include "ceres/compressed_row_sparse_matrix.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -61,7 +62,7 @@ namespace internal { // This is not a problem as sparse linear algebra libraries can ignore // these entries with ease and the space used is minimal/linear in the // size of the matrices. -class CERES_EXPORT_INTERNAL InnerProductComputer { +class CERES_NO_EXPORT InnerProductComputer { public: // Factory // @@ -155,4 +156,6 @@ class CERES_EXPORT_INTERNAL InnerProductComputer { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_INNER_PRODUCT_COMPUTER_H_ diff --git a/internal/ceres/is_close.h b/internal/ceres/is_close.h index 82dc7e9d2..498e75e39 100644 --- a/internal/ceres/is_close.h +++ b/internal/ceres/is_close.h @@ -33,7 +33,8 @@ #ifndef CERES_INTERNAL_IS_CLOSE_H_ #define CERES_INTERNAL_IS_CLOSE_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -42,12 +43,14 @@ namespace internal { // difference in relative/absolute_error if non-nullptr. If one of the two values // is exactly zero, the absolute difference will be compared, and relative_error // will be set to the absolute difference. -CERES_EXPORT_INTERNAL bool IsClose(double x, - double y, - double relative_precision, - double* relative_error, - double* absolute_error); +CERES_NO_EXPORT bool IsClose(double x, + double y, + double relative_precision, + double* relative_error, + double* absolute_error); } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_IS_CLOSE_H_ diff --git a/internal/ceres/iterative_refiner.h b/internal/ceres/iterative_refiner.h index 08f8d6762..87e45b141 100644 --- a/internal/ceres/iterative_refiner.h +++ b/internal/ceres/iterative_refiner.h @@ -33,10 +33,11 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clang-format on #include "ceres/internal/eigen.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -57,7 +58,7 @@ class SparseMatrix; // Definite linear systems. // // The above iterative loop is run until max_num_iterations is reached. -class CERES_EXPORT_INTERNAL IterativeRefiner { +class CERES_NO_EXPORT IterativeRefiner { public: // max_num_iterations is the number of refinement iterations to // perform. diff --git a/internal/ceres/iterative_schur_complement_solver.h b/internal/ceres/iterative_schur_complement_solver.h index 909332a54..674a4ff5e 100644 --- a/internal/ceres/iterative_schur_complement_solver.h +++ b/internal/ceres/iterative_schur_complement_solver.h @@ -33,8 +33,9 @@ #include +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" #include "ceres/types.h" @@ -69,7 +70,7 @@ class Preconditioner; // a proof of this fact and others related to this solver please see // the section on Domain Decomposition Methods in Saad's book // "Iterative Methods for Sparse Linear Systems". -class CERES_EXPORT_INTERNAL IterativeSchurComplementSolver +class CERES_NO_EXPORT IterativeSchurComplementSolver : public BlockSparseMatrixSolver { public: explicit IterativeSchurComplementSolver(const LinearSolver::Options& options); @@ -96,4 +97,6 @@ class CERES_EXPORT_INTERNAL IterativeSchurComplementSolver } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_ITERATIVE_SCHUR_COMPLEMENT_SOLVER_H_ diff --git a/internal/ceres/levenberg_marquardt_strategy.h b/internal/ceres/levenberg_marquardt_strategy.h index c67f5ab30..b75c27515 100644 --- a/internal/ceres/levenberg_marquardt_strategy.h +++ b/internal/ceres/levenberg_marquardt_strategy.h @@ -31,8 +31,9 @@ #ifndef CERES_INTERNAL_LEVENBERG_MARQUARDT_STRATEGY_H_ #define CERES_INTERNAL_LEVENBERG_MARQUARDT_STRATEGY_H_ +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/trust_region_strategy.h" namespace ceres { @@ -43,8 +44,7 @@ namespace internal { // K. Madsen, H.B. Nielsen and O. Tingleff. Available to download from // // http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/3215/pdf/imm3215.pdf -class CERES_EXPORT_INTERNAL LevenbergMarquardtStrategy - : public TrustRegionStrategy { +class CERES_NO_EXPORT LevenbergMarquardtStrategy : public TrustRegionStrategy { public: explicit LevenbergMarquardtStrategy( const TrustRegionStrategy::Options& options); @@ -86,4 +86,6 @@ class CERES_EXPORT_INTERNAL LevenbergMarquardtStrategy } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_LEVENBERG_MARQUARDT_STRATEGY_H_ diff --git a/internal/ceres/line_search.h b/internal/ceres/line_search.h index 958d71d2c..b194fee34 100644 --- a/internal/ceres/line_search.h +++ b/internal/ceres/line_search.h @@ -39,7 +39,7 @@ #include "ceres/function_sample.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/types.h" namespace ceres { @@ -58,11 +58,11 @@ class LineSearchFunction; // sufficient decrease condition. Depending on the particular // condition used, we get a variety of different line search // algorithms, e.g., Armijo, Wolfe etc. -class LineSearch { +class CERES_NO_EXPORT LineSearch { public: struct Summary; - struct Options { + struct CERES_NO_EXPORT Options { // Degree of the polynomial used to approximate the objective // function. LineSearchInterpolationType interpolation_type = CUBIC; @@ -210,7 +210,7 @@ class LineSearch { // In practice, this object provides access to the objective // function value and the directional derivative of the underlying // optimization problem along a specific search direction. -class LineSearchFunction { +class CERES_NO_EXPORT LineSearchFunction { public: explicit LineSearchFunction(Evaluator* evaluator); void Init(const Vector& position, const Vector& direction); @@ -259,7 +259,7 @@ class LineSearchFunction { // minFunc package by Mark Schmidt. // // For more details: http://www.di.ens.fr/~mschmidt/Software/minFunc.html -class ArmijoLineSearch : public LineSearch { +class CERES_NO_EXPORT ArmijoLineSearch : public LineSearch { public: explicit ArmijoLineSearch(const LineSearch::Options& options); @@ -277,7 +277,7 @@ class ArmijoLineSearch : public LineSearch { // // [1] Nocedal J., Wright S., Numerical Optimization, 2nd Ed., Springer, 1999. // [2] http://www.di.ens.fr/~mschmidt/Software/minFunc.html. -class WolfeLineSearch : public LineSearch { +class CERES_NO_EXPORT WolfeLineSearch : public LineSearch { public: explicit WolfeLineSearch(const LineSearch::Options& options); diff --git a/internal/ceres/line_search_direction.cc b/internal/ceres/line_search_direction.cc index 274a52168..90ae14947 100644 --- a/internal/ceres/line_search_direction.cc +++ b/internal/ceres/line_search_direction.cc @@ -33,6 +33,7 @@ #include #include "ceres/internal/eigen.h" +#include "ceres/internal/export.h" #include "ceres/line_search_minimizer.h" #include "ceres/low_rank_inverse_hessian.h" #include "glog/logging.h" @@ -40,7 +41,7 @@ namespace ceres { namespace internal { -class SteepestDescent : public LineSearchDirection { +class CERES_NO_EXPORT SteepestDescent : public LineSearchDirection { public: bool NextDirection(const LineSearchMinimizer::State& previous, const LineSearchMinimizer::State& current, @@ -50,7 +51,7 @@ class SteepestDescent : public LineSearchDirection { } }; -class NonlinearConjugateGradient : public LineSearchDirection { +class CERES_NO_EXPORT NonlinearConjugateGradient : public LineSearchDirection { public: NonlinearConjugateGradient(const NonlinearConjugateGradientType type, const double function_tolerance) @@ -96,7 +97,7 @@ class NonlinearConjugateGradient : public LineSearchDirection { const double function_tolerance_; }; -class LBFGS : public LineSearchDirection { +class CERES_NO_EXPORT LBFGS : public LineSearchDirection { public: LBFGS(const int num_parameters, const int max_lbfgs_rank, @@ -140,7 +141,7 @@ class LBFGS : public LineSearchDirection { bool is_positive_definite_; }; -class BFGS : public LineSearchDirection { +class CERES_NO_EXPORT BFGS : public LineSearchDirection { public: BFGS(const int num_parameters, const bool use_approximate_eigenvalue_scaling) : num_parameters_(num_parameters), diff --git a/internal/ceres/line_search_direction.h b/internal/ceres/line_search_direction.h index 0394c7e7d..be7497e22 100644 --- a/internal/ceres/line_search_direction.h +++ b/internal/ceres/line_search_direction.h @@ -34,13 +34,14 @@ #include #include "ceres/internal/eigen.h" +#include "ceres/internal/export.h" #include "ceres/line_search_minimizer.h" #include "ceres/types.h" namespace ceres { namespace internal { -class LineSearchDirection { +class CERES_NO_EXPORT LineSearchDirection { public: struct Options { Options() diff --git a/internal/ceres/line_search_minimizer.cc b/internal/ceres/line_search_minimizer.cc index 6768d4b19..ad1e18523 100644 --- a/internal/ceres/line_search_minimizer.cc +++ b/internal/ceres/line_search_minimizer.cc @@ -51,7 +51,7 @@ #include "ceres/array_utils.h" #include "ceres/evaluator.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/line_search.h" #include "ceres/line_search_direction.h" #include "ceres/stringprintf.h" diff --git a/internal/ceres/line_search_minimizer.h b/internal/ceres/line_search_minimizer.h index 75928f898..c5cc9ddb6 100644 --- a/internal/ceres/line_search_minimizer.h +++ b/internal/ceres/line_search_minimizer.h @@ -32,6 +32,7 @@ #define CERES_INTERNAL_LINE_SEARCH_MINIMIZER_H_ #include "ceres/internal/eigen.h" +#include "ceres/internal/export.h" #include "ceres/minimizer.h" #include "ceres/solver.h" #include "ceres/types.h" @@ -43,7 +44,7 @@ namespace internal { // Generic line search minimization algorithm. // // For example usage, see SolverImpl::Minimize. -class LineSearchMinimizer : public Minimizer { +class CERES_NO_EXPORT LineSearchMinimizer : public Minimizer { public: struct State { State(int num_parameters, int num_effective_parameters) diff --git a/internal/ceres/line_search_preprocessor.h b/internal/ceres/line_search_preprocessor.h index cdce43869..4cb7d6890 100644 --- a/internal/ceres/line_search_preprocessor.h +++ b/internal/ceres/line_search_preprocessor.h @@ -31,13 +31,14 @@ #ifndef CERES_INTERNAL_LINE_SEARCH_PREPROCESSOR_H_ #define CERES_INTERNAL_LINE_SEARCH_PREPROCESSOR_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/preprocessor.h" namespace ceres { namespace internal { -class CERES_EXPORT_INTERNAL LineSearchPreprocessor : public Preprocessor { +class CERES_NO_EXPORT LineSearchPreprocessor : public Preprocessor { public: bool Preprocess(const Solver::Options& options, ProblemImpl* problem, @@ -47,4 +48,6 @@ class CERES_EXPORT_INTERNAL LineSearchPreprocessor : public Preprocessor { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_LINE_SEARCH_PREPROCESSOR_H_ diff --git a/internal/ceres/linear_least_squares_problems.h b/internal/ceres/linear_least_squares_problems.h index 2120cc290..35ba24635 100644 --- a/internal/ceres/linear_least_squares_problems.h +++ b/internal/ceres/linear_least_squares_problems.h @@ -35,7 +35,8 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/sparse_matrix.h" namespace ceres { @@ -43,7 +44,7 @@ namespace internal { // Structure defining a linear least squares problem and if possible // ground truth solutions. To be used by various LinearSolver tests. -struct CERES_EXPORT_INTERNAL LinearLeastSquaresProblem { +struct CERES_NO_EXPORT LinearLeastSquaresProblem { LinearLeastSquaresProblem() : num_eliminate_blocks(0) {} std::unique_ptr A; @@ -60,17 +61,23 @@ struct CERES_EXPORT_INTERNAL LinearLeastSquaresProblem { }; // Factories for linear least squares problem. -CERES_EXPORT_INTERNAL std::unique_ptr +CERES_NO_EXPORT std::unique_ptr CreateLinearLeastSquaresProblemFromId(int id); +CERES_NO_EXPORT std::unique_ptr LinearLeastSquaresProblem0(); +CERES_NO_EXPORT std::unique_ptr LinearLeastSquaresProblem1(); +CERES_NO_EXPORT std::unique_ptr LinearLeastSquaresProblem2(); +CERES_NO_EXPORT std::unique_ptr LinearLeastSquaresProblem3(); +CERES_NO_EXPORT std::unique_ptr LinearLeastSquaresProblem4(); // Write the linear least squares problem to disk. The exact format // depends on dump_format_type. +CERES_NO_EXPORT bool DumpLinearLeastSquaresProblem(const std::string& filename_base, DumpFormatType dump_format_type, const SparseMatrix* A, @@ -81,4 +88,6 @@ bool DumpLinearLeastSquaresProblem(const std::string& filename_base, } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_LINEAR_LEAST_SQUARES_PROBLEMS_H_ diff --git a/internal/ceres/linear_operator.h b/internal/ceres/linear_operator.h index 9c59fc39c..c9e6188e2 100644 --- a/internal/ceres/linear_operator.h +++ b/internal/ceres/linear_operator.h @@ -33,7 +33,7 @@ #ifndef CERES_INTERNAL_LINEAR_OPERATOR_H_ #define CERES_INTERNAL_LINEAR_OPERATOR_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/types.h" namespace ceres { @@ -41,7 +41,7 @@ namespace internal { // This is an abstract base class for linear operators. It supports // access to size information and left and right multiply operators. -class CERES_EXPORT_INTERNAL LinearOperator { +class CERES_NO_EXPORT LinearOperator { public: virtual ~LinearOperator(); diff --git a/internal/ceres/linear_solver.h b/internal/ceres/linear_solver.h index 0ecc35cd5..962208cda 100644 --- a/internal/ceres/linear_solver.h +++ b/internal/ceres/linear_solver.h @@ -46,7 +46,8 @@ #include "ceres/context_impl.h" #include "ceres/dense_sparse_matrix.h" #include "ceres/execution_summary.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/triplet_sparse_matrix.h" #include "ceres/types.h" #include "glog/logging.h" @@ -102,7 +103,7 @@ class LinearOperator; // The Options struct configures the LinearSolver object for its // lifetime. The PerSolveOptions struct is used to specify options for // a particular Solve call. -class CERES_EXPORT_INTERNAL LinearSolver { +class CERES_NO_EXPORT LinearSolver { public: struct Options { LinearSolverType type = SPARSE_NORMAL_CHOLESKY; @@ -340,4 +341,6 @@ typedef TypedLinearSolver TripletSparseMatrixSolver; } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_LINEAR_SOLVER_H_ diff --git a/internal/ceres/low_rank_inverse_hessian.h b/internal/ceres/low_rank_inverse_hessian.h index 00414b7f6..9a7497296 100644 --- a/internal/ceres/low_rank_inverse_hessian.h +++ b/internal/ceres/low_rank_inverse_hessian.h @@ -37,6 +37,7 @@ #include #include "ceres/internal/eigen.h" +#include "ceres/internal/export.h" #include "ceres/linear_operator.h" namespace ceres { @@ -59,7 +60,7 @@ namespace internal { // Byrd, R. H.; Nocedal, J.; Schnabel, R. B. (1994). // "Representations of Quasi-Newton Matrices and their use in // Limited Memory Methods". Mathematical Programming 63 (4): -class LowRankInverseHessian : public LinearOperator { +class CERES_NO_EXPORT LowRankInverseHessian : public LinearOperator { public: // num_parameters is the row/column size of the Hessian. // max_num_corrections is the rank of the Hessian approximation. diff --git a/internal/ceres/manifold_adapter.h b/internal/ceres/manifold_adapter.h index 5aa2005f8..c61234974 100644 --- a/internal/ceres/manifold_adapter.h +++ b/internal/ceres/manifold_adapter.h @@ -1,3 +1,4 @@ +#include "ceres/internal/export.h" #include "ceres/local_parameterization.h" #include "ceres/manifold.h" #include "glog/logging.h" @@ -8,7 +9,7 @@ namespace internal { // Adapter to wrap LocalParameterization and make them look like Manifolds. // // ManifoldAdapter NEVER takes ownership of local_parameterization. -class ManifoldAdapter : public Manifold { +class CERES_NO_EXPORT ManifoldAdapter : public Manifold { public: ManifoldAdapter(const LocalParameterization* local_parameterization) : local_parameterization_(local_parameterization) { diff --git a/internal/ceres/map_util.h b/internal/ceres/map_util.h index 6e310f8db..bb6241da5 100644 --- a/internal/ceres/map_util.h +++ b/internal/ceres/map_util.h @@ -35,7 +35,7 @@ #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "glog/logging.h" namespace ceres { diff --git a/internal/ceres/miniglog/glog/logging.h b/internal/ceres/miniglog/glog/logging.h index 8f95e09f2..23bb614bb 100644 --- a/internal/ceres/miniglog/glog/logging.h +++ b/internal/ceres/miniglog/glog/logging.h @@ -105,11 +105,6 @@ #include #include -// For appropriate definition of CERES_EXPORT macro. -// clang-format off -#include "ceres/internal/port.h" -// clang-format on - #include "ceres/internal/disable_warnings.h" // Log severity level constants. @@ -136,7 +131,7 @@ const int FATAL = ::FATAL; // added, all log output is also sent to each sink through the send function. // In this implementation, WaitTillSent() is called immediately after the send. // This implementation is not thread safe. -class CERES_EXPORT LogSink { +class CERES_NO_EXPORT LogSink { public: virtual ~LogSink() = default; virtual void send(LogSeverity severity, @@ -150,7 +145,7 @@ class CERES_EXPORT LogSink { }; // Global set of log sinks. The actual object is defined in logging.cc. -extern CERES_EXPORT std::set log_sinks_global; +extern CERES_NO_EXPORT std::set log_sinks_global; inline void InitGoogleLogging(const char* /* argv */) { // Do nothing; this is ignored. @@ -173,7 +168,7 @@ inline void RemoveLogSink(LogSink* sink) { log_sinks_global.erase(sink); } // defined, output is directed to std::cerr. This class should not // be directly instantiated in code, rather it should be invoked through the // use of the log macros LG, LOG, or VLOG. -class CERES_EXPORT MessageLogger { +class CERES_NO_EXPORT MessageLogger { public: MessageLogger(const char* file, int line, const char* tag, int severity) : file_(file), line_(line), tag_(tag), severity_(severity) { @@ -292,7 +287,7 @@ class CERES_EXPORT MessageLogger { // This class is used to explicitly ignore values in the conditional // logging macros. This avoids compiler warnings like "value computed // is not used" and "statement has no effect". -class CERES_EXPORT LoggerVoidify { +class CERES_NO_EXPORT LoggerVoidify { public: // This has to be an operator with a precedence lower than << but // higher than ?: diff --git a/internal/ceres/minimizer.h b/internal/ceres/minimizer.h index 326b325cf..c2c1f71df 100644 --- a/internal/ceres/minimizer.h +++ b/internal/ceres/minimizer.h @@ -35,7 +35,8 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/iteration_callback.h" #include "ceres/solver.h" @@ -49,7 +50,7 @@ class CoordinateDescentMinimizer; class LinearSolver; // Interface for non-linear least squares solvers. -class CERES_EXPORT_INTERNAL Minimizer { +class CERES_NO_EXPORT Minimizer { public: // Options struct to control the behaviour of the Minimizer. Please // see solver.h for detailed information about the meaning and @@ -195,4 +196,6 @@ class CERES_EXPORT_INTERNAL Minimizer { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_MINIMIZER_H_ diff --git a/internal/ceres/numeric_diff_test_utils.h b/internal/ceres/numeric_diff_test_utils.h index 392636e18..742ab6b89 100644 --- a/internal/ceres/numeric_diff_test_utils.h +++ b/internal/ceres/numeric_diff_test_utils.h @@ -32,7 +32,7 @@ #define CERES_INTERNAL_NUMERIC_DIFF_TEST_UTILS_H_ #include "ceres/cost_function.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/sized_cost_function.h" #include "ceres/types.h" @@ -48,7 +48,7 @@ static constexpr unsigned int kRandomSeed = 1234; // y1 = x1'x2 -> dy1/dx1 = x2, dy1/dx2 = x1 // y2 = (x1'x2)^2 -> dy2/dx1 = 2 * x2 * (x1'x2), dy2/dx2 = 2 * x1 * (x1'x2) // y3 = x2'x2 -> dy3/dx1 = 0, dy3/dx2 = 2 * x2 -class CERES_EXPORT_INTERNAL EasyFunctor { +class CERES_NO_EXPORT EasyFunctor { public: bool operator()(const double* x1, const double* x2, double* residuals) const; void ExpectCostFunctionEvaluationIsNearlyCorrect( @@ -72,14 +72,14 @@ class EasyCostFunction : public SizedCostFunction<3, 5, 5> { // // dy1/dx1 = x2 * cos(x1'x2), dy1/dx2 = x1 * cos(x1'x2) // dy2/dx1 = -x2 * exp(-x1'x2 / 10) / 10, dy2/dx2 = -x2 * exp(-x1'x2 / 10) / 10 -class CERES_EXPORT TranscendentalFunctor { +class CERES_NO_EXPORT TranscendentalFunctor { public: bool operator()(const double* x1, const double* x2, double* residuals) const; void ExpectCostFunctionEvaluationIsNearlyCorrect( const CostFunction& cost_function, NumericDiffMethodType method) const; }; -class CERES_EXPORT_INTERNAL TranscendentalCostFunction +class CERES_EXPORT TranscendentalCostFunction : public SizedCostFunction<2, 5, 5> { public: bool Evaluate(double const* const* parameters, @@ -93,7 +93,7 @@ class CERES_EXPORT_INTERNAL TranscendentalCostFunction }; // y = exp(x), dy/dx = exp(x) -class CERES_EXPORT_INTERNAL ExponentialFunctor { +class CERES_NO_EXPORT ExponentialFunctor { public: bool operator()(const double* x1, double* residuals) const; void ExpectCostFunctionEvaluationIsNearlyCorrect( @@ -115,7 +115,7 @@ class ExponentialCostFunction : public SizedCostFunction<1, 1> { // Test adaptive numeric differentiation by synthetically adding random noise // to a functor. // y = x^2 + [random noise], dy/dx ~ 2x -class CERES_EXPORT_INTERNAL RandomizedFunctor { +class CERES_NO_EXPORT RandomizedFunctor { public: RandomizedFunctor(double noise_factor, unsigned int random_seed) : noise_factor_(noise_factor), random_seed_(random_seed) {} @@ -129,8 +129,7 @@ class CERES_EXPORT_INTERNAL RandomizedFunctor { unsigned int random_seed_; }; -class CERES_EXPORT_INTERNAL RandomizedCostFunction - : public SizedCostFunction<1, 1> { +class CERES_EXPORT RandomizedCostFunction : public SizedCostFunction<1, 1> { public: RandomizedCostFunction(double noise_factor, unsigned int random_seed) : functor_(noise_factor, random_seed) {} diff --git a/internal/ceres/pair_hash.h b/internal/ceres/pair_hash.h index abbedccf9..1e7ddeb49 100644 --- a/internal/ceres/pair_hash.h +++ b/internal/ceres/pair_hash.h @@ -36,7 +36,7 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { diff --git a/internal/ceres/parallel_for.h b/internal/ceres/parallel_for.h index b64bd3106..af6eadb0d 100644 --- a/internal/ceres/parallel_for.h +++ b/internal/ceres/parallel_for.h @@ -34,31 +34,32 @@ #include #include "ceres/context_impl.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { // Returns the maximum number of threads supported by the threading backend // Ceres was compiled with. +CERES_NO_EXPORT int MaxNumThreadsAvailable(); // Execute the function for every element in the range [start, end) with at most // num_threads. It will execute all the work on the calling thread if // num_threads is 1. -CERES_EXPORT_INTERNAL void ParallelFor( - ContextImpl* context, - int start, - int end, - int num_threads, - const std::function& function); +CERES_NO_EXPORT void ParallelFor(ContextImpl* context, + int start, + int end, + int num_threads, + const std::function& function); // Execute the function for every element in the range [start, end) with at most // num_threads. It will execute all the work on the calling thread if // num_threads is 1. Each invocation of function() will be passed a thread_id // in [0, num_threads) that is guaranteed to be distinct from the value passed // to any concurrent execution of function(). -CERES_EXPORT_INTERNAL void ParallelFor( +CERES_NO_EXPORT void ParallelFor( ContextImpl* context, int start, int end, @@ -67,4 +68,6 @@ CERES_EXPORT_INTERNAL void ParallelFor( } // namespace internal } // namespace ceres +#include "ceres/internal/disable_warnings.h" + #endif // CERES_INTERNAL_PARALLEL_FOR_H_ diff --git a/internal/ceres/parallel_for_cxx.cc b/internal/ceres/parallel_for_cxx.cc index a697d8039..5b78db19a 100644 --- a/internal/ceres/parallel_for_cxx.cc +++ b/internal/ceres/parallel_for_cxx.cc @@ -29,7 +29,7 @@ // Author: vitus@google.com (Michael Vitus) // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifdef CERES_USE_CXX_THREADS diff --git a/internal/ceres/parallel_for_nothreads.cc b/internal/ceres/parallel_for_nothreads.cc index 79314450f..1c1871662 100644 --- a/internal/ceres/parallel_for_nothreads.cc +++ b/internal/ceres/parallel_for_nothreads.cc @@ -29,7 +29,7 @@ // Author: alexs.mac@gmail.com (Alex Stewart) // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifdef CERES_NO_THREADS diff --git a/internal/ceres/parallel_for_openmp.cc b/internal/ceres/parallel_for_openmp.cc index 882f244f3..1d44bf997 100644 --- a/internal/ceres/parallel_for_openmp.cc +++ b/internal/ceres/parallel_for_openmp.cc @@ -29,7 +29,7 @@ // Author: vitus@google.com (Michael Vitus) // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #if defined(CERES_USE_OPENMP) diff --git a/internal/ceres/parallel_for_test.cc b/internal/ceres/parallel_for_test.cc index 434f99344..b6eb5dcd0 100644 --- a/internal/ceres/parallel_for_test.cc +++ b/internal/ceres/parallel_for_test.cc @@ -30,7 +30,7 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clang-format on #include "ceres/parallel_for.h" diff --git a/internal/ceres/parallel_utils.h b/internal/ceres/parallel_utils.h index 89d21106d..b2d9e0da7 100644 --- a/internal/ceres/parallel_utils.h +++ b/internal/ceres/parallel_utils.h @@ -31,7 +31,7 @@ #ifndef CERES_INTERNAL_PARALLEL_UTILS_H_ #define CERES_INTERNAL_PARALLEL_UTILS_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -61,10 +61,10 @@ namespace internal { // }); // which in each iteration will produce i and j satisfying // 0 <= i <= j < n -CERES_EXPORT_INTERNAL void LinearIndexToUpperTriangularIndex(int k, - int n, - int* i, - int* j); +CERES_NO_EXPORT void LinearIndexToUpperTriangularIndex(int k, + int n, + int* i, + int* j); } // namespace internal } // namespace ceres diff --git a/internal/ceres/parallel_utils_test.cc b/internal/ceres/parallel_utils_test.cc index 53870bbf1..4d5a3f636 100644 --- a/internal/ceres/parallel_utils_test.cc +++ b/internal/ceres/parallel_utils_test.cc @@ -30,7 +30,7 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clang-format on #include "ceres/parallel_utils.h" diff --git a/internal/ceres/parameter_block.h b/internal/ceres/parameter_block.h index 304b76986..ff238fb5d 100644 --- a/internal/ceres/parameter_block.h +++ b/internal/ceres/parameter_block.h @@ -40,8 +40,9 @@ #include #include "ceres/array_utils.h" +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/manifold.h" #include "ceres/stringprintf.h" #include "glog/logging.h" @@ -61,7 +62,7 @@ class ResidualBlock; // parameter block may also hold a pointer to a manifold; the parameter block // does not take ownership of this pointer, so the user is responsible for the // proper disposal of the manifold. -class ParameterBlock { +class CERES_NO_EXPORT ParameterBlock { public: typedef std::unordered_set ResidualBlockSet; @@ -384,4 +385,6 @@ class ParameterBlock { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_PARAMETER_BLOCK_H_ diff --git a/internal/ceres/parameter_block_ordering.h b/internal/ceres/parameter_block_ordering.h index d9b321004..f9a447adf 100644 --- a/internal/ceres/parameter_block_ordering.h +++ b/internal/ceres/parameter_block_ordering.h @@ -35,7 +35,8 @@ #include #include "ceres/graph.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/ordered_groups.h" #include "ceres/types.h" @@ -58,20 +59,20 @@ class ParameterBlock; // ordering = [independent set, // complement of the independent set, // fixed blocks] -CERES_EXPORT_INTERNAL int ComputeSchurOrdering( +CERES_NO_EXPORT int ComputeSchurOrdering( const Program& program, std::vector* ordering); // Same as above, except that ties while computing the independent set // ordering are resolved in favour of the order in which the parameter // blocks occur in the program. -CERES_EXPORT_INTERNAL int ComputeStableSchurOrdering( +CERES_NO_EXPORT int ComputeStableSchurOrdering( const Program& program, std::vector* ordering); // Use an approximate independent set ordering to decompose the // parameter blocks of a problem in a sequence of independent // sets. The ordering covers all the non-constant parameter blocks in // the program. -CERES_EXPORT_INTERNAL void ComputeRecursiveIndependentSetOrdering( +CERES_NO_EXPORT void ComputeRecursiveIndependentSetOrdering( const Program& program, ParameterBlockOrdering* ordering); // Builds a graph on the parameter blocks of a Problem, whose @@ -79,15 +80,17 @@ CERES_EXPORT_INTERNAL void ComputeRecursiveIndependentSetOrdering( // vertex corresponds to a parameter block in the Problem except for // parameter blocks that are marked constant. An edge connects two // parameter blocks, if they co-occur in a residual block. -CERES_EXPORT_INTERNAL std::unique_ptr> -CreateHessianGraph(const Program& program); +CERES_NO_EXPORT std::unique_ptr> CreateHessianGraph( + const Program& program); // Iterate over each of the groups in order of their priority and fill // summary with their sizes. -CERES_EXPORT_INTERNAL void OrderingToGroupSizes( +CERES_NO_EXPORT void OrderingToGroupSizes( const ParameterBlockOrdering* ordering, std::vector* group_sizes); } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_PARAMETER_BLOCK_ORDERING_H_ diff --git a/internal/ceres/partitioned_matrix_view.h b/internal/ceres/partitioned_matrix_view.h index b7b6a918d..dc2ef1897 100644 --- a/internal/ceres/partitioned_matrix_view.h +++ b/internal/ceres/partitioned_matrix_view.h @@ -42,8 +42,9 @@ #include #include "ceres/block_structure.h" +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" #include "ceres/small_blas.h" #include "glog/logging.h" @@ -61,7 +62,7 @@ namespace internal { // block structure of the matrix does not satisfy the requirements of // the Schur complement solver it will result in unpredictable and // wrong output. -class CERES_EXPORT_INTERNAL PartitionedMatrixViewBase { +class CERES_NO_EXPORT PartitionedMatrixViewBase { public: virtual ~PartitionedMatrixViewBase(); @@ -116,7 +117,7 @@ class CERES_EXPORT_INTERNAL PartitionedMatrixViewBase { template -class PartitionedMatrixView : public PartitionedMatrixViewBase { +class CERES_NO_EXPORT PartitionedMatrixView : public PartitionedMatrixViewBase { public: // matrix = [E F], where the matrix E contains the first // num_col_blocks_a column blocks. @@ -154,4 +155,6 @@ class PartitionedMatrixView : public PartitionedMatrixViewBase { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_PARTITIONED_MATRIX_VIEW_H_ diff --git a/internal/ceres/partitioned_matrix_view_template.py b/internal/ceres/partitioned_matrix_view_template.py index b0ca6b9d4..a19708364 100644 --- a/internal/ceres/partitioned_matrix_view_template.py +++ b/internal/ceres/partitioned_matrix_view_template.py @@ -104,7 +104,7 @@ template class PartitionedMatrixView<%s, SPECIALIZATION_FILE = """ // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/polynomial.cc b/internal/ceres/polynomial.cc index feb12227d..c263f98fb 100644 --- a/internal/ceres/polynomial.cc +++ b/internal/ceres/polynomial.cc @@ -37,7 +37,7 @@ #include "Eigen/Dense" #include "ceres/function_sample.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "glog/logging.h" namespace ceres { diff --git a/internal/ceres/polynomial.h b/internal/ceres/polynomial.h index 3d43284cf..236533f09 100644 --- a/internal/ceres/polynomial.h +++ b/internal/ceres/polynomial.h @@ -34,8 +34,9 @@ #include +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -49,6 +50,7 @@ struct FunctionSample; // and are given by a vector of coefficients of size N + 1. // Evaluate the polynomial at x using the Horner scheme. +CERES_NO_EXPORT inline double EvaluatePolynomial(const Vector& polynomial, double x) { double v = 0.0; for (int i = 0; i < polynomial.size(); ++i) { @@ -66,13 +68,13 @@ inline double EvaluatePolynomial(const Vector& polynomial, double x) { // On failure, a more detailed message will be written to LOG(ERROR). // If real is not nullptr, the real parts of the roots will be returned in it. // Likewise, if imaginary is not nullptr, imaginary parts will be returned in it. -CERES_EXPORT_INTERNAL bool FindPolynomialRoots(const Vector& polynomial, - Vector* real, - Vector* imaginary); +CERES_NO_EXPORT bool FindPolynomialRoots(const Vector& polynomial, + Vector* real, + Vector* imaginary); // Return the derivative of the given polynomial. It is assumed that // the input polynomial is at least of degree zero. -CERES_EXPORT_INTERNAL Vector DifferentiatePolynomial(const Vector& polynomial); +CERES_NO_EXPORT Vector DifferentiatePolynomial(const Vector& polynomial); // Find the minimum value of the polynomial in the interval [x_min, // x_max]. The minimum is obtained by computing all the roots of the @@ -80,11 +82,11 @@ CERES_EXPORT_INTERNAL Vector DifferentiatePolynomial(const Vector& polynomial); // interval [x_min, x_max] are considered as well as the end points // x_min and x_max. Since polynomials are differentiable functions, // this ensures that the true minimum is found. -CERES_EXPORT_INTERNAL void MinimizePolynomial(const Vector& polynomial, - double x_min, - double x_max, - double* optimal_x, - double* optimal_value); +CERES_NO_EXPORT void MinimizePolynomial(const Vector& polynomial, + double x_min, + double x_max, + double* optimal_x, + double* optimal_value); // Given a set of function value and/or gradient samples, find a // polynomial whose value and gradients are exactly equal to the ones @@ -97,7 +99,7 @@ CERES_EXPORT_INTERNAL void MinimizePolynomial(const Vector& polynomial, // Of course its possible to sample a polynomial any number of times, // in which case, generally speaking the spurious higher order // coefficients will be zero. -CERES_EXPORT_INTERNAL Vector +CERES_NO_EXPORT Vector FindInterpolatingPolynomial(const std::vector& samples); // Interpolate the function described by samples with a polynomial, @@ -106,7 +108,7 @@ FindInterpolatingPolynomial(const std::vector& samples); // finding algorithms may fail due to numerical difficulties. But the // function is guaranteed to return its best guess of an answer, by // considering the samples and the end points as possible solutions. -CERES_EXPORT_INTERNAL void MinimizeInterpolatingPolynomial( +CERES_NO_EXPORT void MinimizeInterpolatingPolynomial( const std::vector& samples, double x_min, double x_max, @@ -116,4 +118,6 @@ CERES_EXPORT_INTERNAL void MinimizeInterpolatingPolynomial( } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_POLYNOMIAL_SOLVER_H_ diff --git a/internal/ceres/preconditioner.h b/internal/ceres/preconditioner.h index 04dffefdd..d309e4fae 100644 --- a/internal/ceres/preconditioner.h +++ b/internal/ceres/preconditioner.h @@ -36,7 +36,8 @@ #include "ceres/casts.h" #include "ceres/compressed_row_sparse_matrix.h" #include "ceres/context_impl.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/linear_operator.h" #include "ceres/sparse_matrix.h" #include "ceres/types.h" @@ -47,7 +48,7 @@ namespace internal { class BlockSparseMatrix; class SparseMatrix; -class CERES_EXPORT_INTERNAL Preconditioner : public LinearOperator { +class CERES_NO_EXPORT Preconditioner : public LinearOperator { public: struct Options { PreconditionerType type = JACOBI; @@ -147,7 +148,7 @@ class CERES_EXPORT_INTERNAL Preconditioner : public LinearOperator { // other preconditioners that depend on the particular matrix layout of // the underlying linear operator. template -class TypedPreconditioner : public Preconditioner { +class CERES_NO_EXPORT TypedPreconditioner : public Preconditioner { public: bool Update(const LinearOperator& A, const double* D) final { return UpdateImpl(*down_cast(&A), D); @@ -166,7 +167,8 @@ typedef TypedPreconditioner CompressedRowSparseMatrix // clang-format on // Wrap a SparseMatrix object as a preconditioner. -class SparseMatrixPreconditionerWrapper : public SparseMatrixPreconditioner { +class CERES_NO_EXPORT SparseMatrixPreconditionerWrapper + : public SparseMatrixPreconditioner { public: // Wrapper does NOT take ownership of the matrix pointer. explicit SparseMatrixPreconditionerWrapper(const SparseMatrix* matrix); @@ -184,4 +186,6 @@ class SparseMatrixPreconditionerWrapper : public SparseMatrixPreconditioner { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_PRECONDITIONER_H_ diff --git a/internal/ceres/preprocessor.h b/internal/ceres/preprocessor.h index 7dc74ccb9..8b99dd54e 100644 --- a/internal/ceres/preprocessor.h +++ b/internal/ceres/preprocessor.h @@ -37,8 +37,9 @@ #include "ceres/coordinate_descent_minimizer.h" #include "ceres/evaluator.h" +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/iteration_callback.h" #include "ceres/linear_solver.h" #include "ceres/minimizer.h" @@ -67,7 +68,7 @@ struct PreprocessedProblem; // // The output of the Preprocessor is stored in a PreprocessedProblem // object. -class CERES_EXPORT_INTERNAL Preprocessor { +class CERES_NO_EXPORT Preprocessor { public: // Factory. static std::unique_ptr Create(MinimizerType minimizer_type); @@ -79,7 +80,7 @@ class CERES_EXPORT_INTERNAL Preprocessor { // A PreprocessedProblem is the result of running the Preprocessor on // a Problem and Solver::Options object. -struct PreprocessedProblem { +struct CERES_NO_EXPORT PreprocessedProblem { PreprocessedProblem() : fixed_cost(0.0) {} std::string error; @@ -108,14 +109,18 @@ struct PreprocessedProblem { // If the user has specified a num_threads > the maximum number of threads // available from the compiled threading model, bound the number of threads // to the maximum. +CERES_NO_EXPORT void ChangeNumThreadsIfNeeded(Solver::Options* options); // Extract the effective parameter vector from the preprocessed // problem and setup bits of the Minimizer::Options object that are // common to all Preprocessors. +CERES_NO_EXPORT void SetupCommonMinimizerOptions(PreprocessedProblem* pp); } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_PREPROCESSOR_H_ diff --git a/internal/ceres/problem_impl.cc b/internal/ceres/problem_impl.cc index f256aab6d..27ada0ff0 100644 --- a/internal/ceres/problem_impl.cc +++ b/internal/ceres/problem_impl.cc @@ -49,8 +49,8 @@ #include "ceres/crs_matrix.h" #include "ceres/evaluation_callback.h" #include "ceres/evaluator.h" +#include "ceres/internal/export.h" #include "ceres/internal/fixed_array.h" -#include "ceres/internal/port.h" #include "ceres/loss_function.h" #include "ceres/manifold.h" #include "ceres/manifold_adapter.h" diff --git a/internal/ceres/problem_impl.h b/internal/ceres/problem_impl.h index 9a0c4f86f..921bb4e8b 100644 --- a/internal/ceres/problem_impl.h +++ b/internal/ceres/problem_impl.h @@ -47,6 +47,8 @@ #include #include "ceres/context_impl.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/internal/port.h" #include "ceres/manifold.h" #include "ceres/problem.h" @@ -65,7 +67,7 @@ namespace internal { class Program; class ResidualBlock; -class CERES_EXPORT_INTERNAL ProblemImpl { +class CERES_NO_EXPORT ProblemImpl { public: typedef std::map ParameterMap; typedef std::unordered_set ResidualBlockSet; @@ -250,4 +252,6 @@ class CERES_EXPORT_INTERNAL ProblemImpl { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_PUBLIC_PROBLEM_IMPL_H_ diff --git a/internal/ceres/program.cc b/internal/ceres/program.cc index e65ffcd6f..d9e6db248 100644 --- a/internal/ceres/program.cc +++ b/internal/ceres/program.cc @@ -41,7 +41,7 @@ #include "ceres/compressed_row_sparse_matrix.h" #include "ceres/cost_function.h" #include "ceres/evaluator.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/loss_function.h" #include "ceres/manifold.h" #include "ceres/map_util.h" diff --git a/internal/ceres/program.h b/internal/ceres/program.h index 82ae1308a..4dbd1ba5f 100644 --- a/internal/ceres/program.h +++ b/internal/ceres/program.h @@ -37,7 +37,8 @@ #include #include "ceres/evaluation_callback.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -57,7 +58,7 @@ class TripletSparseMatrix; // another; for example, the first stage of solving involves stripping all // constant parameters and residuals. This is in contrast with Problem, which is // not built for transformation. -class CERES_EXPORT_INTERNAL Program { +class CERES_NO_EXPORT Program { public: // The ordered parameter and residual blocks for the program. const std::vector& parameter_blocks() const; @@ -194,4 +195,6 @@ class CERES_EXPORT_INTERNAL Program { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_PROGRAM_H_ diff --git a/internal/ceres/program_evaluator.h b/internal/ceres/program_evaluator.h index c009719c1..e0f7bf03a 100644 --- a/internal/ceres/program_evaluator.h +++ b/internal/ceres/program_evaluator.h @@ -83,7 +83,7 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clang-format on #include diff --git a/internal/ceres/random.h b/internal/ceres/random.h index 6b280f9ee..14f2ebdce 100644 --- a/internal/ceres/random.h +++ b/internal/ceres/random.h @@ -35,7 +35,7 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { diff --git a/internal/ceres/reorder_program.cc b/internal/ceres/reorder_program.cc index 2d93487e7..31d9ae0fe 100644 --- a/internal/ceres/reorder_program.cc +++ b/internal/ceres/reorder_program.cc @@ -37,7 +37,7 @@ #include "Eigen/SparseCore" #include "ceres/cxsparse.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/ordered_groups.h" #include "ceres/parameter_block.h" #include "ceres/parameter_block_ordering.h" diff --git a/internal/ceres/reorder_program.h b/internal/ceres/reorder_program.h index 2e0c32643..df96923e6 100644 --- a/internal/ceres/reorder_program.h +++ b/internal/ceres/reorder_program.h @@ -33,7 +33,8 @@ #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/parameter_block_ordering.h" #include "ceres/problem_impl.h" #include "ceres/types.h" @@ -44,7 +45,7 @@ namespace internal { class Program; // Reorder the parameter blocks in program using the ordering -CERES_EXPORT_INTERNAL bool ApplyOrdering( +CERES_NO_EXPORT bool ApplyOrdering( const ProblemImpl::ParameterMap& parameter_map, const ParameterBlockOrdering& ordering, Program* program, @@ -53,7 +54,7 @@ CERES_EXPORT_INTERNAL bool ApplyOrdering( // Reorder the residuals for program, if necessary, so that the residuals // involving each E block occur together. This is a necessary condition for the // Schur eliminator, which works on these "row blocks" in the jacobian. -CERES_EXPORT_INTERNAL bool LexicographicallyOrderResidualBlocks( +CERES_NO_EXPORT bool LexicographicallyOrderResidualBlocks( int size_of_first_elimination_group, Program* program, std::string* error); // Schur type solvers require that all parameter blocks eliminated @@ -72,7 +73,7 @@ CERES_EXPORT_INTERNAL bool LexicographicallyOrderResidualBlocks( // // Upon return, ordering contains the parameter block ordering that // was used to order the program. -CERES_EXPORT_INTERNAL bool ReorderProgramForSchurTypeLinearSolver( +CERES_NO_EXPORT bool ReorderProgramForSchurTypeLinearSolver( LinearSolverType linear_solver_type, SparseLinearAlgebraLibraryType sparse_linear_algebra_library_type, const ProblemImpl::ParameterMap& parameter_map, @@ -90,7 +91,7 @@ CERES_EXPORT_INTERNAL bool ReorderProgramForSchurTypeLinearSolver( // fill-reducing ordering is available in the sparse linear algebra // library (SuiteSparse version >= 4.2.0) then the fill reducing // ordering will take it into account, otherwise it will be ignored. -CERES_EXPORT_INTERNAL bool ReorderProgramForSparseCholesky( +CERES_NO_EXPORT bool ReorderProgramForSparseCholesky( SparseLinearAlgebraLibraryType sparse_linear_algebra_library_type, const ParameterBlockOrdering& parameter_block_ordering, int start_row_block, @@ -107,11 +108,13 @@ CERES_EXPORT_INTERNAL bool ReorderProgramForSparseCholesky( // bottom_residual_blocks.size() because we allow // bottom_residual_blocks to contain residual blocks not present in // the Program. -CERES_EXPORT_INTERNAL int ReorderResidualBlocksByPartition( +CERES_NO_EXPORT int ReorderResidualBlocksByPartition( const std::unordered_set& bottom_residual_blocks, Program* program); } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_REORDER_PROGRAM_ diff --git a/internal/ceres/residual_block.h b/internal/ceres/residual_block.h index 80c8dd620..2de363bbd 100644 --- a/internal/ceres/residual_block.h +++ b/internal/ceres/residual_block.h @@ -40,7 +40,8 @@ #include #include "ceres/cost_function.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/stringprintf.h" #include "ceres/types.h" @@ -65,7 +66,7 @@ class ParameterBlock; // // The residual block stores pointers to but does not own the cost functions, // loss functions, and parameter blocks. -class CERES_EXPORT_INTERNAL ResidualBlock { +class CERES_NO_EXPORT ResidualBlock { public: // Construct the residual block with the given cost/loss functions. Loss may // be null. The index is the index of the residual block in the Program's @@ -147,4 +148,6 @@ class CERES_EXPORT_INTERNAL ResidualBlock { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_RESIDUAL_BLOCK_H_ diff --git a/internal/ceres/residual_block_utils.cc b/internal/ceres/residual_block_utils.cc index 17cf619ea..11c7623ce 100644 --- a/internal/ceres/residual_block_utils.cc +++ b/internal/ceres/residual_block_utils.cc @@ -36,7 +36,7 @@ #include "ceres/array_utils.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/parameter_block.h" #include "ceres/residual_block.h" #include "ceres/stringprintf.h" diff --git a/internal/ceres/residual_block_utils.h b/internal/ceres/residual_block_utils.h index 1ffff8e4a..f75b6aecc 100644 --- a/internal/ceres/residual_block_utils.h +++ b/internal/ceres/residual_block_utils.h @@ -45,7 +45,7 @@ #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -53,6 +53,7 @@ namespace internal { class ResidualBlock; // Invalidate cost, resdual and jacobian arrays (if not nullptr). +CERES_NO_EXPORT void InvalidateEvaluation(const ResidualBlock& block, double* cost, double* residuals, @@ -60,6 +61,7 @@ void InvalidateEvaluation(const ResidualBlock& block, // Check if any of the arrays cost, residuals or jacobians contains an // NaN, return true if it does. +CERES_NO_EXPORT bool IsEvaluationValid(const ResidualBlock& block, double const* const* parameters, double* cost, @@ -69,6 +71,7 @@ bool IsEvaluationValid(const ResidualBlock& block, // Create a string representation of the Residual block containing the // value of the parameters, residuals and jacobians if present. // Useful for debugging output. +CERES_NO_EXPORT std::string EvaluationToString(const ResidualBlock& block, double const* const* parameters, double* cost, diff --git a/internal/ceres/rotation_test.cc b/internal/ceres/rotation_test.cc index 951d7caba..3184376ad 100644 --- a/internal/ceres/rotation_test.cc +++ b/internal/ceres/rotation_test.cc @@ -35,7 +35,7 @@ #include #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/is_close.h" #include "ceres/jet.h" #include "ceres/stringprintf.h" diff --git a/internal/ceres/schur_complement_solver.h b/internal/ceres/schur_complement_solver.h index 2060cc8e5..0f9e01135 100644 --- a/internal/ceres/schur_complement_solver.h +++ b/internal/ceres/schur_complement_solver.h @@ -41,7 +41,7 @@ #include "ceres/block_sparse_matrix.h" #include "ceres/block_structure.h" #include "ceres/dense_cholesky.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" #include "ceres/schur_eliminator.h" #include "ceres/types.h" @@ -51,6 +51,8 @@ #include "Eigen/SparseCholesky" #endif +#include "ceres/internal/disable_warnings.h" + namespace ceres { namespace internal { @@ -108,8 +110,7 @@ class SparseCholesky; // set to DENSE_SCHUR and SPARSE_SCHUR // respectively. LinearSolver::Options::elimination_groups[0] should // be at least 1. -class CERES_EXPORT_INTERNAL SchurComplementSolver - : public BlockSparseMatrixSolver { +class CERES_NO_EXPORT SchurComplementSolver : public BlockSparseMatrixSolver { public: explicit SchurComplementSolver(const LinearSolver::Options& options); SchurComplementSolver(const SchurComplementSolver&) = delete; @@ -147,7 +148,8 @@ class CERES_EXPORT_INTERNAL SchurComplementSolver }; // Dense Cholesky factorization based solver. -class DenseSchurComplementSolver : public SchurComplementSolver { +class CERES_NO_EXPORT DenseSchurComplementSolver + : public SchurComplementSolver { public: explicit DenseSchurComplementSolver(const LinearSolver::Options& options); DenseSchurComplementSolver(const DenseSchurComplementSolver&) = delete; @@ -165,7 +167,8 @@ class DenseSchurComplementSolver : public SchurComplementSolver { }; // Sparse Cholesky factorization based solver. -class SparseSchurComplementSolver : public SchurComplementSolver { +class CERES_NO_EXPORT SparseSchurComplementSolver + : public SchurComplementSolver { public: explicit SparseSchurComplementSolver(const LinearSolver::Options& options); SparseSchurComplementSolver(const SparseSchurComplementSolver&) = delete; @@ -190,4 +193,6 @@ class SparseSchurComplementSolver : public SchurComplementSolver { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_SCHUR_COMPLEMENT_SOLVER_H_ diff --git a/internal/ceres/schur_eliminator.h b/internal/ceres/schur_eliminator.h index dd3d4b290..e03d2d99f 100644 --- a/internal/ceres/schur_eliminator.h +++ b/internal/ceres/schur_eliminator.h @@ -40,8 +40,9 @@ #include "ceres/block_random_access_matrix.h" #include "ceres/block_sparse_matrix.h" #include "ceres/block_structure.h" +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" namespace ceres { @@ -163,7 +164,7 @@ namespace internal { // 2008 for an example of such use]. // // Example usage: Please see schur_complement_solver.cc -class CERES_EXPORT_INTERNAL SchurEliminatorBase { +class CERES_NO_EXPORT SchurEliminatorBase { public: virtual ~SchurEliminatorBase(); @@ -223,7 +224,7 @@ class CERES_EXPORT_INTERNAL SchurEliminatorBase { template -class SchurEliminator : public SchurEliminatorBase { +class CERES_NO_EXPORT SchurEliminator : public SchurEliminatorBase { public: explicit SchurEliminator(const LinearSolver::Options& options) : num_threads_(options.num_threads), context_(options.context) { @@ -378,7 +379,7 @@ class SchurEliminator : public SchurEliminatorBase { template -class SchurEliminatorForOneFBlock : public SchurEliminatorBase { +class CERES_NO_EXPORT SchurEliminatorForOneFBlock : public SchurEliminatorBase { public: void Init(int num_eliminate_blocks, bool assume_full_rank_ete, @@ -623,4 +624,6 @@ class SchurEliminatorForOneFBlock : public SchurEliminatorBase { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_SCHUR_ELIMINATOR_H_ diff --git a/internal/ceres/schur_eliminator_impl.h b/internal/ceres/schur_eliminator_impl.h index 271d4cbb2..32344f502 100644 --- a/internal/ceres/schur_eliminator_impl.h +++ b/internal/ceres/schur_eliminator_impl.h @@ -47,7 +47,7 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clang-format on #include diff --git a/internal/ceres/schur_eliminator_template.py b/internal/ceres/schur_eliminator_template.py index 2bb78c31d..62a5f2f38 100644 --- a/internal/ceres/schur_eliminator_template.py +++ b/internal/ceres/schur_eliminator_template.py @@ -106,7 +106,7 @@ template class SchurEliminator<%s, %s, %s>; SPECIALIZATION_FILE = """ // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION diff --git a/internal/ceres/schur_jacobi_preconditioner.h b/internal/ceres/schur_jacobi_preconditioner.h index 81f584b40..59f271fbe 100644 --- a/internal/ceres/schur_jacobi_preconditioner.h +++ b/internal/ceres/schur_jacobi_preconditioner.h @@ -43,6 +43,8 @@ #include #include +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/preconditioner.h" namespace ceres { @@ -72,7 +74,8 @@ class SchurEliminatorBase; // preconditioner.Update(A, nullptr); // preconditioner.RightMultiply(x, y); // -class SchurJacobiPreconditioner : public BlockSparseMatrixPreconditioner { +class CERES_NO_EXPORT SchurJacobiPreconditioner + : public BlockSparseMatrixPreconditioner { public: // Initialize the symbolic structure of the preconditioner. bs is // the block structure of the linear system to be solved. It is used @@ -104,4 +107,6 @@ class SchurJacobiPreconditioner : public BlockSparseMatrixPreconditioner { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_SCHUR_JACOBI_PRECONDITIONER_H_ diff --git a/internal/ceres/schur_templates.h b/internal/ceres/schur_templates.h index 90aee0a1a..da6e934ab 100644 --- a/internal/ceres/schur_templates.h +++ b/internal/ceres/schur_templates.h @@ -32,11 +32,13 @@ #ifndef CERES_INTERNAL_SCHUR_TEMPLATES_H_ #define CERES_INTERNAL_SCHUR_TEMPLATES_H_ +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" namespace ceres { namespace internal { +CERES_NO_EXPORT void GetBestSchurTemplateSpecialization(int* row_block_size, int* e_block_size, int* f_block_size); diff --git a/internal/ceres/scoped_thread_token.h b/internal/ceres/scoped_thread_token.h index c167397cc..a126412f3 100644 --- a/internal/ceres/scoped_thread_token.h +++ b/internal/ceres/scoped_thread_token.h @@ -31,6 +31,7 @@ #ifndef CERES_INTERNAL_SCOPED_THREAD_TOKEN_H_ #define CERES_INTERNAL_SCOPED_THREAD_TOKEN_H_ +#include "ceres/internal/export.h" #include "ceres/thread_token_provider.h" namespace ceres { @@ -38,7 +39,7 @@ namespace internal { // Helper class for ThreadTokenProvider. This object acquires a token in its // constructor and puts that token back with destruction. -class ScopedThreadToken { +class CERES_NO_EXPORT ScopedThreadToken { public: ScopedThreadToken(ThreadTokenProvider* provider) : provider_(provider), token_(provider->Acquire()) {} diff --git a/internal/ceres/scratch_evaluate_preparer.h b/internal/ceres/scratch_evaluate_preparer.h index d0ecc3d7b..3f4e7df8d 100644 --- a/internal/ceres/scratch_evaluate_preparer.h +++ b/internal/ceres/scratch_evaluate_preparer.h @@ -37,6 +37,9 @@ #include +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" + namespace ceres { namespace internal { @@ -44,7 +47,7 @@ class Program; class ResidualBlock; class SparseMatrix; -class ScratchEvaluatePreparer { +class CERES_NO_EXPORT ScratchEvaluatePreparer { public: // Create num_threads ScratchEvaluatePreparers. static std::unique_ptr Create( @@ -66,4 +69,6 @@ class ScratchEvaluatePreparer { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_SCRATCH_EVALUATE_PREPARER_H_ diff --git a/internal/ceres/single_linkage_clustering.h b/internal/ceres/single_linkage_clustering.h index e891a9eec..b4a7e0776 100644 --- a/internal/ceres/single_linkage_clustering.h +++ b/internal/ceres/single_linkage_clustering.h @@ -34,7 +34,8 @@ #include #include "ceres/graph.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -55,12 +56,14 @@ struct SingleLinkageClusteringOptions { // // The return value of this function is the number of clusters // identified by the algorithm. -int CERES_EXPORT_INTERNAL -ComputeSingleLinkageClustering(const SingleLinkageClusteringOptions& options, - const WeightedGraph& graph, - std::unordered_map* membership); +CERES_NO_EXPORT int ComputeSingleLinkageClustering( + const SingleLinkageClusteringOptions& options, + const WeightedGraph& graph, + std::unordered_map* membership); } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_SINGLE_LINKAGE_CLUSTERING_H_ diff --git a/internal/ceres/small_blas.h b/internal/ceres/small_blas.h index 4ee9229f3..856a2a24a 100644 --- a/internal/ceres/small_blas.h +++ b/internal/ceres/small_blas.h @@ -36,7 +36,7 @@ #define CERES_INTERNAL_SMALL_BLAS_H_ #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "glog/logging.h" #include "small_blas_generic.h" diff --git a/internal/ceres/solver.cc b/internal/ceres/solver.cc index 6561f18c5..7560883e9 100644 --- a/internal/ceres/solver.cc +++ b/internal/ceres/solver.cc @@ -41,7 +41,7 @@ #include "ceres/context_impl.h" #include "ceres/detect_structure.h" #include "ceres/gradient_checking_cost_function.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/parameter_block_ordering.h" #include "ceres/preprocessor.h" #include "ceres/problem.h" diff --git a/internal/ceres/solver_utils.cc b/internal/ceres/solver_utils.cc index 1622e0ff2..22fa13705 100644 --- a/internal/ceres/solver_utils.cc +++ b/internal/ceres/solver_utils.cc @@ -34,7 +34,7 @@ #include "Eigen/Core" #include "ceres/internal/config.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/version.h" #ifndef CERES_NO_CUDA #include "cuda_runtime.h" diff --git a/internal/ceres/solver_utils.h b/internal/ceres/solver_utils.h index 5715cb78d..298564a89 100644 --- a/internal/ceres/solver_utils.h +++ b/internal/ceres/solver_utils.h @@ -34,6 +34,8 @@ #include #include +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/iteration_callback.h" #include "ceres/types.h" @@ -58,9 +60,12 @@ void SetSummaryFinalCost(SummaryType* summary) { } } +CERES_NO_EXPORT std::string VersionString(); } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_SOLVER_UTILS_H_ diff --git a/internal/ceres/sparse_cholesky.h b/internal/ceres/sparse_cholesky.h index 32dfbd5a0..25249eb4e 100644 --- a/internal/ceres/sparse_cholesky.h +++ b/internal/ceres/sparse_cholesky.h @@ -33,11 +33,13 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clang-format on #include +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" #include "glog/logging.h" @@ -67,7 +69,7 @@ namespace internal { // CHECK_EQ(sparse_cholesky->Solve(rhs.data(), solution.data(), &message), // LINEAR_SOLVER_SUCCESS); -class CERES_EXPORT_INTERNAL SparseCholesky { +class CERES_NO_EXPORT SparseCholesky { public: static std::unique_ptr Create( const LinearSolver::Options& options); @@ -114,7 +116,7 @@ class IterativeRefiner; // Computes an initial solution using the given instance of // SparseCholesky, and then refines it using the IterativeRefiner. -class CERES_EXPORT_INTERNAL RefinedSparseCholesky : public SparseCholesky { +class CERES_NO_EXPORT RefinedSparseCholesky : public SparseCholesky { public: RefinedSparseCholesky(std::unique_ptr sparse_cholesky, std::unique_ptr iterative_refiner); @@ -136,4 +138,6 @@ class CERES_EXPORT_INTERNAL RefinedSparseCholesky : public SparseCholesky { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_SPARSE_CHOLESKY_H_ diff --git a/internal/ceres/sparse_matrix.h b/internal/ceres/sparse_matrix.h index 3b6b55ac8..1dbb96e60 100644 --- a/internal/ceres/sparse_matrix.h +++ b/internal/ceres/sparse_matrix.h @@ -36,7 +36,7 @@ #include #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/linear_operator.h" #include "ceres/types.h" @@ -64,7 +64,7 @@ namespace internal { // matrix type dependent and we are at this stage unable to come up // with an efficient high level interface that spans multiple sparse // matrix types. -class CERES_EXPORT_INTERNAL SparseMatrix : public LinearOperator { +class CERES_NO_EXPORT SparseMatrix : public LinearOperator { public: ~SparseMatrix() override; diff --git a/internal/ceres/sparse_normal_cholesky_solver.h b/internal/ceres/sparse_normal_cholesky_solver.h index 7973f7318..caec56661 100644 --- a/internal/ceres/sparse_normal_cholesky_solver.h +++ b/internal/ceres/sparse_normal_cholesky_solver.h @@ -36,12 +36,13 @@ // This include must come before any #ifndef check on Ceres compile options. // clang-format off -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" // clang-format on #include #include +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" namespace ceres { @@ -53,7 +54,8 @@ class SparseCholesky; // Solves the normal equations (A'A + D'D) x = A'b, using the sparse // linear algebra library of the user's choice. -class SparseNormalCholeskySolver : public BlockSparseMatrixSolver { +class CERES_NO_EXPORT SparseNormalCholeskySolver + : public BlockSparseMatrixSolver { public: explicit SparseNormalCholeskySolver(const LinearSolver::Options& options); SparseNormalCholeskySolver(const SparseNormalCholeskySolver&) = delete; diff --git a/internal/ceres/stringprintf.cc b/internal/ceres/stringprintf.cc index def40fe9f..e45b4301e 100644 --- a/internal/ceres/stringprintf.cc +++ b/internal/ceres/stringprintf.cc @@ -36,7 +36,7 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { diff --git a/internal/ceres/stringprintf.h b/internal/ceres/stringprintf.h index 4d5127849..e24325fbd 100644 --- a/internal/ceres/stringprintf.h +++ b/internal/ceres/stringprintf.h @@ -41,7 +41,8 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -63,32 +64,35 @@ namespace internal { #endif // Return a C++ string. -CERES_EXPORT_INTERNAL extern std::string StringPrintf(const char* format, ...) +CERES_NO_EXPORT extern std::string StringPrintf(const char* format, ...) // Tell the compiler to do printf format string checking. CERES_PRINTF_ATTRIBUTE(1, 2); // Store result into a supplied string and return it. -CERES_EXPORT_INTERNAL extern const std::string& SStringPrintf( - std::string* dst, const char* format, ...) +CERES_NO_EXPORT extern const std::string& SStringPrintf(std::string* dst, + const char* format, + ...) // Tell the compiler to do printf format string checking. CERES_PRINTF_ATTRIBUTE(2, 3); // Append result to a supplied string. -CERES_EXPORT_INTERNAL extern void StringAppendF(std::string* dst, - const char* format, - ...) +CERES_NO_EXPORT extern void StringAppendF(std::string* dst, + const char* format, + ...) // Tell the compiler to do printf format string checking. CERES_PRINTF_ATTRIBUTE(2, 3); // Lower-level routine that takes a va_list and appends to a specified string. // All other routines are just convenience wrappers around it. -CERES_EXPORT_INTERNAL extern void StringAppendV(std::string* dst, - const char* format, - va_list ap); +CERES_NO_EXPORT extern void StringAppendV(std::string* dst, + const char* format, + va_list ap); #undef CERES_PRINTF_ATTRIBUTE } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_STRINGPRINTF_H_ diff --git a/internal/ceres/subset_preconditioner.h b/internal/ceres/subset_preconditioner.h index 00c3f3851..7b6c31770 100644 --- a/internal/ceres/subset_preconditioner.h +++ b/internal/ceres/subset_preconditioner.h @@ -33,7 +33,8 @@ #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/preconditioner.h" namespace ceres { @@ -67,7 +68,7 @@ class InnerProductComputer; // computationally expensive this preconditioner will be. // // See the tests for example usage. -class CERES_EXPORT_INTERNAL SubsetPreconditioner +class CERES_NO_EXPORT SubsetPreconditioner : public BlockSparseMatrixPreconditioner { public: SubsetPreconditioner(const Preconditioner::Options& options, @@ -91,4 +92,6 @@ class CERES_EXPORT_INTERNAL SubsetPreconditioner } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_SUBSET_PRECONDITIONER_H_ diff --git a/internal/ceres/suitesparse.cc b/internal/ceres/suitesparse.cc index 99c7ff258..883dcc8f6 100644 --- a/internal/ceres/suitesparse.cc +++ b/internal/ceres/suitesparse.cc @@ -29,7 +29,7 @@ // Author: sameeragarwal@google.com (Sameer Agarwal) // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_NO_SUITESPARSE #include diff --git a/internal/ceres/suitesparse.h b/internal/ceres/suitesparse.h index 8ab45be2f..604c7fc3e 100644 --- a/internal/ceres/suitesparse.h +++ b/internal/ceres/suitesparse.h @@ -34,7 +34,7 @@ #define CERES_INTERNAL_SUITESPARSE_H_ // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifndef CERES_NO_SUITESPARSE @@ -71,6 +71,8 @@ #define SuiteSparse_long UF_long #endif +#include "ceres/internal/disable_warnings.h" + namespace ceres { namespace internal { @@ -82,7 +84,7 @@ class TripletSparseMatrix; // provides the user with a simpler interface. The methods here cannot // be static as a cholmod_common object serves as a global variable // for all cholmod function calls. -class SuiteSparse { +class CERES_NO_EXPORT SuiteSparse { public: SuiteSparse(); ~SuiteSparse(); @@ -289,7 +291,7 @@ class SuiteSparse { cholmod_common cc_; }; -class SuiteSparseCholesky : public SparseCholesky { +class CERES_NO_EXPORT SuiteSparseCholesky : public SparseCholesky { public: static std::unique_ptr Create(OrderingType ordering_type); @@ -313,14 +315,18 @@ class SuiteSparseCholesky : public SparseCholesky { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #else // CERES_NO_SUITESPARSE typedef void cholmod_factor; +#include "ceres/internal/disable_warnings.h" + namespace ceres { namespace internal { -class SuiteSparse { +class CERES_NO_EXPORT SuiteSparse { public: // Defining this static function even when SuiteSparse is not // available, allows client code to check for the presence of CAMD @@ -339,6 +345,8 @@ class SuiteSparse { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_NO_SUITESPARSE #endif // CERES_INTERNAL_SUITESPARSE_H_ diff --git a/internal/ceres/test_util.cc b/internal/ceres/test_util.cc index 1e0aa6ced..3ba86cf29 100644 --- a/internal/ceres/test_util.cc +++ b/internal/ceres/test_util.cc @@ -36,6 +36,7 @@ #include #include "ceres/file.h" +#include "ceres/internal/port.h" #include "ceres/stringprintf.h" #include "ceres/types.h" #include "gflags/gflags.h" diff --git a/internal/ceres/test_util.h b/internal/ceres/test_util.h index c33c69cd0..e46f23102 100644 --- a/internal/ceres/test_util.h +++ b/internal/ceres/test_util.h @@ -33,7 +33,8 @@ #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/problem.h" #include "ceres/solver.h" #include "ceres/stringprintf.h" @@ -45,20 +46,19 @@ namespace internal { // Expects that x and y have a relative difference of no more than // max_abs_relative_difference. If either x or y is zero, then the relative // difference is interpreted as an absolute difference. -// // If x and y have the same non-finite value (inf or nan) we treat them as being // close. In such a case no error is thrown and true is returned. -CERES_EXPORT_INTERNAL bool ExpectClose(double x, - double y, - double max_abs_relative_difference); +CERES_NO_EXPORT bool ExpectClose(double x, + double y, + double max_abs_relative_difference); // Expects that for all i = 1,.., n - 1 // // |p[i] - q[i]| / max(|p[i]|, |q[i]|) < tolerance -CERES_EXPORT_INTERNAL void ExpectArraysClose(int n, - const double* p, - const double* q, - double tolerance); +CERES_NO_EXPORT void ExpectArraysClose(int n, + const double* p, + const double* q, + double tolerance); // Expects that for all i = 1,.., n - 1 // @@ -66,17 +66,16 @@ CERES_EXPORT_INTERNAL void ExpectArraysClose(int n, // // where max_norm_p and max_norm_q are the max norms of the arrays p // and q respectively. -CERES_EXPORT_INTERNAL void ExpectArraysCloseUptoScale(int n, - const double* p, - const double* q, - double tolerance); +CERES_NO_EXPORT void ExpectArraysCloseUptoScale(int n, + const double* p, + const double* q, + double tolerance); // Construct a fully qualified path for the test file depending on the // local build/testing environment. -CERES_EXPORT_INTERNAL std::string TestFileAbsolutePath( - const std::string& filename); +CERES_NO_EXPORT std::string TestFileAbsolutePath(const std::string& filename); -CERES_EXPORT_INTERNAL std::string ToString(const Solver::Options& options); +CERES_NO_EXPORT std::string ToString(const Solver::Options& options); // A templated test fixture, that is used for testing Ceres end to end // by computing a solution to the problem for a given solver @@ -85,7 +84,7 @@ CERES_EXPORT_INTERNAL std::string ToString(const Solver::Options& options); // It is assumed that the SystemTestProblem has an Solver::Options // struct that contains the reference Solver configuration. template -class SystemTest : public ::testing::Test { +class CERES_NO_EXPORT SystemTest : public ::testing::Test { protected: void SetUp() final { SystemTestProblem system_test_problem; @@ -130,4 +129,6 @@ class SystemTest : public ::testing::Test { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_TEST_UTIL_H_ diff --git a/internal/ceres/thread_pool.cc b/internal/ceres/thread_pool.cc index 69753df0a..b50353769 100644 --- a/internal/ceres/thread_pool.cc +++ b/internal/ceres/thread_pool.cc @@ -29,7 +29,7 @@ // Author: vitus@google.com (Michael Vitus) // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifdef CERES_USE_CXX_THREADS diff --git a/internal/ceres/thread_pool.h b/internal/ceres/thread_pool.h index cdf6625e1..94ab1e66b 100644 --- a/internal/ceres/thread_pool.h +++ b/internal/ceres/thread_pool.h @@ -37,7 +37,7 @@ #include #include "ceres/concurrent_queue.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -58,7 +58,7 @@ namespace internal { // workers to stop. The workers will finish all of the tasks that have already // been added to the thread pool. // -class CERES_EXPORT_INTERNAL ThreadPool { +class CERES_NO_EXPORT ThreadPool { public: // Returns the maximum number of hardware threads. static int MaxNumThreadsAvailable(); diff --git a/internal/ceres/thread_pool_test.cc b/internal/ceres/thread_pool_test.cc index e39f673dc..b204cf3ce 100644 --- a/internal/ceres/thread_pool_test.cc +++ b/internal/ceres/thread_pool_test.cc @@ -29,7 +29,7 @@ // Author: vitus@google.com (Michael Vitus) // This include must come before any #ifndef check on Ceres compile options. -#include "ceres/internal/port.h" +#include "ceres/internal/config.h" #ifdef CERES_USE_CXX_THREADS diff --git a/internal/ceres/thread_token_provider.h b/internal/ceres/thread_token_provider.h index 06dc04385..cd9f58f99 100644 --- a/internal/ceres/thread_token_provider.h +++ b/internal/ceres/thread_token_provider.h @@ -32,7 +32,7 @@ #define CERES_INTERNAL_THREAD_TOKEN_PROVIDER_H_ #include "ceres/internal/config.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #ifdef CERES_USE_CXX_THREADS #include "ceres/concurrent_queue.h" @@ -66,7 +66,7 @@ namespace internal { // ttp.Release(token); // return token to the pool // } // -class ThreadTokenProvider { +class CERES_NO_EXPORT ThreadTokenProvider { public: ThreadTokenProvider(int num_threads); @@ -87,8 +87,8 @@ class ThreadTokenProvider { ConcurrentQueue pool_; #endif - ThreadTokenProvider(ThreadTokenProvider&); - ThreadTokenProvider& operator=(ThreadTokenProvider&); + ThreadTokenProvider(ThreadTokenProvider&) = delete; + ThreadTokenProvider& operator=(ThreadTokenProvider&) = delete; }; } // namespace internal diff --git a/internal/ceres/triplet_sparse_matrix.cc b/internal/ceres/triplet_sparse_matrix.cc index 7cfd69ecf..ad81fd2ce 100644 --- a/internal/ceres/triplet_sparse_matrix.cc +++ b/internal/ceres/triplet_sparse_matrix.cc @@ -34,7 +34,7 @@ #include #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/random.h" #include "ceres/types.h" #include "glog/logging.h" diff --git a/internal/ceres/triplet_sparse_matrix.h b/internal/ceres/triplet_sparse_matrix.h index ba426c433..2c2bc1320 100644 --- a/internal/ceres/triplet_sparse_matrix.h +++ b/internal/ceres/triplet_sparse_matrix.h @@ -34,8 +34,9 @@ #include #include +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/sparse_matrix.h" #include "ceres/types.h" @@ -46,7 +47,7 @@ namespace internal { // manipulate sparse matrices in triplet (i,j,s) form. This object is // inspired by the design of the cholmod_triplet struct used in the // SuiteSparse package and is memory layout compatible with it. -class CERES_EXPORT_INTERNAL TripletSparseMatrix : public SparseMatrix { +class CERES_NO_EXPORT TripletSparseMatrix : public SparseMatrix { public: TripletSparseMatrix(); TripletSparseMatrix(int num_rows, int num_cols, int max_num_nonzeros); @@ -156,4 +157,6 @@ class CERES_EXPORT_INTERNAL TripletSparseMatrix : public SparseMatrix { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_TRIPLET_SPARSE_MATRIX_H__ diff --git a/internal/ceres/trust_region_minimizer.cc b/internal/ceres/trust_region_minimizer.cc index f8e6b2978..9ef5167ba 100644 --- a/internal/ceres/trust_region_minimizer.cc +++ b/internal/ceres/trust_region_minimizer.cc @@ -62,8 +62,6 @@ namespace ceres { namespace internal { -TrustRegionMinimizer::~TrustRegionMinimizer() = default; - void TrustRegionMinimizer::Minimize(const Minimizer::Options& options, double* parameters, Solver::Summary* solver_summary) { diff --git a/internal/ceres/trust_region_minimizer.h b/internal/ceres/trust_region_minimizer.h index 440cf69a8..4df05105c 100644 --- a/internal/ceres/trust_region_minimizer.h +++ b/internal/ceres/trust_region_minimizer.h @@ -33,8 +33,9 @@ #include +#include "ceres/internal/disable_warnings.h" #include "ceres/internal/eigen.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/minimizer.h" #include "ceres/solver.h" #include "ceres/sparse_matrix.h" @@ -48,10 +49,8 @@ namespace internal { // Generic trust region minimization algorithm. // // For example usage, see SolverImpl::Minimize. -class CERES_EXPORT_INTERNAL TrustRegionMinimizer : public Minimizer { +class CERES_NO_EXPORT TrustRegionMinimizer : public Minimizer { public: - ~TrustRegionMinimizer() override; - // This method is not thread safe. void Minimize(const Minimizer::Options& options, double* parameters, @@ -164,4 +163,6 @@ class CERES_EXPORT_INTERNAL TrustRegionMinimizer : public Minimizer { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_TRUST_REGION_MINIMIZER_H_ diff --git a/internal/ceres/trust_region_minimizer_test.cc b/internal/ceres/trust_region_minimizer_test.cc index 26878f32e..54642d549 100644 --- a/internal/ceres/trust_region_minimizer_test.cc +++ b/internal/ceres/trust_region_minimizer_test.cc @@ -43,7 +43,7 @@ #include "ceres/dense_qr_solver.h" #include "ceres/dense_sparse_matrix.h" #include "ceres/evaluator.h" -#include "ceres/internal/port.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" #include "ceres/minimizer.h" #include "ceres/problem.h" diff --git a/internal/ceres/trust_region_preprocessor.cc b/internal/ceres/trust_region_preprocessor.cc index a6a8b9f0f..9892e1eff 100644 --- a/internal/ceres/trust_region_preprocessor.cc +++ b/internal/ceres/trust_region_preprocessor.cc @@ -356,8 +356,6 @@ void SetupMinimizerOptions(PreprocessedProblem* pp) { } // namespace -TrustRegionPreprocessor::~TrustRegionPreprocessor() = default; - bool TrustRegionPreprocessor::Preprocess(const Solver::Options& options, ProblemImpl* problem, PreprocessedProblem* pp) { diff --git a/internal/ceres/trust_region_preprocessor.h b/internal/ceres/trust_region_preprocessor.h index af56a98fa..a1db8e865 100644 --- a/internal/ceres/trust_region_preprocessor.h +++ b/internal/ceres/trust_region_preprocessor.h @@ -31,15 +31,15 @@ #ifndef CERES_INTERNAL_TRUST_REGION_PREPROCESSOR_H_ #define CERES_INTERNAL_TRUST_REGION_PREPROCESSOR_H_ -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/preprocessor.h" namespace ceres { namespace internal { -class CERES_EXPORT_INTERNAL TrustRegionPreprocessor : public Preprocessor { +class CERES_NO_EXPORT TrustRegionPreprocessor : public Preprocessor { public: - ~TrustRegionPreprocessor() override; bool Preprocess(const Solver::Options& options, ProblemImpl* problem, PreprocessedProblem* preprocessed_problem) override; @@ -48,4 +48,6 @@ class CERES_EXPORT_INTERNAL TrustRegionPreprocessor : public Preprocessor { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_TRUST_REGION_PREPROCESSOR_H_ diff --git a/internal/ceres/trust_region_step_evaluator.h b/internal/ceres/trust_region_step_evaluator.h index 03c00362d..8e0c4e91f 100644 --- a/internal/ceres/trust_region_step_evaluator.h +++ b/internal/ceres/trust_region_step_evaluator.h @@ -31,6 +31,8 @@ #ifndef CERES_INTERNAL_TRUST_REGION_STEP_EVALUATOR_H_ #define CERES_INTERNAL_TRUST_REGION_STEP_EVALUATOR_H_ +#include "ceres/internal/export.h" + namespace ceres { namespace internal { @@ -74,7 +76,7 @@ namespace internal { // x = x + delta; // step_evaluator->StepAccepted(cost, model_cost_change); // } -class TrustRegionStepEvaluator { +class CERES_NO_EXPORT TrustRegionStepEvaluator { public: // initial_cost is as the name implies the cost of the starting // state of the trust region minimizer. diff --git a/internal/ceres/trust_region_strategy.h b/internal/ceres/trust_region_strategy.h index ae45f2b10..33086cafb 100644 --- a/internal/ceres/trust_region_strategy.h +++ b/internal/ceres/trust_region_strategy.h @@ -34,7 +34,8 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/linear_solver.h" namespace ceres { @@ -55,7 +56,7 @@ class SparseMatrix; // the LevenbergMarquardtStrategy uses the inverse of the trust region // radius to scale the damping term, which controls the step size, but // does not set a hard limit on its size. -class CERES_EXPORT_INTERNAL TrustRegionStrategy { +class CERES_NO_EXPORT TrustRegionStrategy { public: struct Options { TrustRegionStrategyType trust_region_strategy_type = LEVENBERG_MARQUARDT; @@ -143,4 +144,6 @@ class CERES_EXPORT_INTERNAL TrustRegionStrategy { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_TRUST_REGION_STRATEGY_H_ diff --git a/internal/ceres/types.cc b/internal/ceres/types.cc index bf995686b..ebd454fd2 100644 --- a/internal/ceres/types.cc +++ b/internal/ceres/types.cc @@ -34,6 +34,7 @@ #include #include +#include "ceres/internal/config.h" #include "glog/logging.h" namespace ceres { diff --git a/internal/ceres/visibility.h b/internal/ceres/visibility.h index e86bb8833..d8f6968d9 100644 --- a/internal/ceres/visibility.h +++ b/internal/ceres/visibility.h @@ -40,7 +40,8 @@ #include #include "ceres/graph.h" -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" namespace ceres { namespace internal { @@ -55,7 +56,7 @@ struct CompressedRowBlockStructure; // // In a structure from motion problem, e_blocks correspond to 3D // points and f_blocks correspond to cameras. -CERES_EXPORT_INTERNAL void ComputeVisibility( +CERES_NO_EXPORT void ComputeVisibility( const CompressedRowBlockStructure& block_structure, int num_eliminate_blocks, std::vector>* visibility); @@ -73,10 +74,12 @@ CERES_EXPORT_INTERNAL void ComputeVisibility( // // Caller acquires ownership of the returned WeightedGraph pointer // (heap-allocated). -CERES_EXPORT_INTERNAL std::unique_ptr> -CreateSchurComplementGraph(const std::vector>& visibility); +CERES_NO_EXPORT std::unique_ptr> CreateSchurComplementGraph( + const std::vector>& visibility); } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_VISIBILITY_H_ diff --git a/internal/ceres/visibility_based_preconditioner.h b/internal/ceres/visibility_based_preconditioner.h index 1150d3345..04d87ce38 100644 --- a/internal/ceres/visibility_based_preconditioner.h +++ b/internal/ceres/visibility_based_preconditioner.h @@ -124,7 +124,8 @@ class SchurEliminatorBase; // *A.block_structure(), options); // preconditioner.Update(A, nullptr); // preconditioner.RightMultiply(x, y); -class VisibilityBasedPreconditioner : public BlockSparseMatrixPreconditioner { +class CERES_NO_EXPORT VisibilityBasedPreconditioner + : public BlockSparseMatrixPreconditioner { public: // Initialize the symbolic structure of the preconditioner. bs is // the block structure of the linear system to be solved. It is used diff --git a/internal/ceres/wall_time.h b/internal/ceres/wall_time.h index 9c92e9e60..f093eed04 100644 --- a/internal/ceres/wall_time.h +++ b/internal/ceres/wall_time.h @@ -34,7 +34,8 @@ #include #include -#include "ceres/internal/port.h" +#include "ceres/internal/disable_warnings.h" +#include "ceres/internal/export.h" #include "ceres/stringprintf.h" #include "glog/logging.h" @@ -45,7 +46,7 @@ namespace internal { // OpenMP is available then the high precision openmp_get_wtime() // function is used. Otherwise on unixes, gettimeofday is used. The // granularity is in seconds on windows systems. -CERES_EXPORT_INTERNAL double WallTimeInSeconds(); +CERES_NO_EXPORT double WallTimeInSeconds(); // Log a series of events, recording for each event the time elapsed // since the last event and since the creation of the object. @@ -71,7 +72,7 @@ CERES_EXPORT_INTERNAL double WallTimeInSeconds(); // Bar1: time1 time1 // Bar2: time2 time1 + time2; // Total: time3 time1 + time2 + time3; -class EventLogger { +class CERES_NO_EXPORT EventLogger { public: explicit EventLogger(const std::string& logger_name); ~EventLogger(); @@ -86,4 +87,6 @@ class EventLogger { } // namespace internal } // namespace ceres +#include "ceres/internal/reenable_warnings.h" + #endif // CERES_INTERNAL_WALL_TIME_H_