Mark the internal headers as private for IWYU

The installed headers below ceres/internal are implementation details,
but nothing tells include-what-you-use and similar tools to keep users
from including them. Annotate them, including the generated
configuration and export headers, with IWYU pragmas that mark them as
private and map the Euler angle conventions and Jet traits to their
public headers.

Change-Id: I7ab3c59450b6e88f938d7f54a9bec5b4dbb9cc64
diff --git a/cmake/config.h.in b/cmake/config.h.in
index 94120ae..1924f48 100644
--- a/cmake/config.h.in
+++ b/cmake/config.h.in
@@ -41,6 +41,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_CONFIG_H_
 #define CERES_PUBLIC_INTERNAL_CONFIG_H_
 
+// IWYU pragma: private
+
 // If defined, use the LGPL code in Eigen.
 @CERES_USE_EIGEN_SPARSE@
 
diff --git a/include/ceres/internal/array_selector.h b/include/ceres/internal/array_selector.h
index 100b80d..fd56a60 100644
--- a/include/ceres/internal/array_selector.h
+++ b/include/ceres/internal/array_selector.h
@@ -32,6 +32,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_ARRAY_SELECTOR_H_
 #define CERES_PUBLIC_INTERNAL_ARRAY_SELECTOR_H_
 
+// IWYU pragma: private
+
 #include <array>
 #include <vector>
 
diff --git a/include/ceres/internal/autodiff.h b/include/ceres/internal/autodiff.h
index e83ce16..5317aff 100644
--- a/include/ceres/internal/autodiff.h
+++ b/include/ceres/internal/autodiff.h
@@ -140,6 +140,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_AUTODIFF_H_
 #define CERES_PUBLIC_INTERNAL_AUTODIFF_H_
 
+// IWYU pragma: private
+
 #include <array>
 #include <cstddef>
 #include <utility>
diff --git a/include/ceres/internal/disable_warnings.h b/include/ceres/internal/disable_warnings.h
index 408698b..02807cd 100644
--- a/include/ceres/internal/disable_warnings.h
+++ b/include/ceres/internal/disable_warnings.h
@@ -31,6 +31,8 @@
 // NOTE: An include guard is not necessary and in fact counterproductive because
 // #pragma warning(push) will depend on the inclusion order.
 
+// IWYU pragma: private
+
 #ifdef _MSC_VER
 #pragma warning(push)
 // Disable the warning C4251 which is triggered by stl classes in
diff --git a/include/ceres/internal/euler_angles.h b/include/ceres/internal/euler_angles.h
index 38f2702..4782a07 100644
--- a/include/ceres/internal/euler_angles.h
+++ b/include/ceres/internal/euler_angles.h
@@ -29,6 +29,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_EULER_ANGLES_H_
 #define CERES_PUBLIC_INTERNAL_EULER_ANGLES_H_
 
