Skip to content

Commit e281d10

Browse files
ibricchimtrofin
authored andcommitted
[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
1 parent 27ea470 commit e281d10

File tree

10 files changed

+54
-42
lines changed

10 files changed

+54
-42
lines changed

llvm/unittests/Passes/CMakeLists.txt

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,8 @@
1-
# Needed by LLVM's CMake checks because this file defines multiple targets.
2-
set(LLVM_OPTIONAL_SOURCES PluginsTest.cpp TestPlugin.cpp DoublerPlugin.cpp PassBuilderBindingsTest.cpp)
3-
4-
# The plugin expects to not link against the Support and Core libraries,
5-
# but expects them to exist in the process loading the plugin. This doesn't
6-
# work with DLLs on Windows (where a shared library can't have undefined
7-
# references), so just skip this testcase on Windows.
8-
if (NOT WIN32)
9-
# On AIX, enable run-time linking to allow symbols from the plugins shared
10-
# objects to be properly bound.
11-
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
12-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-brtl")
13-
endif()
14-
set(LLVM_LINK_COMPONENTS Support Passes Core AsmParser)
15-
add_llvm_unittest(PluginsTests
16-
PluginsTest.cpp
17-
)
18-
export_executable_symbols_for_plugins(PluginsTests)
19-
target_link_libraries(PluginsTests PRIVATE LLVMTestingSupport)
20-
21-
set(LLVM_LINK_COMPONENTS)
22-
foreach(PLUGIN TestPlugin DoublerPlugin)
23-
add_llvm_library(${PLUGIN} MODULE BUILDTREE_ONLY ${PLUGIN}.cpp)
24-
25-
# Put PLUGIN next to the unit test executable.
26-
set_output_directory(${PLUGIN}
27-
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
28-
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
29-
)
30-
set_target_properties(${PLUGIN} PROPERTIES FOLDER "Tests")
31-
32-
add_dependencies(${PLUGIN} intrinsics_gen)
33-
add_dependencies(PluginsTests ${PLUGIN})
34-
endforeach()
35-
1+
# On AIX, enable run-time linking to allow symbols from the plugins shared
2+
# objects to be properly bound.
3+
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
4+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-brtl")
365
endif()
376

38-
set(LLVM_LINK_COMPONENTS Support Passes Core Target native AllTargetsInfos)
39-
add_llvm_unittest(PassesBindingsTests
40-
PassBuilderBindingsTest.cpp
41-
)
42-
target_link_libraries(PassesBindingsTests PRIVATE LLVMTestingSupport)
43-
7+
add_subdirectory(PassBuilderBindings)
8+
add_subdirectory(Plugins)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set(LLVM_LINK_COMPONENTS Support Passes Core Target native AllTargetsInfos)
2+
add_llvm_unittest(PassesBindingsTests
3+
PassBuilderBindingsTest.cpp
4+
)
5+
target_link_libraries(PassesBindingsTests PRIVATE LLVMTestingSupport)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The plugin expects to not link against the Support and Core libraries,
2+
# but expects them to exist in the process loading the plugin. This doesn't
3+
# work with DLLs on Windows (where a shared library can't have undefined
4+
# references), so just skip this testcase on Windows.
5+
if (NOT WIN32)
6+
set(LLVM_LINK_COMPONENTS Support Passes Core AsmParser)
7+
add_llvm_unittest(PluginsTests
8+
PluginsTest.cpp
9+
)
10+
export_executable_symbols_for_plugins(PluginsTests)
11+
target_link_libraries(PluginsTests PRIVATE LLVMTestingSupport)
12+
13+
unset(LLVM_LINK_COMPONENTS)
14+
add_subdirectory(TestPlugin)
15+
add_subdirectory(DoublerPlugin)
16+
endif()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
add_llvm_library(DoublerPlugin MODULE BUILDTREE_ONLY DoublerPlugin.cpp)
2+
3+
# Put PLUGIN next to the unit test executable.
4+
set_output_directory(DoublerPlugin
5+
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
6+
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
7+
)
8+
set_target_properties(DoublerPlugin PROPERTIES FOLDER "Tests")
9+
10+
# The plugin depends on some of the output files of intrinsics_gen, so make sure
11+
# it is built before the plugin.
12+
add_dependencies(DoublerPlugin intrinsics_gen)
13+
add_dependencies(PluginsTests DoublerPlugin)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
add_llvm_library(TestPlugin MODULE BUILDTREE_ONLY TestPlugin.cpp)
2+
3+
# Put PLUGIN next to the unit test executable.
4+
set_output_directory(TestPlugin
5+
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
6+
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
7+
)
8+
set_target_properties(TestPlugin PROPERTIES FOLDER "Tests")
9+
10+
# The plugin depends on some of the output files of intrinsics_gen, so make sure
11+
# it is built before the plugin.
12+
add_dependencies(TestPlugin intrinsics_gen)
13+
add_dependencies(PluginsTests TestPlugin)

llvm/unittests/Passes/TestPlugin.cpp renamed to llvm/unittests/Passes/Plugins/TestPlugin/TestPlugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "llvm/Passes/PassBuilder.h"
1010
#include "llvm/Passes/PassPlugin.h"
1111

12-
#include "TestPlugin.h"
12+
#include "../TestPlugin.h"
1313

1414
using namespace llvm;
1515

0 commit comments

Comments
 (0)