2015-09-10 18:05:05 +00:00
|
|
|
cmake_minimum_required(VERSION 3.3)
|
2015-12-21 07:23:01 +00:00
|
|
|
|
|
|
|
# Support legacy OS X versions
|
2015-12-14 12:31:28 +00:00
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "Minimum OS X deployment version")
|
|
|
|
|
2015-12-29 10:44:55 +00:00
|
|
|
set(appName "Rhubarb Lip Sync")
|
2016-01-12 21:04:11 +00:00
|
|
|
set(appVersionMajor 0)
|
|
|
|
set(appVersionMinor 1)
|
|
|
|
set(appVersionPatch 0)
|
2016-02-02 19:37:24 +00:00
|
|
|
set(appVersionSuffix "")
|
2016-01-12 21:04:11 +00:00
|
|
|
set(appVersion "${appVersionMajor}.${appVersionMinor}.${appVersionPatch}${appVersionSuffix}")
|
2015-12-29 10:44:55 +00:00
|
|
|
|
|
|
|
project(${appName})
|
2015-09-10 18:05:05 +00:00
|
|
|
|
2015-12-21 07:23:01 +00:00
|
|
|
# Enable C++14
|
2016-01-13 11:01:22 +00:00
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
|
2015-12-21 07:23:01 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
|
|
|
endif()
|
2015-09-10 18:05:05 +00:00
|
|
|
|
2015-12-21 07:23:01 +00:00
|
|
|
# Make sure Xcode uses libc++ instead of libstdc++, allowing us to use the C++14 standard library prior to OS X 10.9
|
2015-12-14 12:31:28 +00:00
|
|
|
if("${CMAKE_GENERATOR}" STREQUAL "Xcode")
|
2015-12-21 07:23:01 +00:00
|
|
|
add_compile_options(-stdlib=libc++)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
|
2015-12-14 12:31:28 +00:00
|
|
|
endif()
|
|
|
|
|
2015-12-21 12:09:09 +00:00
|
|
|
# Use static run-time
|
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
|
|
|
add_compile_options(/MT$<$<CONFIG:Debug>:d>)
|
|
|
|
endif()
|
|
|
|
|
2016-02-29 20:00:38 +00:00
|
|
|
# Set global flags and define flags variables for later use
|
2015-12-21 12:09:09 +00:00
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
2015-12-21 07:23:01 +00:00
|
|
|
set(enableWarningsFlags "-Wall;-Wextra")
|
|
|
|
set(disableWarningsFlags "-w")
|
2015-12-21 12:09:09 +00:00
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
2015-12-21 07:23:01 +00:00
|
|
|
set(enableWarningsFlags "/W4")
|
|
|
|
set(disableWarningsFlags "/W0")
|
2016-02-29 20:00:38 +00:00
|
|
|
|
2016-03-15 19:12:11 +00:00
|
|
|
# Disable warning C4714: function '...' marked as __forceinline not inlined
|
|
|
|
# This is caused by Boost.Log
|
2016-02-29 20:00:38 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4714")
|
2016-03-15 19:12:11 +00:00
|
|
|
|
|
|
|
# Disable warning C4456: declaration of '...' hides previous local declaration
|
|
|
|
# I'm doing that on purpose.
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4458")
|
2015-12-21 07:23:01 +00:00
|
|
|
endif()
|
|
|
|
|
2015-12-29 10:41:26 +00:00
|
|
|
# Enable project folders
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
2015-12-21 07:23:01 +00:00
|
|
|
# Define libraries
|
|
|
|
|
|
|
|
# ... Boost
|
2015-11-03 14:31:13 +00:00
|
|
|
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
|
2016-02-29 20:00:38 +00:00
|
|
|
find_package(Boost REQUIRED COMPONENTS filesystem locale system log date_time thread chrono)
|
2015-12-21 07:23:01 +00:00
|
|
|
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
# ... C++ Format
|
|
|
|
include_directories(SYSTEM "lib/cppformat")
|
|
|
|
FILE(GLOB cppFormatFiles "lib/cppformat/*.cc")
|
|
|
|
add_library(cppFormat ${cppFormatFiles})
|
|
|
|
target_compile_options(cppFormat PRIVATE ${disableWarningsFlags})
|
2015-12-29 10:41:26 +00:00
|
|
|
set_target_properties(cppFormat PROPERTIES FOLDER lib)
|
2015-12-21 07:23:01 +00:00
|
|
|
|
|
|
|
# ... sphinxbase
|
2016-01-12 21:13:42 +00:00
|
|
|
include_directories(SYSTEM "lib/sphinxbase-5prealpha-2015-08-05/include")
|
2015-12-21 07:23:01 +00:00
|
|
|
FILE(GLOB_RECURSE sphinxbaseFiles "lib/sphinxbase-5prealpha-2015-08-05/src/libsphinxbase/*.c")
|
|
|
|
add_library(sphinxbase ${sphinxbaseFiles})
|
|
|
|
target_compile_options(sphinxbase PRIVATE ${disableWarningsFlags})
|
2015-12-29 10:41:26 +00:00
|
|
|
set_target_properties(sphinxbase PROPERTIES FOLDER lib)
|
2015-12-21 07:23:01 +00:00
|
|
|
|
|
|
|
# ... PocketSphinx
|
2016-01-19 21:05:06 +00:00
|
|
|
include_directories(SYSTEM "lib/pocketsphinx-5prealpha-2015-08-05/include" "lib/pocketsphinx-5prealpha-2015-08-05/src/libpocketsphinx")
|
2015-12-21 07:23:01 +00:00
|
|
|
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})
|
2015-12-29 10:41:26 +00:00
|
|
|
set_target_properties(pocketSphinx PROPERTIES FOLDER lib)
|
2015-12-21 07:23:01 +00:00
|
|
|
|
2015-12-29 10:44:55 +00:00
|
|
|
# ... TCLAP
|
|
|
|
include_directories(SYSTEM "lib/tclap-1.2.1/include")
|
|
|
|
|
2015-12-29 14:55:05 +00:00
|
|
|
# ... Google Test
|
|
|
|
add_subdirectory("lib/googletest")
|
|
|
|
set_target_properties(gmock PROPERTIES FOLDER lib)
|
|
|
|
set_target_properties(gmock_main PROPERTIES FOLDER lib)
|
|
|
|
set_target_properties(gtest PROPERTIES FOLDER lib)
|
|
|
|
set_target_properties(gtest_main PROPERTIES FOLDER lib)
|
|
|
|
|
2016-02-29 19:57:14 +00:00
|
|
|
# ... GSL
|
|
|
|
include_directories(SYSTEM "lib/gsl/include")
|
|
|
|
|
2015-12-21 07:23:01 +00:00
|
|
|
# Define executable
|
|
|
|
include_directories("src" "src/audio_input")
|
2015-12-29 15:26:01 +00:00
|
|
|
configure_file(src/appInfo.cpp.in src/appInfo.cpp ESCAPE_QUOTES)
|
2015-12-21 07:23:01 +00:00
|
|
|
set(SOURCE_FILES
|
2015-12-29 15:26:01 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/src/appInfo.cpp
|
2015-12-21 07:23:01 +00:00
|
|
|
src/main.cpp
|
|
|
|
src/Phone.cpp
|
|
|
|
src/Shape.cpp
|
|
|
|
src/centiseconds.cpp
|
2016-03-08 20:44:57 +00:00
|
|
|
src/enumTools.cpp
|
2015-12-29 15:26:01 +00:00
|
|
|
src/mouthAnimation.cpp
|
|
|
|
src/phoneExtraction.cpp
|
|
|
|
src/platformTools.cpp
|
2015-12-21 07:23:01 +00:00
|
|
|
src/tools.cpp
|
2016-03-08 17:21:17 +00:00
|
|
|
src/audio/AudioStream.cpp
|
2016-03-15 18:56:02 +00:00
|
|
|
src/audio/DCOffset.cpp
|
2016-03-08 17:21:17 +00:00
|
|
|
src/audio/SampleRateConverter.cpp
|
2016-03-15 18:56:02 +00:00
|
|
|
src/audio/UnboundedStream.cpp
|
2016-03-15 21:52:31 +00:00
|
|
|
src/audio/voiceActivityDetection.cpp
|
2016-03-08 17:21:17 +00:00
|
|
|
src/audio/WaveFileReader.cpp
|
|
|
|
src/audio/waveFileWriting.cpp
|
2015-12-29 15:26:01 +00:00
|
|
|
src/stringTools.cpp
|
2016-01-06 19:45:04 +00:00
|
|
|
src/NiceCmdLineOutput.cpp
|
|
|
|
src/TablePrinter.cpp
|
2016-01-08 09:53:35 +00:00
|
|
|
src/ProgressBar.cpp
|
2016-02-29 20:00:38 +00:00
|
|
|
src/logging.cpp
|
2016-03-15 21:52:31 +00:00
|
|
|
src/Timed.cpp
|
2016-03-28 18:25:11 +00:00
|
|
|
src/TimeRange.cpp
|
2016-04-04 18:10:28 +00:00
|
|
|
src/Timeline.cpp
|
2016-04-12 18:49:06 +00:00
|
|
|
src/Exporter.cpp
|
2015-12-21 07:23:01 +00:00
|
|
|
)
|
|
|
|
add_executable(rhubarb ${SOURCE_FILES})
|
|
|
|
target_link_libraries(rhubarb ${Boost_LIBRARIES} cppFormat sphinxbase pocketSphinx)
|
|
|
|
target_compile_options(rhubarb PUBLIC ${enableWarningsFlags})
|
2015-11-11 19:25:47 +00:00
|
|
|
|
2015-12-29 14:55:05 +00:00
|
|
|
# Define test project
|
|
|
|
#include_directories("${gtest_SOURCE_DIR}/include")
|
2015-12-29 10:47:22 +00:00
|
|
|
set(TEST_FILES
|
2015-12-29 15:26:01 +00:00
|
|
|
tests/stringToolsTests.cpp
|
2016-04-04 18:10:28 +00:00
|
|
|
tests/TimelineTests.cpp
|
2015-12-29 15:26:01 +00:00
|
|
|
src/stringTools.cpp
|
2016-04-04 18:10:28 +00:00
|
|
|
src/Timeline.cpp
|
|
|
|
src/TimeRange.cpp
|
|
|
|
src/centiseconds.cpp
|
2015-12-29 10:47:22 +00:00
|
|
|
)
|
2015-12-29 14:55:05 +00:00
|
|
|
add_executable(runTests ${TEST_FILES})
|
|
|
|
target_link_libraries(runTests gtest gmock gmock_main)
|
|
|
|
|
2016-01-12 21:04:11 +00:00
|
|
|
set(CPACK_PACKAGE_NAME ${appName})
|
|
|
|
string(REPLACE " " "-" CPACK_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
|
2016-01-13 13:43:01 +00:00
|
|
|
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
|
|
|
set(CPACK_SYSTEM_NAME "OSX")
|
|
|
|
endif()
|
2016-01-12 21:04:11 +00:00
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR ${appVersionMajor})
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR ${appVersionMinor})
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH ${appVersionPatch})
|
|
|
|
set(CPACK_PACKAGE_VERSION ${appVersion})
|
|
|
|
set(CPACK_GENERATOR ZIP)
|
|
|
|
|
|
|
|
# Copy resource files at build time; install them at package time
|
2015-12-21 07:23:01 +00:00
|
|
|
include(tools.cmake)
|
2015-11-11 19:25:47 +00:00
|
|
|
set(modelDir "${CMAKE_SOURCE_DIR}/lib/pocketsphinx-5prealpha-2015-08-05/model")
|
2016-01-19 21:05:06 +00:00
|
|
|
copy_and_install("${modelDir}/en-us/*" "res/sphinx")
|
|
|
|
copy_and_install("${modelDir}/en-us/en-us/*" "res/sphinx/acoustic-model")
|
2016-01-12 21:04:11 +00:00
|
|
|
|
|
|
|
install(
|
|
|
|
TARGETS rhubarb
|
|
|
|
RUNTIME
|
|
|
|
DESTINATION .
|
|
|
|
)
|
|
|
|
install(
|
2016-02-02 19:37:24 +00:00
|
|
|
FILES README.md LICENSE.md VERSION.md
|
2016-01-12 21:04:11 +00:00
|
|
|
DESTINATION .
|
|
|
|
)
|
|
|
|
|
2016-01-13 11:01:22 +00:00
|
|
|
include(CPack)
|