+// IWYU pragma: private, include "ceres/rotation.h"
+
 #include <type_traits>
 
 namespace ceres {
diff --git a/include/ceres/internal/householder_vector.h b/include/ceres/internal/householder_vector.h
index 3398d00..0d35ccd 100644
--- a/include/ceres/internal/householder_vector.h
+++ b/include/ceres/internal/householder_vector.h
@@ -31,6 +31,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_HOUSEHOLDER_VECTOR_H_
 #define CERES_PUBLIC_INTERNAL_HOUSEHOLDER_VECTOR_H_
 
+// IWYU pragma: private
+
 #include "Eigen/Core"
 #include "absl/log/check.h"
 
diff --git a/include/ceres/internal/integer_sequence_algorithm.h b/include/ceres/internal/integer_sequence_algorithm.h
index 0c27d72..267a1d2 100644
--- a/include/ceres/internal/integer_sequence_algorithm.h
+++ b/include/ceres/internal/integer_sequence_algorithm.h
@@ -36,6 +36,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_INTEGER_SEQUENCE_ALGORITHM_H_
 #define CERES_PUBLIC_INTERNAL_INTEGER_SEQUENCE_ALGORITHM_H_
 
+// IWYU pragma: private
+
 #include <utility>
 
 #include "ceres/jet_fwd.h"
diff --git a/include/ceres/internal/jet_traits.h b/include/ceres/internal/jet_traits.h
index a6c1e1f..e0a1e08 100644
--- a/include/ceres/internal/jet_traits.h
+++ b/include/ceres/internal/jet_traits.h
@@ -32,6 +32,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_JET_TRAITS_H_
 #define CERES_PUBLIC_INTERNAL_JET_TRAITS_H_
 
+// IWYU pragma: private, include "ceres/jet.h"
+
 #include <tuple>
 #include <type_traits>
 #include <utility>
diff --git a/include/ceres/internal/numeric_diff.h b/include/ceres/internal/numeric_diff.h
index 32d3ea2..07d1c70 100644
--- a/include/ceres/internal/numeric_diff.h
+++ b/include/ceres/internal/numeric_diff.h
@@ -35,6 +35,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_NUMERIC_DIFF_H_
 #define CERES_PUBLIC_INTERNAL_NUMERIC_DIFF_H_
 
+// IWYU pragma: private
+
 #include <cstring>
 #include <utility>
 
diff --git a/include/ceres/internal/parameter_dims.h b/include/ceres/internal/parameter_dims.h
index 8d4e9e4..3024a5f 100644
--- a/include/ceres/internal/parameter_dims.h
+++ b/include/ceres/internal/parameter_dims.h
@@ -31,6 +31,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_PARAMETER_DIMS_H_
 #define CERES_PUBLIC_INTERNAL_PARAMETER_DIMS_H_
 
+// IWYU pragma: private
+
 #include <array>
 #include <utility>
 
diff --git a/include/ceres/internal/port.h b/include/ceres/internal/port.h
index 151d30e..e00ccaa 100644
--- a/include/ceres/internal/port.h
+++ b/include/ceres/internal/port.h
@@ -31,6 +31,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_PORT_H_
 #define CERES_PUBLIC_INTERNAL_PORT_H_
 
+// IWYU pragma: private
+
 #include <cmath>  // Necessary for __cpp_lib_math_special_functions feature test
 
 // A macro to mark a function/variable/class as deprecated.
diff --git a/include/ceres/internal/reenable_warnings.h b/include/ceres/internal/reenable_warnings.h
index 947cdfd..5e6114f 100644
--- a/include/ceres/internal/reenable_warnings.h
+++ b/include/ceres/internal/reenable_warnings.h
@@ -27,6 +27,8 @@
 // POSSIBILITY OF SUCH DAMAGE.
 //
 
+// IWYU pragma: private
+
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
diff --git a/include/ceres/internal/sphere_manifold_functions.h b/include/ceres/internal/sphere_manifold_functions.h
index 4793442..ee39c89 100644
--- a/include/ceres/internal/sphere_manifold_functions.h
+++ b/include/ceres/internal/sphere_manifold_functions.h
@@ -32,6 +32,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_SPHERE_MANIFOLD_HELPERS_H_
 #define CERES_PUBLIC_INTERNAL_SPHERE_MANIFOLD_HELPERS_H_
 
+// IWYU pragma: private
+
 #include "ceres/constants.h"
 #include "ceres/internal/householder_vector.h"
 
diff --git a/include/ceres/internal/variadic_evaluate.h b/include/ceres/internal/variadic_evaluate.h
index f6dae6d..133ba3a 100644
--- a/include/ceres/internal/variadic_evaluate.h
+++ b/include/ceres/internal/variadic_evaluate.h
@@ -33,6 +33,8 @@
 #ifndef CERES_PUBLIC_INTERNAL_VARIADIC_EVALUATE_H_
 #define CERES_PUBLIC_INTERNAL_VARIADIC_EVALUATE_H_
 
+// IWYU pragma: private
+
 #include <algorithm>
 #include <array>
 #include <cstddef>
diff --git a/include/ceres/rotation.h b/include/ceres/rotation.h
index a5a205a..8647fbf 100644
--- a/include/ceres/rotation.h
+++ b/include/ceres/rotation.h
@@ -53,7 +53,7 @@
 #include "absl/log/check.h"
 #include "ceres/accurate_norm.h"
 #include "ceres/constants.h"
-#include "ceres/internal/euler_angles.h"
+#include "ceres/internal/euler_angles.h"  // IWYU pragma: export
 
 namespace ceres {
 
diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt
index ff2b267..0456c29 100644
--- a/internal/ceres/CMakeLists.txt
+++ b/internal/ceres/CMakeLists.txt
@@ -336,10 +336,14 @@
 # results in all compiler warnings from them being suppressed.
 target_link_libraries(ceres PUBLIC Eigen3::Eigen)
 
-# Generate an export header for annotating symbols visibility
+# Generate an export header for annotating symbols visibility. The header is
+# an implementation detail that must not be included directly by users.
 include(GenerateExportHeader)
+set(_Ceres_EXPORT_HEADER_CONTENT "// IWYU pragma: private")
 generate_export_header(ceres EXPORT_FILE_NAME
-  ${Ceres_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/ceres/internal/export.h)
+  ${Ceres_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/ceres/internal/export.h
+  CUSTOM_CONTENT_FROM_VARIABLE _Ceres_EXPORT_HEADER_CONTENT)
+unset(_Ceres_EXPORT_HEADER_CONTENT)
 
 if (_Ceres_FEATURE_CUDA)
   install(TARGETS ceres_cuda_kernels