aboutsummaryrefslogtreecommitdiff
path: root/tools/clang/blink_gc_plugin/CMakeLists.txt
blob: 009807b4164f92838d790d16f3a69df09407797a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
set(LIBRARYNAME BlinkGCPlugin)

set(plugin_sources
  BlinkGCPlugin.cpp
  BlinkGCPluginConsumer.cpp
  CheckDispatchVisitor.cpp
  CheckFieldsVisitor.cpp
  CheckFinalizerVisitor.cpp
  CheckGCRootsVisitor.cpp
  CheckTraceVisitor.cpp
  CollectVisitor.cpp
  Config.cpp
  DiagnosticsReporter.cpp
  Edge.cpp
  RecordInfo.cpp)

if(WIN32)
  # Clang doesn't support loadable modules on Windows. Unfortunately, building
  # the plugin as a static library and linking clang against it doesn't work.
  # Since clang doesn't reference any symbols in our static library, the linker
  # strips it out completely.
  # Instead, we rely on the fact that the SOURCES property of a target is no
  # read-only after CMake 3.1 and use it to compile the plugin directly into
  # clang...
  cmake_minimum_required(VERSION 3.1)
  # Paths must be absolute, since we're modifying a target in another directory.
  set(absolute_sources "")
  foreach(source ${plugin_sources})
    list(APPEND absolute_sources ${CMAKE_CURRENT_SOURCE_DIR}/${source})
  endforeach()
  set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources})

  cr_add_test(blink_gc_plugin_test
    python tests/test.py
    ${CMAKE_BINARY_DIR}/bin/clang
    )
else()
  add_llvm_loadable_module("lib${LIBRARYNAME}" ${plugin_sources})
  add_dependencies("lib${LIBRARYNAME}" clang)

  cr_install(TARGETS "lib${LIBRARYNAME}" LIBRARY DESTINATION lib)

  cr_add_test(blink_gc_plugin_test
    python tests/test.py
    ${CMAKE_BINARY_DIR}/bin/clang
    $<TARGET_FILE:lib${LIBRARYNAME}>
    )
endif()