diff --git a/CMake/DefineOptions.cmake b/CMake/DefineOptions.cmake index 5032e08c11..4708ad6291 100644 --- a/CMake/DefineOptions.cmake +++ b/CMake/DefineOptions.cmake @@ -31,6 +31,9 @@ option(WITH_NO_ROLC_TOMCRYPT "Build without the ROLC assembly instructions for t # Turn this option off to not use the GPL exclusive components. option(WITH_GPL_LIBS "Build with GPL libraries." ON) +# Turn this option off to disable using MP3 files with the game. +option(WITH_MP3 "Build with MP3 Support." ON) + if(WIN32) option(WITH_MINIMAID "Build with Minimaid Lights Support." ON) elseif(LINUX) @@ -43,7 +46,6 @@ elseif(LINUX) option(WITH_GLES2 "Build with OpenGL ES 2.0 Support." ON) option(WITH_GTK2 "Build with GTK2 Support." ON) option(WITH_OGG "Build with OGG/Vorbis Support." ON) - option(WITH_MP3 "Build with MP3 Support." ON) option(WITH_PARALLEL_PORT "Build with Parallel Lights I/O Support." OFF) option(WITH_CRASH_HANDLER "Build with Crash Handler Support." ON) endif() diff --git a/StepmaniaCore.cmake b/StepmaniaCore.cmake index 88a2f6171d..a30d5f3082 100644 --- a/StepmaniaCore.cmake +++ b/StepmaniaCore.cmake @@ -131,13 +131,22 @@ if (WITH_VERSION_INFO) set(HAVE_VERSION_INFO 1) endif() -configure_file("${SM_SRC_DIR}/config.in.hpp" "${SM_SRC_DIR}/generated/config.hpp") - # Dependencies go here. +if(WITH_MP3) + if(WIN32 OR MACOSX) + set(HAS_MP3 TRUE) + else() + find_package(Mad) + if(NOT LIBMAD_FOUND) + message(FATAL_ERROR "Libmad library not found. If you wish to skip mp3 support, set WITH_MP3 to OFF when configuring.") + else() + set(HAS_MP3 TRUE) + endif() + endif() +endif() if(WIN32) set(HAS_OGG TRUE) - set(HAS_MP3 TRUE) set(SYSTEM_PCRE_FOUND FALSE) find_package(DirectX REQUIRED) @@ -163,7 +172,6 @@ if(WIN32) get_filename_component(LIB_AVUTIL ${LIB_AVUTIL} NAME) elseif(MACOSX) set(HAS_OGG TRUE) - set(HAS_MP3 TRUE) set(SYSTEM_PCRE_FOUND FALSE) set(WITH_CRASH_HANDLER TRUE) # Apple Archs needs to be 32-bit for now. @@ -272,15 +280,6 @@ elseif(LINUX) endif() endif() - if (WITH_MP3) - find_package(Mad) - if(NOT LIBMAD_FOUND) - message(FATAL_ERROR "Libmad library not found. If you wish to skip mp3 support, set WITH_MP3 to OFF when configuring.") - else() - set(HAS_MP3 TRUE) - endif() - endif() - find_package(PulseAudio) if (PULSEAUDIO_FOUND) set(HAS_PULSE TRUE) @@ -410,5 +409,7 @@ elseif(LINUX) endif() +configure_file("${SM_SRC_DIR}/config.in.hpp" "${SM_SRC_DIR}/generated/config.hpp") + # Define installer based items for cpack. include("${CMAKE_CURRENT_LIST_DIR}/CMake/CPackSetup.cmake") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 82d617fb47..742a0b483f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -424,12 +424,20 @@ list(APPEND SMDATA_LINK_LIB "tommath" "zlib" "jsoncpp" - "mad" "png" "glew" "jpeg" ) +if (HAS_MP3) + list(FIND SMDATA_LINK_LIB "jsoncpp" JSON_INDEX) + if (WIN32 OR MACOSX) + list(INSERT SMDATA_LINK_LIB ${JSON_INDEX} "mad") + else() + list(INSERT SMDATA_LINK_LIB ${JSON_INDEX} ${LIBMAD_LIBRARY}) + endif() +endif() + if (NOT SYSTEM_PCRE_FOUND) list(APPEND SMDATA_LINK_LIB "pcre") endif() @@ -472,10 +480,8 @@ elseif(APPLE) # ${MAC_FRAME_APPKIT} # ${MAC_FRAME_FOUNDATION} # "ffmpeg" - - # TODO: Adjust the target when StepMania-Data returns. - # TODO: Find a cleaner way besides just setting to wipe the slate clean. - set(SMDATA_LINK_LIB + + list(INSERT SMDATA_LINK_LIB 0 ${MAC_FRAME_ACCELERATE} ${MAC_FRAME_CARBON} ${MAC_FRAME_COCOA} @@ -490,16 +496,9 @@ elseif(APPLE) "ogg" "theora" "vorbis" - "lua-5.1" - "tomcrypt" - "tommath" - "zlib" - "jsoncpp" - "mad" - "png" - "glew" + ) + list(APPEND SMDATA_LINK_LIB "pcre" - "jpeg" "avcodec" "avdevice" "avfilter" @@ -546,12 +545,6 @@ else() # Unix / Linux ) endif() - if(HAS_MP3) - list(APPEND SMDATA_LINK_LIB - "${LIBMAD_LIBRARY}" - ) - endif() - list(APPEND SMDATA_LINK_LIB "${OPENGL_LIBRARY}" ) diff --git a/src/RageSoundReader_FileReader.cpp b/src/RageSoundReader_FileReader.cpp index 38de079107..193142cbf8 100644 --- a/src/RageSoundReader_FileReader.cpp +++ b/src/RageSoundReader_FileReader.cpp @@ -9,7 +9,7 @@ #include "RageSoundReader_WAV.h" #endif -#ifndef NO_MP3_SUPPORT +#if defined(HAS_MP3) #include "RageSoundReader_MP3.h" #endif @@ -25,7 +25,8 @@ RageSoundReader_FileReader *RageSoundReader_FileReader::TryOpenFile( RageFileBas if( !format.CompareNoCase("wav") ) Sample = new RageSoundReader_WAV; #endif -#ifndef NO_MP3_SUPPORT + +#if defined(HAS_MP3) if( !format.CompareNoCase("mp3") ) Sample = new RageSoundReader_MP3; #endif @@ -57,7 +58,7 @@ RageSoundReader_FileReader *RageSoundReader_FileReader::TryOpenFile( RageFileBas * wrong file format. The error message always looks like "unknown file format" or * "Not Vorbis data"; ignore it so we always give a consistent error message, and * continue trying other file formats. - * + * * OPEN_FATAL_ERROR: Either the file was opened successfully and appears to be the * correct format, but a fatal format-specific error was encountered that will probably * not be fixed by using a different reader (for example, an Ogg file that doesn't diff --git a/src/config.in.hpp b/src/config.in.hpp index be4369c870..3aa5460915 100644 --- a/src/config.in.hpp +++ b/src/config.in.hpp @@ -114,6 +114,9 @@ typedef long ssize_t; /* Defined to 1 if version information will be printed out. */ #cmakedefine HAVE_VERSION_INFO 1 +/* Defined to 1 if compiling with MP3 support. */ +#cmakedefine HAS_MP3 1 + #if defined(__GNUC__) /** @brief Define a macro to tell the compiler that a function has printf() * semantics, to aid warning output. */