From b6cc0ce80d9672477914490fa0e50125cd93b874 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Fri, 12 May 2023 00:29:13 -0700 Subject: [PATCH] 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 --- cmake/SapiBuildDefs.cmake | 6 +++++- cmake/SapiDeps.cmake | 8 +++++++- sandboxed_api/CMakeLists.txt | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmake/SapiBuildDefs.cmake b/cmake/SapiBuildDefs.cmake index 0362673..95adc13 100644 --- a/cmake/SapiBuildDefs.cmake +++ b/cmake/SapiBuildDefs.cmake @@ -155,8 +155,12 @@ function(add_sapi_library) if(SAPI_ENABLE_CLANG_TOOL) set(_sapi_isystem_args ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) 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 - sapi_generator_tool -p "${CMAKE_CURRENT_BINARY_DIR}" ${_sapi_generator_args} ${_sapi_isystem_args} diff --git a/cmake/SapiDeps.cmake b/cmake/SapiDeps.cmake index 4dba192..2e595c6 100644 --- a/cmake/SapiDeps.cmake +++ b/cmake/SapiDeps.cmake @@ -95,7 +95,13 @@ endif() 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 # the add_sapi_library() macro in embedding projects. find_package(Python3 COMPONENTS Interpreter REQUIRED) diff --git a/sandboxed_api/CMakeLists.txt b/sandboxed_api/CMakeLists.txt index 890ed07..ad6baec 100644 --- a/sandboxed_api/CMakeLists.txt +++ b/sandboxed_api/CMakeLists.txt @@ -15,7 +15,7 @@ add_subdirectory(tools/filewrapper) add_subdirectory(sandbox2) add_subdirectory(util) -if(SAPI_ENABLE_CLANG_TOOL) +if(SAPI_ENABLE_CLANG_TOOL AND NOT SAPI_CLANG_TOOL_EXECUTABLE) add_subdirectory(tools/clang_generator) endif() add_subdirectory(examples)