Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MinGW crossbuilding cmake file and README.mingw_cross #654

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions README.mingw_cross
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
How to cross-build libfreenect for Windows on e.g. Ubuntu Linux

== Compile libusb (v1.0.26 or git) ==

Below instructions assume this is built in ~/SRC/libusb

cd ~/SRC/libusb
./configure --host=x86_64-w64-mingw32
make -j5

== Compile freeglut (v3.2.3 or git) ==

Below instructions assume this is built in ~/SRC/freeglut
Follow the instructions in the README.mingw_cross but with
the addition of this cmake flag:
-D FREEGLUT_REPLACE_GLUT=1
(Note the dll will actually end up in the bin folder)

== Compile libfreenect ==

This can surely be improved, the system FindGLUT doesn't work well.
Also the included FindThreads.cmake doesn't seem to help in this case.

touch ../cmake_modules/FindGLUT.cmake

cmake -D CMAKE_TOOLCHAIN_FILE=mingw.cmake \
-D LIBUSB_1_INCLUDE_DIR=~/SRC/libusb/libusb \
-D LIBUSB_1_LIBRARY=~/SRC/libusb/libusb/.libs/libusb-1.0.dll \
-D THREADS_PTHREADS_WIN32_LIBRARY=/usr/x86_64-w64-mingw32/lib/libpthread.dll.a \
-D GLUT_FOUND=1 \
-D GLUT_INCLUDE_DIR=~/SRC/freeglut/freeglut/include \
-D GLUT_LIBRARY=~/SRC/freeglut/freeglut/bin/libglut.dll \
-D CMAKE_INSTALL_PREFIX=install-win \
..

make -j5
make install
find install-win

This results in dynamically linked executables, so you'd need
libusb.dll libglut.dll libphreads-1.0.dll on the target computer.

23 changes: 23 additions & 0 deletions mingw.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# CMake toolchain file, cf. README.mingw_cross

# the name of the target operating system
set(CMAKE_SYSTEM_NAME Windows)

IF("${GNU_HOST}" STREQUAL "")
SET(GNU_HOST x86_64-w64-mingw32)
ENDIF()

# which compilers to use for C and C++
set(CMAKE_C_COMPILER ${GNU_HOST}-gcc)
set(CMAKE_CXX_COMPILER ${GNU_HOST}-g++)

# where is the target environment located
set(CMAKE_FIND_ROOT_PATH /usr/${GNU_HOST})

# adjust the default behavior of the FIND_XXX() commands:
# do not search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# search headers and libraries only in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)