Skip to content

Commit

Permalink
Merge pull request #1438 from pedrolcl/debug-libsndfile
Browse files Browse the repository at this point in the history
updated cmake build system
  • Loading branch information
derselbst authored Nov 25, 2024
2 parents d93f84f + 79f2d78 commit 06ddb9b
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 16 deletions.
19 changes: 13 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ set ( FLUIDSYNTH_VERSION_MAJOR 2 )
set ( FLUIDSYNTH_VERSION_MINOR 4 )
set ( FLUIDSYNTH_VERSION_MICRO 0 )
set ( VERSION "${FLUIDSYNTH_VERSION_MAJOR}.${FLUIDSYNTH_VERSION_MINOR}.${FLUIDSYNTH_VERSION_MICRO}" )
set ( FLUIDSYNTH_VERSION "\"${VERSION}\"" )
set ( FLUIDSYNTH_VERSION ${VERSION} )

# libfluidsynth - Library version
# *** NOTICE ***
Expand Down Expand Up @@ -339,7 +339,7 @@ if ( WIN32 )
set ( LIBFLUID_CPPFLAGS "-DFLUIDSYNTH_DLL_EXPORTS" )
set ( FLUID_CPPFLAGS "-DFLUIDSYNTH_NOT_A_DLL" )
if ( NOT MSVC )
# only set debug postfix if not MSVS building
# only set debug postfix if not MSVC building
set ( CMAKE_DEBUG_POSTFIX "_debug" )
endif ( NOT MSVC )

Expand Down Expand Up @@ -544,30 +544,37 @@ endif ( GLib2_VERSION AND GLib2_VERSION VERSION_LESS "2.26.0" )
unset ( LIBSNDFILE_SUPPORT CACHE )
unset ( LIBSNDFILE_HASVORBIS CACHE )
if ( enable-libsndfile )
find_package ( SndFile ${LIBSNDFILE_MINIMUM_VERSION} )
#set(CMAKE_FIND_DEBUG_MODE ON)
find_package ( SndFile ${LIBSNDFILE_MINIMUM_VERSION} QUIET )
set ( LIBSNDFILE_SUPPORT ${SndFile_FOUND} )
if ( LIBSNDFILE_SUPPORT )
message ( STATUS "Found libSndFile: ${SndFile_VERSION}" )
#cmake_print_properties(TARGETS SndFile::sndfile PROPERTIES LOCATION INTERFACE_INCLUDE_DIRECTORIES IMPORTED_CONFIGURATIONS)
cmake_print_variables(SndFile_WITH_EXTERNAL_LIBS SndFile_WITH_MPEG)
list( APPEND PC_REQUIRES_PRIV "sndfile")
if ( SndFile_WITH_EXTERNAL_LIBS )
set ( LIBSNDFILE_HASVORBIS 1 )
else (SndFile_WITH_EXTERNAL_LIBS)
message ( NOTICE "Seems like libsndfile was compiled without OGG/Vorbis support." )
endif (SndFile_WITH_EXTERNAL_LIBS)
else ( LIBSNDFILE_SUPPORT )
message( STATUS "Could NOT find SndFile (Set SndFile_DIR to the directory containing its CMake config) (Required is at least version ${LIBSNDFILE_MINIMUM_VERSION})" )
endif ( LIBSNDFILE_SUPPORT )
#set(CMAKE_FIND_DEBUG_MODE OFF)
endif ( enable-libsndfile )

