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

2
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
Joshua Warner's avatar
Joshua Warner committed
3

4
# Tests ========================================================================
5

6 7
if(BUILD_TESTING)
  include(CTest)
8

9 10
  # Setup CAPNP_GENERATE_CPP for compiling test schemas
  find_package(CapnProto QUIET)
11
  set(CAPNP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
12

13 14 15 16
  # Setup googletest build and library targets (gtest and gtest_main)
  include(ExternalProject)
  ExternalProject_Add(gtest_build
    URL http://googletest.googlecode.com/files/gtest-1.7.0.zip
17
    URL_MD5 2d6ec8ccdf5c46b05ba54a9fd1d130d7
18
    CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -Dgtest_force_shared_crt=1
19 20 21 22 23
    INSTALL_COMMAND ""  # Disable install
  )

  ExternalProject_Get_Property(gtest_build binary_dir)

24 25 26 27 28 29 30 31 32
  # Set platform-specific library prefix/extensions.
  if(MSVC)
    set(gtest_prefix)
    set(gtest_suffix ".lib")
  else()
    set(gtest_prefix "lib")
    set(gtest_suffix ".a")
  endif()

33
  add_library(gtest UNKNOWN IMPORTED)
34 35 36
  if(CMAKE_GENERATOR MATCHES "Visual Studio.*" OR CMAKE_GENERATOR STREQUAL Xcode)
    set_target_properties(gtest PROPERTIES IMPORTED_LOCATION_DEBUG "${binary_dir}/Debug/${gtest_prefix}gtest${gtest_suffix}")
    set_target_properties(gtest PROPERTIES IMPORTED_LOCATION_RELEASE "${binary_dir}/Release/${gtest_prefix}gtest${gtest_suffix}")
37
  else()
38
    set_target_properties(gtest PROPERTIES IMPORTED_LOCATION "${binary_dir}/${gtest_prefix}gtest${gtest_suffix}")
39 40
  endif()
  
41 42 43
  add_dependencies(gtest gtest_build)

  add_library(gtest_main UNKNOWN IMPORTED)
44 45 46
  if(CMAKE_GENERATOR MATCHES "Visual Studio.*" OR CMAKE_GENERATOR STREQUAL Xcode)
    set_target_properties(gtest_main PROPERTIES IMPORTED_LOCATION_DEBUG "${binary_dir}/Debug/${gtest_prefix}gtest_main${gtest_suffix}")
    set_target_properties(gtest_main PROPERTIES IMPORTED_LOCATION_RELEASE "${binary_dir}/Release/${gtest_prefix}gtest_main${gtest_suffix}")
47
  else()
48
    set_target_properties(gtest_main PROPERTIES IMPORTED_LOCATION "${binary_dir}/${gtest_prefix}gtest_main${gtest_suffix}")
49
  endif()
50 51 52
  add_dependencies(gtest_main gtest)

  ExternalProject_Get_Property(gtest_build source_dir)
53
  include_directories("${source_dir}/include")
54

55
  # Sadly, we can't use the 'test' target, as that's coopted by ctest
56
  add_custom_target(check "${CMAKE_CTEST_COMMAND}" -V)
57
endif()  # BUILD_TESTING
58

59
# kj ===========================================================================
60

61
add_subdirectory(kj)
62

63
# capnp ========================================================================
64

65
add_subdirectory(capnp)