Skip to content

Commit 1c3944c

Browse files
committed
Add MinGW crossbuilding cmake file and README.mingw_cross
Signed-off-by: Tormod Volden <[email protected]>
1 parent 5b2a20e commit 1c3944c

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

README.mingw_cross

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
How to cross-build libfreenect for Windows on e.g. Ubuntu Linux
2+
3+
== Compile libusb (v1.0.26 or git) ==
4+
5+
Below instructions assume this is built in ~/SRC/libusb
6+
7+
cd ~/SRC/libusb
8+
./configure --host=x86_64-w64-mingw32
9+
make -j5
10+
11+
== Compile freeglut (v3.2.2 or git) ==
12+
13+
Below instructions assume this is built in ~/SRC/freeglut
14+
https://github.com/FreeGLUTProject/freeglut/pull/98 must be applied.
15+
Follow the instructions in the README.mingw_cross exactly, only with
16+
the addition of the cmake flag
17+
-D FREEGLUT_REPLACE_GLUT=1
18+
(Note the dll will actually end up in the bin folder)
19+
20+
== Compile libfreenect ==
21+
22+
This can surely be improved, the system FindGLUT doesn't work well.
23+
Also the included FindThreads.cmake doesn't seem to help in this case.
24+
25+
touch ../cmake_modules/FindGLUT.cmake
26+
27+
cmake -D CMAKE_TOOLCHAIN_FILE=mingw.cmake \
28+
-D LIBUSB_1_INCLUDE_DIR=~/SRC/libusb/libusb \
29+
-D LIBUSB_1_LIBRARY=~/SRC/libusb/libusb/.libs/libusb-1.0.dll \
30+
-D THREADS_PTHREADS_WIN32_LIBRARY=/usr/x86_64-w64-mingw32/lib/libpthread.dll.a \
31+
-D GLUT_FOUND=1 \
32+
-D GLUT_INCLUDE_DIR=~/SRC/freeglut/freeglut/include \
33+
-D GLUT_LIBRARY=~/SRC/freeglut/freeglut/bin/libglut.dll \
34+
-D CMAKE_INSTALL_PREFIX=install-win \
35+
..
36+
37+
make -j5
38+
make install
39+
find install-win
40+
41+
This results in dynamically linked executables, so you'd need
42+
libusb.dll libglut.dll libphreads-1.0.dll on the target computer.
43+

mingw.cmake

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# CMake toolchain file, cf. README.mingw_cross
2+
3+
# the name of the target operating system
4+
set(CMAKE_SYSTEM_NAME Windows)
5+
6+
IF("${GNU_HOST}" STREQUAL "")
7+
SET(GNU_HOST x86_64-w64-mingw32)
8+
ENDIF()
9+
10+
# which compilers to use for C and C++
11+
set(CMAKE_C_COMPILER ${GNU_HOST}-gcc)
12+
set(CMAKE_CXX_COMPILER ${GNU_HOST}-g++)
13+
14+
# where is the target environment located
15+
set(CMAKE_FIND_ROOT_PATH /usr/${GNU_HOST})
16+
17+
# adjust the default behavior of the FIND_XXX() commands:
18+
# do not search programs in the host environment
19+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
20+
# search headers and libraries only in the target environment
21+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
22+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
23+
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

0 commit comments

Comments
 (0)