diff --git a/ThunkLibs/Generator/CMakeLists.txt b/ThunkLibs/Generator/CMakeLists.txt index f628db6874..8214c558f5 100644 --- a/ThunkLibs/Generator/CMakeLists.txt +++ b/ThunkLibs/Generator/CMakeLists.txt @@ -1,13 +1,6 @@ find_package(Clang REQUIRED CONFIG) find_package(OpenSSL REQUIRED COMPONENTS Crypto) -add_library(thunkgenlib analysis.cpp data_layout.cpp gen.cpp) -target_include_directories(thunkgenlib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -target_include_directories(thunkgenlib SYSTEM PUBLIC ${CLANG_INCLUDE_DIRS}) -target_link_libraries(thunkgenlib PUBLIC clang-cpp LLVM) -target_link_libraries(thunkgenlib PRIVATE OpenSSL::Crypto) -target_link_libraries(thunkgenlib PRIVATE fmt::fmt) - # Query clang's global resource directory for system include directories if (NOT CLANG_RESOURCE_DIR) find_program(CLANG_EXEC_PATH clang REQUIRED) @@ -18,6 +11,13 @@ if (NOT CLANG_RESOURCE_DIR) OUTPUT_STRIP_TRAILING_WHITESPACE) endif() +add_library(thunkgenlib analysis.cpp data_layout.cpp gen.cpp) +target_include_directories(thunkgenlib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(thunkgenlib SYSTEM PUBLIC ${CLANG_INCLUDE_DIRS}) +target_link_libraries(thunkgenlib PUBLIC clang-cpp LLVM) +target_link_libraries(thunkgenlib PRIVATE OpenSSL::Crypto) +target_link_libraries(thunkgenlib PRIVATE fmt::fmt) +target_compile_definitions(thunkgenlib INTERFACE -DCLANG_RESOURCE_DIR="${CLANG_RESOURCE_DIR}") + add_executable(thunkgen main.cpp) target_link_libraries(thunkgen PRIVATE thunkgenlib) -target_compile_definitions(thunkgen PRIVATE -DCLANG_RESOURCE_DIR="${CLANG_RESOURCE_DIR}") diff --git a/unittests/ThunkLibs/common.h b/unittests/ThunkLibs/common.h index d31b104104..6fe13022eb 100644 --- a/unittests/ThunkLibs/common.h +++ b/unittests/ThunkLibs/common.h @@ -65,6 +65,10 @@ inline void run_tool(clang::tooling::ToolAction& action, std::string_view code, const char* memory_filename = "gen_input.cpp"; auto adjuster = clang::tooling::getClangStripDependencyFileAdjuster(); std::vector args = { "clang-tool", "-fsyntax-only", "-std=c++17", "-Werror", "-I.", memory_filename }; + if (CLANG_RESOURCE_DIR[0] != 0) { + args.push_back("-resource-dir"); + args.push_back(CLANG_RESOURCE_DIR); + } if (guest_abi == GuestABI::X86_64) { args.push_back("-target"); args.push_back("x86_64-linux-gnu");