unset ( PULSE_SUPPORT CACHE )
if ( enable-pulseaudio )
find_package ( PulseAudio ${PULSEAUDIO_MINIMUM_VERSION} )
find_package ( PulseAudio ${PULSEAUDIO_MINIMUM_VERSION} QUIET )
# Upstream config does not search for pulse-simple
find_library ( PULSEAUDIO_SIMPLE_LIBRARY NAMES "pulse-simple" )
find_library ( PULSEAUDIO_SIMPLE_LIBRARY NAMES "pulse-simple" QUIET )
if ( PULSEAUDIO_FOUND AND PULSEAUDIO_SIMPLE_LIBRARY )
set ( PULSE_SUPPORT TRUE )
set ( PULSEAUDIO_LIBRARIES ${PULSEAUDIO_SIMPLE_LIBRARY} ${PULSEAUDIO_LIBRARY} )
message ( STATUS "Found PulseAudio: ${PULSEAUDIO_LIBRARIES}" )
list( APPEND PC_REQUIRES_PRIV "libpulse-simple")
else ( PULSEAUDIO_FOUND AND PULSEAUDIO_SIMPLE_LIBRARY )
message( STATUS "Could NOT find PulseAudio (Set PulseAudio_DIR to the directory containing its CMake config)" )
message( STATUS "Could NOT find PulseAudio (Set PulseAudio_DIR to the directory containing its CMake config) (Required is at least version ${PULSEAUDIO_MINIMUM_VERSION})" )
endif ( PULSEAUDIO_FOUND AND PULSEAUDIO_SIMPLE_LIBRARY )
endif ( enable-pulseaudio )

Expand Down
50 changes: 50 additions & 0 deletions cmake_admin/SCMRevision.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#[=======================================================================[
Copyright © 2019-2024 Pedro López-Cabanillas <[email protected]>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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 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
HOLDER 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.
#]=======================================================================]

if (NOT DEFINED PROJECT_WC_REVISION)
find_package(Git QUIET)
if (Git_FOUND)
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE _res
OUTPUT_VARIABLE PROJECT_WC_REVISION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (${_res} EQUAL 0)
message(STATUS "Current revision (Git) is ${PROJECT_WC_REVISION}")
else()
unset(PROJECT_WC_REVISION)
endif()
endif()
endif()

if (DEFINED PROJECT_WC_REVISION)
set(${PROJECT_NAME}_WC_REVISION ${PROJECT_WC_REVISION})
else()
set(${PROJECT_NAME}_WC_REVISION "not a git working copy")
endif()
18 changes: 18 additions & 0 deletions cmake_admin/report.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include( SCMRevision )

set ( AUDIO_MIDI_REPORT "\n" )

Expand Down Expand Up @@ -189,6 +190,19 @@ else ( HAVE_GETOPT_H )
set ( MISC_REPORT "${MISC_REPORT} getopt: no\n" )
endif ( HAVE_GETOPT_H )

if ( WIN32 OR CYGWIN )
set ( WINDOWS_REPORT "\nWindows specific info:\n" )
if ( windows-version )
set ( WINDOWS_REPORT "${WINDOWS_REPORT} target version: ${windows-version}\n" )
endif ( windows-version )
if ( enable-unicode )
set ( WINDOWS_REPORT "${WINDOWS_REPORT} unicode support: yes\n" )
else ( enable-unicode )
set ( WINDOWS_REPORT "${WINDOWS_REPORT} unicode support: no\n" )
endif ( enable-unicode )
else ( WIN32 OR CYGWIN )
set ( WINDOWS_REPORT "")
endif ( WIN32 OR CYGWIN )

set ( DEVEL_REPORT "\nDeveloper nerds info:\n" )

