Blob Blame History Raw
From 5495595234e8fb7b1715429cfa41fe6d9c0e710c Mon Sep 17 00:00:00 2001
From: Jeremy Newton <Jeremy.Newton@amd.com>
Date: Thu, 14 Apr 2022 12:55:00 -0400
Subject: [PATCH] Detect if clang is static or shared

For some distros, such as Fedora, they discourage use of static
libraries, so static clang might not be available. The issue is that
shared clang is separated into two libs, clang and clang-cpp, while the
static libs are much more granular, so the library names are different
in either case.

To allow the shared clang case, look for the static clangFrontendTool
lib before attempting to link with it, else wise fall back to linking
against the shared clang-cpp lib, which contains the symbols we need.

Signed-off-by: Jeremy Newton <Jeremy.Newton@amd.com>
Change-Id: I61917bcc0d5a3064aa841ff104b8008296dd85b7
---
 lib/comgr/CMakeLists.txt | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/comgr/CMakeLists.txt b/lib/comgr/CMakeLists.txt
index 8b5ca2f..f69f1a9 100644
--- a/lib/comgr/CMakeLists.txt
+++ b/lib/comgr/CMakeLists.txt
@@ -293,8 +293,13 @@ install(FILES
   "${AMD_COMGR_VERSION_PATH}"
   DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}")
 
-set(CLANG_LIBS
-  clangFrontendTool)
+if(TARGET clangFrontendTool)
+  set(CLANG_LIBS
+    clangFrontendTool)
+else()
+  set(CLANG_LIBS
+    clang-cpp)
+endif()
 
 set(LLD_LIBS
   lldELF
-- 
2.35.1