1 # Needed by LLVM's CMake checks because this file defines multiple targets.
2 set(LLVM_OPTIONAL_SOURCES ExportedFuncs.cpp PipSqueak.cpp)
4 set(LLVM_LINK_COMPONENTS Support)
6 add_library(DynamicLibraryLib STATIC
9 set_target_properties(DynamicLibraryLib PROPERTIES FOLDER "Tests")
11 # extract_symbols.py relies on all its library arguments being in the same
12 # directory, so we must set the output directory in the same way as if
13 # add_llvm_library was used.
14 set_output_directory(DynamicLibraryLib
15 LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}
18 add_llvm_unittest(DynamicLibraryTests
19 DynamicLibraryTest.cpp
21 target_link_libraries(DynamicLibraryTests PRIVATE DynamicLibraryLib)
22 export_executable_symbols(DynamicLibraryTests)
24 function(dynlib_add_module NAME)
25 add_library(${NAME} MODULE
28 set_target_properties(${NAME} PROPERTIES FOLDER "Tests")
30 set_output_directory(${NAME}
31 BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
32 LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
35 set_target_properties(${NAME}
37 SUFFIX ${LLVM_PLUGIN_EXT}
40 add_dependencies(DynamicLibraryTests ${NAME})
42 if(LLVM_INTEGRATED_CRT_ALLOC)
43 # We need to link in the Support lib for the Memory allocator override,
44 # otherwise the DynamicLibrary.Shutdown test will fail, because it would
45 # allocate memory with the CRT allocator, and release it with our custom
46 # allocator (see llvm/lib/Support/Windows/Memory.inc).
47 # /INCLUDE:malloc is there to force searching into LLVMSupport before libucrt
48 llvm_map_components_to_libnames(llvm_libs Support)
49 target_link_libraries(${NAME} ${llvm_libs} "-INCLUDE:malloc")
52 endfunction(dynlib_add_module)
54 # Revert -Wl,-z,nodelete on this test since it relies on the file
56 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
57 string(REPLACE "-Wl,-z,nodelete" "" CMAKE_MODULE_LINKER_FLAGS
58 ${CMAKE_MODULE_LINKER_FLAGS})
61 dynlib_add_module(PipSqueak)
62 dynlib_add_module(SecondLib)