CMakeLists.txt 2.47 KB
Newer Older
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

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

set(kj_sources
  common.c++
  units.c++
  memory.c++
  refcount.c++
  array.c++
  string.c++
  string-tree.c++
  exception.c++
  debug.c++
  arena.c++
  io.c++
  mutex.c++
  thread.c++
  main.c++
  parse/char.c++
)
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
33
  miniposix.h
34 35 36 37 38 39 40 41 42 43 44 45 46 47
  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
)
48 49 50
set(kj-std_headers
  std/iostream.h
)
51
add_library(kj ${kj_sources})
52 53 54
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")
55
install(FILES ${kj-std_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj/std")
56 57 58 59 60

set(kj-async_sources
  async.c++
  async-unix.c++
  async-io.c++
61
  time.c++
62 63 64 65 66 67 68
)
set(kj-async_headers
  async-prelude.h
  async.h
  async-inl.h
  async-unix.h
  async-io.h
69
  time.h
70 71 72 73
)
if(NOT CAPNP_LITE)
  add_library(kj-async ${kj-async_sources})
  target_link_libraries(kj-async kj)
74 75
  install(TARGETS kj-async ARCHIVE DESTINATION "${LIB_INSTALL_DIR}")
  install(FILES ${kj-async_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/kj")
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
endif()

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

if(BUILD_TESTING)
  add_executable(kj-tests
    common-test.c++
    memory-test.c++
    refcount-test.c++
    array-test.c++
    string-test.c++
    string-tree-test.c++
    exception-test.c++
    debug-test.c++
    arena-test.c++
    units-test.c++
    tuple-test.c++
    one-of-test.c++
    function-test.c++
    io-test.c++
    mutex-test.c++
    threadlocal-test.c++
    threadlocal-pthread-test.c++
  )
  # TODO: Link with librt on Solaris for sched_yield
  target_link_libraries(kj-tests kj gtest gtest_main)
  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++
      parse/common-test.c++
      parse/char-test.c++
112
      std/iostream-test.c++
113 114 115 116 117 118
    )
    target_link_libraries(kj-heavy-tests kj kj-async gtest gtest_main)
    add_dependencies(check kj-heavy-tests)
    add_test(NAME kj-heavy-tests-run COMMAND kj-heavy-tests)
  endif()  # NOT CAPNP_LITE
endif()  # BUILD_TESTING