Skip to content

Commit

Permalink
Modified cmake build system and added support files for MSVC2013 x64.…
Browse files Browse the repository at this point in the history
… Also

switched libusb to a submodule. Note that the MSVC build currently does
not work with OpenCV3 whereas all other builds do.
  • Loading branch information
cboulay committed Jul 21, 2015
1 parent c3d7b5e commit 550ef35
Show file tree
Hide file tree
Showing 119 changed files with 16,944 additions and 65,773 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include/psmove_config.h
build*
bindings/processing
external/opencv
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "external/PS3EYEDriver"]
path = external/PS3EYEDriver
url = git://github.com/thp/PS3EYEDriver.git
[submodule "external/libusb-1.0"]
path = external/libusb-1.0
url = https://github.com/libusb/libusb.git
4 changes: 1 addition & 3 deletions README.osx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ You will need...
$ cd /Developer/Library/

3. Grab binaries
$ git clone git://github.com/thp/psmoveapi.git
$ git clone --recursive git://github.com/thp/psmoveapi.git
$ cd psmoveapi
$ git submodule init
$ git submodule update

4. Build all
$ bash -e -x contrib/build-osx-snapshot
Expand Down
23 changes: 18 additions & 5 deletions README.win32 → README.win32_mingw64
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,20 @@ IMPORTANT: Get the right MinGW version!
mingw32-make
mingw32-make install

5. Configure the PS Move API build
5. (Optional) Get libusb-1.0 static libraries

If you wish to use the optical tracker without the CL Eye driver then you need the
PS3EYEDriver and its libusb-1.0 dependency. You can either use precompiled binaries
or build from source.

To use the precompiled binaries, go to http://libusb.info/ and click on Downloads
and "Latest Windows Binaries". Extract the archive into psmoveapi/external/libusb-1.0

Building from source requires MSys. Specific instructions for installing and using
MSys are not provided here. In brief, from the libusb-1.0 directory you will have
to run autogen.sh and then configure and make.

6. Configure the PS Move API build

Switch back to the psmoveapi root directory.

Expand All @@ -129,13 +142,13 @@ IMPORTANT: Get the right MinGW version!
cmake .. -G "MinGW Makefiles" -DPSMOVE_USE_CL_EYE_SDK=1

Also alternatively, if you want to use the PS3EYEDriver:
cmake .. -G "MinGW Makefiles" -DPSMOVE_USE_PS3EYE_DRIVER=1 -DPSMOVE_USE_LOCAL_LIBUSB=1
cmake .. -G "MinGW Makefiles" -DPSMOVE_USE_PS3EYE_DRIVER=1

6. Finally build the PS Move API
7. Finally build the PS Move API

mingw32-make

7. Pair the controller to the host
8. Pair the controller to the host

Using the controllers' Bluetooth capabilities requires you to pair the
controller to the host computer first. That is what the psmovepair utility
Expand All @@ -157,7 +170,7 @@ IMPORTANT: Get the right MinGW version!
the controller from the list of Bluetooth devices you need to run
psmovepair again for that controller.

8. Start one of the desired test applications
9. Start one of the desired test applications

If you previously chose to build the example applications (which is the
default), you can then run
Expand Down
66 changes: 66 additions & 0 deletions README.win64_msvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Requirements
------------

- Visual Studio Community 2013
http://www.visualstudio.com/en-us/news/vs2013-community-vs.aspx
- CMake
http://www.cmake.org/cmake/resources/software.html
- OpenCV
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/
- Git
http://code.google.com/p/msysgit/

1. Clone the PS Move API repository
`git clone --recursive https://github.com/cboulay/psmoveapi.git`
`cd psmoveapi`

2. Build libusb-1.0
Open psmoveapi\external\libusb-1.0\msvc\libusb_2013.sln
Change the target to Release x64 (at the top of the Visual Studio window).
Right-click on libusb-1.0 (static) and select Properties.
In the properties Window, make sure the Platform is set to Active or All Platforms.
In the properties Window, navigate to Configuration Properties > C/C++ > Code Generation
Change "Runtime Library" to Multi-threaded DLL (/MD)
Click OK
Right-click on libusb-1.0 (static) and Build.

3. OpenCV
Still in `psmoveapi/external`
git clone --depth 1 --branch 2.4.11 git://github.com/Itseez/opencv.git
`cd opencv`
`mkdir build`
`cd build`
`cmake .. -G "Visual Studio 12 Win64" -DBUILD_SHARED_LIBS=0 -DBUILD_WITH_STATIC_CRT=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_DOCS=OFF -DBUILD_opencv_apps=OFF -DBUILD_opencv_flann=ON -DBUILD_opencv_features2d=ON -DBUILD_opencv_objdetect=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_ts=OFF -DBUILD_opencv_ml=OFF -DBUILD_opencv_video=OFF -DBUILD_opencv_java=OFF -DWITH_OPENEXR=OFF -DWITH_FFMPEG=OFF -DWITH_JASPER=OFF -DWITH_TIFF=OFF`

