# This file is part of MXE. See LICENSE.md for licensing information.

# https://cmake.org/cmake/help/latest

# Can't set `cmake_minimum_required` or `cmake_policy` in toolchain
# since toolchain is read before CMakeLists.txt
# See `target-cmake.in` for CMAKE_POLICY_DEFAULT_CMPNNNN

# Check if we are using mxe supplied version
#   - toolchain is included multiple times so set a guard in
#     environment to suppress duplicate messages
if(NOT ${CMAKE_COMMAND} STREQUAL /home/gregwar/git/mxe/usr/x86_64-unknown-linux-gnu/bin/cmake AND NOT DEFINED ENV{_MXE_CMAKE_TOOLCHAIN_INCLUDED})
    message(WARNING "
** Warning: direct use of toolchain file is deprecated
** Please use prefixed wrapper script instead:
     i686-w64-mingw32.shared.posix-cmake [options] <path-to-source>
       - uses mxe supplied cmake version 3.7.2
       - loads toolchain
       - loads common run results
       - sets various policy defaults
    ")
    set(ENV{_MXE_CMAKE_TOOLCHAIN_INCLUDED} TRUE)
endif()

## General configuration
set(CMAKE_SYSTEM_NAME Windows)
set(MSYS 1)
set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY ON)
# Workaround for https://www.cmake.org/Bug/view.php?id=14075
set(CMAKE_CROSS_COMPILING ON)


## Library config
set(BUILD_SHARED_LIBS ON CACHE BOOL "BUILD_SHARED_LIBS" FORCE)
set(BUILD_STATIC_LIBS OFF CACHE BOOL "BUILD_STATIC_LIBS" FORCE)
set(BUILD_SHARED ON CACHE BOOL "BUILD_SHARED" FORCE)
set(BUILD_STATIC OFF CACHE BOOL "BUILD_STATIC" FORCE)
set(LIBTYPE SHARED)


## Paths etc.
set(CMAKE_FIND_ROOT_PATH /home/gregwar/git/mxe/usr/i686-w64-mingw32.shared.posix)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_PREFIX_PATH /home/gregwar/git/mxe/usr/i686-w64-mingw32.shared.posix)
set(CMAKE_INSTALL_PREFIX /home/gregwar/git/mxe/usr/i686-w64-mingw32.shared.posix CACHE PATH "Installation Prefix")
# For custom mxe FindPackage scripts
set(CMAKE_MODULE_PATH "/home/gregwar/git/mxe/usr/share/cmake/modules" ${CMAKE_MODULE_PATH})


## Programs
set(CMAKE_C_COMPILER /home/gregwar/git/mxe/usr/bin/i686-w64-mingw32.shared.posix-gcc)
set(CMAKE_CXX_COMPILER /home/gregwar/git/mxe/usr/bin/i686-w64-mingw32.shared.posix-g++)
set(CMAKE_Fortran_COMPILER /home/gregwar/git/mxe/usr/bin/i686-w64-mingw32.shared.posix-gfortran)
set(CMAKE_RC_COMPILER /home/gregwar/git/mxe/usr/bin/i686-w64-mingw32.shared.posix-windres)
# CMAKE_RC_COMPILE_OBJECT is defined in:
#     <cmake root>/share/cmake-X.Y/Modules/Platform/Windows-windres.cmake

## Individual package configuration
file(GLOB mxe_cmake_files
    "/home/gregwar/git/mxe/usr/i686-w64-mingw32.shared.posix/share/cmake/mxe-conf.d/*.cmake"
)
foreach(mxe_cmake_file ${mxe_cmake_files})
    include(${mxe_cmake_file})
endforeach()