Expand Down Expand Up @@ -249,6 +263,9 @@ endif ( ENABLE_COVERAGE )
message( STATUS
"\n**************************************************************\n"
"Build Summary:\n"
"FluidSynth Version: " ${FLUIDSYNTH_VERSION} "\n"
"Library version: " ${LIB_VERSION_INFO} "\n"
"Git revision: " ${FluidSynth_WC_REVISION} "\n"
"Build type: " ${CMAKE_BUILD_TYPE} "\n"
"Install Prefix: " ${CMAKE_INSTALL_PREFIX} "\n"
"\n"
Expand All @@ -257,6 +274,7 @@ message( STATUS
${INPUTS_REPORT}
${RENDERING_REPORT}
${MISC_REPORT}
${WINDOWS_REPORT}
${DEVEL_REPORT}
)

Expand Down
2 changes: 1 addition & 1 deletion include/fluidsynth/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern "C" {
*
* @{
*/
#define FLUIDSYNTH_VERSION @FLUIDSYNTH_VERSION@ /**< String constant of libfluidsynth version. */
#define FLUIDSYNTH_VERSION "@FLUIDSYNTH_VERSION@" /**< String constant of libfluidsynth version. */
#define FLUIDSYNTH_VERSION_MAJOR @FLUIDSYNTH_VERSION_MAJOR@ /**< libfluidsynth major version integer constant. */
#define FLUIDSYNTH_VERSION_MINOR @FLUIDSYNTH_VERSION_MINOR@ /**< libfluidsynth minor version integer constant. */
#define FLUIDSYNTH_VERSION_MICRO @FLUIDSYNTH_VERSION_MICRO@ /**< libfluidsynth micro version integer constant. */
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ if ( TARGET PipeWire::PipeWire AND PIPEWIRE_SUPPORT ) # because pw_init() etc.
target_link_libraries ( fluidsynth PRIVATE PipeWire::PipeWire )
endif()

if ( MINGW )
if ( MINGW AND enable-unicode )
target_link_options( fluidsynth PRIVATE -municode )
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/bindings/fluid_filerenderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ new_fluid_file_renderer(fluid_synth_t *synth)
goto error_recovery;
}

#ifdef _WIN32
#if defined( _WIN32 ) && defined( _UNICODE )
if (0 == FLUID_STRCMP("-", filename))
{
dev->sndfile = sf_open(filename, SFM_WRITE, &info);
Expand Down
6 changes: 3 additions & 3 deletions src/fluidsynth.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ fast_render_loop(fluid_settings_t *settings, fluid_synth_t *synth, fluid_player_
15)create the audio driver (i.e synthesis thread) and a synchronous user
shell if interactive.
*/
#if defined(_WIN32)
#if defined(_WIN32) && defined(_UNICODE)
int wmain(int argc, wchar_t **wargv)
#else
int main(int argc, char **argv)
Expand Down Expand Up @@ -356,7 +356,7 @@ int main(int argc, char **argv)
int fast_render = 0;
static const char optchars[] = "a:C:c:dE:f:F:G:g:hijK:L:lm:nO:o:p:QqR:r:sT:Vvz:";

#if defined(_WIN32)
#if defined(_WIN32) && defined(_UNICODE)
// WC_ERR_INVALID_CHARS is only supported on Windows Vista and newer. To support older Windows, our only chance is to use zero for this flag.
#ifndef WC_ERR_INVALID_CHARS
#define WC_ERR_INVALID_CHARS 0
Expand Down Expand Up @@ -1164,7 +1164,7 @@ int main(int argc, char **argv)
delete_fluid_synth(synth);
delete_fluid_settings(settings);

#ifdef _WIN32
#if defined(_WIN32) && defined(_UNICODE)
if (argv != NULL)
{
for (i = 0; i < argc; ++i)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/fluid_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1659,8 +1659,8 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void *data)
fluid_socket_cleanup();
return NULL;
}

if(bind(sock, addr, addr_size) == SOCKET_ERROR)
if(bind(sock, addr, (int) addr_size) == SOCKET_ERROR)
{
FLUID_LOG(FLUID_ERR, "Failed to bind server socket: %d", fluid_socket_get_error());
fluid_socket_close(sock);
Expand Down
5 changes: 3 additions & 2 deletions src/utils/fluid_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ typedef gintptr intptr_t;
#endif

/*
* Required by Windows-specific sf_wchar_open() from
* libsndfile that takes a UTF16_BE encoded filename.
* Required by Windows-specific sf_wchar_open() from old libsndfile
* versions before v1.1.0, that takes a UTF16_BE encoded filename.
* Note that FluidSynth needs libsndfile >= v1.2.1 anyway.
*/
#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1

Expand Down

0 comments on commit 06ddb9b

Please sign in to comment.