# ===========================================================================
# tests/CMakeLists.txt
# --------------------
#
# Top-level CMakeLists file configuring the test targets to be built for
# testing the library functionalities.
# -------------------------------------------------------------------------
#
# author : Emanuele Parisi
# ===========================================================================

include(${CMAKE_SOURCE_DIR}/cmake/FetchContent.cmake)

# ---------------------------------------------------------------------------
# Retrieve the external projects CppUtilities tests depend on.
# ---------------------------------------------------------------------------

set(CppUtilities_Test_INCLUDE_DIRS
    "")

# Register Google test dependency.
fetchcontent_declare(cpputilities_deps_googletest
                     GIT_REPOSITORY
                     https://github.com/google/googletest.git
                     GIT_TAG
                     release-1.8.1)
fetchcontent_getproperties(cpputilities_deps_googletest)
if (NOT cpputilities_deps_googletest_POPULATED)
	fetchcontent_populate(cpputilities_deps_googletest)
	set(BUILD_GMOCK
	    CACHE BOOL
	    OFF)
	set(INSTALL_GTEST
	    CACHE BOOL
	    OFF)
	add_subdirectory(${cpputilities_deps_googletest_SOURCE_DIR}
	                 ${cpputilities_deps_googletest_BINARY_DIR})
	set(CppUtilities_Test_INCLUDE_DIRS
	    ${cpputilities_deps_googletest_SOURCE_DIR}/googletest/include)
endif ()

# ---------------------------------------------------------------------------
# Configure the library unit test target CppUtilities_Test.
# ---------------------------------------------------------------------------

add_library(CppUtilities_Test
            INTERFACE)
target_include_directories(CppUtilities_Test
                           INTERFACE
                           ${CppUtilities_Test_INCLUDE_DIRS})
target_link_libraries(CppUtilities_Test
                      INTERFACE
                      CppUtilities
                      gtest_main
                      gtest)
target_compile_options(CppUtilities_Test
                       INTERFACE
                       $<$<CONFIG:Debug>:-pedantic
                                         -Wall
                                         -Wextra>)

# ---------------------------------------------------------------------------
# Configure unit test targets.
# ---------------------------------------------------------------------------

add_subdirectory(units)
