add_compile_options(${WARNING_FLAGS})

if(ENABLE_CODE_COVERAGE)
  if(CMAKE_EXE_LINKER_FLAGS STREQUAL "")
    set(CMAKE_EXE_LINKER_FLAGS "${CODE_COVERAGE_LINKER_FLAGS}" CACHE STRING "" FORCE)
  elseif(NOT CMAKE_EXE_LINKER_FLAGS MATCHES "${CODE_COVERAGE_LINKER_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CODE_COVERAGE_LINKER_FLAGS}" CACHE STRING "" FORCE)
  endif()
endif()

if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows OR TARGET_PLATFORM STREQUAL "PS4")
    # Suppress googlemock warnings about missing "override" keyword specifier
    add_compile_options(-Wno-inconsistent-missing-override)
endif()

# Add common code for all platforms
add_subdirectory(common)
add_subdirectory(framework)
# Add integration tests for all platforms
add_subdirectory(integration)

# Add UNIT tests for selected platforms
if(NOT TARGET_PLATFORM STREQUAL "Android" AND
   NOT TARGET_PLATFORM STREQUAL "iPhone" AND
   NOT TARGET_PLATFORM STREQUAL "AppleTV" AND
   NOT TARGET_PLATFORM STREQUAL "OSX" AND
   NOT TARGET_PLATFORM STREQUAL "XboxOne" AND
   NOT TARGET_PLATFORM STREQUAL "WinStore" AND
   NOT TARGET_PLATFORM STREQUAL "Win64" AND
   NOT TARGET_PLATFORM STREQUAL "PS4" AND
   NOT TARGET_PLATFORM STREQUAL "Web"
   )
  add_subdirectory(unit)
endif()

add_custom_target(all-test
  DEPENDS ${all_test_dependencies}
  COMMENT "Build all of the tests"
)

add_custom_target(run-all-test
  COMMAND ${CMAKE_CTEST_COMMAND}
  DEPENDS all-test
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test/
  COMMENT "Build and run all tests."
)
