From 6acfa41f15c57e4a74054da4fdda662122ade044 Mon Sep 17 00:00:00 2001 From: Sreekanth Arikatla <sreekanth.arikatla@kitware.com> Date: Tue, 12 Sep 2017 17:48:17 -0400 Subject: [PATCH] COMP: Build audio only on windows --- CMakeLists.txt | 22 +++++++++++++++++++--- Examples/Sandbox/CMakeLists.txt | 12 ++++++++---- Examples/Sandbox/main.cpp | 14 +++++++++++++- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d358ce10c..22dcca0cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.2) project(iMSTK VERSION 0.0.1 LANGUAGES C CXX) +if(UNIX AND NOT APPLE) + set(LINUX TRUE) +endif() + #----------------------------------------------------------------------------- # CTest/Dashboards #----------------------------------------------------------------------------- @@ -110,7 +114,14 @@ if(${PROJECT_NAME}_SUPERBUILD) imstk_define_dependency(VTK) imstk_define_dependency(VRPN) imstk_define_dependency(LibNiFalcon) - imstk_define_dependency(SFML) + + if(APPLE OR LINUX) + message("Warning: Building iMSTK WITHOUT audio support!") + set(${PROJECT_NAME}_AUDIO_ENABLED OFF) + else() + set(${PROJECT_NAME}_AUDIO_ENABLED "Windows OS detected: Building iMSTK with AUDIO support." ON) + imstk_define_dependency(SFML) + endif() option(${PROJECT_NAME}_USE_ODE "Build iMSTK with ODE support." OFF) if(${PROJECT_NAME}_USE_ODE) @@ -243,7 +254,7 @@ find_package( VRPN REQUIRED ) include_directories( ${VRPN_INCLUDE_DIRS} ) add_definitions( -DVRPN_USE_LIBNIFALCON ) if(${PROJECT_NAME}_USE_OMNI) - add_definitions( -DiMSTK_USE_OPENHAPTICS ) + add_definitions( -DiMSTK_USE_OPENHAPTICS ) add_definitions( -DVRPN_USE_PHANTOM_SERVER ) else() remove_definitions( -DiMSTK_USE_OPENHAPTICS ) @@ -271,7 +282,12 @@ else() endif() # SFML -find_package( SFML REQUIRED ) +if(APPLE OR LINUX) + remove_definitions( -DiMSTK_AUDIO_ENABLED ) +else() + find_package( SFML REQUIRED ) + add_definitions( -DiMSTK_AUDIO_ENABLED ) +endif() # Google Test if(BUILD_TESTING) diff --git a/Examples/Sandbox/CMakeLists.txt b/Examples/Sandbox/CMakeLists.txt index e3a1a119e..c9e56494c 100644 --- a/Examples/Sandbox/CMakeLists.txt +++ b/Examples/Sandbox/CMakeLists.txt @@ -26,11 +26,15 @@ add_executable(${PROJECT_NAME} main.cpp) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} +if(UNIX) + target_link_libraries(${PROJECT_NAME} + SimulationManager) +else() + target_link_libraries(${PROJECT_NAME} SimulationManager - SFML -) - + SFML) +endif() + #----------------------------------------------------------------------------- # Associate external data #----------------------------------------------------------------------------- diff --git a/Examples/Sandbox/main.cpp b/Examples/Sandbox/main.cpp index 77809bbf1..daa6b9c54 100644 --- a/Examples/Sandbox/main.cpp +++ b/Examples/Sandbox/main.cpp @@ -97,9 +97,13 @@ #include <string> #include <vtkJPEGReader.h> +#ifdef iMSTK_AUDIO_ENABLED + // Audio #include <SFML/Audio.hpp> +#endif + // global variables const std::string phantomOmni1Name = "Phantom1"; const std::string phantomOmni2Name = "Phantom2"; @@ -3340,6 +3344,7 @@ void testRigidBody() // Example modified from SFML/Examples void testSound(const std::string& filename) { +#ifdef iMSTK_AUDIO_ENABLED // Load a sound buffer from a .wav file sf::SoundBuffer buffer; if (!buffer.loadFromFile(filename)) @@ -3378,11 +3383,15 @@ void testSound(const std::string& filename) std::cout << std::flush; } std::cout << "\n" << std::endl; +#else + LOG(INFO) << "testSound: Audio is supported only on windows!"; +#endif } // Example modified from SFML/Examples void playMusic(const std::string& filename) { +#ifdef iMSTK_AUDIO_ENABLED // Load an ogg music file sf::Music music; if (!music.openFromFile(filename)) @@ -3411,6 +3420,9 @@ void playMusic(const std::string& filename) std::cout << std::flush; } std::cout << "\n" << std::endl; +#else + LOG(INFO) << "playMusic: Audio is supported only on windows!"; +#endif } void testAudio() @@ -3463,7 +3475,7 @@ int main() Test physics ------------------*/ //testPbdVolume(); - testPbdCloth(); + //testPbdCloth(); //testPbdCollision(); //testPbdFluidBenchmarking(); //testPbdFluid(); -- GitLab