cmake_minimum_required(VERSION 3.5) project(vgmstream C) enable_language(CXX) # TODO: Figure out how to build audacious plugin via CMake # TODO: Figure out how to build XMPlay plugin via CMake # TODO: Figure out why MinGW-w64 doesn't build if(MINGW) message(FATAL_ERROR "Cannot currently build with MinGW") endif() set(VGM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE) set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE) set(VGM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}) include(vgmstream) # Options option(USE_FDKAAC "Use FDK-AAC/QAAC for support of MP4 AAC" ON) set(QAAC_PATH CACHE PATH "Path to QAAC") set(FDK_AAC_PATH CACHE PATH "Path to FDK-AAC") option(USE_MPEG "Use libmpg123 for support of MPEG (MP1/MP2/MP3)" ON) option(USE_VORBIS "Use libvorbis for support of Vorbis" ON) option(USE_FFMPEG "Use FFmpeg for support of many codecs" ON) option(USE_MAIATRAC3PLUS "Use MAIATRAC3+ for support of ATRAC3+" OFF) set(MAIATRAC3PLUS_PATH CACHE PATH "Path to MAIATRAC3+") if(WIN32) # May need to see if it is possible to get these to work on non-Windows systems too option(USE_G7221 "Use libg7221_decode for support of ITU-T G.722.1 annex C" ON) option(USE_G719 "Use libg719_decode for support ITU-T G.719" ON) option(USE_ATRAC9 "Use LibAtrac9 for support of ATRAC9" ON) option(USE_CELT "Use libcelt for support of FSB CELT versions 0.6.1 and 0.11.0" ON) endif() # Build choices option(BUILD_CLI "Build vgmstream CLI" ON) if(WIN32) option(BUILD_FB2K "Build foobar2000 component" ON) set(FB2K_SDK_PATH CACHE PATH "Path to foobar2000 SDK") set(WTL_INCLUDE_PATH CACHE PATH "Path to WTL include directory") set(FB2K_COMPONENT_INSTALL_PREFIX CACHE PATH "Path to foobar2000 component installation directory") option(BUILD_WINAMP "Build Winamp plugin" ON) set(WINAMP_INSTALL_PREFIX CACHE PATH "Path to Winamp installation directory") option(BUILD_XMPLAY "Build XMPlay plugin" ON) set(XMPLAY_INSTALL_PREFIX CACHE PATH "Path to XMPlay installation directory") else() option(BUILD_AUDACIOUS "Build Audacious plugin" ON) endif() if(WIN32) # Enable support for the resource compiler when using MinGW if(MINGW) enable_language(RC) # Not 100% sure this is needed, but in the past, MinGW's command for compiling resources was incorrect set(CMAKE_RC_COMPILE_OBJECT " -O coff -i -o ") endif(MINGW) # Update the version set(CMAKE_EXECUTABLE_SUFFIX .exe) if(MSVC) file(TO_NATIVE_PATH "${VGM_BINARY_DIR}/version.h" VERSION_H_PATH) add_custom_command(OUTPUT ${VGM_BINARY_DIR}/version.h COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/version.bat" ARGS ${VERSION_H_PATH} VERSION DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/version.bat) add_custom_target(version_h DEPENDS ${VGM_BINARY_DIR}/version.h) else() find_package(Git) if(GIT_FOUND) execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE VGMSTREAM_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) endif() endif() else() # Update the version find_package(Git) if(GIT_FOUND) execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE VGMSTREAM_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) endif() # Find the relevant packages if(USE_MPEG) find_package(MPG123) if(NOT MPG123_FOUND) set(USE_MPEG OFF) endif() endif() if(USE_VORBIS) find_package(VorbisFile) if(NOT VORBISFILE_FOUND) set(USE_VORBIS OFF) endif() endif() if(USE_FFMPEG) find_package(FFmpeg) if(NOT FFMPEG_LIBRARIES) set(USE_FFMPEG OFF) endif() endif() # If building the CLI, we need to include AO as well if(BUILD_CLI) find_package(AO) if(NOT AO_FOUND) message(FATAL_ERROR "Cannot build vgmstream123 without libao") endif() endif() # If building Audacious, we need to make sure we can find its pkg-config module as well as GTK's if(BUILD_AUDACIOUS) include(FindPkgConfig) pkg_search_module(AUDACIOUS REQUIRED audacious>=3.6) pkg_get_variable(AUDACIOUS_PLUGIN_DIR audacious plugin_dir) pkg_search_module(GTK REQUIRED gtk+-3.0 gtk+-2.0) endif() endif() # Set compiler flags if(CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES GNU) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") if(CMAKE_CXX_COMPILER_ID MATCHES Clang) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-parentheses-equality -Wno-header-guard -Wno-unused-function -Wno-shift-negative-value -Wno-deprecated-register") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-parentheses-equality -Wno-header-guard -Wno-unused-function -Wno-shift-negative-value -Wno-deprecated-register") elseif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.9) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-misleading-indentation") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-misleading-indentation") endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 2.99) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format -Wno-sign-compare") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format -Wno-sign-compare") endif() elseif(MSVC) if(CMAKE_C_FLAGS MATCHES "/W[0-4]") string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") endif() if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3") endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4005 /wd4018 /wd4244 /wd4302 /wd4838") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4005 /wd4018 /wd4244 /wd4302 /wd4838") endif() # Add other projects and subdirectories as needed if(USE_FDKAAC) if(FDK_AAC_PATH) include(fdk-aac) else() message(FATAL_ERROR "Path to FDK-AAC must be set. (Use FDK_AAC_PATH)") endif() if(QAAC_PATH) include(mp4v2) else() message(FATAL_ERROR "Path to QAAC must be set. (Use QAAC_PATH)") endif() endif() if(USE_MAIATRAC3PLUS) if(MAIATRAC3PLUS_PATH) add_subdirectory(${MAIATRAC3PLUS_PATH}/MaiAT3PlusDecoder ${CMAKE_CURRENT_BINARY_DIR}/maitrac3plus) else() message(FATAL_ERROR "Path to MAIATRAC3+ must be set. (Use MAIATRAC3PLUS_PATH)") endif() endif() add_subdirectory(src) if(WIN32) add_subdirectory(ext_libs) if(BUILD_WINAMP) if(NOT WINAMP_INSTALL_PREFIX) set(WINAMP_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/winamp) endif() add_subdirectory(winamp) endif() if(BUILD_FB2K) if(NOT FB2K_SDK_PATH) message(FATAL_ERROR "The path to the foobar2000 SDK must be set. (Use FB2K_SDK_PATH)") endif() if(NOT WTL_INCLUDE_PATH) message(FATAL_ERROR "The path to the WTL include directory must be set. (Use WTL_INCLUDE_PATH)") endif() if(NOT FB2K_COMPONENT_INSTALL_PREFIX) set(FB2K_COMPONENT_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/fb2k) endif() include_external_msproject(fb2k_sdk ${FB2K_SDK_PATH}/foobar2000/SDK/foobar2000_SDK.vcxproj) include_external_msproject(fb2k_sdk_helpers ${FB2K_SDK_PATH}/foobar2000/helpers/foobar2000_sdk_helpers.vcxproj) include_external_msproject(fb2k_atl_helpers ${FB2K_SDK_PATH}/foobar2000/ATLHelpers/foobar2000_ATL_helpers.vcxproj) include_external_msproject(fb2k_component_client ${FB2K_SDK_PATH}/foobar2000/foobar2000_component_client/foobar2000_component_client.vcxproj) include_external_msproject(pfc ${FB2K_SDK_PATH}/pfc/pfc.vcxproj) add_subdirectory(fb2k) endif() if(BUILD_XMPLAY) if(NOT XMPLAY_INSTALL_PREFIX) set(XMPLAY_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/xmplay) endif() add_subdirectory(xmplay) endif() else() if(BUILD_AUDACIOUS) add_subdirectory(audacious) endif() endif() if(BUILD_CLI) if(WIN32) add_subdirectory(ext_libs/Getopt) endif() add_subdirectory(cli) endif() # Option Summary message(STATUS " Option Summary") message(STATUS "=================") message(STATUS "FKD-AAC/QAAC: ${USE_FDKAAC}") message(STATUS " MPEG: ${USE_MPEG}") message(STATUS " Vorbis: ${USE_VORBIS}") message(STATUS " FFmpeg: ${USE_FFMPEG}") message(STATUS " MAIATRAC3+: ${USE_MAIATRAC3PLUS}") if(WIN32) message(STATUS " G.722.1: ${USE_G7221}") message(STATUS " G.719: ${USE_G719}") message(STATUS " ATRAC9: ${USE_ATRAC9}") message(STATUS " FSB CELT: ${USE_CELT}") endif() message(STATUS "") # Build Summary message(STATUS " Building") message(STATUS "=========================") if(WIN32) message(STATUS " CLI: ${BUILD_CLI}") message(STATUS "foobar2000 component: ${BUILD_FB2K}") message(STATUS " Winamp plugin: ${BUILD_WINAMP}") message(STATUS " XMPlay plugin: ${BUILD_XMPLAY}") else() message(STATUS "CLI/vgmstream123: ${BUILD_CLI}") message(STATUS "Audacious plugin: ${BUILD_AUDACIOUS}") endif() message(STATUS "") # Install Summary message(STATUS " Install Paths") message(STATUS "=========================") if(WIN32) message(STATUS " CLI: ${CMAKE_INSTALL_PREFIX}/bin") message(STATUS "foobar2000 component: ${FB2K_COMPONENT_INSTALL_PREFIX}") message(STATUS " Winamp plugin: ${WINAMP_INSTALL_PREFIX}") message(STATUS " XMPlay plugin: ${XMPLAY_INSTALL_PREFIX}") else() message(STATUS "CLI/vgmstream123: ${CMAKE_INSTALL_PREFIX}/bin") message(STATUS "Audacious plugin: ${AUDACIOUS_PLUGIN_DIR}/Input") endif() message(STATUS "")