CMake: Make the path to the Clang tool configurable

Set `SAPI_CLANG_TOOL_EXECUTABLE` to specify the location of a pre-built Clang
tool based header generator.

PiperOrigin-RevId: 531425738
Change-Id: I723d19122cc738d9906c8c568d156d44c58d9746
This commit is contained in:
Christian Blichmann 2023-05-12 00:29:13 -07:00 committed by Copybara-Service
parent 4925df5419
commit b6cc0ce80d
3 changed files with 13 additions and 3 deletions

View File

@ -155,8 +155,12 @@ function(add_sapi_library)
if(SAPI_ENABLE_CLANG_TOOL) if(SAPI_ENABLE_CLANG_TOOL)
set(_sapi_isystem_args ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) set(_sapi_isystem_args ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
list(TRANSFORM _sapi_isystem_args PREPEND --extra-arg-before=-isystem) list(TRANSFORM _sapi_isystem_args PREPEND --extra-arg-before=-isystem)
if(SAPI_CLANG_TOOL_EXECUTABLE)
list(APPEND _sapi_generator_command "${SAPI_CLANG_TOOL_EXECUTABLE}")
else()
list(APPEND _sapi_generator_command sapi_generator_tool)
endif()
list(APPEND _sapi_generator_command list(APPEND _sapi_generator_command
sapi_generator_tool
-p "${CMAKE_CURRENT_BINARY_DIR}" -p "${CMAKE_CURRENT_BINARY_DIR}"
${_sapi_generator_args} ${_sapi_generator_args}
${_sapi_isystem_args} ${_sapi_isystem_args}

View File

@ -95,7 +95,13 @@ endif()
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
if(NOT SAPI_ENABLE_CLANG_TOOL) if(SAPI_ENABLE_CLANG_TOOL)
# If unset (the default), CMake will build the tool first and add it as a
# dependency.
set(SAPI_CLANG_TOOL_EXECUTABLE "" CACHE FILEPATH
"Path to the Clang tool based header generator"
)
else()
# Find Python 3 and add its location to the cache so that its available in # Find Python 3 and add its location to the cache so that its available in
# the add_sapi_library() macro in embedding projects. # the add_sapi_library() macro in embedding projects.
find_package(Python3 COMPONENTS Interpreter REQUIRED) find_package(Python3 COMPONENTS Interpreter REQUIRED)

View File

@ -15,7 +15,7 @@
add_subdirectory(tools/filewrapper) add_subdirectory(tools/filewrapper)
add_subdirectory(sandbox2) add_subdirectory(sandbox2)
add_subdirectory(util) add_subdirectory(util)
if(SAPI_ENABLE_CLANG_TOOL) if(SAPI_ENABLE_CLANG_TOOL AND NOT SAPI_CLANG_TOOL_EXECUTABLE)
add_subdirectory(tools/clang_generator) add_subdirectory(tools/clang_generator)
endif() endif()
add_subdirectory(examples) add_subdirectory(examples)