[llvm-nm] - Fix a bug and unbreak ASan BB.
[llvm-complete.git] / unittests / Support / DynamicLibrary / CMakeLists.txt
blob1ea9826a3d155af918b0588f0b5f5757d69615f2
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} SHARED
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 ${LTDL_SHLIB_EXT}
38     )
40   add_dependencies(DynamicLibraryTests ${NAME})
41 endfunction(dynlib_add_module)
43 # Revert -Wl,-z,nodelete on this test since it relies on the file
44 # being unloaded.
45 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
46   string(REPLACE "-Wl,-z,nodelete" "" CMAKE_SHARED_LINKER_FLAGS
47     ${CMAKE_SHARED_LINKER_FLAGS})
48 endif()
50 dynlib_add_module(PipSqueak)
51 dynlib_add_module(SecondLib)