Fix: cmake example with configure based oot build
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 4 Oct 2016 19:17:05 +0000 (15:17 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 4 Oct 2016 21:20:53 +0000 (17:20 -0400)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
doc/examples/cmake-multiple-shared-libraries/cmake/FindLTTngUST.cmake

index 18d28bdebc6652074e6a5518e248b6f908a581b4..a98970c50fb791e2d75f4408b82dd539f1bc720f 100644 (file)
 #  License text for the above reference.)
 
 find_path(LTTNGUST_INCLUDE_DIRS NAMES lttng/tracepoint.h)
+# Must also check for the path of generated header files since out-of-tree
+# build is a possibility (Yocto).
+find_path(LTTNGUST_INCLUDE_DIRS_GENERATED NAMES lttng/ust-config.h)
 find_library(LTTNGUST_LIBRARIES NAMES lttng-ust)
 
-if(LTTNGUST_INCLUDE_DIRS AND LTTNGUST_LIBRARIES)
+if(LTTNGUST_INCLUDE_DIRS AND LTTNGUST_INCLUDE_DIRS_GENERATED AND LTTNGUST_LIBRARIES)
   # find tracef() and tracelog() support
   set(LTTNGUST_HAS_TRACEF 0)
   set(LTTNGUST_HAS_TRACELOG 0)
@@ -61,7 +64,7 @@ if(LTTNGUST_INCLUDE_DIRS AND LTTNGUST_LIBRARIES)
   endif()
 
   # get version
-  set(lttngust_version_file "${LTTNGUST_INCLUDE_DIRS}/lttng/ust-version.h")
+  set(lttngust_version_file "${LTTNGUST_INCLUDE_DIRS_GENERATED}/lttng/ust-version.h")
 
   if(EXISTS "${lttngust_version_file}")
     file(STRINGS "${lttngust_version_file}" lttngust_version_major_string
@@ -84,6 +87,8 @@ if(LTTNGUST_INCLUDE_DIRS AND LTTNGUST_LIBRARIES)
     unset(lttngust_v_major)
     unset(lttngust_v_minor)
     unset(lttngust_v_patch)
+  else()
+    message(FATAL_ERROR "Missing version header")
   endif()
 
   unset(lttngust_version_file)
@@ -91,7 +96,7 @@ if(LTTNGUST_INCLUDE_DIRS AND LTTNGUST_LIBRARIES)
   if(NOT TARGET LTTng::UST)
     add_library(LTTng::UST UNKNOWN IMPORTED)
     set_target_properties(LTTng::UST PROPERTIES
-      INTERFACE_INCLUDE_DIRECTORIES "${LTTNGUST_INCLUDE_DIRS}"
+      INTERFACE_INCLUDE_DIRECTORIES "${LTTNGUST_INCLUDE_DIRS};${LTTNGUST_INCLUDE_DIRS_GENERATED}"
       INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}
       IMPORTED_LINK_INTERFACE_LANGUAGES "C"
       IMPORTED_LOCATION "${LTTNGUST_LIBRARIES}")
This page took 0.025264 seconds and 4 git commands to generate.