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