From fd842111dcdba141b2812141f0eebcb510596252 Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Mon, 21 Dec 2015 08:23:01 +0100 Subject: [PATCH] Refactored CMakeLists.txt; updated LICENSE.md --- .idea/LipSync.iml | 50 ++++++++++++++++++------- CMakeLists.txt | 93 +++++++++++++++++++++++++++++++---------------- LICENSE.md | 42 +++++++++++++-------- tools.cmake | 17 +++++++++ 4 files changed, 142 insertions(+), 60 deletions(-) create mode 100644 tools.cmake diff --git a/.idea/LipSync.iml b/.idea/LipSync.iml index 30ebdaf..b3c2486 100644 --- a/.idea/LipSync.iml +++ b/.idea/LipSync.iml @@ -126,10 +126,8 @@ - - @@ -151,38 +149,64 @@ + - - - - - + + + + + + - - - - - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CMakeLists.txt b/CMakeLists.txt index dbd1dff..fec51c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,56 +1,85 @@ cmake_minimum_required(VERSION 3.3) + +# Support legacy OS X versions set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "Minimum OS X deployment version") project("Rhubarb Lip Sync") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra") - -if("${CMAKE_GENERATOR}" STREQUAL "Xcode") - # Make sure Xcode uses libc++ instead of libstdc++, allowing us to use the C++11 standard library prior to OS X 10.9 - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") +# Enable C++14 +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") endif() +# Make sure Xcode uses libc++ instead of libstdc++, allowing us to use the C++14 standard library prior to OS X 10.9 +if("${CMAKE_GENERATOR}" STREQUAL "Xcode") + add_compile_options(-stdlib=libc++) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") +endif() + +# Set output directories set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -# Find Boost libraries +# Define flags variables for later use +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(enableWarningsFlags "-Wall;-Wextra") + set(disableWarningsFlags "-w") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(enableWarningsFlags "/W4") + set(disableWarningsFlags "/W0") +endif() + +# Define libraries + +# ... Boost set(Boost_USE_STATIC_LIBS ON) # Use static libs set(Boost_USE_MULTITHREADED ON) # Enable multithreading support set(Boost_USE_STATIC_RUNTIME ON) # Use static C++ runtime find_package(Boost REQUIRED COMPONENTS filesystem locale system) -include_directories(${Boost_INCLUDE_DIRS}) +include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) -set(SOURCE_FILES src/main.cpp src/audio_input/WaveFileReader.cpp src/audio_input/WaveFileReader.h src/audio_input/ChannelDownmixer.cpp src/audio_input/ChannelDownmixer.h src/audio_input/AudioStream.h src/audio_input/SampleRateConverter.cpp src/audio_input/SampleRateConverter.h src/audio_input/wave_file_writing.cpp src/audio_input/wave_file_writing.h src/audio_input/io_tools.h src/platform_tools.cpp src/platform_tools.h src/phone_extraction.cpp src/phone_extraction.h src/Phone.cpp src/Phone.h src/centiseconds.cpp src/centiseconds.h src/tools.cpp src/tools.h src/Shape.cpp src/Shape.h src/mouth_animation.cpp src/mouth_animation.h) +# ... C++ Format +include_directories(SYSTEM "lib/cppformat") +FILE(GLOB cppFormatFiles "lib/cppformat/*.cc") +add_library(cppFormat ${cppFormatFiles}) +target_compile_options(cppFormat PRIVATE ${disableWarningsFlags}) -include_directories("lib/sphinxbase-5prealpha-2015-08-05/include" "lib/pocketsphinx-5prealpha-2015-08-05/include" "lib/cppformat") -FILE(GLOB_RECURSE SPHINX_BASE "lib/sphinxbase-5prealpha-2015-08-05/src/libsphinxbase/*.c") -FILE(GLOB POCKETSPHINX "lib/pocketsphinx-5prealpha-2015-08-05/src/libpocketsphinx/*.c") -FILE(GLOB CPPFORMAT "lib/cppformat/*.cc") +# ... sphinxbase +include_directories(SYSTEM "lib/sphinxbase-5prealpha-2015-08-05/include") +FILE(GLOB_RECURSE sphinxbaseFiles "lib/sphinxbase-5prealpha-2015-08-05/src/libsphinxbase/*.c") +add_library(sphinxbase ${sphinxbaseFiles}) +target_compile_options(sphinxbase PRIVATE ${disableWarningsFlags}) -add_executable(rhubarb ${SOURCE_FILES} ${SPHINX_BASE} ${POCKETSPHINX} ${CPPFORMAT}) -target_link_libraries(rhubarb ${Boost_LIBRARIES}) +# ... PocketSphinx +include_directories(SYSTEM "lib/pocketsphinx-5prealpha-2015-08-05/include") +FILE(GLOB pocketSphinxFiles "lib/pocketsphinx-5prealpha-2015-08-05/src/libpocketsphinx/*.c") +add_library(pocketSphinx ${pocketSphinxFiles}) +target_link_libraries(pocketSphinx sphinxbase) +target_compile_options(pocketSphinx PRIVATE ${disableWarningsFlags}) -function(copy_after_build sourceGlob relativeTargetDirectory) - # Set `sourcePaths` - file(GLOB sourcePaths "${sourceGlob}") - - foreach(sourcePath ${sourcePaths}) - # Set `fileName` - get_filename_component(fileName "${sourcePath}" NAME) - - # Set `targetPath` - set(targetPath "${CMAKE_BINARY_DIR}/${relativeTargetDirectory}/${fileName}") - - add_custom_command(TARGET rhubarb POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${sourcePath}" "${targetPath}" - COMMENT "Creating '${relativeTargetDirectory}/${fileName}'" - ) - endforeach() -endfunction() +# Define executable +include_directories("src" "src/audio_input") +set(SOURCE_FILES + src/main.cpp + src/Phone.cpp + src/Shape.cpp + src/centiseconds.cpp + src/mouth_animation.cpp + src/phone_extraction.cpp + src/platform_tools.cpp + src/tools.cpp + src/audio_input/ChannelDownmixer.cpp + src/audio_input/SampleRateConverter.cpp + src/audio_input/WaveFileReader.cpp + src/audio_input/wave_file_writing.cpp +) +add_executable(rhubarb ${SOURCE_FILES}) +target_link_libraries(rhubarb ${Boost_LIBRARIES} cppFormat sphinxbase pocketSphinx) +target_compile_options(rhubarb PUBLIC ${enableWarningsFlags}) # Copy resource files +include(tools.cmake) set(modelDir "${CMAKE_SOURCE_DIR}/lib/pocketsphinx-5prealpha-2015-08-05/model") copy_after_build("${modelDir}/en-us/en-us-phone.lm.bin" "res/sphinx") copy_after_build("${modelDir}/en-us/en-us/*" "res/sphinx/acoustic_model") diff --git a/LICENSE.md b/LICENSE.md index 1213566..90b8b98 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -21,6 +21,18 @@ All parts of [Rhubarb Lip Sync](https://github.com/DanielSWolf/rhubarb-lip-sync) > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +### Boost + +The [Boost](http://www.boost.org/) libraries are released under the **Boost Software License**. + +> Boost Software License - Version 1.0 - August 17th, 2003 +> +> Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: +> +> The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ### C++ Format The [C++ Format](https://github.com/cppformat/cppformat) library is released under the **2-clause BSD License**. @@ -36,6 +48,21 @@ The [C++ Format](https://github.com/cppformat/cppformat) library is released und > > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +### CMU Sphinx common libraries (sphinxbase) + +The [sphinxbase](https://github.com/cmusphinx/sphinxbase) library is released under a variation of the **2-clause BSD License**. + +> Copyright (c) 1999-2015 Carnegie Mellon University. All rights reserved. +> +> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +> +> 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +> 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +> +> This work was supported in part by funding from the Defense Advanced Research Projects Agency and the National Science Foundation of the United States of America, and the CMU Sphinx Speech Consortium. +> +> THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ### PocketSphinx The [PocketSphinx](https://github.com/cmusphinx/pocketsphinx) library is released under a variation of the **2-clause BSD License**. @@ -63,18 +90,3 @@ The US english acoustic model that is distributed along with the [PocketSphinx]( > 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. > > THIS SOFTWARE IS PROVIDED BY ALPHA CEPHEI INC. ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ALPHA CEPHEI INC. NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -### CMU Sphinx common libraries (sphinxbase) - -The [sphinxbase](https://github.com/cmusphinx/sphinxbase) library is released under a variation of the **2-clause BSD License**. - -> Copyright (c) 1999-2015 Carnegie Mellon University. All rights reserved. -> -> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -> -> 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -> 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -> -> This work was supported in part by funding from the Defense Advanced Research Projects Agency and the National Science Foundation of the United States of America, and the CMU Sphinx Speech Consortium. -> -> THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tools.cmake b/tools.cmake new file mode 100644 index 0000000..65a475c --- /dev/null +++ b/tools.cmake @@ -0,0 +1,17 @@ +function(copy_after_build sourceGlob relativeTargetDirectory) + # Set `sourcePaths` + file(GLOB sourcePaths "${sourceGlob}") + + foreach(sourcePath ${sourcePaths}) + # Set `fileName` + get_filename_component(fileName "${sourcePath}" NAME) + + # Set `targetPath` + set(targetPath "${CMAKE_BINARY_DIR}/${relativeTargetDirectory}/${fileName}") + + add_custom_command(TARGET rhubarb POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${sourcePath}" "${targetPath}" + COMMENT "Creating '${relativeTargetDirectory}/${fileName}'" + ) + endforeach() +endfunction()