Skip to content

Commit

Permalink
examples: Do not require all dependencies; skip building examples wit…
Browse files Browse the repository at this point in the history
…h missing dependencies

win32: Compiles as pure C

Signed-off-by: Benn Snyder <[email protected]>
  • Loading branch information
piedar committed Jan 7, 2015
1 parent 01c119a commit e551c9a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 76 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ set(C_CXX_FLAGS_DEFAULT "${C_FLAGS_WARNING} -O2")
# These defaults can be overriden by -DCMAKE_C_FLAGS=""
set(CMAKE_C_FLAGS "${C_CXX_FLAGS_DEFAULT} ${CMAKE_C_FLAGS}")
# C Configurations
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -DDEBUG=1")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -O0 -g -DDEBUG=1")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS}")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g")

# These defaults can be overriden by -DCMAKE_CXX_FLAGS=""
set(CMAKE_CXX_FLAGS "${C_CXX_FLAGS_DEFAULT} ${CMAKE_CXX_FLAGS}")
# C++ Configurations
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -DDEBUG=1")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g -DDEBUG=1")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")

Expand Down
106 changes: 43 additions & 63 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,60 @@
# Packages needed for examples
######################################################################################

# todo: use these throughout
file(GLOB SRC_STANDARD chunkview.c glview.c hiview.c regview.c camtest.c)
file(GLOB SRC_AUDIO micview.c wavrecord.c)
file(GLOB SRC_SYNC glpclview.c regtest.c tiltdemo.c)
set (SRC_ALL ${SRC_STANDARD} ${SRC_AUDIO} ${SRC_SYNC})

if (WIN32)
set(THREADS_USE_PTHREADS_WIN32 true)
find_package(Threads REQUIRED)
include_directories(${THREADS_PTHREADS_INCLUDE_DIR})
set_source_files_properties(${SRC_ALL} PROPERTIES LANGUAGE CXX)
endif()

add_executable(freenect-glview glview.c)
add_executable(freenect-regview regview.c)
add_executable(freenect-hiview hiview.c)
add_executable(freenect-chunkview chunkview.c)
add_executable(freenect-wavrecord wavrecord.c)
add_executable(freenect-micview micview.c)
# These examples have no external dependencies and should always build.
add_executable(freenect-camtest camtest.c)
add_executable(freenect-wavrecord wavrecord.c)
target_link_libraries(freenect-camtest freenect)
target_link_libraries(freenect-wavrecord freenect)
install(TARGETS freenect-camtest freenect-wavrecord
DESTINATION bin)

if (BUILD_C_SYNC)
add_executable(freenect-glpclview glpclview.c)
add_executable(freenect-tiltdemo tiltdemo.c)
add_executable(freenect-regtest regtest.c)

add_dependencies(freenect-glpclview freenect-tiltdemo freenect-regtest
freenect_sync)
endif()

# We need to include libfreenect_sync.h for glpclview
include_directories (../wrappers/c_sync/)
# All viewers need pthreads and GLUT.
set(THREADS_USE_PTHREADS_WIN32 true)
find_package(Threads)
include_directories(${THREADS_PTHREADS_INCLUDE_DIR})

# Mac just has everything already
if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "-framework OpenGL -framework GLUT")
target_link_libraries(freenect-glview freenect)
target_link_libraries(freenect-regview freenect)
target_link_libraries(freenect-hiview freenect)
target_link_libraries(freenect-chunkview freenect)
target_link_libraries(freenect-wavrecord freenect)
target_link_libraries(freenect-micview freenect)
target_link_libraries(freenect-camtest freenect)
if (BUILD_C_SYNC)
target_link_libraries(freenect-glpclview freenect_sync)
target_link_libraries(freenect-tiltdemo freenect_sync)
target_link_libraries(freenect-regtest freenect_sync)
endif()
else()
find_package(OpenGL)
find_package(GLUT)

find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
if (Threads_FOUND AND OPENGL_FOUND AND GLUT_FOUND)
include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})

include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ${USB_INCLUDE_DIRS})
add_executable(freenect-glview glview.c)
add_executable(freenect-regview regview.c)
add_executable(freenect-hiview hiview.c)
add_executable(freenect-chunkview chunkview.c)
add_executable(freenect-micview micview.c)

target_link_libraries(freenect-glview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
target_link_libraries(freenect-regview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
target_link_libraries(freenect-hiview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
target_link_libraries(freenect-chunkview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
target_link_libraries(freenect-wavrecord freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
target_link_libraries(freenect-micview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
target_link_libraries(freenect-camtest freenect)
if (BUILD_C_SYNC)
target_link_libraries(freenect-glpclview freenect_sync ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
target_link_libraries(freenect-tiltdemo freenect_sync ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
target_link_libraries(freenect-regtest freenect_sync ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()

install (TARGETS freenect-glview freenect-regview freenect-hiview freenect-chunkview freenect-wavrecord freenect-micview
DESTINATION bin)
install(TARGETS freenect-glview freenect-regview freenect-hiview freenect-chunkview freenect-micview
DESTINATION bin)
endif ()

# A few examples use c_sync.
if (BUILD_C_SYNC)
install (TARGETS freenect-glpclview freenect-tiltdemo
DESTINATION bin)
endif()
find_package(Threads REQUIRED)
include_directories(../wrappers/c_sync/)
include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})

add_executable(freenect-regtest regtest.c)
add_executable(freenect-tiltdemo tiltdemo.c)

target_link_libraries(freenect-regtest freenect_sync ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
target_link_libraries(freenect-tiltdemo freenect_sync ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})

install(TARGETS freenect-regtest freenect-tiltdemo
DESTINATION bin)

if (OPENGL_FOUND AND GLUT_FOUND)
add_executable(freenect-glpclview glpclview.c)
target_link_libraries(freenect-glpclview freenect_sync ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
install(TARGETS freenect-glpclview
DESTINATION bin)
endif ()
endif ()
9 changes: 3 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
# Build for main library
######################################################################################

include_directories (${CMAKE_CURRENT_SOURCE_DIR})

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${LIBUSB_1_INCLUDE_DIRS})
LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c audio.c loader.c)
IF(WIN32)
set_source_files_properties(${SRC} PROPERTIES LANGUAGE CXX)
ENDIF(WIN32)

# Audio Firmware
include(FindPythonInterp)
Expand All @@ -24,6 +19,8 @@ ELSE(BUILD_REDIST_PACKAGE)
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/../audios.bin" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/libfreenect")
ENDIF()

LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c audio.c loader.c)

add_library (freenect SHARED ${SRC})
set_target_properties ( freenect PROPERTIES
VERSION ${PROJECT_VER}
Expand Down
6 changes: 1 addition & 5 deletions wrappers/c_sync/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
######################################################################################
# C Synchronous Interface
######################################################################################
if (WIN32)
set_source_files_properties(libfreenect_sync.c PROPERTIES LANGUAGE CXX)
set(THREADS_USE_PTHREADS_WIN32 true)
endif()

set(THREADS_USE_PTHREADS_WIN32 true)
find_package(Threads REQUIRED)
include_directories(${THREADS_PTHREADS_INCLUDE_DIR})

Expand All @@ -26,4 +23,3 @@ install (TARGETS freenect_sync_static
DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}")
install (FILES "libfreenect_sync.h"
DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})

0 comments on commit e551c9a

Please sign in to comment.