# ============================================================================
# Copyright 2017-2024, Schlumberger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================

if (WIN32)
	# For Windows: Prevent overriding the parent project's compiler/linker settings
	set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif()

set(TEST_PATH ${sdapi_SOURCE_DIR}/test)
set(GTEST_PATH ${TEST_PATH}/googletest)
set(GTEST_INCLUDE_PATH ${GTEST_PATH}/googletest/include ${GTEST_PATH}/googlemock/include)
set(GTEST_BIN_PATH ${CMAKE_CURRENT_BINARY_DIR}/googletest)
add_subdirectory(${GTEST_PATH} ${GTEST_BIN_PATH} EXCLUDE_FROM_ALL)
include_directories(${GTEST_INCLUDE_PATH})

if(NOT WIN32)
    set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl")
endif()

add_executable(utest main.cc )
target_link_libraries(utest PRIVATE sdapi_static gtest gmock ${CURL_LIBRARY} ${OPENSSL_LIBRARY})
target_include_directories(utest PRIVATE ${CMAKE_SOURCE_DIR})
add_test(utest utest --gtest_output=xml:report.xml)
