Browse Source

Added cmake compilation for examples.
Simple is enabled by default, OpenGL SDL test is optional.
Fixed inclusion of some libraries for beter static compilation

TheOnlyJoey 8 years ago
parent
commit
bca1f018a9
3 changed files with 30 additions and 1 deletions
  1. 20 1
      CMakeLists.txt
  2. 5 0
      examples/opengl/CMakeLists.txt
  3. 5 0
      examples/simple/CMakeLists.txt

+ 20 - 1
CMakeLists.txt

@@ -31,6 +31,9 @@ OPTION(OPENHMD_DRIVER_DEEPOON "Deepoon E2" ON)
 OPTION(OPENHMD_DRIVER_EXTERNAL "External sensor driver" ON)
 OPTION(OPENHMD_DRIVER_ANDROID "General Android driver" OFF)
 
+OPTION(OPENHMD_EXAMPLE_SIMPLE "Simple test binary" ON)
+OPTION(OPENHMD_EXAMPLE_SDL "SDL OpenGL test (outdated)" OFF)
+
 if(OPENHMD_DRIVER_OCULUS_RIFT)
 	set(openhmd_source_files ${openhmd_source_files}
 	${CMAKE_CURRENT_LIST_DIR}/src/drv_oculus_rift/rift.c
@@ -69,7 +72,23 @@ if (OPENHMD_DRIVER_ANDROID)
 	add_definitions(-DDRIVER_ANDROID)
 endif(OPENHMD_DRIVER_ANDROID)
 
-add_library(openhmd ${openhmd_source_files} ${LIBS})
+if (OPENHMD_EXAMPLE_SIMPLE)
+	add_subdirectory(./examples/simple)
+endif(OPENHMD_EXAMPLE_SIMPLE)
+
+if (OPENHMD_EXAMPLE_SDL)
+	find_package(SDL REQUIRED)
+	find_package(GLEW REQUIRED)
+	find_package(OpenGL REQUIRED)
+	add_subdirectory(./examples/opengl)
+endif (OPENHMD_EXAMPLE_SDL)
+
+if (UNIX)
+	set(LIBS ${LIBS} rt pthread)
+endif (UNIX)
+
+link_libraries(${LIBS})
+add_library(openhmd ${openhmd_source_files})
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_DIR}/)
 
 #install properties

+ 5 - 0
examples/opengl/CMakeLists.txt

@@ -0,0 +1,5 @@
+project (openglexample)
+include_directories(${CMAKE_BINARY_DIR}/include ${SDL_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR})
+link_directories(${CMAKE_BINARY_DIR})
+link_libraries (openhmd m ${SDL_LIBRARY} ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES})
+add_executable(openglexample gl.c main.c)

+ 5 - 0
examples/simple/CMakeLists.txt

@@ -0,0 +1,5 @@
+project (simple)
+include_directories(${CMAKE_BINARY_DIR}/include)
+link_directories(${CMAKE_BINARY_DIR})
+link_libraries (openhmd m)
+add_executable(simple simple.c)