diff --git a/llvm/unittests/Passes/CMakeLists.txt b/llvm/unittests/Passes/CMakeLists.txt --- a/llvm/unittests/Passes/CMakeLists.txt +++ b/llvm/unittests/Passes/CMakeLists.txt @@ -1,43 +1,34 @@ -# 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) + # Needed by LLVM's CMake checks because this file defines multiple targets. + set(LLVM_OPTIONAL_SOURCES PassBuilderBindingsTest.cpp) + # 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 + 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() - + unset(LLVM_LINK_COMPONENTS) + add_subdirectory(TestPlugin) + add_subdirectory(DoublerPlugin) endif() +# Needed by LLVM's CMake checks because this file defines multiple targets. +set(LLVM_OPTIONAL_SOURCES PluginsTest.cpp) + set(LLVM_LINK_COMPONENTS Support Passes Core Target native AllTargetsInfos) add_llvm_unittest(PassesBindingsTests - PassBuilderBindingsTest.cpp - ) +PassBuilderBindingsTest.cpp +) target_link_libraries(PassesBindingsTests PRIVATE LLVMTestingSupport) diff --git a/llvm/unittests/Passes/DoublerPlugin/CMakeLists.txt b/llvm/unittests/Passes/DoublerPlugin/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/llvm/unittests/Passes/DoublerPlugin/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/llvm/unittests/Passes/DoublerPlugin.cpp b/llvm/unittests/Passes/DoublerPlugin/DoublerPlugin.cpp rename from llvm/unittests/Passes/DoublerPlugin.cpp rename to llvm/unittests/Passes/DoublerPlugin/DoublerPlugin.cpp diff --git a/llvm/unittests/Passes/TestPlugin/CMakeLists.txt b/llvm/unittests/Passes/TestPlugin/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/llvm/unittests/Passes/TestPlugin/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/llvm/unittests/Passes/TestPlugin.cpp b/llvm/unittests/Passes/TestPlugin/TestPlugin.cpp rename from llvm/unittests/Passes/TestPlugin.cpp rename to llvm/unittests/Passes/TestPlugin/TestPlugin.cpp --- a/llvm/unittests/Passes/TestPlugin.cpp +++ b/llvm/unittests/Passes/TestPlugin/TestPlugin.cpp @@ -9,7 +9,7 @@ #include "llvm/Passes/PassBuilder.h" #include "llvm/Passes/PassPlugin.h" -#include "TestPlugin.h" +#include "../TestPlugin.h" using namespace llvm;