Allow using parent project's hdr_histogram_static target
Tested-by: Build Bot
@@ -111,13 +111,20 @@ IF(LCB_USE_PROFILER)
INCLUDE(cmake/Modules/FindProfiler.cmake)
ENDIF()
IF(LCB_USE_HDR_HISTOGRAM)
+ # Allow for building libcouchbase inside a larger CMake project that
+ # already includes HdrHistogram_c
+ IF (NOT TARGET hdr_histogram_static)
ADD_SUBDIRECTORY(contrib/HdrHistogram_c)
+ ENDIF ()
+
+ # Use #include files from wherever the hdr_histogram project was loaded
+ INCLUDE_DIRECTORIES(BEFORE SYSTEM "${hdr_histogram_SOURCE_DIR}/src")
+
# Given we are linking hdr_histogram_static into libcouchbase.so, need
# -fPIC set also on hdr_histogram_static.
SET_TARGET_PROPERTIES(hdr_histogram_static
PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
- INCLUDE_DIRECTORIES(contrib/HdrHistogram_c/src)
SET(LCB_HDR_HISTOGRAM_LINK hdr_histogram_static)
LIST(APPEND LCB_CORE_SRC "src/hdr_timings.c")
ELSE()
