1From f6ca8c930d0fbd2491b3cc77169e32806a14e5e9 Mon Sep 17 00:00:00 2001
2From: Matteo Croce <mcroce@microsoft.com>
3Date: Mon, 30 Aug 2021 16:25:56 +0200
4Subject: [PATCH] CMakeList.txt: make python optional
5
6Upstream-Status: Backport [https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=88431099950ab3e8bc1645353508d7978a6cad35]
7
8ostra-cg, which requires python, is installed in the destination dir.
9Make it optional for embedded distributions which doesn't have the
10python interpreter available.
11
12Signed-off-by: Matteo Croce <mcroce@microsoft.com>
13---
14 CMakeLists.txt | 7 +++++--
15 1 file changed, 5 insertions(+), 2 deletions(-)
16
17diff --git a/CMakeLists.txt b/CMakeLists.txt
18index 4140574..8523bce 100644
19--- a/CMakeLists.txt
20+++ b/CMakeLists.txt
21@@ -61,6 +61,7 @@ find_package(DWARF REQUIRED)
22 find_package(ZLIB REQUIRED)
23 find_package(argp REQUIRED)
24 find_package(obstack REQUIRED)
25+find_package(Python3 QUIET)
26
27 # make sure git submodule(s) are checked out
28 find_package(Git QUIET)
29@@ -185,8 +186,10 @@ install(FILES dwarves.h dwarves_emit.h dwarves_reorganize.h
30 	      elfcreator.h elf_symtab.h hash.h libctf.h
31 	DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dwarves/)
32 install(FILES man-pages/pahole.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1/)
33-install(PROGRAMS ostra/ostra-cg DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
34+if(Python3_FOUND)
35+	install(PROGRAMS ostra/ostra-cg DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
36+	install(FILES ostra/python/ostra.py DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dwarves/runtime/python)
37+endif()
38 install(PROGRAMS btfdiff fullcircle DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
39-install(FILES ostra/python/ostra.py DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dwarves/runtime/python)
40 install(FILES lib/Makefile lib/ctracer_relay.c lib/ctracer_relay.h lib/linux.blacklist.cu
41 	DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dwarves/runtime)
42--
432.31.1
44
45