Adding autogenerated Ceres config.h to #define Ceres compile options.
- Previously we passed all compile options to Ceres via add_definitions
in CMake. This was fine for private definitions (used only by Ceres)
but required additional work for public definitions to ensure they
were correctly propagated to clients via CMake using
target_compile_definitions() (>= 2.8.11) or add_definitions().
- A drawback to these approaches is that they did not work for chained
dependencies on Ceres, as in if in the users project B <- A <- Ceres,
then although the required Ceres public compile definitions would
be used when compiling A, they would not be propagated to B.
- This patch replaces the addition of compile definitions via
add_definitions() with an autogenerated config.h header which
is installed with Ceres and defines all of the enabled Ceres compile
options.
- This removes the need for the user to propagate any compile
definitions in their projects, and additionally allows post-install
inspect of the options with which Ceres was compiled.
Change-Id: Idbdb6abdad0eb31e7540370e301afe87a07f2260
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index eda929b..dff6ef0 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -28,8 +28,11 @@
#
# Author: keir@google.com (Keir Mierle)
+# Only Ceres itself should be compiled with CERES_BUILDING_SHARED_LIBRARY
+# defined, any users of Ceres will have CERES_USING_SHARED_LIBRARY defined
+# for them in Ceres' config.h if appropriate.
IF (BUILD_SHARED_LIBS)
- ADD_DEFINITIONS(-DCERES_USING_SHARED_LIBRARY)
+ REMOVE_DEFINITIONS(-DCERES_BUILDING_SHARED_LIBRARY)
ENDIF()
ADD_EXECUTABLE(helloworld helloworld.cc)