Open the solution in psmoveapi\external\opencv\build\OpenCV.sln
Change the target to Release (at the top of the Visual Studio window).
Build the solution (Press F7).

4. Build psmoveapi

Still in the VS2013 command prompt:

`cd ..\..\..`
`mkdir build `
`cd build`
`cmake .. -G "Visual Studio 12 Win64" -DPSMOVE_USE_MADGWICK_AHRS=1 -DPSMOVE_USE_PS3EYE_DRIVER=1`

Open the `build\Project.sln` solution file.
Change the target to Release.
Build the solution (Press F7).

5. Read [this Wiki](https://github.com/cboulay/psmove-ue4/wiki) for windows-specific information on pairing and connecting the psmove controller and on using the PS3Eye camera.

6. Start one of the desired test applications

If you previously chose to build the example applications (which is the
default), you can then run

example.exe

for a basic example.

For questions, please read the archives of the PS Move Mailing List. If you
cannot find an answer to your question in the archives, send an e-mail:

https://groups.google.com/forum/#!aboutgroup/psmove
84 changes: 84 additions & 0 deletions contrib/FindUSB1.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# - Try to find the freetype library
# Once done this defines
#
# LIBUSB_FOUND - system has libusb
# LIBUSB_INCLUDE_DIR - the libusb include directory
# LIBUSB_LIBRARIES - Link these to use libusb

# Copyright (c) 2006, 2008 Laurent Montel, <[email protected]>
#
#
# Modified on 2015/07/14 by Chadwick Boulay <[email protected]>
# to use static local libraries only.
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.


IF (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)

# in cache already
set(LIBUSB_FOUND TRUE)

ELSE (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
# Because we want to use the static library,
# look locally only.
find_path(LIBUSB_INCLUDE_DIR
NAMES
libusb.h
PATHS
${CMAKE_CURRENT_LIST_DIR}/../external/libusb-1.0/libusb
${CMAKE_CURRENT_LIST_DIR}/../external/libusb-1.0/libusb-1.0
/usr/local/include
)
# There are 4 platform-specific ways we might get the libraries.
# 1 - Windows MSVC, download the source, compile with MSVC
# 2 - Windows MSVC, download pre-compiled binaries <- Do not use; wrong CRT library
# 3 - Windows MinGW, download pre-compiled binaries
# 4 - OSX, download the source, build, but do not install
# 5 - OSX, homebrew OR download the source, build, and install
# Each of these puts the compiled library into a different folder
# and that is also architecture-specific.

set(LIBUSB_LIB_SEARCH_PATH ${CMAKE_CURRENT_LIST_DIR}/../external/libusb-1.0)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
IF(MINGW)
set(LIBUSB_PLATFORM_PREFIX MinGW)
IF (${CMAKE_C_SIZEOF_DATA_PTR} EQUAL 8)
list(APPEND LIBUSB_LIB_SEARCH_PATH
${CMAKE_CURRENT_LIST_DIR}/../external/libusb-1.0/MinGW64/static)
#TODO: Add self-compiled folder for MinGW
ELSE()
list(APPEND LIBUSB_LIB_SEARCH_PATH
${CMAKE_CURRENT_LIST_DIR}/../external/libusb-1.0/MinGW32/static)
#TODO: Add self-compiled folder for MinGW
ENDIF()
ELSE()
IF (${CMAKE_C_SIZEOF_DATA_PTR} EQUAL 8)
list(APPEND LIBUSB_LIB_SEARCH_PATH
${CMAKE_CURRENT_LIST_DIR}/../external/libusb-1.0/x64/Release/lib)
ELSE()
list(APPEND LIBUSB_LIB_SEARCH_PATH
${CMAKE_CURRENT_LIST_DIR}/../external/libusb-1.0/Win32/Release/lib)
ENDIF()
set(LIBUSB_PLATFORM_PREFIX MS)
ENDIF()
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
list(APPEND LIBUSB_LIB_SEARCH_PATH
${CMAKE_CURRENT_LIST_DIR}/../external/libusb-1.0/libusb/.libs
/usr/local/lib)
ENDIF()

find_library(LIBUSB_LIBRARIES
NAMES
libusb-1.0.a libusb-1.0.lib libusb-1.0 usb-1.0 usb
PATHS
${LIBUSB_LIB_SEARCH_PATH}
)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIR)

MARK_AS_ADVANCED(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES)

ENDIF (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
5 changes: 4 additions & 1 deletion contrib/README
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ Here are some files that might be useful for users of the library:
Sets a few compiler-specific variables and defines a macro that are
to be used across all CMakeLists.txt files. It also adds its path
(i.e., the contrib path) to the CMAKE_MODULE_PATH folder so any
Find<Library>.cmake files placed here will be used.
Find<Library>.cmake files placed here will be used.

FindUSB1.cmake
A module to help cmake with find_library(USB1)
18 changes: 5 additions & 13 deletions contrib/build-osx-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ export PSMOVEAPI_CHECKOUT=$(pwd)
export OPENCV_CHECKOUT_DIR=$PSMOVEAPI_CHECKOUT/external/opencv
export OPENCV_INSTALL_DIR=$OPENCV_CHECKOUT_DIR/build/install

# Known-good Git tag of OpenCV that can still be built correctly
OPENCV_TARGET_GIT_TAG=2.4.4

# For parallel builds
MAKE_ARGS=-j4

Expand All @@ -32,18 +29,16 @@ if [ ! -f $PSMOVEAPI_CHECKOUT/CMakeLists.txt ]; then
exit 1
fi

# Build libusb-1.0.9 as universal static library
# Build libusb-1.0 as universal static library
# needed for the PS3EYEDriver to access the PSEye
# otherwise we'd dynamically link against some the Homebrew libusb
(
cd $PSMOVEAPI_CHECKOUT/external/libusb-1.0.9
cd $PSMOVEAPI_CHECKOUT/external/libusb-1.0
export ARCHFLAGS='-arch x86_64'
export CFLAGS="$CFLAGS $ARCHFLAGS"
export CXXFLAGS="$CXXFLAGS $ARCHFLAGS"
rm -rf build
mkdir -p build
cd build
../configure --disable-shared --enable-static
./autogen.sh
./configure.ac
make ${MAKE_ARGS}
)

Expand All @@ -59,7 +54,6 @@ if [ ! -d $OPENCV_INSTALL_DIR ]; then
rm -rf build
mkdir -p build
cd build
#git checkout --force $OPENCV_TARGET_GIT_TAG
cmake -DBUILD_SHARED_LIBS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_TESTS=OFF \
Expand Down Expand Up @@ -98,9 +92,7 @@ PSMOVEAPI_PREFIX=/opt/psmoveapi_${PSMOVEAPI_VERSION}/
rm -rf build
mkdir build
cd build
cmake -DPSMOVE_USE_LOCAL_OPENCV=ON \
-DPSMOVE_USE_LOCAL_LIBUSB=ON \
-DPSMOVE_USE_PS3EYE_DRIVER=ON \
cmake -DPSMOVE_USE_PS3EYE_DRIVER=ON \
-DPSMOVE_BUILD_TRACKER=ON \
-DPSMOVE_BUILD_JAVA_BINDINGS=ON \
-DPSMOVE_BUILD_PROCESSING_BINDINGS=ON \
Expand Down
32 changes: 32 additions & 0 deletions contrib/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,38 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ENDIF()

# Windows' math include does not define constants by default.
# Set this definition so it does.
# Also set NOMINMAX so the min and max functions are not overwritten with macros.
IF(MSVC)
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-DNOMINMAX)
ENDIF()

# Targets requiring symbols not present by default in MSVC
# can include ${MSVC_INCLUDES}, link ${MSVC_LIBS}, and
# add ${MSVC_SRCS} to their list of sources.
IF(MSVC_INCLUDES AND MSVC_LIBS AND MSVC_SRCS) #pragma once guard
ELSE()
set(MSVC_INCLUDES)
set(MSVC_LIBS)
set(MSVC_SRCS)
IF(MSVC)
list(APPEND MSVC_INCLUDES ${CMAKE_CURRENT_LIST_DIR}/../external/pthreads-w32/include ${CMAKE_CURRENT_LIST_DIR}/../external/msvc-support)
list(APPEND MSVC_SRCS ${CMAKE_CURRENT_LIST_DIR}/../external/msvc-support/getopt.c ${CMAKE_CURRENT_LIST_DIR}/../external/msvc-support/unistd.c)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(PThreadLib
NAMES pthreadVC2
PATHS ${CMAKE_CURRENT_LIST_DIR}/../external/pthreads-w32/lib/x64)
ELSE()
find_library(PThreadLib
NAMES pthreadVC2
PATHS ${CMAKE_CURRENT_LIST_DIR}/../external/pthreads-w32/lib/x86)
ENDIF()
list(APPEND MSVC_LIBS ${PThreadLib})
ENDIF(MSVC)
ENDIF()

# Pretty-print if a "use" feature has been enabled
macro(feature_use_info CAPTION FEATURE)
if(${FEATURE})
Expand Down
25 changes: 14 additions & 11 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ option(PSMOVE_BUILD_OPENGL_EXAMPLES "Build the OpenGL examples" OFF)
option(PSMOVE_BUILD_TESTS "Build the C tests" ON)
option(PSMOVE_BUILD_TUIO_SERVER "Build the TUIO server" OFF)

include_directories(${MSVC_INCLUDES})
# C examples
if(PSMOVE_BUILD_EXAMPLES)
foreach(EXAMPLE example multiple dump_calibration battery_check)
add_executable(${EXAMPLE} ${CMAKE_CURRENT_LIST_DIR}/c/${EXAMPLE}.c)
add_executable(${EXAMPLE} ${CMAKE_CURRENT_LIST_DIR}/c/${EXAMPLE}.c ${MSVC_SRCS})
target_link_libraries(${EXAMPLE} psmoveapi)
endforeach()

Expand All @@ -30,34 +31,35 @@ if(PSMOVE_BUILD_EXAMPLES)
external/TUIO_CPP/oscpack/ip/posix/NetworkingUtils.cpp
external/TUIO_CPP/oscpack/ip/posix/UdpSocket.cpp
external/TUIO_CPP/oscpack/ip/win32/NetworkingUtils.cpp
external/TUIO_CPP/oscpack/ip/win32/UdpSocket.cpp)
external/TUIO_CPP/oscpack/ip/win32/UdpSocket.cpp
${MSVC_SRCS})
set_target_properties(tuio_server PROPERTIES
COMPILE_FLAGS -DOSC_HOST_LITTLE_ENDIAN)
target_link_libraries(tuio_server psmoveapi psmoveapi_tracker)
target_link_libraries(tuio_server psmoveapi psmoveapi_tracker ${MSVC_LIBS})
else()
# Disable the TUIO Server if we don't build the tracker
set(PSMOVE_BUILD_TUIO_SERVER OFF)
endif()

