Files
llvm-project/polly/unittests/CMakeLists.txt
Peter Waller d629a22170 [Polly] Disable PCH reuse for unit tests (#193209)
Polly library targets already disable PCH reuse because Polly
unconditionally builds with -fno-rtti and -fno-exceptions. Reusing LLVM
PCHs that were built with RTTI or exceptions enabled is incompatible
with Clang when compiling Polly targets under those flags.

After 47eb8b43c9 enabled PCH reuse for unit tests, Polly unit tests
can hit the same mismatch as the library targets. Pass DISABLE_PCH_REUSE
through the shared add_polly_unittest wrapper so all Polly unit tests
follow the existing Polly target policy.

cc @aengelke -- a minor fix for polly.
2026-04-21 12:43:13 +00:00

35 lines
1.3 KiB
CMake

add_custom_target(PollyUnitTests)
set_target_properties(PollyUnitTests PROPERTIES FOLDER "Polly/Tests")
# add_polly_unittest(test_dirname file1.cpp file2.cpp)
#
# Will compile the list of files together and link against Polly and its dependences.
function(add_polly_unittest test_name)
if(COMMAND add_unittest)
# Match Polly library targets: Polly unit tests inherit Polly's
# unconditional -fno-rtti -fno-exceptions policy. Reusing LLVM PCHs
# built with RTTI or exceptions enabled is incompatible with Clang.
add_unittest(PollyUnitTests ${test_name} DISABLE_PCH_REUSE ${ARGN})
else()
add_executable(${test_name} EXCLUDE_FROM_ALL ${ARGN})
set_target_properties(${test_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(${test_name} PRIVATE gtest_main gtest)
add_dependencies(PollyUnitTests ${test_name})
endif()
set_property(TARGET ${test_name} PROPERTY FOLDER "Polly/Tests/Unit")
if(LLVM_LINK_LLVM_DYLIB AND LLVM_POLLY_LINK_INTO_TOOLS)
# In this case Polly is already present in libLLVM,
# no need to link it again.
else()
target_link_libraries(${test_name} PRIVATE Polly)
endif()
endfunction()
add_subdirectory(Isl)
add_subdirectory(Flatten)
add_subdirectory(DeLICM)
add_subdirectory(ScheduleOptimizer)
add_subdirectory(Support)