1d4afb5ceSopenharmony_ci#
2d4afb5ceSopenharmony_ci# CMake Toolchain file for crosscompiling on MingW.
3d4afb5ceSopenharmony_ci#
4d4afb5ceSopenharmony_ci# This can be used when running cmake in the following way:
5d4afb5ceSopenharmony_ci#  cd build/
6d4afb5ceSopenharmony_ci#  cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross-ming.cmake
7d4afb5ceSopenharmony_ci#
8d4afb5ceSopenharmony_ci
9d4afb5ceSopenharmony_ciset(CROSS_PATH /usr/bin)
10d4afb5ceSopenharmony_ci
11d4afb5ceSopenharmony_ci# Target operating system name.
12d4afb5ceSopenharmony_ciset(CMAKE_SYSTEM_NAME Windows)
13d4afb5ceSopenharmony_ciset(BUILD_SHARED_LIBS OFF)
14d4afb5ceSopenharmony_ci
15d4afb5ceSopenharmony_ci# Name of C compiler.
16d4afb5ceSopenharmony_ciset(CMAKE_C_COMPILER "${CROSS_PATH}/x86_64-w64-mingw32-gcc")
17d4afb5ceSopenharmony_ci#set(CMAKE_CXX_COMPILER "${CROSS_PATH}/x86_64-w64-mingw32-g++")
18d4afb5ceSopenharmony_ciset(CMAKE_RC_COMPILER "${CROSS_PATH}/x86_64-w64-mingw32-windres")
19d4afb5ceSopenharmony_ciset(CMAKE_C_FLAGS "-Wno-error")
20d4afb5ceSopenharmony_ci
21d4afb5ceSopenharmony_ci#
22d4afb5ceSopenharmony_ci# Different build system distros set release optimization level to different
23d4afb5ceSopenharmony_ci# things according to their local policy, eg, Fedora is -O2 and Ubuntu is -O3
24d4afb5ceSopenharmony_ci# here.  Actually the build system's local policy is completely unrelated to
25d4afb5ceSopenharmony_ci# our desire for cross-build release optimization policy for code built to run
26d4afb5ceSopenharmony_ci# on a completely different target than the build system itself.
27d4afb5ceSopenharmony_ci#
28d4afb5ceSopenharmony_ci# Since this goes last on the compiler commandline we have to override it to a
29d4afb5ceSopenharmony_ci# sane value for cross-build here.  Notice some gcc versions enable broken
30d4afb5ceSopenharmony_ci# optimizations with -O3.
31d4afb5ceSopenharmony_ci#
32d4afb5ceSopenharmony_ciif (CMAKE_BUILD_TYPE MATCHES RELEASE OR CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES release)
33d4afb5ceSopenharmony_ci	set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
34d4afb5ceSopenharmony_ci	set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
35d4afb5ceSopenharmony_ciendif()
36d4afb5ceSopenharmony_ci
37d4afb5ceSopenharmony_ci# Where to look for the target environment. (More paths can be added here)
38d4afb5ceSopenharmony_ciset(CMAKE_FIND_ROOT_PATH "${CROSS_PATH}")
39d4afb5ceSopenharmony_ci
40d4afb5ceSopenharmony_ci# Adjust the default behavior of the FIND_XXX() commands:
41d4afb5ceSopenharmony_ci# search programs in the host environment only.
42d4afb5ceSopenharmony_ciset(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
43d4afb5ceSopenharmony_ci
44d4afb5ceSopenharmony_ci# Search headers and libraries in the target environment only.
45d4afb5ceSopenharmony_ciset(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
46d4afb5ceSopenharmony_ciset(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
47d4afb5ceSopenharmony_ci
48