diff --git a/CMakeLists.txt b/CMakeLists.txt index a6f73278e5..df1e4677d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 2.8) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") project(hifi) -set(GLM_DIR "${CMAKE_SOURCE_DIR}/thirdparty/glm") -set(PORTAUDIO_DIR "${CMAKE_SOURCE_DIR}/thirdparty/PortAudio") +set(GLM_ROOT_DIR ${CMAKE_SOURCE_DIR}/thirdparty) +set(PORTAUDIO_ROOT_DIR ${CMAKE_SOURCE_DIR}/thirdparty/Portaudio) +set(LODEPNG_ROOT_DIR ${CMAKE_SOURCE_DIR}/thirdparty/LodePNG) add_subdirectory(interface) \ No newline at end of file diff --git a/cmake/modules/FindGLM.cmake b/cmake/modules/FindGLM.cmake new file mode 100644 index 0000000000..2d9009298f --- /dev/null +++ b/cmake/modules/FindGLM.cmake @@ -0,0 +1,63 @@ +# FindGLM - attempts to locate the glm matrix/vector library. +# +# This module defines the following variables (on success): +# GLM_INCLUDE_DIRS - where to find glm/glm.hpp +# GLM_FOUND - if the library was successfully located +# +# It is trying a few standard installation locations, but can be customized +# with the following variables: +# GLM_ROOT_DIR - root directory of a glm installation +# Headers are expected to be found in either: +# /glm/glm.hpp OR +# /include/glm/glm.hpp +# This variable can either be a cmake or environment +# variable. Note however that changing the value +# of the environment varible will NOT result in +# re-running the header search and therefore NOT +# adjust the variables set by this module. + +#============================================================================= +# Copyright 2012 Carsten Neumann +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# default search dirs +SET(_glm_HEADER_SEARCH_DIRS + "/usr/include" + "/usr/local/include") + +# check environment variable +SET(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}") + +IF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR) + SET(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}") +ENDIF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR) + +# put user specified location at beginning of search +IF(GLM_ROOT_DIR) + SET(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}" + "${GLM_ROOT_DIR}/include" + ${_glm_HEADER_SEARCH_DIRS}) +ENDIF(GLM_ROOT_DIR) + +# locate header +FIND_PATH(GLM_INCLUDE_DIR "glm/glm.hpp" + PATHS ${_glm_HEADER_SEARCH_DIRS}) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM DEFAULT_MSG + GLM_INCLUDE_DIR) + +IF(GLM_FOUND) + SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") + + MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}") +ENDIF(GLM_FOUND) diff --git a/cmake/modules/FindLodePNG.cmake b/cmake/modules/FindLodePNG.cmake new file mode 100644 index 0000000000..d3631df907 --- /dev/null +++ b/cmake/modules/FindLodePNG.cmake @@ -0,0 +1,44 @@ +# - Try to find the LodePNG library +# +# You must provide a LODEPNG_ROOT_DIR which contains the header and cpp file +# +# Once done this will define +# +# LODEPNG_FOUND - system has LODEPNG_FOUND +# LODEPNG_INCLUDE_DIRS - the LodePNG include directory +# LODEPNG_LIBRARY - Link these to use LodePNG +# +# Copyright (c) 2013 Stephen Birarda +# + +if (LODEPNG_LIBRARY AND LODEPNG_INCLUDE_DIRS) + # in cache already + set(LODEPNG_FOUND TRUE) +else (LODEPNG_LIBRARY AND LODEPNG_INCLUDE_DIRS) + + set(LODEPNG_INCLUDE_DIRS + ${LODEPNG_ROOT_DIR}/lodepng.h + ) + + set(LODEPNG_LIBRARY + ${LODEPNG_ROOT_DIR}/lodepng.cpp + ) + + if (LODEPNG_INCLUDE_DIRS AND LODEPNG_LIBRARY) + set(LODEPNG_FOUND TRUE) + endif (LODEPNG_INCLUDE_DIRS AND LODEPNG_LIBRARY) + + if (LODEPNG_FOUND) + if (NOT LodePNG_FIND_QUIETLY) + message(STATUS "Found LodePNG: ${LODEPNG_LIBRARY}") + endif (NOT LodePNG_FIND_QUIETLY) + else (LODEPNG_FOUND) + if (LodePNG_FIND_REQUIRED) + message(FATAL_ERROR "Could not find LodePNG") + endif (LodePNG_FIND_REQUIRED) + endif (LODEPNG_FOUND) + + # show the LODEPNG_INCLUDE_DIRS and LODEPNG_LIBRARY variables only in the advanced view + mark_as_advanced(LODEPNG_INCLUDE_DIRS LODEPNG_LIBRARY) + +endif (LODEPNG_LIBRARY AND LODEPNG_INCLUDE_DIRS) \ No newline at end of file diff --git a/cmake/modules/FindPortaudio.cmake b/cmake/modules/FindPortaudio.cmake new file mode 100644 index 0000000000..01dae4b670 --- /dev/null +++ b/cmake/modules/FindPortaudio.cmake @@ -0,0 +1,46 @@ +# - Try to find the Portaudio library +# +# You must provide a PORTAUDIO_ROOT_DIR which contains the header and library +# +# Once done this will define +# +# PORTAUDIO_FOUND - system has Portaudio +# PORTAUDIO_INCLUDE_DIRS - the Portaudio include directory +# PORTAUDIO_LIBRARY - Link these to use Portaudio +# +# Copyright (c) 2013 Stephen Birarda +# +# Heavily based on Andreas Schneider's original FindPortaudio.cmake +# which can be found at http://gnuradio.org/redmine/projects/gnuradio/repository/ + + +if (PORTAUDIO_LIBRARY AND PORTAUDIO_INCLUDE_DIRS) + # in cache already + set(PORTAUDIO_FOUND TRUE) +else (PORTAUDIO_LIBRARY AND PORTAUDIO_INCLUDE_DIRS) + + set(PORTAUDIO_INCLUDE_DIRS + ${PORTAUDIO_ROOT_DIR}/portaudio.h + ) + set(PORTAUDIO_LIBRARY + ${PORTAUDIO_ROOT_DIR}/libportaudio.a + ) + + if (PORTAUDIO_INCLUDE_DIRS AND PORTAUDIO_LIBRARY) + set(PORTAUDIO_FOUND TRUE) + endif (PORTAUDIO_INCLUDE_DIRS AND PORTAUDIO_LIBRARY) + + if (PORTAUDIO_FOUND) + if (NOT Portaudio_FIND_QUIETLY) + message(STATUS "Found Portaudio: ${PORTAUDIO_LIBRARY}") + endif (NOT Portaudio_FIND_QUIETLY) + else (PORTAUDIO_FOUND) + if (Portaudio_FIND_REQUIRED) + message(FATAL_ERROR "Could not find Portaudio") + endif (Portaudio_FIND_REQUIRED) + endif (PORTAUDIO_FOUND) + + # show the PORTAUDIO_INCLUDE_DIRS and PORTAUDIO_LIBRARY variables only in the advanced view + mark_as_advanced(PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARY) + +endif (PORTAUDIO_LIBRARY AND PORTAUDIO_INCLUDE_DIRS) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 9fc2804422..26d4247b5e 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -6,8 +6,26 @@ file(GLOB INTERFACE_SRCS src/*.cpp src/*.h) add_executable(interface ${INTERFACE_SRCS}) -include_directories(${GLM_DIR}) -target_link_libraries(interface GLM) +if (APPLE) + set(CMAKE_EXE_LINKER_FLAGS "-framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreServices -framework Carbon") +endif (APPLE) -include_directories(${PORTAUDIO_DIR}) -target_link_libraries(interface ${PORTAUDIO_DIR}/libportaudio.a) \ No newline at end of file +find_package(OpenGL REQUIRED) +find_package(GLUT REQUIRED) +find_package(GLM REQUIRED) +find_package(Portaudio REQUIRED) +find_package(LodePNG REQUIRED) + +include_directories( + ${OPENGL_INCLUDE_DIRS} + ${GLUT_INCLUDE_DIRS} + ${GLM_INCLUDE_DIRS} + ${PORTAUDIO_INCLUDE_DIRS} + ${LODEPNG_INCLUDE_DIRS} +) +target_link_libraries(interface + ${OPENGL_LIBRARY} + ${GLUT_LIBRARY} + ${PORTAUDIO_LIBRARY} + ${LODEPNG_LIBRARY} +) \ No newline at end of file diff --git a/interface/src/Agent.h b/interface/src/Agent.h index 68d360c2aa..27f355c9ec 100644 --- a/interface/src/Agent.h +++ b/interface/src/Agent.h @@ -9,7 +9,7 @@ #ifndef __interface__Agent__ #define __interface__Agent__ -#include +#include #include #include #include diff --git a/interface/src/Audio.h b/interface/src/Audio.h index f1c8ac1d8a..046a76f6b0 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -10,7 +10,7 @@ #define __interface__Audio__ #include -#include "portaudio.h" +#include #include "Head.h" #include "AudioData.h" diff --git a/interface/src/AudioSource.h b/interface/src/AudioSource.h index 4a857e8d91..1485d90bae 100644 --- a/interface/src/AudioSource.h +++ b/interface/src/AudioSource.h @@ -10,7 +10,7 @@ #define __interface__AudioSource__ #include -#include +#include class AudioSource { public: diff --git a/interface/src/Cube.h b/interface/src/Cube.h index b9e93df292..405c7c0f6f 100644 --- a/interface/src/Cube.h +++ b/interface/src/Cube.h @@ -9,7 +9,7 @@ #ifndef __interface__Cube__ #define __interface__Cube__ -#include +#include #include "Util.h" #include "world.h" #include diff --git a/interface/src/Field.cpp b/interface/src/Field.cpp index 762932b619..2793d8de5d 100644 --- a/interface/src/Field.cpp +++ b/interface/src/Field.cpp @@ -7,7 +7,7 @@ // #include "Field.h" -#include +#include #define FIELD_SCALE 0.00050 #define COLOR_DRIFT_RATE 0.001f // per-frame drift of particle color towards field element color #define COLOR_MIN 0.2f // minimum R/G/B value at 0,0,0 - also needs setting in cloud.cpp diff --git a/interface/src/Field.h b/interface/src/Field.h index af615b9859..76aaab5420 100644 --- a/interface/src/Field.h +++ b/interface/src/Field.h @@ -17,7 +17,7 @@ #include #include "world.h" #include "Util.h" -#include +#include // Field is a lattice of vectors uniformly distributed FIELD_ELEMENTS^(1/3) on side const int FIELD_ELEMENTS = 1000; diff --git a/interface/src/Finger.h b/interface/src/Finger.h index c257689bed..7e1d15742a 100644 --- a/interface/src/Finger.h +++ b/interface/src/Finger.h @@ -9,7 +9,7 @@ #ifndef __interface__Finger__ #define __interface__Finger__ -#include +#include #include "Util.h" #include "world.h" #include diff --git a/interface/src/Hand.h b/interface/src/Hand.h index 99129001bf..448bf7823a 100644 --- a/interface/src/Hand.h +++ b/interface/src/Hand.h @@ -9,7 +9,7 @@ #ifndef __interface__Hand__ #define __interface__Hand__ -#include +#include #include #include "Util.h" #include "Field.h" diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 9b8795dc14..73c5e9b5bf 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -9,7 +9,7 @@ #include #include "Head.h" #include "Util.h" -#include +#include #include "SerialInterface.h" float skinColor[] = {1.0, 0.84, 0.66}; diff --git a/interface/src/Lattice.h b/interface/src/Lattice.h index 9ac37d42a1..4099f1488c 100644 --- a/interface/src/Lattice.h +++ b/interface/src/Lattice.h @@ -9,7 +9,7 @@ #ifndef __interface__Lattice__ #define __interface__Lattice__ -#include +#include #include "Util.h" #include "world.h" #include diff --git a/interface/src/Oscilloscope.h b/interface/src/Oscilloscope.h index 21add31e4d..d4ce9f04c5 100644 --- a/interface/src/Oscilloscope.h +++ b/interface/src/Oscilloscope.h @@ -9,7 +9,7 @@ #ifndef __interface__Oscilloscope__ #define __interface__Oscilloscope__ -#include +#include #include "Util.h" #include "World.h" #include diff --git a/interface/src/Particle.h b/interface/src/Particle.h index 171296af7e..b3b1895013 100644 --- a/interface/src/Particle.h +++ b/interface/src/Particle.h @@ -9,7 +9,7 @@ #ifndef __interface__Particle__ #define __interface__Particle__ -#include +#include #include "Util.h" #include "world.h" #include diff --git a/interface/src/SerialInterface.h b/interface/src/SerialInterface.h index dc80c20650..e8d3ec9412 100644 --- a/interface/src/SerialInterface.h +++ b/interface/src/SerialInterface.h @@ -6,7 +6,7 @@ #ifndef __interface__SerialInterface__ #define __interface__SerialInterface__ -#include +#include #include "util.h" #include "world.h" #include diff --git a/interface/src/Texture.cpp b/interface/src/Texture.cpp index 7d8349b617..2e6bd782f3 100644 --- a/interface/src/Texture.cpp +++ b/interface/src/Texture.cpp @@ -13,7 +13,7 @@ #else #include #endif -#include "lodepng.h" +#include #include #include diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index f8d69dacfa..80d299b577 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -13,7 +13,7 @@ #endif #include #include "world.h" -#include +#include #include "util.h" diff --git a/interface/src/Util.h b/interface/src/Util.h index 17b11c02e2..de5fe6c8dd 100644 --- a/interface/src/Util.h +++ b/interface/src/Util.h @@ -9,7 +9,7 @@ #ifndef __interface__Util__ #define __interface__Util__ -#include +#include float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos); float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float head_yaw); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index e799872b8b..499aa80863 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -36,8 +36,7 @@ #include #include #include -#include -#include "portaudio.h" +#include // Bring in OpenCV diff --git a/thirdparty/PortAudio/libportaudio.a b/thirdparty/Portaudio/libportaudio.a similarity index 100% rename from thirdparty/PortAudio/libportaudio.a rename to thirdparty/Portaudio/libportaudio.a diff --git a/thirdparty/PortAudio/portaudio.h b/thirdparty/Portaudio/portaudio.h similarity index 100% rename from thirdparty/PortAudio/portaudio.h rename to thirdparty/Portaudio/portaudio.h