set(CMAKE_COLOR_MAKEFILE OFF)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(PROJECT_STATIC_LINK)
  set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
else()
  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

set(CMAKE_BUILD_TYPE ${PROJECT_CMAKE_BUILD_TYPE})

file(MAKE_DIRECTORY ${PROJECT_EXTERNAL_BUILD_ROOT}/lib)
file(CREATE_LINK ${PROJECT_EXTERNAL_BUILD_ROOT}/lib ${PROJECT_EXTERNAL_BUILD_ROOT}/lib64 SYMBOLIC)

list(PREPEND CMAKE_PREFIX_PATH
  ${PROJECT_EXTERNAL_BUILD_ROOT}
  ${PROJECT_EXTERNAL_BUILD_ROOT}/share
)

if(PROJECT_IS_MINGW)
  list(PREPEND CMAKE_PREFIX_PATH
    /mingw64
  )

  include_directories(BEFORE 
    /mingw64/include
  )

  link_directories(BEFORE
    /mingw64/lib
    /mingw64/lib64
  )
endif()

include_directories(BEFORE SYSTEM
  ${PROJECT_SUPPORT_DIR}/include
  ${PROJECT_EXTERNAL_BUILD_ROOT}/include
)

link_directories(BEFORE
  ${PROJECT_EXTERNAL_BUILD_ROOT}/lib
  ${PROJECT_EXTERNAL_BUILD_ROOT}/lib64
)
