CMakeLists.txt 1.85 KB
Newer Older
Joshua Warner's avatar
Joshua Warner committed
1

2
# Tests ========================================================================
3

4 5
if(BUILD_TESTING)
  include(CTest)
6

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
  if (EXTERNAL_CAPNP)
    # Setup CAPNP_GENERATE_CPP for compiling test schemas
    find_package(CapnProto CONFIG QUIET)
    if (NOT CapnProto_FOUND)
      # Try and find the executables from an autotools-based installation
      # Setup paths to the schema compiler for generating ${test_capnp_files}
      if(NOT EXTERNAL_CAPNP AND NOT CAPNP_LITE)
        set(CAPNP_EXECUTABLE $<TARGET_FILE:capnp_tool>)
        set(CAPNPC_CXX_EXECUTABLE $<TARGET_FILE:capnpc_cpp>)
      else()
        # Allow paths to tools to be set with either environment variables or find_program()
        if (NOT CAPNP_EXECUTABLE)
            if (DEFINED ENV{CAPNP})
            set(CAPNP_EXECUTABLE "$ENV{CAPNP}")
            else()
            find_program(CAPNP_EXECUTABLE capnp)
            endif()
24 25
        endif()

26 27 28 29 30 31 32 33
        if(NOT CAPNPC_CXX_EXECUTABLE)
          if (DEFINED ENV{CAPNPC_CXX})
            set(CAPNPC_CXX_EXECUTABLE "$ENV{CAPNPC_CXX}")
          else()
            # Also search in the same directory that `capnp` was found in
            get_filename_component(capnp_dir "${CAPNP_EXECUTABLE}" DIRECTORY)
            find_program(CAPNPC_CXX_EXECUTABLE capnpc-c++ HINTS "${capnp_dir}")
          endif()
34 35 36 37
        endif()
      endif()
    endif()

38 39 40
    set(CAPNP_INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
    #TODO(someday) It would be nice to use targets instead of variables in CAPNP_GENERATE_CPP macro
  endif()
41

42
  # Sadly, we can't use the 'test' target, as that's coopted by ctest
43
  add_custom_target(check "${CMAKE_CTEST_COMMAND}" -V)
44
endif()  # BUILD_TESTING
45

46
# kj ===========================================================================
47

48
add_subdirectory(kj)
49

50
# capnp ========================================================================
51

52
add_subdirectory(capnp)