if (ALPINE_FOUND)
  set(CMAKE_POSITION_INDEPENDENT_CODE OFF)

  set(REPERTORY_MUSL ON)
  set(REPERTORY_DEFINITIONS ${REPERTORY_DEFINITIONS} -DREPERTORY_MUSL)
else()
  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

set(CMAKE_COLOR_MAKEFILE OFF)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)

if (NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
  set(DEBUG_EXTRA d)
  set(DEBUG_EXTRA2 -${DEBUG_EXTRA})
  set(DEBUG_EXTRA3 _${DEBUG_EXTRA})
  set(BOOST_DEBUG_EXTRA gd-)
  set(CMAKE_BUILD_TYPE_LOWER debug)
else()
  set(CMAKE_BUILD_TYPE_LOWER release)
endif()
string(TOLOWER "${CMAKE_GENERATOR}" CMAKE_GENERATOR_LOWER)

set(REPERTORY_OUTPUT_DIR ${CMAKE_BINARY_DIR})

set(EXTERNAL_BUILD_ROOT ${CMAKE_BINARY_DIR}/external)
set(EXTERNAL_BUILD_TYPE ${CMAKE_BUILD_TYPE})

if (UNIX OR MINGW)
  file(MAKE_DIRECTORY ${EXTERNAL_BUILD_ROOT}/lib)
  file(CREATE_LINK ${EXTERNAL_BUILD_ROOT}/lib ${EXTERNAL_BUILD_ROOT}/lib64 SYMBOLIC)
endif()
