Skip to content

Commit 2f36f41

Browse files
committed
Fix GTest include search path with other runtimes
1 parent 8f9da82 commit 2f36f41

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

flang-rt/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if (LLVM_TREE_AVAILABLE)
4343
# flang-new uses the same resource dir as clang.
4444
include(GetClangResourceDir)
4545
get_clang_resource_dir(FLANGRT_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
46-
get_clang_resource_dir(FLANGRT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command find the install prefix itself
46+
get_clang_resource_dir(FLANGRT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command finds the install prefix itself
4747
else ()
4848
set(FLANGRT_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
4949
set(FLANGRT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ function (add_flangrt_library name)
102102
else()
103103
llvm_map_components_to_libnames(llvm_libs Support)
104104
endif()
105-
target_link_libraries(${name} PUBLIC ${llvm_libs})
106-
target_include_directories(${name} PRIVATE ${LLVM_INCLUDE_DIRS})
105+
target_link_libraries(${name} PUBLIC ${llvm_libs})
106+
target_include_directories(${name} PUBLIC ${LLVM_INCLUDE_DIRS})
107107
endif ()
108108

109109
# If this is part of the toolchain, put it into the compiler's resource

flang-rt/unittests/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
#===------------------------------------------------------------------------===#
88

99
# Add GTest if not already present.
10-
# Using a function so include_directories/LLVM_SUBPROJECT_TITLE does not propagate
10+
# Using a function so LLVM_SUBPROJECT_TITLE does not propagate.
1111
function (build_gtest)
12-
include_directories("${LLVM_INCLUDE_DIR}" "${LLVM_MAIN_INCLUDE_DIR}")
1312
set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
1413
add_subdirectory("${LLVM_THIRD_PARTY_DIR}/unittest" "${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest")
1514
endfunction ()
1615
if (NOT TARGET llvm_gtest)
1716
build_gtest()
1817
endif ()
1918

19+
# LLVM's modified GTest depends on LLVM, but not all runtime projects using
20+
# GTest also add the include search path.
21+
target_include_directories(llvm_gtest PUBLIC "${LLVM_INCLUDE_DIR}" "${LLVM_MAIN_INCLUDE_DIR}")
22+
2023
# Required because LLVMSupport is compiled with this option (by default).
2124
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
2225

0 commit comments

Comments
 (0)