Skip to content

Instantly share code, notes, and snippets.

@take-cheeze
Created June 1, 2012 09:47
Show Gist options
  • Save take-cheeze/2850831 to your computer and use it in GitHub Desktop.
Save take-cheeze/2850831 to your computer and use it in GitHub Desktop.
# the name of the target operating system
set(CMAKE_SYSTEM_NAME Windows)
# which compilers to use for C and C++
include(CMakeForceCompiler)
cmake_force_c_compiler(i686-w64-mingw32-gcc GNU)
cmake_force_cxx_compiler(i686-w64-mingw32-g++ GNU)
set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
set(CMAKE_RC_FLAGS -DGCC_WINDRES)
# here is the target environment located
set(CMAKE_FIND_ROOT_PATH
/usr/i686-w64-mingw32
$ENV{PWD}/download-mingw-rpm/usr/i686-w64-mingw32/sys-root/mingw
$ENV{PWD}/mingw-install
$ENV{HOME}/mingw-install)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".lib" ".a")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment