# Tests
set(TEST_EXECS "")
file(GLOB TEST_SRCS tests/cpp/*.cc)
+find_path(GTEST_INCLUDE_DIR gtest/gtest.h)
find_library(GTEST_LIB gtest "$ENV{GTEST_LIB}")
-if(GTEST_LIB)
+# Create the `cpptest` target if we can find GTest. If not, we create dummy
+# targets that give the user an informative error message.
+if(GTEST_INCLUDE_DIR AND GTEST_LIB)
foreach(__srcpath ${TEST_SRCS})
get_filename_component(__srcname ${__srcpath} NAME)
string(REPLACE ".cc" "" __execname ${__srcname})
add_executable(${__execname} ${__srcpath})
list(APPEND TEST_EXECS ${__execname})
- target_link_libraries(${__execname}
- tvm ${GTEST_LIB} pthread dl)
+ target_include_directories(${__execname} PUBLIC ${GTEST_INCLUDE_DIR})
+ target_link_libraries(${__execname} tvm ${GTEST_LIB} pthread dl)
set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_ALL 1)
set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
endforeach()
add_custom_target(cpptest DEPENDS ${TEST_EXECS})
+elseif(NOT GTEST_INCLUDE_DIR)
+ add_custom_target(cpptest
+ COMMAND echo "Missing Google Test headers in include path"
+ COMMAND exit 1)
+elseif(NOT GTEST_LIB)
+ add_custom_target(cpptest
+ COMMAND echo "Missing Google Test library"
+ COMMAND exit 1)
endif()
# Custom targets
git submodule update
+.. _build-shared-library:
+
Build the Shared Library
------------------------
.. code:: bash
pip install --user tornado psutil xgboost
-
+
* If you want to parse Relay text format progams, you must use Python 3 and run the following
.. code:: bash
:maxdepth: 1
nnpack
+
+
+Enable C++ Tests
+----------------
+We use `Google Test <https://github.com/google/googletest>`_ to drive the C++
+tests in TVM. The easiest way to install GTest is from source.
+
+ .. code:: bash
+
+ git clone https://github.com/google/googletest
+ cd googletest
+ mkdir build
+ cd build
+ cmake ..
+ make
+ make install
+
+Now, you'll need to modify ``build/config.cmake`` and change ``set(USE_GTEST
+OFF)`` to ``set(USE_GTEST ON)``.
+
+TVM can then be built `as usual`__.
+
+__ build-shared-library_
+
+After building, the C++ tests can be run with ``make cpptest``.