cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)

set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE)

project(StgSharpDevelop C)

################################################################################
# Compiler and environment checks
################################################################################

# Detect compiler family and allow only GCC or Clang when using CMake.
if(MSVC)
    message(FATAL_ERROR "MSVC detected while configuring with CMake. This repository provides .vcxproj files for MSVC/Visual Studio.\nPlease open the solution in Visual Studio or use the existing .vcxproj files to build with MSVC. CMake-based MSVC builds are not supported by this project.")
endif()

if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
    message(STATUS "Using GCC: ${CMAKE_C_COMPILER}")
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
    message(STATUS "Using Clang: ${CMAKE_C_COMPILER}")
else()
    message(FATAL_ERROR "Unsupported compiler '${CMAKE_C_COMPILER_ID}'. Supported compilers for CMake builds are: GCC and Clang. MSVC users: use the provided .vcxproj and Visual Studio.")
endif()

################################################################################
# Global configuration types
################################################################################
set(CMAKE_CONFIGURATION_TYPES
    "Debug"
    "Release"
    CACHE STRING "" FORCE
)

################################################################################
# Nuget packages function stub.
################################################################################
function(use_package TARGET PACKAGE VERSION)
    message(WARNING "No implementation of use_package. Create yours. "
                    "Package \"${PACKAGE}\" with version \"${VERSION}\" "
                    "for target \"${TARGET}\" is ignored!")
endfunction()

################################################################################
# Common utils
################################################################################
include(CMake/Utils.cmake)

################################################################################
# Additional Global Settings(add specific info there)
################################################################################
include(CMake/GlobalSettingsInclude.cmake OPTIONAL)

################################################################################
# Use solution folders feature
################################################################################
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

################################################################################
# Sub-projects
################################################################################
add_subdirectory(StgSharp.Native)