if(PSMOVE_BUILD_TRACKER)
foreach(EXAMPLE distance_calibration)
add_executable(${EXAMPLE} ${CMAKE_CURRENT_LIST_DIR}/c/${EXAMPLE}.c)
target_link_libraries(${EXAMPLE} psmoveapi psmoveapi_tracker)
add_executable(${EXAMPLE} ${CMAKE_CURRENT_LIST_DIR}/c/${EXAMPLE}.c ${MSVC_SRCS})
target_link_libraries(${EXAMPLE} psmoveapi psmoveapi_tracker ${MSVC_LIBS})
endforeach()
endif()
endif()

# C test programs
if(PSMOVE_BUILD_TESTS)
foreach(TESTNAME led_update read_performance calibration responsiveness extension led_pwm_frequency)
add_executable(test_${TESTNAME} ${CMAKE_CURRENT_LIST_DIR}/c/test_${TESTNAME}.c)
target_link_libraries(test_${TESTNAME} psmoveapi)
add_executable(test_${TESTNAME} ${CMAKE_CURRENT_LIST_DIR}/c/test_${TESTNAME}.c ${MSVC_SRCS})
target_link_libraries(test_${TESTNAME} psmoveapi ${MSVC_LIBS})
endforeach(TESTNAME)

if(PSMOVE_BUILD_TRACKER)
foreach(TESTNAME tracker capture_performance record_video roi_size end2end_latency)
add_executable(test_${TESTNAME} ${CMAKE_CURRENT_LIST_DIR}/c/test_${TESTNAME}.c)
target_link_libraries(test_${TESTNAME} psmoveapi psmoveapi_tracker)
add_executable(test_${TESTNAME} ${CMAKE_CURRENT_LIST_DIR}/c/test_${TESTNAME}.c ${MSVC_SRCS})
target_link_libraries(test_${TESTNAME} psmoveapi psmoveapi_tracker ${MSVC_LIBS})
endforeach(TESTNAME)

if (PSMOVE_BUILD_OPENGL_EXAMPLES)
Expand All @@ -73,11 +75,12 @@ if(PSMOVE_BUILD_TESTS)
endif()

foreach(EXAMPLE test_opengl test_opengl2 test_opengl3)
add_executable(${EXAMPLE} ${CMAKE_CURRENT_LIST_DIR}/c/${EXAMPLE}.cpp)
add_executable(${EXAMPLE} ${CMAKE_CURRENT_LIST_DIR}/c/${EXAMPLE}.cpp ${MSVC_SRCS})
target_link_libraries(${EXAMPLE}
psmoveapi
psmoveapi_tracker
${OPENGL_EXAMPLES_LIBRARIES})
${OPENGL_EXAMPLES_LIBRARIES}
${MSVC_LIBS})
endforeach()
endif()
endif()
Expand Down
Loading

0 comments on commit 550ef35

Please sign in to comment.