CMakeLists.txt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. set(the_description "The ts module")
  2. if(NOT BUILD_opencv_ts AND NOT BUILD_TESTS AND NOT BUILD_PERF_TESTS)
  3. ocv_module_disable(ts)
  4. endif()
  5. set(OPENCV_MODULE_TYPE STATIC)
  6. set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE)
  7. if(WINRT)
  8. # WINRT doesn't have access to environment variables
  9. # so adding corresponding macros during CMake run
  10. add_env_definitions(OPENCV_TEST_DATA_PATH)
  11. add_env_definitions(OPENCV_PERF_VALIDATION_DIR)
  12. endif()
  13. ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
  14. ocv_add_module(ts INTERNAL opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui)
  15. ocv_glob_module_sources()
  16. ocv_module_include_directories()
  17. ocv_create_module()
  18. # generate config file
  19. set(OPENCV_TESTS_CONFIG_FILE "${CMAKE_BINARY_DIR}/opencv_tests_config.hpp")
  20. set(OPENCV_TESTS_CONFIG_STR "")
  21. if(CMAKE_INSTALL_PREFIX)
  22. set(OPENCV_TESTS_CONFIG_STR "${OPENCV_TESTS_CONFIG_STR}
  23. #define OPENCV_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\"
  24. ")
  25. endif()
  26. if(OPENCV_TEST_DATA_INSTALL_PATH)
  27. set(OPENCV_TESTS_CONFIG_STR "${OPENCV_TESTS_CONFIG_STR}
  28. #define OPENCV_TEST_DATA_INSTALL_PATH \"${OPENCV_TEST_DATA_INSTALL_PATH}\"
  29. ")
  30. endif()
  31. if(EXISTS "${OPENCV_TESTS_CONFIG_FILE}")
  32. file(READ "${OPENCV_TESTS_CONFIG_FILE}" __content)
  33. endif()
  34. if(NOT OPENCV_TESTS_CONFIG_STR STREQUAL "${__content}")
  35. file(WRITE "${OPENCV_TESTS_CONFIG_FILE}" "${OPENCV_TESTS_CONFIG_STR}")
  36. endif()
  37. if(OPENCV_DISABLE_THREAD_SUPPORT)
  38. # This is required to disable threads in the ts module, as
  39. # described in `ts_gtest.h`.
  40. ocv_target_compile_definitions(${the_module} PUBLIC GTEST_HAS_PTHREAD=0)
  41. endif()