cmake_minimum_required(VERSION 3.16)
project(artis-factory)
enable_testing()

IF (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR
        ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-as-needed -Wall -Wextra -std=c++17")
    IF (UNIX)
        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -fPIC")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -fPIC")
    ENDIF (UNIX)
ENDIF ()

if (CMAKE_BUILD_TYPE STREQUAL "")
    SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE)
endif ()

INCLUDE(CheckIncludeFileCXX)
INCLUDE(CheckIncludeFile)
INCLUDE(CheckLibraryExists)
INCLUDE(CMakeDetermineCCompiler)

FIND_PACKAGE(PkgConfig REQUIRED)

PKG_CHECK_MODULES(ARTIS REQUIRED artis-star-1.0)

find_package(Boost REQUIRED COMPONENTS unit_test_framework)

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test)

MESSAGE(STATUS "${ARTIS_LIBRARY_DIRS} | ${ARTIS_LIBRARIES}")
MESSAGE(STATUS "- - - -")
MESSAGE(STATUS "${PROJECT_NAME_COMPLETE} configured successfully")
MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation")
MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}")
IF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
    MESSAGE(STATUS "Build with GCC ABI Demangle...: yes")
ENDIF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
IF (ARTIS_HAVE_EXECINFO)
    MESSAGE(STATUS "Build with execinfo.h.........: yes")
ENDIF (ARTIS_HAVE_EXECINFO)
IF (Boost_FOUND)
    MESSAGE(STATUS "Build with boost..............: yes")
ENDIF (Boost_FOUND)
MESSAGE(STATUS "- - - -")