CMakeLists.txt 3.04 KB
Newer Older
1 2 3

# kj ===========================================================================

4
set(kj_sources_lite
5
  array.c++
6
  common.c++
7
  debug.c++
8
  exception.c++
9
  io.c++
10
  memory.c++
11
  mutex.c++
12
  string.c++
13
  thread.c++
14 15 16 17 18 19
)
set(kj_sources_heavy
  units.c++
  refcount.c++
  string-tree.c++
  arena.c++
20 21 22
  main.c++
  parse/char.c++
)
23 24 25 26 27 28
if(NOT CAPNP_LITE)
  set(kj_sources ${kj_sources_lite} ${kj_sources_heavy})
else()
  set(kj_sources ${kj_sources_lite})
endif()

29 30 31 32 33 34 35 36 37 38 39 40
set(kj_headers
  common.h
  units.h
  memory.h
  refcount.h
  array.h
  vector.h
  string.h
  string-tree.h
  exception.h
  debug.h
  arena.h
41
  miniposix.h
42 43 44 45 46 47 48 49 50 51 52 53 54 55
  io.h
  tuple.h
  one-of.h
  function.h
  mutex.h
  thread.h
  threadlocal.h
  main.h
  windows-sanity.h
)
set(kj-parse_headers
  parse/common.h
  parse/char.h
)
56 57 58
set(kj-std_headers
  std/iostream.h
)
59
add_library(kj ${kj_sources})
60 61 62
install(TARGETS kj ARCHIVE DESTINATION "${LIB_INSTALL_DIR}")
install(FILES ${kj_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj")
install(FILES ${kj-parse_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj/parse")
63
install(FILES ${kj-std_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj/std")
64

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
set(kj-test_sources
  test.c++
)
set(kj-test_headers
  test.h
)
set(kj-test-compat_headers
  compat/gtest.h
)
add_library(kj-test ${kj-test_sources})
target_link_libraries(kj-test kj)
install(TARGETS kj-test ARCHIVE DESTINATION "${LIB_INSTALL_DIR}")
install(FILES ${kj-test_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj")
install(FILES ${kj-test-compat_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj/compat")

80 81 82 83
set(kj-async_sources
  async.c++
  async-unix.c++
  async-io.c++
84
  time.c++
85 86 87 88 89 90 91
)
set(kj-async_headers
  async-prelude.h
  async.h
  async-inl.h
  async-unix.h
  async-io.h
92
  time.h
93 94 95 96
)
if(NOT CAPNP_LITE)
  add_library(kj-async ${kj-async_sources})
  target_link_libraries(kj-async kj)
97 98
  install(TARGETS kj-async ARCHIVE DESTINATION "${LIB_INSTALL_DIR}")
  install(FILES ${kj-async_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj")
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
endif()

# Tests ========================================================================

if(BUILD_TESTING)
  add_executable(kj-tests
    common-test.c++
    memory-test.c++
    array-test.c++
    string-test.c++
    exception-test.c++
    debug-test.c++
    io-test.c++
    mutex-test.c++
    threadlocal-test.c++
Kenton Varda's avatar
Kenton Varda committed
114
    test-test.c++
115
    std/iostream-test.c++
116 117
  )
  # TODO: Link with librt on Solaris for sched_yield
118
  target_link_libraries(kj-tests kj-test kj)
119 120 121 122 123 124 125 126
  add_dependencies(check kj-tests)
  add_test(NAME kj-tests-run COMMAND kj-tests)

  if(NOT CAPNP_LITE)
    add_executable(kj-heavy-tests
      async-test.c++
      async-unix-test.c++
      async-io-test.c++
127 128 129 130 131 132 133 134
      refcount-test.c++
      string-tree-test.c++
      arena-test.c++
      units-test.c++
      tuple-test.c++
      one-of-test.c++
      function-test.c++
      threadlocal-pthread-test.c++
135 136 137
      parse/common-test.c++
      parse/char-test.c++
    )
138
    target_link_libraries(kj-heavy-tests kj-async kj-test kj)
139 140 141 142
    add_dependencies(check kj-heavy-tests)
    add_test(NAME kj-heavy-tests-run COMMAND kj-heavy-tests)
  endif()  # NOT CAPNP_LITE
endif()  # BUILD_TESTING