Skip to content

Commit f9d2b61

Browse files
committed
Add cross compile cmake file
1 parent b26a7c7 commit f9d2b61

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

cmake/mingw-w64-x86_64.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Sample toolchain file for building for Windows from an Ubuntu Linux system.
2+
#
3+
# Typical usage:
4+
# *) install cross compiler: `sudo apt-get install mingw-w64`
5+
# *) cd build
6+
# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/mingw-w64-x86_64.cmake ..
7+
# This is free and unencumbered software released into the public domain.
8+
9+
set(CMAKE_SYSTEM_NAME Windows)
10+
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
11+
set(CMAKE_SYSTEM_PROCESSOR x86_64)
12+
13+
# cross compilers to use for C, C++ and Fortran
14+
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
15+
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
16+
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
17+
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
18+
19+
# target environment on the build host system
20+
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
21+
22+
# modify default behavior of FIND_XXX() commands
23+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
24+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
25+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

0 commit comments

Comments
 (0)