Debian Codegraph @

llvm/unittests/Support/DynamicLibrary/CMakeLists.txt

raw
1 # Needed by LLVM's CMake checks because this file defines multiple targets.
2 set(LLVM_OPTIONAL_SOURCES ExportedFuncs.cpp PipSqueak.cpp)
3
4 set(LLVM_LINK_COMPONENTS Support)
5
6 add_library(DynamicLibraryLib STATIC
7 ExportedFuncs.cpp
8 )
9 set_target_properties(DynamicLibraryLib PROPERTIES FOLDER "LLVM/Tests/Support")
10
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 )
17
18 # FIXME: Find out why AIX fails with new DynamicLibrary symbols behavior.
19 if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
20 add_llvm_unittest(DynamicLibraryTests
21 DynamicLibraryTest.cpp
22 )
23 else()
24 add_llvm_unittest(DynamicLibraryTests
25 DynamicLibraryTest.cpp
26
27 EXPORT_SYMBOLS
28 )
29 endif()
30 target_link_libraries(DynamicLibraryTests PRIVATE DynamicLibraryLib)
31 if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
32 export_executable_symbols(DynamicLibraryTests)
33 endif()
34
35 function(dynlib_add_module NAME)
36 add_library(${NAME} MODULE
37 PipSqueak.cpp
38 )
39 set_target_properties(${NAME} PROPERTIES FOLDER "LLVM/Tests/Support")
40
41 set_output_directory(${NAME}
42 BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
43 LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
44 )
45
46 set_target_properties(${NAME}
47 PROPERTIES PREFIX ""
48 SUFFIX ${LLVM_PLUGIN_EXT}
49 )
50
51 add_dependencies(DynamicLibraryTests ${NAME})
52
53 if(LLVM_INTEGRATED_CRT_ALLOC)
54 # We need to link in the Support lib for the Memory allocator override,
55 # otherwise the DynamicLibrary.Shutdown test will fail, because it would
56 # allocate memory with the CRT allocator, and release it with our custom
57 # allocator (see llvm/lib/Support/Windows/Memory.inc).
58 # /INCLUDE:malloc is there to force searching into LLVMSupport before libucrt
59 llvm_map_components_to_libnames(llvm_libs Support)
60 target_link_libraries(${NAME} ${llvm_libs} "-INCLUDE:malloc")
61 endif()
62
63 endfunction(dynlib_add_module)
64
65 # Revert -Wl,-z,nodelete on this test since it relies on the file
66 # being unloaded.
67 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
68 string(REPLACE "-Wl,-z,nodelete" "" CMAKE_MODULE_LINKER_FLAGS
69 ${CMAKE_MODULE_LINKER_FLAGS})
70 endif()
71
72 dynlib_add_module(PipSqueak)
73 dynlib_add_module(SecondLib)