Add and use FindLibClang module for c-picker setup
c-picker uses libclang to parse the code. If compatible libclang is not
available in the system's default library directory c-picker needs to
have CLANG_LIBRARY_PATH environment variable pointing to the suitable
directory. The new module tries to find this directory and the
environment variable is now set during the c-picker call.
Change-Id: I09327b2d09620884ee72ff831ead546a0d10b900
Signed-off-by: Imre Kis <imre.kis@arm.com>
diff --git a/cmake/UnitTest.cmake b/cmake/UnitTest.cmake
index d2255df..207b25c 100644
--- a/cmake/UnitTest.cmake
+++ b/cmake/UnitTest.cmake
@@ -11,6 +11,7 @@
# CPICKER_COMMAND: command of the c-picker
# CPICKER_CACHE_PATH: root directory of the c-picker generate files
# UNIT_TEST_COMMON_SOURCES: common source files for every test build
+# CLANG_LIBRARY_PATH: libclang directory for c-picker
# Modules
# CTest module should be included in the root CMakeLists.txt before calling this function
@@ -43,14 +44,18 @@
# Fetching referenced source files as the dependencies of the generated file
execute_process(
- COMMAND ${CPICKER_COMMAND} --config ${TEST_SOURCE} --root ${TF_A_PATH} --print-dependencies
+ COMMAND
+ ${CMAKE_COMMAND} -E env CLANG_LIBRARY_PATH=${CLANG_LIBRARY_PATH}
+ ${CPICKER_COMMAND} --config ${TEST_SOURCE} --root ${TF_A_PATH} --print-dependencies
OUTPUT_VARIABLE CPICKER_DEPENDENCIES
)
# Adding custom command for invoking c-picker
add_custom_command(
OUTPUT ${CPICKER_OUTPUT}
- COMMAND ${CPICKER_COMMAND} --config ${TEST_SOURCE} --root ${TF_A_PATH} > ${CPICKER_OUTPUT}
+ COMMAND
+ ${CMAKE_COMMAND} -E env CLANG_LIBRARY_PATH=${CLANG_LIBRARY_PATH}
+ ${CPICKER_COMMAND} --config ${TEST_SOURCE} --root ${TF_A_PATH} > ${CPICKER_OUTPUT}
DEPENDS ${TEST_SOURCE} ${CPICKER_DEPENDENCIES}
COMMENT "Generating c-picker output ${CPICKER_OUTPUT}"
)