brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 98b7f2d Raw
74 lines · plain
1# Needed by LLVM's CMake checks because this file defines multiple targets.2set(LLVM_OPTIONAL_SOURCES ExportedFuncs.cpp PipSqueak.cpp)3 4set(LLVM_LINK_COMPONENTS Support)5 6add_library(DynamicLibraryLib STATIC7  ExportedFuncs.cpp8  )9set_target_properties(DynamicLibraryLib PROPERTIES FOLDER "LLVM/Tests/Support")10 11# extract_symbols.py relies on all its library arguments being in the same12# directory, so we must set the output directory in the same way as if13# add_llvm_library was used.14set_output_directory(DynamicLibraryLib15  LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}16  )17 18# FIXME: Find out why AIX fails with new DynamicLibrary symbols behavior.19if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")20  add_llvm_unittest(DynamicLibraryTests21    DynamicLibraryTest.cpp22    )23else()24  add_llvm_unittest(DynamicLibraryTests25    DynamicLibraryTest.cpp26 27    EXPORT_SYMBOLS28    )29endif()30target_link_libraries(DynamicLibraryTests PRIVATE DynamicLibraryLib)31if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")32  export_executable_symbols(DynamicLibraryTests)33endif()34 35function(dynlib_add_module NAME)36  add_library(${NAME} MODULE37    PipSqueak.cpp38    )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 would56    # allocate memory with the CRT allocator, and release it with our custom57    # allocator (see llvm/lib/Support/Windows/Memory.inc).58    # /INCLUDE:malloc is there to force searching into LLVMSupport before libucrt59    llvm_map_components_to_libnames(llvm_libs Support)60    target_link_libraries(${NAME} ${llvm_libs} "-INCLUDE:malloc")61  endif()62 63endfunction(dynlib_add_module)64 65# Revert -Wl,-z,nodelete on this test since it relies on the file66# being unloaded.67if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")68  string(REPLACE "-Wl,-z,nodelete" "" CMAKE_MODULE_LINKER_FLAGS69    ${CMAKE_MODULE_LINKER_FLAGS})70endif()71 72dynlib_add_module(PipSqueak)73dynlib_add_module(SecondLib)74