cmake_minimum_required(VERSION 3.12)

project(P2Pool_SSL LANGUAGES C CXX)

if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
	set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /W0 /Zi /Od /Ob0 /MP /MTd")
	set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W0 /Zi /Od /Ob0 /MP /MTd")
	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /W0 /O1 /Ob2 /Oi /Os /Oy /MP /MT")
	set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W0 /O1 /Ob2 /Oi /Os /Oy /MP /MT")
	set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /W0 /Ob1 /Ot /Zi /MP /MT")
	set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /W0 /Ob1 /Ot /Zi /MP /MT")
else()
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -w")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -w")
endif()

if(CMAKE_GENERATOR MATCHES "Visual Studio")
	if(CMAKE_VERSION VERSION_LESS 3.13)
		message(WARNING "Disabling SSL assembly support because CMake version ${CMAKE_VERSION} is too old (less than 3.13)")
		set(OPENSSL_NO_ASM ON)
	else()
		include(CheckLanguage)
		check_language(ASM_NASM)
		if(NOT CMAKE_ASM_NASM_COMPILER)
			message(WARNING "Disabling SSL assembly support because NASM could not be found")
			set(OPENSSL_NO_ASM ON)
		endif()
	endif()
endif()

add_subdirectory(../../external/src/grpc/third_party/boringssl-with-bazel BoringSSL)
