Skip to content

Commit

Permalink
Let CMake find OpenGL/GLUT automatically
Browse files Browse the repository at this point in the history
Signed-off-by: Benn Snyder <benn.snyder@gmail.com>
  • Loading branch information
piedar committed Jan 15, 2015
1 parent d8729aa commit ed30d6f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 34 deletions.
6 changes: 2 additions & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ install(TARGETS freenect-camtest freenect-wavrecord
# All viewers need pthreads and GLUT.
set(THREADS_USE_PTHREADS_WIN32 true)
find_package(Threads)
include_directories(${THREADS_PTHREADS_INCLUDE_DIR})

find_package(OpenGL)
find_package(GLUT)

if (Threads_FOUND AND OPENGL_FOUND AND GLUT_FOUND)
include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})
include_directories(${THREADS_PTHREADS_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})

add_executable(freenect-glview glview.c)
add_executable(freenect-regview regview.c)
Expand All @@ -41,7 +39,7 @@ endif ()
if (BUILD_C_SYNC)
find_package(Threads REQUIRED)
include_directories(../wrappers/c_sync/)
include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})
include_directories(${THREADS_PTHREADS_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})

add_executable(freenect-regtest regtest.c)
add_executable(freenect-tiltdemo tiltdemo.c)
Expand Down
40 changes: 10 additions & 30 deletions wrappers/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
INSTALL(FILES libfreenect.hpp
DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})
install(FILES libfreenect.hpp
DESTINATION ${PROJECT_INCLUDE_INSTALL_DIR})

IF(BUILD_EXAMPLES)

if (WIN32)
if (BUILD_EXAMPLES)
set(THREADS_USE_PTHREADS_WIN32 true)
find_package(Threads REQUIRED)

include_directories(${THREADS_PTHREADS_INCLUDE_DIR})
endif()

include_directories(.)

add_executable(freenect-cppview cppview.cpp)
add_executable(freenect-cpp_pcview cpp_pc_view.cpp)

# Mac just has everything already
if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "-framework OpenGL -framework GLUT")
target_link_libraries(freenect-cppview freenect)
target_link_libraries(freenect-cpp_pcview freenect)
else()
find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)

include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ${USB_INCLUDE_DIRS})

target_link_libraries(freenect-cppview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
target_link_libraries(freenect-cpp_pcview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
endif()
include_directories(. ${THREADS_PTHREADS_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})

install (TARGETS freenect-cppview
DESTINATION bin)
add_executable(freenect-cppview cppview.cpp)
add_executable(freenect-cpp_pcview cpp_pc_view.cpp)

install (TARGETS freenect-cpp_pcview
DESTINATION bin)
target_link_libraries(freenect-cppview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})
target_link_libraries(freenect-cpp_pcview freenect ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIB})

install(TARGETS freenect-cppview freenect-cpp_pcview
DESTINATION bin)
ENDIF()
Empty file modified wrappers/cpp/cppview.cpp
100755 → 100644
Empty file.

0 comments on commit ed30d6f

Please sign in to comment.