[unittest] Restructure plugin cmake target

Move plugin source and cmake files into separate directory.
Typically cmake targets in LLVM have a single target per directory.
This change brings this unittest more inline with that structure.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D140588
This commit is contained in:
ibricchi 2023-02-28 08:19:48 -08:00 committed by Mircea Trofin
parent 27ea470f22
commit e281d102fb
10 changed files with 54 additions and 42 deletions

View File

@ -1,43 +1,8 @@
# Needed by LLVM's CMake checks because this file defines multiple targets.
set(LLVM_OPTIONAL_SOURCES PluginsTest.cpp TestPlugin.cpp DoublerPlugin.cpp PassBuilderBindingsTest.cpp)
# The plugin expects to not link against the Support and Core libraries,
# but expects them to exist in the process loading the plugin. This doesn't
# work with DLLs on Windows (where a shared library can't have undefined
# references), so just skip this testcase on Windows.
if (NOT WIN32)
# On AIX, enable run-time linking to allow symbols from the plugins shared
# objects to be properly bound.
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-brtl")
endif()
set(LLVM_LINK_COMPONENTS Support Passes Core AsmParser)
add_llvm_unittest(PluginsTests
PluginsTest.cpp
)
export_executable_symbols_for_plugins(PluginsTests)
target_link_libraries(PluginsTests PRIVATE LLVMTestingSupport)
set(LLVM_LINK_COMPONENTS)
foreach(PLUGIN TestPlugin DoublerPlugin)
add_llvm_library(${PLUGIN} MODULE BUILDTREE_ONLY ${PLUGIN}.cpp)
# Put PLUGIN next to the unit test executable.
set_output_directory(${PLUGIN}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
)
set_target_properties(${PLUGIN} PROPERTIES FOLDER "Tests")
add_dependencies(${PLUGIN} intrinsics_gen)
add_dependencies(PluginsTests ${PLUGIN})
endforeach()
# On AIX, enable run-time linking to allow symbols from the plugins shared
# objects to be properly bound.
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-brtl")
endif()
set(LLVM_LINK_COMPONENTS Support Passes Core Target native AllTargetsInfos)
add_llvm_unittest(PassesBindingsTests
PassBuilderBindingsTest.cpp
)
target_link_libraries(PassesBindingsTests PRIVATE LLVMTestingSupport)
add_subdirectory(PassBuilderBindings)
add_subdirectory(Plugins)

View File

@ -0,0 +1,5 @@
set(LLVM_LINK_COMPONENTS Support Passes Core Target native AllTargetsInfos)
add_llvm_unittest(PassesBindingsTests
PassBuilderBindingsTest.cpp
)
target_link_libraries(PassesBindingsTests PRIVATE LLVMTestingSupport)

View File

@ -0,0 +1,16 @@
# The plugin expects to not link against the Support and Core libraries,
# but expects them to exist in the process loading the plugin. This doesn't
# work with DLLs on Windows (where a shared library can't have undefined
# references), so just skip this testcase on Windows.
if (NOT WIN32)
set(LLVM_LINK_COMPONENTS Support Passes Core AsmParser)
add_llvm_unittest(PluginsTests
PluginsTest.cpp
)
export_executable_symbols_for_plugins(PluginsTests)
target_link_libraries(PluginsTests PRIVATE LLVMTestingSupport)
unset(LLVM_LINK_COMPONENTS)
add_subdirectory(TestPlugin)
add_subdirectory(DoublerPlugin)
endif()

View File

@ -0,0 +1,13 @@
add_llvm_library(DoublerPlugin MODULE BUILDTREE_ONLY DoublerPlugin.cpp)
# Put PLUGIN next to the unit test executable.
set_output_directory(DoublerPlugin
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
)
set_target_properties(DoublerPlugin PROPERTIES FOLDER "Tests")
# The plugin depends on some of the output files of intrinsics_gen, so make sure
# it is built before the plugin.
add_dependencies(DoublerPlugin intrinsics_gen)
add_dependencies(PluginsTests DoublerPlugin)

View File

@ -0,0 +1,13 @@
add_llvm_library(TestPlugin MODULE BUILDTREE_ONLY TestPlugin.cpp)
# Put PLUGIN next to the unit test executable.
set_output_directory(TestPlugin
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
)
set_target_properties(TestPlugin PROPERTIES FOLDER "Tests")
# The plugin depends on some of the output files of intrinsics_gen, so make sure
# it is built before the plugin.
add_dependencies(TestPlugin intrinsics_gen)
add_dependencies(PluginsTests TestPlugin)

View File

@ -9,7 +9,7 @@
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "TestPlugin.h"
#include "../TestPlugin.h"
using namespace llvm;