Michael Platings 95f8d2a9fb Fix DynamicLibraryTests build on Windows when LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is ON
extract_symbols.py (introduced in D18826) expects all of its library arguments
to be in the same directory - typically <config>/lib. DynamicLibraryLib.lib is
instead to be found in lib/<config>.
This patch intended to make DynamicLibraryLib.lib be created in <config>/lib
alongside most of the other libraries.

I previously tried passing absolute paths to extract_symbols.py but this
generated command lines that were too long for Visual Studio 2015: D54587

Differential Revision: https://reviews.llvm.org/D54701


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347764 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-28 15:19:55 +00:00

52 lines
1.5 KiB
CMake

# Needed by LLVM's CMake checks because this file defines multiple targets.
set(LLVM_OPTIONAL_SOURCES ExportedFuncs.cpp PipSqueak.cpp)
set(LLVM_LINK_COMPONENTS Support)
add_library(DynamicLibraryLib STATIC
ExportedFuncs.cpp
)
set_target_properties(DynamicLibraryLib PROPERTIES FOLDER "Tests")
# extract_symbols.py relies on all its library arguments being in the same
# directory, so we must set the output directory in the same way as if
# add_llvm_library was used.
set_output_directory(DynamicLibraryLib
LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}
)
add_llvm_unittest(DynamicLibraryTests
DynamicLibraryTest.cpp
)
target_link_libraries(DynamicLibraryTests PRIVATE DynamicLibraryLib)
export_executable_symbols(DynamicLibraryTests)
function(dynlib_add_module NAME)
add_library(${NAME} SHARED
PipSqueak.cpp
)
set_target_properties(${NAME} PROPERTIES FOLDER "Tests")
set_output_directory(${NAME}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
)
set_target_properties(${NAME}
PROPERTIES PREFIX ""
SUFFIX ${LTDL_SHLIB_EXT}
)
add_dependencies(DynamicLibraryTests ${NAME})
endfunction(dynlib_add_module)
# Revert -Wl,-z,nodelete on this test since it relies on the file
# being unloaded.
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
string(REPLACE "-Wl,-z,nodelete" "" CMAKE_SHARED_LINKER_FLAGS
${CMAKE_SHARED_LINKER_FLAGS})
endif()
dynlib_add_module(PipSqueak)
dynlib_add_module(SecondLib)