[docs] Fix build-docs.sh
[llvm-project.git] / llvm / unittests / Support / DynamicLibrary / CMakeLists.txt
blob9e5d3b3dfb159eff67c69c3f51521668206f1dd8
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
7   ExportedFuncs.cpp
8   )
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}
16   )
18 add_llvm_unittest(DynamicLibraryTests
19   DynamicLibraryTest.cpp
20   )
21 target_link_libraries(DynamicLibraryTests PRIVATE DynamicLibraryLib)
22 export_executable_symbols(DynamicLibraryTests)
24 function(dynlib_add_module NAME)
25   add_library(${NAME} MODULE
26     PipSqueak.cpp
27     )
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}
33     )
35   set_target_properties(${NAME}
36     PROPERTIES PREFIX ""
37     SUFFIX ${LLVM_PLUGIN_EXT}
38     )
40   add_dependencies(DynamicLibraryTests ${NAME})
41   
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")
50   endif()
51   
52 endfunction(dynlib_add_module)
54 # Revert -Wl,-z,nodelete on this test since it relies on the file
55 # being unloaded.
56 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
57   string(REPLACE "-Wl,-z,nodelete" "" CMAKE_MODULE_LINKER_FLAGS
58     ${CMAKE_MODULE_LINKER_FLAGS})
59 endif()
61 dynlib_add_module(PipSqueak)
62 dynlib_add_module(SecondLib)