SET(CppUTestRootDirectory ${CMAKE_CURRENT_LIST_DIR}/cpputest-upstream)

# Either set CPP_PLATFORM to one of the provided platforms under
# ${CppUTestRootDirectory}/src/Platforms/, or provide a project-specific
# platform.cpp (as shown below)
add_subdirectory(${CppUTestRootDirectory}/src/CppUTest CppUTest)
add_subdirectory(${CppUTestRootDirectory}/src/CppUTestExt CppUTestExt)

if((CMAKE_CXX_COMPILER_ID STREQUAL "CLANG") OR
	(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
	(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
	target_sources(CppUTest
		PRIVATE
			${CppUTestRootDirectory}/src/Platforms/Gcc/UtestPlatform.cpp
	)
    target_sources(CppUTestExt
		PRIVATE
			${CppUTestRootDirectory}/src/Platforms/Gcc/UtestPlatform.cpp
	)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
	target_sources(CppUTest
		PRIVATE
			${CppUTestRootDirectory}/src/Platforms/VisualCpp/UtestPlatform.cpp
	)
else()
	message(FATAL_ERROR "Test platform not configured for Compiler ${CMAKE_CXX_COMPILER_ID}")
endif()

if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "MSVC"))
target_compile_options(CppUTest PRIVATE
    -Wno-old-style-cast
    -Wno-zero-as-null-pointer-constant
    -Wno-cast-qual
    -Wno-unused-variable
    -Wno-unused-parameter
    -Wno-sign-conversion
    -Wno-missing-declarations
    -Wno-undef
    -Wno-cast-align
    -Wno-shadow
    -DCPPUTEST_HAVE_LONG_LONG_INT
)
target_compile_options(CppUTestExt PRIVATE
	-Wno-old-style-cast
)
endif()
