OSDN Git Service

Add CMake target for unittests.
authorNicolas Capens <capn@google.com>
Mon, 4 Jun 2018 19:55:45 +0000 (15:55 -0400)
committerNicolas Capens <nicolascapens@google.com>
Tue, 5 Jun 2018 21:09:56 +0000 (21:09 +0000)
Change-Id: I0984f43de3846428c30232192c7ba83342b1debd
Reviewed-on: https://swiftshader-review.googlesource.com/19228
Reviewed-by: Krzysztof Kosiński <krzysio@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
CMakeLists.txt

index aa8ddfa..f526116 100644 (file)
@@ -1028,3 +1028,27 @@ if(BUILD_TESTS AND ${REACTOR_BACKEND} STREQUAL "Subzero")
         target_link_libraries(SubzeroTest ReactorSubzero pthread dl)
     endif()
 endif()
+
+if(BUILD_TESTS)
+    set(UNITTESTS_LIST
+        ${CMAKE_SOURCE_DIR}/tests/unittests/main.cpp
+        ${CMAKE_SOURCE_DIR}/tests/unittests/unittests.cpp
+        ${CMAKE_SOURCE_DIR}/third_party/googletest/googletest/src/gtest-all.cc
+    )
+
+    set(UNITTESTS_INCLUDE_DIR
+        ${CMAKE_SOURCE_DIR}/third_party/googletest/googletest/include/
+        ${CMAKE_SOURCE_DIR}/third_party/googletest/googlemock/include/
+        ${CMAKE_SOURCE_DIR}/third_party/googletest/googletest/
+        ${CMAKE_SOURCE_DIR}/include/
+    )
+
+    add_executable(unittests ${UNITTESTS_LIST})
+    set_target_properties(unittests PROPERTIES
+        INCLUDE_DIRECTORIES "${UNITTESTS_INCLUDE_DIR}"
+        FOLDER "Tests"
+        COMPILE_DEFINITIONS "STANDALONE"
+    )
+
+    target_link_libraries(unittests libEGL libGLESv2 ${OS_LIBS})
+endif()