cmake_minimum_required(VERSION 3.14)

set(CMAKE_CXX_STANDARD 11)

if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
	cmake_policy(SET CMP0135 NEW)
endif()

include(FetchContent)
FetchContent_Declare(
  googletest
  URL https://github.com/google/googletest/archive/58d77fa8070e8cec2dc1ed015d66b454c8d78850.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(BUILD_GMOCK OFF CACHE BOOL "Build Google Mock" FORCE)
FetchContent_MakeAvailable(googletest)

enable_testing()

include(GoogleTest)

macro(pip_test NAME)
	file(GLOB _CPPS "${NAME}/*.cpp")
	file(GLOB _HDRS "${NAME}/*.h")
	set(_target pip_${NAME}_test)
	add_executable(${_target} ${_CPPS} ${_HDRS})
	target_link_libraries(${_target} pip ${ARGN} gtest_main)
	if (TESTS_RUN)
		gtest_discover_tests(${_target})
	endif()
	list(APPEND PIP_TESTS_LIST "${NAME}")
	set(PIP_TESTS_LIST ${PIP_TESTS_LIST} PARENT_SCOPE)
endmacro()

pip_test(math)
pip_test(core)
pip_test(piobject)
pip_test(client_server pip_client_server)
pip_test(io)
pip_test(system)
pip_test(thread)
