Overhaul CMakeLists to conform with modern CMake

- Prefer target properties instead of setting variables whenever possible.
  A zmusic-obj target now exists to represent the commonality between zmusic
  and zmusiclite.
- Factored out as much as possible from global settings to per target settings
  which will make it easier to support using ZMusic as a submodule. Moved
  helper functions into a ZUtility.cmake module.
- We now generate and install ZMusicConfig.cmake so find_package(ZMusic)
  will work either automatically or given ZMusic_DIR is set.
- CPack is enabled although some refinement is still needed.
- Requires CMake >= 3.13 which is newer than I would normally like, but given
  how no one like to refactor these things it may be better to deal with the
  short term pain of going a little aggressive on the requirement in order to
  avoid having to make things ugly. Especially given that these scripts have
  a tendency to be copy/pasted into sister projects. CMake itself has very few
  dependencies so users of old Linux distros should be able to easily compile
  a supported version of CMake.
- On Windows CMake >= 3.15 is required for redistributable results.
- Cleaned out bits that were copied from GZDoom but not relevant to ZMusic.
This commit is contained in:
Braden Obrzut 2021-01-08 16:49:44 -05:00
parent 0bd339d737
commit b3c4b55dab
23 changed files with 864 additions and 663 deletions

View file

@ -1,251 +1,154 @@
cmake_minimum_required( VERSION 2.8.7 )
project(ZMusic)
cmake_minimum_required(VERSION 3.13...3.19)
project(ZMusic
VERSION 1.1.4
LANGUAGES C CXX
)
set(ZMUSIC_VERSION_MAJOR 1)
set(ZMUSIC_VERSION_MINOR 1)
set(ZMUSIC_VERSION_PATCH 0)
set(ZMUSIC_VERSION "${ZMUSIC_VERSION_MAJOR}.${ZMUSIC_VERSION_MINOR}.${ZMUSIC_VERSION_PATCH}")
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
if( COMMAND cmake_policy )
if( POLICY CMP0011 )
cmake_policy( SET CMP0011 NEW )
endif()
if( POLICY CMP0054 )
cmake_policy( SET CMP0054 NEW )
endif()
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(ZUtility)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# If building standalone give the user the option to build shared or static.
# Otherwise the vendoring project should set the variable.
if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
elseif(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif()
list( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake )
include( FindPackageHandleStandardArgs )
# Support cross compiling
option( FORCE_CROSSCOMPILE "Turn on cross compiling." NO )
if( FORCE_CROSSCOMPILE )
set( CMAKE_CROSSCOMPILING TRUE )
endif()
if(CMAKE_CROSSCOMPILING)
set(IMPORT_EXECUTABLES "IMPORTFILE-NOTFOUND" CACHE FILEPATH "Export file from native build.")
# todo: if compile-time executables should ever be required, this must be promoted to a fatal error
if (IMPORT_EXECUTABLES STREQUAL "IMPORTFILE-NOTFOUND")
message(WARNING "IMPORT_EXECUTABLES not set!")
else()
include(${IMPORT_EXECUTABLES})
endif()
endif()
# Macro for building libraries without debugging information
macro( make_release_only )
set( CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_RELEASE} )
set( CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELEASE} )
string( REPLACE "/MT " "/MTd " CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_RELEASE} )
set( CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_RELEASE} )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELEASE} )
string( REPLACE "/MT " "/MTd " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_RELEASE} )
endmacro()
IF( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE Debug CACHE STRING
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE )
ENDIF()
# Replacement variables for a possible long list of C/C++ compilers compatible with GCC
if( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" )
set( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE TRUE )
else()
set( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE FALSE )
FORCE)
endif()
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
set( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE TRUE )
else()
set( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE FALSE )
if(MSVC AND CMAKE_VERSION VERSION_LESS 3.15)
message(WARNING "Some things may be misconfigured. Please update to CMake >= 3.15 with Visual Studio.")
endif()
if(NOT CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
set( PROFILE 0 CACHE BOOL "Enable profiling with gprof for Debug and RelWithDebInfo build types." )
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Install path prefix" FORCE)
endif()
# Fast math flags, required by some subprojects
set( ZD_FASTMATH_FLAG "" )
if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
set( ZD_FASTMATH_FLAG "-ffast-math -ffp-contract=fast" )
elseif( MSVC )
set( ZD_FASTMATH_FLAG "/fp:fast" )
endif()
macro( use_fast_math )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZD_FASTMATH_FLAG}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ZD_FASTMATH_FLAG}" )
endmacro()
include( CheckFunctionExists )
macro( require_stricmp )
CHECK_FUNCTION_EXISTS( stricmp STRICMP_EXISTS )
if( NOT STRICMP_EXISTS )
add_definitions( -Dstricmp=strcasecmp )
endif()
endmacro()
macro( require_strnicmp )
CHECK_FUNCTION_EXISTS( strnicmp STRNICMP_EXISTS )
if( NOT STRNICMP_EXISTS )
add_definitions( -Dstrnicmp=strncasecmp )
endif()
endmacro()
find_package( ZLIB )
if( MSVC )
# Eliminate unreferenced functions and data
# Perform identical COMDAT folding
set( REL_LINKER_FLAGS "/opt:ref /opt:icf /nodefaultlib:msvcrt /TSAWARE /LARGEADDRESSAWARE" )
# String pooling
# Function-level linking
# Disable run-time type information
set( ALL_C_FLAGS "/GF /Gy /GR- /permissive-" )
# Avoid CRT DLL dependancies in release builds, optionally generate assembly output for checking crash locations.
option( ZDOOM_GENERATE_ASM "Generate assembly output." OFF )
if( ZDOOM_GENERATE_ASM )
set( REL_C_FLAGS "/MT /Oy /Oi /FAcs /GS-" )
else()
set( REL_C_FLAGS "/MT /Oy /Oi /GS-" )
if(MSVC)
# optionally generate assembly output for checking crash locations.
option(ZMUSIC_GENERATE_ASM "Generate assembly output." OFF)
if(ZMUSIC_GENERATE_ASM)
add_compile_options("/FAcs")
endif()
add_compile_options(
"/GF" # String pooling
"/Gy" # Function-level linking
"/GR-" # Disable run-time type information
"/permissive-"
"/Oy" "/Oi" "/GS-"
# Debug allocations in debug builds
set( DEB_C_FLAGS "/D _CRTDBG_MAP_ALLOC /MTd" )
# Disable warnings for unsecure CRT functions from VC8+
"/wd4996"
)
# Disable warnings for unsecure CRT functions from VC8+
set( ALL_C_FLAGS "${ALL_C_FLAGS} /wd4996 /DUNICODE /D_UNICODE /D_WIN32_WINNT=0x0600" )
add_compile_definitions(
"UNICODE"
"_UNICODE"
"_WIN32_WINNT=0x0600"
# Debug allocations in debug builds
$<$<CONFIG:DEBUG>:_CRTDBG_MAP_ALLOC>
)
# The CMake configurations set /GR and /MD by default, which conflict with our settings.
string(REPLACE "/MD " " " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )
string(REPLACE "/MD " " " CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL} )
string(REPLACE "/MD " " " CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} )
add_link_options(
"/opt:ref" # Eliminate unreferenced functions and data
"/opt:icf" # Perform identical COMDAT folding
"/nodefaultlib:msvcrt"
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:/TSAWARE>
"/LARGEADDRESSAWARE"
)
# RelWithDebInfo uses /Ob1 by default instead of Ob2 like Release
string(REPLACE "/Ob1 " "/Ob2 " CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} )
string(REPLACE "/MDd " " " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} )
string(REPLACE "/MD " " " CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} )
string(REPLACE "/MD " " " CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL} )
string(REPLACE "/MD " " " CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO} )
string(REPLACE "/MDd " " " CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} )
# The CMake configurations set /GR by default, which conflict with our settings.
# CMake 3.20 fixes the need to do this
string(REPLACE " /GR" " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} )
else()
set( REL_LINKER_FLAGS "" )
set( ALL_C_FLAGS "-ffp-contract=off" )
add_compile_options("-ffp-contract=off")
if ( UNIX )
include(CheckSymbolExists)
check_symbol_exists( "fts_set" "fts.h" HAVE_FTS )
if ( NOT HAVE_FTS )
include ( FindPkgConfig )
pkg_check_modules( MUSL_FTS musl-fts )
if ( MUSL_FTS_FOUND )
set ( ALL_C_FLAGS "${ALL_C_FLAGS} ${MUSL_FTS_LDFLAGS}" )
else ( MUSL_FTS_FOUND )
message (ERROR "fts_* functions not found in the system" )
endif ( MUSL_FTS_FOUND )
endif ( NOT HAVE_FTS )
endif ( UNIX )
set( REL_C_FLAGS "" )
set( DEB_C_FLAGS "" )
if( APPLE )
set( CMAKE_OSX_DEPLOYMENT_TARGET "10.9" )
if( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# With standard Apple tools -stdlib=libc++ needs to be specified in order to get
# C++11 support using SDKs 10.7 and 10.8.
set( CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}" )
set( CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++ ${CMAKE_EXE_LINKER_FLAGS}" )
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
add_compile_options("-stdlib=libc++")
add_link_options("-stdlib=libc++")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# If we're compiling with a custom GCC on the Mac (which we know since g++-4.2 doesn't support C++11) statically link libgcc.
set( ALL_C_FLAGS "-static-libgcc" )
add_compile_options("-static-libgcc")
endif()
elseif( NOT MINGW )
# Generic GCC/Clang requires position independent code to be enabled explicitly
set( ALL_C_FLAGS "${ALL_C_FLAGS} -fPIC" )
endif( APPLE )
endif()
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${REL_LINKER_FLAGS}" )
set( CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} ${REL_LINKER_FLAGS}" )
set( CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} ${REL_LINKER_FLAGS}" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ALL_C_FLAGS}" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${REL_C_FLAGS}" )
set( CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${REL_C_FLAGS}" )
set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${REL_C_FLAGS}" )
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEB_C_FLAGS} -D_DEBUG" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ALL_C_FLAGS}" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${REL_C_FLAGS}" )
set( CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${REL_C_FLAGS}" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${REL_C_FLAGS}" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEB_C_FLAGS} -D_DEBUG" )
option(FORCE_INTERNAL_ZLIB "Use internal zlib")
option(FORCE_INTERNAL_GME "Use internal gme" ON)
mark_as_advanced( FORCE_INTERNAL_GME )
if( ZLIB_FOUND AND NOT FORCE_INTERNAL_ZLIB )
message( STATUS "Using system zlib, includes found at ${ZLIB_INCLUDE_DIR}" )
else()
message( STATUS "Using internal zlib" )
set( SKIP_INSTALL_ALL TRUE ) # Avoid installing zlib alongside zdoom
add_subdirectory( thirdparty/zlib )
set( ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zlib )
set( ZLIB_LIBRARIES z )
set( ZLIB_LIBRARY z )
endif()
if( GME_FOUND AND NOT FORCE_INTERNAL_GME )
message( STATUS "Using system gme library, includes found at ${GME_INCLUDE_DIR}" )
else()
message( STATUS "Using internal gme library" )
# Use MAME as it's a balanced emulator: well-accurate, but doesn't eats lot of CPU
# Nuked OPN2 is very accurate emulator, but it eats too much CPU for the workflow
set( GME_YM2612_EMU "MAME" )
add_subdirectory( thirdparty/game-music-emu )
set( GME_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/game-music-emu" )
set( GME_LIBRARIES gme )
endif()
set( ADL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/adlmidi" )
set( OPN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/opnmidi" )
set( TIMIDITYPP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/timidityplus" )
set( TIMIDITY_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/timidity" )
set( WILDMIDI_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/wildmidi" )
set( OPLSYNTH_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/oplsynth" )
if( NOT CMAKE_CROSSCOMPILING )
if( NOT CROSS_EXPORTS )
set( CROSS_EXPORTS "" )
endif()
endif()
option( DYN_FLUIDSYNTH "Dynamically load fluidsynth" ON )
option( DYN_SNDFILE "Dynamically load libsndfile" ON )
option( DYN_MPG123 "Dynamically load libmpg123" ON )
# Initialize our list of find_package dependencies for configure_package_config_file
set(ZMUSIC_PACKAGE_DEPENDENCIES "" CACHE INTERNAL "")
add_subdirectory( thirdparty/dumb )
add_subdirectory( thirdparty/adlmidi )
add_subdirectory( thirdparty/opnmidi )
add_subdirectory( thirdparty/timidity )
add_subdirectory( thirdparty/timidityplus )
add_subdirectory( thirdparty/wildmidi )
add_subdirectory( thirdparty/oplsynth )
add_subdirectory( source )
add_subdirectory(thirdparty)
add_subdirectory(source)
if( NOT CMAKE_CROSSCOMPILING )
export(TARGETS ${CROSS_EXPORTS} FILE "${CMAKE_BINARY_DIR}/ImportExecutables.cmake" )
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ZMusicConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
cmake/ZMusicConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ZMusicConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ZMusicConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/ZMusicConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ZMusic
COMPONENT devel
)
if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CPACK_PACKAGE_CONTACT "First Last <example@example.com>" CACHE STRING "Contact info for archive maintainer.")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "GZDoom's music system as a standalone library")
string(TOLOWER "${PROJECT_NAME}" CPACK_PACKAGE_NAME)
set(CPACK_PACKAGE_NAME "lib${CPACK_PACKAGE_NAME}")
# Use same prefix for packaging for consistency
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set(CPACK_STRIP_FILES ON)
set(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
set(CPACK_COMPONENT_DEVEL_DEPENDS Full Lite)
if(WIN32)
set(CPACK_GENERATOR "ZIP")
else()
set(CPACK_GENERATOR "DEB")
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://zdoom.org")
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION ON)
set(CPACK_DEBIAN_COMPRESSION_TYPE "xz")
set(CPACK_DEBIAN_FULL_PACKAGE_NAME "${CPACK_PACKAGE_NAME}${PROJECT_VERSION_MAJOR}")
set(CPACK_DEBIAN_LITE_PACKAGE_NAME "${CPACK_PACKAGE_NAME}lite${PROJECT_VERSION_MAJOR}")
set(CPACK_DEBIAN_DEVEL_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-dev")
set(CPACK_DEBIAN_DEVEL_PACKAGE_SECTION "libdevel")
endif()
include(CPack)
endif()

View file

@ -2,22 +2,37 @@
# Find the native fluidsynth includes and library
#
# FLUIDSYNTH_INCLUDE_DIR - where to find fluidsynth.h
# FLUIDSYNTH_LIBRARIES - List of libraries when using fluidsynth.
# FLUIDSYNTH_LIBRARY - Path to fluidsynth library.
# FLUIDSYNTH_FOUND - True if fluidsynth found.
IF (FLUIDSYNTH_INCLUDE_DIR AND FLUIDSYNTH_LIBRARIES)
if(FLUIDSYNTH_INCLUDE_DIR AND FLUIDSYNTH_LIBRARY)
# Already in cache, be silent
SET(FluidSynth_FIND_QUIETLY TRUE)
ENDIF (FLUIDSYNTH_INCLUDE_DIR AND FLUIDSYNTH_LIBRARIES)
set(FluidSynth_FIND_QUIETLY TRUE)
endif()
FIND_PATH(FLUIDSYNTH_INCLUDE_DIR fluidsynth.h)
if(NOT FLUIDSYNTH_INCLUDE_DIR)
find_path(FLUIDSYNTH_INCLUDE_DIR fluidsynth.h)
endif()
FIND_LIBRARY(FLUIDSYNTH_LIBRARIES NAMES fluidsynth )
MARK_AS_ADVANCED( FLUIDSYNTH_LIBRARIES FLUIDSYNTH_INCLUDE_DIR )
if(NOT FLUIDSYNTH_LIBRARY)
find_library(FLUIDSYNTH_LIBRARY NAMES fluidsynth)
endif()
# handle the QUIETLY and REQUIRED arguments and set FLUIDSYNTH_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FluidSynth DEFAULT_MSG FLUIDSYNTH_LIBRARIES FLUIDSYNTH_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FluidSynth DEFAULT_MSG FLUIDSYNTH_LIBRARY FLUIDSYNTH_INCLUDE_DIR)
if(FLUIDSYNTH_FOUND)
add_library(libfluidsynth UNKNOWN IMPORTED)
set_target_properties(libfluidsynth
PROPERTIES
IMPORTED_LOCATION "${FLUIDSYNTH_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FLUIDSYNTH_INCLUDE_DIR}"
)
# Legacy variables
set(FLUIDSYNTH_INCLUDE_DIRS ${FLUIDSYNTH_INCLUDE_DIR})
set(FLUIDSYNTH_LIBRARIES ${FLUIDSYNTH_LIBRARY})
endif()

37
cmake/FindGME.cmake Normal file
View file

@ -0,0 +1,37 @@
# - Find Game Music Emulation
#
# GME_INCLUDE_DIR - where to find gme.h
# GME_LIBRARY - Path to gme library.
# GME_FOUND - True if gme found.
if(GME_INCLUDE_DIR AND GME_LIBRARY)
# Already in cache, be silent
set(GME_FIND_QUIETLY TRUE)
endif()
if(NOT GME_INCLUDE_DIR)
find_path(GME_INCLUDE_DIR gme.h)
endif()
if(NOT GME_LIBRARY)
find_library(GME_LIBRARY NAMES gme)
endif()
# handle the QUIETLY and REQUIRED arguments and set GME_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GME DEFAULT_MSG GME_LIBRARY GME_INCLUDE_DIR)
if(GME_FOUND)
add_library(gme UNKNOWN IMPORTED)
set_target_properties(gme
PROPERTIES
IMPORTED_LOCATION "${GME_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${GME_INCLUDE_DIR}"
)
# Legacy variables
set(GME_INCLUDE_DIRS ${GME_INCLUDE_DIR})
set(GME_LIBRARIES ${GME_LIBRARY})
endif()

View file

@ -2,27 +2,42 @@
# Find the native mpg123 includes and library
#
# MPG123_INCLUDE_DIR - where to find mpg123.h
# MPG123_LIBRARIES - List of libraries when using mpg123.
# MPG123_LIBRARY - Path to mpg123 library.
# MPG123_FOUND - True if mpg123 found.
IF(MPG123_INCLUDE_DIR AND MPG123_LIBRARIES)
if(MPG123_INCLUDE_DIR AND MPG123_LIBRARY)
# Already in cache, be silent
SET(MPG123_FIND_QUIETLY TRUE)
ENDIF(MPG123_INCLUDE_DIR AND MPG123_LIBRARIES)
set(MPG123_FIND_QUIETLY TRUE)
endif(MPG123_INCLUDE_DIR AND MPG123_LIBRARY)
FIND_PATH(MPG123_INCLUDE_DIR mpg123.h
PATHS "${MPG123_DIR}"
PATH_SUFFIXES include
)
if(NOT MPG123_INCLUDE_DIR)
find_path(MPG123_INCLUDE_DIR mpg123.h
PATHS "${MPG123_DIR}"
PATH_SUFFIXES include
)
endif()
FIND_LIBRARY(MPG123_LIBRARIES NAMES mpg123 mpg123-0
PATHS "${MPG123_DIR}"
PATH_SUFFIXES lib
)
# MARK_AS_ADVANCED(MPG123_LIBRARIES MPG123_INCLUDE_DIR)
if(NOT MPG123_LIBRARY)
find_library(MPG123_LIBRARY NAMES mpg123 mpg123-0
PATHS "${MPG123_DIR}"
PATH_SUFFIXES lib
)
endif()
# handle the QUIETLY and REQUIRED arguments and set MPG123_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MPG123 DEFAULT_MSG MPG123_LIBRARIES MPG123_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MPG123 DEFAULT_MSG MPG123_LIBRARY MPG123_INCLUDE_DIR)
if(MPG123_FOUND)
add_library(mpg123 UNKNOWN IMPORTED)
set_target_properties(mpg123
PROPERTIES
IMPORTED_LOCATION "${MPG123_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MPG123_INCLUDE_DIR}"
)
# Legacy variables
set(MPG123_INCLUDE_DIRS ${MPG123_INCLUDE_DIR})
set(MPG123_LIBRARIES ${MPG123_LIBRARY})
endif()

View file

@ -13,17 +13,30 @@
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
find_path(SNDFILE_INCLUDE_DIR NAMES sndfile.h)
if(NOT SNDFILE_INCLUDE_DIR)
find_path(SNDFILE_INCLUDE_DIR NAMES sndfile.h)
endif()
find_library(SNDFILE_LIBRARY NAMES sndfile sndfile-1)
if(NOT SNDFILE_LIBRARY)
find_library(SNDFILE_LIBRARY NAMES sndfile sndfile-1)
endif()
set(SNDFILE_INCLUDE_DIRS ${SNDFILE_INCLUDE_DIR})
set(SNDFILE_LIBRARIES ${SNDFILE_LIBRARY})
INCLUDE(FindPackageHandleStandardArgs)
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set SNDFILE_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SndFile DEFAULT_MSG SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
find_package_handle_standard_args(SndFile DEFAULT_MSG SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
# show the SNDFILE_INCLUDE_DIRS and SNDFILE_LIBRARIES variables only in the advanced view
mark_as_advanced(SNDFILE_INCLUDE_DIRS SNDFILE_LIBRARIES)
if(SNDFILE_FOUND)
add_library(sndfile UNKNOWN IMPORTED)
set_target_properties(sndfile
PROPERTIES
IMPORTED_LOCATION "${SNDFILE_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SNDFILE_INCLUDE_DIR}"
)
add_library(SndFile::sndfile ALIAS sndfile)
# Legacy variables
set(SNDFILE_INCLUDE_DIRS "${SNDFILE_INCLUDE_DIR}")
set(SNDFILE_LIBRARIES "${SNDFILE_LIBRARY}")
endif()

View file

@ -1,21 +0,0 @@
# - Find ZMusic
# Find the native fluidsynth includes and library
#
# ZMUSIC_INCLUDE_DIR - where to find zmusic.h
# ZMUSIC_LIBRARIES - List of libraries when using ZMusic
# ZMUSIC_FOUND - True if ZMusic found.
if(ZMUSIC_INCLUDE_DIR AND ZMUSIC_LIBRARIES)
# Already in cache, be silent
set(ZMUSIC_FIND_QUIETLY TRUE)
endif()
find_path(ZMUSIC_INCLUDE_DIR zmusic.h)
find_library(ZMUSIC_LIBRARIES NAMES zmusic)
mark_as_advanced(ZMUSIC_LIBRARIES ZMUSIC_INCLUDE_DIR)
# handle the QUIETLY and REQUIRED arguments and set ZMUSIC_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZMusic DEFAULT_MSG ZMUSIC_LIBRARIES ZMUSIC_INCLUDE_DIR)

View file

@ -0,0 +1,19 @@
@PACKAGE_INIT@
set(_supported_components "Full;Lite")
if(NOT ZMusic_FIND_COMPONENTS)
set(ZMusic_FIND_COMPONENTS "${_supported_components}")
endif()
include(CMakeFindDependencyMacro)
foreach(_module @ZMUSIC_PACKAGE_DEPENDENCIES@)
find_dependency(${_module})
endforeach()
foreach(_comp ${ZMusic_FIND_COMPONENTS})
include("${CMAKE_CURRENT_LIST_DIR}/ZMusic${_comp}Targets.cmake")
set(ZMusic_${_comp}_FOUND TRUE)
endforeach()
check_required_components(ZMusic)

129
cmake/ZUtility.cmake Normal file
View file

@ -0,0 +1,129 @@
include_guard(DIRECTORY)
include(CheckFunctionExists)
# BEGIN: Variables
set(COMPILER_ID_GNU_COMPATIBLE "AppleClang;Clang;GNU")
# Replacement variables for a possible long list of C/C++ compilers compatible with GCC
if(CMAKE_C_COMPILER_ID IN_LIST COMPILER_ID_GNU_COMPATIBLE)
set(COMPILER_IS_GNUC_COMPATIBLE TRUE)
else()
set(COMPILER_IS_GNUC_COMPATIBLE FALSE)
endif()
if(CMAKE_CXX_COMPILER_ID IN_LIST COMPILER_ID_GNU_COMPATIBLE)
set(COMPILER_IS_GNUCXX_COMPATIBLE TRUE)
else()
set(COMPILER_IS_GNUCXX_COMPATIBLE FALSE)
endif()
# BEGIN: Functions
function(determine_package_config_dependency)
# Don't need to worry about this when building shared libraries
if(BUILD_SHARED_LIBS)
return()
endif()
set(Dest "${ARGV0}")
cmake_parse_arguments(PARSE_ARGV 1 ARG "" "TARGET;MODULE" "")
if(TARGET ${ARG_TARGET})
get_property(TgtImported TARGET ${ARG_TARGET} PROPERTY IMPORTED)
if(TgtImported)
list(APPEND "${Dest}" "${ARG_MODULE}")
endif()
endif()
set("${Dest}" "${${Dest}}" CACHE INTERNAL "")
endfunction()
# Adds private links to a given target, but any OBJECT or INTERFACE library will
# be hidden from install(EXPORT).
function(target_link_libraries_hidden Tgt)
set(Links ${ARGV})
list(REMOVE_AT Links 0)
get_property(TgtType TARGET "${Tgt}" PROPERTY TYPE)
foreach(Link IN LISTS Links)
if(TARGET "${Link}")
get_property(LinkImported TARGET "${Link}" PROPERTY IMPORTED)
get_property(LinkType TARGET "${Link}" PROPERTY TYPE)
if(NOT LinkImported AND (LinkType STREQUAL "OBJECT_LIBRARY" OR LinkType STREQUAL "INTERFACE_LIBRARY"))
target_link_libraries("${Tgt}" PRIVATE "$<BUILD_INTERFACE:${Link}>")
# Since we're potentially hiding usage requirements from the
# exported targets, we need to do this recursively.
if(TgtType STREQUAL "STATIC_LIBRARY")
get_property(TransitiveLinks TARGET "${Link}" PROPERTY INTERFACE_LINK_LIBRARIES)
target_link_libraries_hidden("${Tgt}" ${TransitiveLinks})
endif()
else()
target_link_libraries("${Tgt}" PRIVATE "${Link}")
endif()
else()
target_link_libraries("${Tgt}" PRIVATE "${Link}")
endif()
endforeach()
endfunction()
# For a given subdirectory, set all configs to release.
function(make_release_only)
if(CMAKE_CONFIGURATION_TYPES)
set(ConfigTypes ${CMAKE_CONFIGURATION_TYPES})
list(REMOVE_ITEM ConfigTypes "Release")
else()
set(ConfigTypes "Debug;MinSizeRel;RelWithDebInfo")
endif()
foreach(Config IN LISTS ConfigTypes)
string(TOUPPER "${Config}" ConfigUpper)
set("CMAKE_C_FLAGS_${ConfigUpper}" "${CMAKE_C_FLAGS_RELEASE}" PARENT_SCOPE)
endforeach()
endfunction()
# As documented, OBJECT libraries in INTERFACE_LINK_LIBRARIES are treated as if
# they were INTERFACE libraries. So if we want to have an INTERFACE library
# which links to OBJECT libraries we need to copy those objects into the
# INTERFACE_SOURCES.
#
# This function should only be used on INTERFACE_LIBRARY targets.
function(propagate_object_links Tgt)
get_property(Links TARGET "${Tgt}" PROPERTY INTERFACE_LINK_LIBRARIES)
foreach(Link IN LISTS Links)
if(TARGET "${Link}")
get_property(LinkType TARGET "${Link}" PROPERTY TYPE)
if(LinkType STREQUAL "OBJECT_LIBRARY")
target_sources("${Tgt}" INTERFACE $<TARGET_OBJECTS:${Link}>)
endif()
endif()
endforeach()
endfunction()
function(require_stricmp Tgt Visibility)
check_function_exists(stricmp STRICMP_EXISTS)
if(NOT STRICMP_EXISTS)
target_compile_definitions(${Tgt} ${Visibility} stricmp=strcasecmp)
endif()
endfunction()
function(require_strnicmp Tgt Visibility)
check_function_exists(strnicmp STRNICMP_EXISTS)
if(NOT STRNICMP_EXISTS)
target_compile_definitions(${Tgt} ${Visibility} strnicmp=strncasecmp)
endif()
endfunction()
function(use_fast_math Tgt)
if(MSVC)
set_property( TARGET "${Tgt}" APPEND PROPERTY COMPILE_OPTIONS "/fp:fast" )
elseif(ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE)
set_property( TARGET "${Tgt}" APPEND PROPERTY COMPILE_OPTIONS "-ffast-math" "-ffp-contract=fast" )
endif()
endfunction()

View file

@ -1,10 +1,7 @@
cmake_minimum_required(VERSION 2.8.7)
cmake_minimum_required(VERSION 2.8.7...3.19)
project(list_midi_devices)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../cmake")
find_package(ZMusic REQUIRED)
add_executable(list_midi_devices list_midi_devices.cpp)
target_include_directories(list_midi_devices PRIVATE ${ZMUSIC_INCLUDE_DIR})
target_link_libraries(list_midi_devices PRIVATE ${ZMUSIC_LIBRARIES} ${SDL2_LIBRARIES})
target_link_libraries(list_midi_devices PRIVATE ZMusic::zmusic)

View file

@ -1,94 +1,10 @@
cmake_minimum_required( VERSION 2.8.7 )
use_fast_math()
require_stricmp()
require_strnicmp()
if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
endif()
include( CheckFunctionExists )
if( NOT WIN32 AND NOT APPLE )
find_package( Threads )
endif()
find_package( ALSA )
if (WIN32 OR ALSA_FOUND)
add_definitions( -DHAVE_SYSTEM_MIDI )
endif()
if( DYN_SNDFILE)
add_definitions( -DHAVE_SNDFILE -DDYN_SNDFILE )
else()
find_package( SndFile )
if( SNDFILE_FOUND )
add_definitions( -DHAVE_SNDFILE )
endif()
endif()
if( DYN_MPG123)
add_definitions( -DHAVE_MPG123 -DDYN_MPG123 )
else()
find_package( MPG123 )
if( MPG123_FOUND )
add_definitions( -DHAVE_MPG123 )
endif()
endif()
if( DYN_FLUIDSYNTH )
add_definitions( -DHAVE_FLUIDSYNTH -DDYN_FLUIDSYNTH )
else()
find_package( FluidSynth )
if( FLUIDSYNTH_FOUND )
add_definitions( -DHAVE_FLUIDSYNTH )
endif()
endif()
if( WIN32 )
add_definitions( -D_WIN32 )
set( SYS_LIBS winmm )
else()
set( SYS_LIBS ${CMAKE_DL_LIBS} )
endif()
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/zmusic" "${CMAKE_CURRENT_SOURCE_DIR}/../include" "${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/dumb/include" "${ZLIB_INCLUDE_DIR}" "${ADL_INCLUDE_DIR}" "${OPN_INCLUDE_DIR}" "${TIMIDITYPP_INCLUDE_DIR}" "${TIMIDITY_INCLUDE_DIR}" "${WILDMIDI_INCLUDE_DIR}" "${OPLSYNTH_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" )
if (WIN32)
set( PLAT_SOURCES
mididevices/music_win_mididevice.cpp
musicformats/win32/i_cd.cpp
musicformats/win32/helperthread.cpp
)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if (ALSA_FOUND)
set( PLAT_SOURCES
mididevices/music_alsa_mididevice.cpp
mididevices/music_alsa_state.cpp
)
endif()
endif()
file( GLOB HEADER_FILES
zmusic/*.h
loader/*.h
mididevices/*.h
midisources/*.h
musicformats/*.h
musicformats/win32/*.h
decoder/*.h
streamsources/*.h
../thirdparty/*.h
../include/*.h
)
set( all_files
${HEADER_FILES}
# zmusic-obj doesn't actually build anything itself, but rather all sources are
# added as interface sources. Thus whatever links to zmusic-obj will be in
# charge of compiling. As a result any properties set on zmusic-obj should be
# interface.
add_library(zmusic-obj INTERFACE)
target_sources(zmusic-obj
INTERFACE
loader/i_module.cpp
mididevices/music_base_mididevice.cpp
mididevices/music_adlmidi_mididevice.cpp
@ -121,72 +37,178 @@ set( all_files
zmusic/zmusic.cpp
zmusic/critsec.cpp
loader/test.c
${PLAT_SOURCES}
)
file(GLOB HEADER_FILES
zmusic/*.h
loader/*.h
mididevices/*.h
midisources/*.h
musicformats/*.h
musicformats/win32/*.h
decoder/*.h
streamsources/*.h
../thirdparty/*.h
../include/*.h
)
target_sources(zmusic-obj INTERFACE ${HEADER_FILES})
target_compile_features(zmusic-obj INTERFACE cxx_std_11)
#set_target_properties(zmusic-obj PROPERTIES LINKER_LANGUAGE CXX)
require_stricmp(zmusic-obj INTERFACE)
require_strnicmp(zmusic-obj INTERFACE)
if(NOT WIN32 AND NOT APPLE)
find_package(Threads)
target_link_libraries(zmusic-obj INTERFACE Threads::Threads)
determine_package_config_dependency(ZMUSIC_PACKAGE_DEPENDENCIES TARGET Threads::Threads MODULE Threads)
endif()
option(DYN_SNDFILE "Dynamically load libsndfile" ON)
if(DYN_SNDFILE)
target_compile_definitions(zmusic-obj INTERFACE HAVE_SNDFILE DYN_SNDFILE)
else()
find_package(SndFile)
if(SNDFILE_FOUND)
target_compile_definitions(zmusic-obj INTERFACE HAVE_SNDFILE)
target_link_libraries(zmusic-obj INTERFACE SndFile::sndfile)
determine_package_config_dependency(ZMUSIC_PACKAGE_DEPENDENCIES TARGET SndFile::sndfile MODULE SndFile)
endif()
endif()
option(DYN_MPG123 "Dynamically load libmpg123" ON)
if(DYN_MPG123)
target_compile_definitions(zmusic-obj INTERFACE HAVE_MPG123 DYN_MPG123)
else()
find_package(MPG123)
if(MPG123_FOUND)
target_compile_definitions(zmusic-obj INTERFACE HAVE_MPG123)
target_link_libraries(zmusic-obj INTERFACE mpg123)
determine_package_config_dependency(ZMUSIC_PACKAGE_DEPENDENCIES TARGET mpg123 MODULE MPG123)
endif()
endif()
option(DYN_FLUIDSYNTH "Dynamically load fluidsynth" ON)
if(DYN_FLUIDSYNTH)
target_compile_definitions(zmusic-obj INTERFACE HAVE_FLUIDSYNTH DYN_FLUIDSYNTH)
else()
find_package(FluidSynth)
if(FLUIDSYNTH_FOUND)
target_compile_definitions(zmusic-obj INTERFACE HAVE_FLUIDSYNTH)
target_link_libraries(zmusic-obj INTERFACE libfluidsynth)
determine_package_config_dependency(ZMUSIC_PACKAGE_DEPENDENCIES TARGET libfluidsynth MODULE FluidSynth)
endif()
endif()
# System MIDI support
if(WIN32)
target_compile_definitions(zmusic-obj INTERFACE HAVE_SYSTEM_MIDI)
target_link_libraries(zmusic-obj INTERFACE winmm)
target_sources(zmusic-obj INTERFACE mididevices/music_win_mididevice.cpp)
elseif(NOT APPLE)
find_package(ALSA)
if(ALSA_FOUND)
target_compile_definitions(zmusic-obj INTERFACE HAVE_SYSTEM_MIDI)
target_sources(zmusic-obj
INTERFACE
mididevices/music_alsa_mididevice.cpp
mididevices/music_alsa_state.cpp
)
target_link_libraries(zmusic-obj INTERFACE ALSA::ALSA)
determine_package_config_dependency(ZMUSIC_PACKAGE_DEPENDENCIES TARGET ALSA::ALSA MODULE ALSA)
endif()
endif()
if(WIN32)
target_sources(zmusic-obj
INTERFACE
musicformats/win32/i_cd.cpp
musicformats/win32/helperthread.cpp
)
endif()
option( BUILD_SHARED_LIBS "Build shared libraries" ON )
target_link_libraries(zmusic-obj INTERFACE dumb gme ZLIB::ZLIB ${CMAKE_DL_LIBS})
target_include_directories(zmusic-obj
INTERFACE
../include
${CMAKE_CURRENT_SOURCE_DIR}
zmusic
)
propagate_object_links(zmusic-obj)
add_library(zmusic)
add_library(ZMusic::zmusic ALIAS zmusic)
add_library(zmusiclite)
add_library(ZMusic::zmusiclite ALIAS zmusiclite)
use_fast_math(zmusic)
use_fast_math(zmusiclite)
# Although zmusic-obj puts the public include directory in our private include
# list, we need to add it to the interface include directories for consumers.
target_include_directories(zmusic INTERFACE $<INSTALL_INTERFACE:include>)
target_include_directories(zmusiclite INTERFACE $<INSTALL_INTERFACE:include>)
target_link_libraries_hidden(zmusic zmusic-obj adl oplsynth opn timidity timidityplus wildmidi)
target_link_libraries_hidden(zmusiclite zmusic-obj)
add_library( zmusic ${all_files} )
add_library( zmusiclite ${all_files} )
target_compile_definitions(zmusiclite PRIVATE ZMUSIC_LITE=1)
if( MSVC )
option( GENERATE_MAPFILE "Generate .map file for debugging." OFF )
if( GENERATE_MAPFILE )
set( LINKERSTUFF "${LINKERSTUFF} /MAP" )
set_target_properties(zmusic PROPERTIES LINK_FLAGS ${LINKERSTUFF})
set_target_properties(zmusiclite PROPERTIES LINK_FLAGS ${LINKERSTUFF})
endif()
endif()
target_link_libraries( zmusic "${SYS_LIBS}" adl dumb gme oplsynth opn timidity timidityplus wildmidi "${ZLIB_LIBRARIES}" )
target_link_libraries( zmusiclite "${SYS_LIBS}" dumb gme "${ZLIB_LIBRARIES}" )
if( NOT DYN_SNDFILE AND SNDFILE_FOUND )
include_directories( "${SNDFILE_INCLUDE_DIRS}" )
target_link_libraries( zmusic ${SNDFILE_LIBRARIES} )
target_link_libraries( zmusiclite ${SNDFILE_LIBRARIES} )
endif()
if( NOT DYN_MPG123 AND MPG123_FOUND )
include_directories( "${MPG123_INCLUDE_DIR}" )
target_link_libraries( zmusic ${MPG123_LIBRARIES} )
target_link_libraries( zmusiclite ${MPG123_LIBRARIES} )
endif()
if( NOT DYN_FLUIDSYNTH AND FLUIDSYNTH_FOUND )
include_directories( "${FLUIDSYNTH_INCLUDE_DIR}" )
target_link_libraries( zmusic ${FLUIDSYNTH_LIBRARIES} )
target_link_libraries( zmusiclite ${FLUIDSYNTH_LIBRARIES} )
endif()
if(ALSA_FOUND)
include_directories( "${ALSA_INCLUDE_DIR}" )
target_link_libraries( zmusic ${ALSA_LIBRARIES} )
target_link_libraries( zmusiclite ${ALSA_LIBRARIES} )
endif()
if(APPLE)
set_target_properties(zmusic PROPERTIES MACOSX_RPATH TRUE)
set_target_properties(zmusiclite PROPERTIES MACOSX_RPATH TRUE)
endif()
set_target_properties(zmusic zmusiclite PROPERTIES
set_target_properties(zmusic zmusiclite
PROPERTIES
MACOSX_RPATH ON
PUBLIC_HEADER ../include/zmusic.h
VERSION ${ZMUSIC_VERSION}
SOVERSION ${ZMUSIC_VERSION_MAJOR}
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
include(GNUInstallDirs)
install(TARGETS zmusic zmusiclite
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
install(TARGETS zmusic EXPORT ZMusicFullTargets
PUBLIC_HEADER
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT devel
LIBRARY
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT full
NAMELINK_COMPONENT devel
)
install(TARGETS zmusiclite EXPORT ZMusicLiteTargets
PUBLIC_HEADER
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT devel
LIBRARY
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT lite
NAMELINK_COMPONENT devel
)
install(EXPORT ZMusicFullTargets
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ZMusic"
NAMESPACE ZMusic::
COMPONENT devel
)
install(EXPORT ZMusicLiteTargets
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ZMusic"
NAMESPACE ZMusic::
COMPONENT devel
)
if( MSVC )
option( ZMUSIC_GENERATE_MAPFILE "Generate .map file for debugging." OFF )
if( ZMUSIC_GENERATE_MAPFILE )
target_link_options(zmusic PRIVATE "/MAP")
target_link_options(zmusiclite PRIVATE "/MAP")
endif()
endif()
source_group("MIDI Devices" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/mididevices/.+")
source_group("MIDI Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/midisources/.+")
source_group("Music Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/musicformats/.+")

View file

@ -31,13 +31,16 @@
**---------------------------------------------------------------------------
*/
#include "zmusic_internal.h"
#ifdef HAVE_OPL
#include "streamsource.h"
#include "oplsynth/opl.h"
#include "oplsynth/opl_mus_player.h"
#include "fileio.h"
#include "zmusic/midiconfig.h"
#ifdef HAVE_OPL
//==========================================================================
//
// OPL file played by a software OPL2 synth and streamed through the sound system

View file

@ -37,17 +37,22 @@
#include <mmsystem.h>
#endif
#include <algorithm>
#include "timidity/timidity.h"
#include "timiditypp/timidity.h"
#include "oplsynth/oplio.h"
#include "critsec.h"
#include "../../thirdparty/dumb/include/dumb.h"
#include "dumb.h"
#include "zmusic_internal.h"
#include "musinfo.h"
#include "midiconfig.h"
#include "mididevices/music_alsa_state.h"
#ifdef HAVE_TIMIDITY
#include "timidity/timidity.h"
#include "timiditypp/timidity.h"
#endif
#ifdef HAVE_OPL
#include "oplsynth/oplio.h"
#endif
struct Dummy
{
void ChangeSettingInt(const char*, int) {}

45
thirdparty/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,45 @@
option(FORCE_INTERNAL_ZLIB "Use internal zlib" OFF)
find_package(ZLIB QUIET)
if(ZLIB_FOUND AND NOT FORCE_INTERNAL_ZLIB)
message(STATUS "Using system zlib, includes found at ${ZLIB_INCLUDE_DIRS}")
set_property(TARGET ZLIB::ZLIB PROPERTY IMPORTED_GLOBAL TRUE)
determine_package_config_dependency(ZMUSIC_PACKAGE_DEPENDENCIES TARGET ZLIB::ZLIB MODULE ZLIB)
else()
message(STATUS "Using internal zlib")
set(SKIP_INSTALL_ALL TRUE) # Avoid installing zlib alongside ZMusic
add_subdirectory(zlib)
add_library(ZLIB::ZLIB ALIAS z)
# Setup variables for GME's CMakeLists
set(ZLIB_LIBRARY ZLIB::ZLIB)
get_property(ZLIB_INCLUDE_DIR TARGET ZLIB::ZLIB PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
endif()
# GME is not currently released in a way that's conducive to using as a system
# library. Nevertheless at least one person tried, and so the ability to use a
# system copy exists soley to placate people following distro guidelines to the
# letter without regard as to why the vendored copy is forced.
# [Blzut3] Commented out per request from Graf Zahl.
#option(FORCE_INTERNAL_GME "Use internal gme (it is highly unlikely this should be turned off)" ON)
#mark_as_advanced(FORCE_INTERNAL_GME GME_INCLUDE_DIR GME_LIBRARY)
#find_package(GME QUIET)
#if(GME_FOUND AND NOT FORCE_INTERNAL_GME)
# message(STATUS "Using system gme library, includes found at ${GME_INCLUDE_DIRS}")
# set_property(TARGET gme PROPERTY IMPORTED_GLOBAL TRUE)
# determine_package_config_dependency(ZMUSIC_PACKAGE_DEPENDENCIES TARGET gme MODULE GME)
#else()
# message(STATUS "Using internal gme library")
# Use MAME as it's a balanced emulator: well-accurate, but doesn't eats lot of CPU
# Nuked OPN2 is very accurate emulator, but it eats too much CPU for the workflow
set(GME_YM2612_EMU "MAME" CACHE STRING "Which YM2612 emulator to use: \"Nuked\" (LGPLv2.1+), \"MAME\" (GPLv2+), or \"GENS\" (LGPLv2.1+)")
mark_as_advanced(GME_YM2612_EMU)
add_subdirectory(game-music-emu)
#endif()
add_subdirectory(dumb)
add_subdirectory(adlmidi)
add_subdirectory(opnmidi)
add_subdirectory(timidity)
add_subdirectory(timidityplus)
add_subdirectory(wildmidi)
add_subdirectory(oplsynth)

View file

@ -1,11 +1,9 @@
cmake_minimum_required( VERSION 2.8.7 )
make_release_only()
use_fast_math()
add_definitions(-DADLMIDI_DISABLE_MIDI_SEQUENCER)
add_library(adl OBJECT)
add_library( adl STATIC
target_sources(adl
PRIVATE
adlmidi_midiplay.cpp
adlmidi_opl3.cpp
adlmidi_private.cpp
@ -21,5 +19,10 @@ add_library( adl STATIC
chips/nuked/nukedopl3_174.c
chips/nuked/nukedopl3.c
wopl/wopl_file.c
)
target_link_libraries( adl )
)
target_compile_definitions(adl PRIVATE ADLMIDI_DISABLE_MIDI_SEQUENCER)
target_include_directories(adl PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
use_fast_math(adl)

View file

@ -1,119 +1,118 @@
cmake_minimum_required( VERSION 2.8.7 )
make_release_only()
use_fast_math()
include( CheckFunctionExists )
include( CheckCXXCompilerFlag )
include(CheckFunctionExists)
include(CheckCXXCompilerFlag)
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -DDEBUGMODE=1" )
if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-pointer-sign -Wno-uninitialized" )
if( CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.5" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable" )
endif()
endif()
CHECK_FUNCTION_EXISTS( itoa ITOA_EXISTS )
if( NOT ITOA_EXISTS )
add_definitions( -DNEED_ITOA=1 )
endif()
include_directories( include )
add_library( dumb STATIC
src/core/unload.c
src/core/rendsig.c
src/core/rendduh.c
src/core/register.c
src/core/readduh.c
src/core/rawsig.c
src/core/makeduh.c
src/core/loadduh.c
src/core/dumbfile.c
src/core/duhtag.c
src/core/duhlen.c
src/core/atexit.c
src/helpers/stdfile.c
src/helpers/silence.c
src/helpers/sampbuf.c
src/helpers/riff.c
src/helpers/resample.c
src/helpers/memfile.c
src/helpers/clickrem.c
src/helpers/barray.c
src/it/xmeffect.c
src/it/readxm2.c
src/it/readxm.c
src/it/readstm2.c
src/it/readstm.c
src/it/reads3m2.c
src/it/reads3m.c
src/it/readriff.c
src/it/readptm.c
src/it/readpsm.c
src/it/readoldpsm.c
src/it/readokt2.c
src/it/readokt.c
src/it/readmtm.c
src/it/readmod2.c
src/it/readmod.c
src/it/readdsmf.c
src/it/readasy.c
src/it/readamf2.c
src/it/readamf.c
src/it/readam.c
src/it/read6692.c
src/it/read669.c
src/it/ptmeffect.c
src/it/loadxm2.c
src/it/loadxm.c
src/it/loadstm2.c
src/it/loadstm.c
src/it/loads3m2.c
src/it/loads3m.c
src/it/loadriff2.c
src/it/loadriff.c
src/it/loadptm2.c
src/it/loadptm.c
src/it/loadpsm2.c
src/it/loadpsm.c
src/it/loadoldpsm2.c
src/it/loadoldpsm.c
src/it/loadokt2.c
src/it/loadokt.c
src/it/loadmtm2.c
src/it/loadmtm.c
src/it/loadmod2.c
src/it/loadmod.c
src/it/loadasy2.c
src/it/loadasy.c
src/it/loadamf2.c
src/it/loadamf.c
src/it/load6692.c
src/it/load669.c
src/it/itunload.c
src/it/itrender.c
src/it/itread2.c
src/it/itread.c
src/it/itorder.c
src/it/itmisc.c
src/it/itload2.c
src/it/itload.c
src/it/readany.c
src/it/loadany2.c
src/it/loadany.c
src/it/readany2.c
src/helpers/resampler.c
src/helpers/lpc.c
add_library(dumb OBJECT
src/core/unload.c
src/core/rendsig.c
src/core/rendduh.c
src/core/register.c
src/core/readduh.c
src/core/rawsig.c
src/core/makeduh.c
src/core/loadduh.c
src/core/dumbfile.c
src/core/duhtag.c
src/core/duhlen.c
src/core/atexit.c
src/helpers/stdfile.c
src/helpers/silence.c
src/helpers/sampbuf.c
src/helpers/riff.c
src/helpers/resample.c
src/helpers/memfile.c
src/helpers/clickrem.c
src/helpers/barray.c
src/it/xmeffect.c
src/it/readxm2.c
src/it/readxm.c
src/it/readstm2.c
src/it/readstm.c
src/it/reads3m2.c
src/it/reads3m.c
src/it/readriff.c
src/it/readptm.c
src/it/readpsm.c
src/it/readoldpsm.c
src/it/readokt2.c
src/it/readokt.c
src/it/readmtm.c
src/it/readmod2.c
src/it/readmod.c
src/it/readdsmf.c
src/it/readasy.c
src/it/readamf2.c
src/it/readamf.c
src/it/readam.c
src/it/read6692.c
src/it/read669.c
src/it/ptmeffect.c
src/it/loadxm2.c
src/it/loadxm.c
src/it/loadstm2.c
src/it/loadstm.c
src/it/loads3m2.c
src/it/loads3m.c
src/it/loadriff2.c
src/it/loadriff.c
src/it/loadptm2.c
src/it/loadptm.c
src/it/loadpsm2.c
src/it/loadpsm.c
src/it/loadoldpsm2.c
src/it/loadoldpsm.c
src/it/loadokt2.c
src/it/loadokt.c
src/it/loadmtm2.c
src/it/loadmtm.c
src/it/loadmod2.c
src/it/loadmod.c
src/it/loadasy2.c
src/it/loadasy.c
src/it/loadamf2.c
src/it/loadamf.c
src/it/load6692.c
src/it/load669.c
src/it/itunload.c
src/it/itrender.c
src/it/itread2.c
src/it/itread.c
src/it/itorder.c
src/it/itmisc.c
src/it/itload2.c
src/it/itload.c
src/it/readany.c
src/it/loadany2.c
src/it/loadany.c
src/it/readany2.c
src/helpers/resampler.c
src/helpers/lpc.c
)
target_link_libraries( dumb )
if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
CHECK_CXX_COMPILER_FLAG( -msse DUMB_CAN_USE_SSE )
use_fast_math(dumb)
if( DUMB_CAN_USE_SSE )
set_source_files_properties( src/helpers/resampler.c PROPERTIES COMPILE_FLAGS -msse )
target_include_directories(dumb PUBLIC include)
if(COMPILER_IS_GNUC_COMPATIBLE)
target_compile_options(dumb
PRIVATE
-Wall -Wno-pointer-sign -Wno-uninitialized
)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.5")
target_compile_options(dumb PRIVATE -Wno-unused-but-set-variable)
endif()
endif()
check_function_exists(itoa ITOA_EXISTS)
if(NOT ITOA_EXISTS)
target_compile_definitions(dumb PRIVATE NEED_ITOA=1)
endif()
if(COMPILER_IS_GNUCXX_COMPATIBLE)
check_cxx_compiler_flag(-msse DUMB_CAN_USE_SSE)
if(DUMB_CAN_USE_SSE)
set_source_files_properties(src/helpers/resampler.c PROPERTIES COMPILE_FLAGS -msse)
endif()
endif()

View file

@ -1,3 +1,5 @@
cmake_minimum_required(VERSION 2.8...3.19)
# CMake project definition file.
project(libgme)
@ -6,36 +8,29 @@ include (CheckCXXCompilerFlag)
# When version is changed, also change the one in gme/gme.h to match
set(GME_VERSION 0.6.2 CACHE INTERNAL "libgme Version")
# 2.6+ always assumes FATAL_ERROR, but 2.4 and below don't.
# Of course, 2.4 might work, in which case you're welcome to drop
# down the requirement, but I can't test that.
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
# I don't plan on debugging this, so make it a release build.
if( NOT CMAKE_BUILD_TYPE MATCHES "Release" )
set( CMAKE_BUILD_TYPE "RelWithDebInfo" )
endif()
if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra" )
if( NOT PROFILE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer" )
if(COMPILER_IS_GNUCXX_COMPATIBLE)
add_compile_options(-Wall -Wextra)
if(NOT PROFILE)
add_compile_options(-fomit-frame-pointer)
endif()
check_cxx_compiler_flag( -Wno-array-bounds HAVE_NO_ARRAY_BOUNDS )
if( HAVE_NO_ARRAY_BOUNDS )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-array-bounds" )
check_cxx_compiler_flag(-Wno-array-bounds HAVE_NO_ARRAY_BOUNDS)
if(HAVE_NO_ARRAY_BOUNDS)
add_compile_options(-Wno-array-bounds)
endif()
endif()
#[ZDoom] Disable most of bogus and annoying MSVC warnings
if( MSVC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4101 /wd4800 /wd4702 /wd4706 /wd4805 /wd4310 /wd4244 /wd4456 /wd4459 /wd4146 /wd4127 /wd4458 /wd4267 /wd4804")
#[ZMusic] Disable most of bogus and annoying MSVC warnings
if(MSVC)
add_compile_options(/wd4101 /wd4800 /wd4702 /wd4706 /wd4805 /wd4310 /wd4244 /wd4456 /wd4459 /wd4146 /wd4127 /wd4458 /wd4267 /wd4804)
endif()
use_fast_math()
# Default emulators to build (all of them! ;)
# [ZDoom] No options, enable all of them by default.
# [ZMusic] No options, enable all of them by default.
#if (NOT DEFINED USE_GME_AY)
SET(USE_GME_AY 1 CACHE BOOL "Enable support for Spectrum ZX music emulation")
@ -89,9 +84,7 @@ use_fast_math()
set(ENABLE_UBSAN OFF)
# Check for GCC/Clang "visibility" support.
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (COMPILER_IS_GNUCXX_COMPATIBLE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -W -Wextra")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
@ -136,8 +129,10 @@ endif()
add_subdirectory(gme)
# EXCLUDE_FROM_ALL adds build rules but keeps it out of default build
# [ZDoom] Not needed.
# [ZMusic] Not needed.
if( FALSE )
add_subdirectory(player EXCLUDE_FROM_ALL)
add_subdirectory(demo EXCLUDE_FROM_ALL)
endif()
use_fast_math( gme )

View file

@ -156,20 +156,20 @@ set (EXPORTED_HEADERS gme.h)
# we're building the library or merely using the library. The following is
# only defined when building the library to allow us to tell which is which.
#[ZDoom] Not needed
#[ZMusic] Not needed
#add_definitions(-DBLARGG_BUILD_DLL)
# For the gme_types.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# Add library to be compiled.
add_library(gme STATIC ${libgme_SRCS})
add_library(gme OBJECT ${libgme_SRCS})
if(ZLIB_FOUND)
message(" ** ZLib library located, compressed file formats will be supported")
target_compile_definitions(gme PRIVATE -DHAVE_ZLIB_H)
target_include_directories(gme PRIVATE ${ZLIB_INCLUDE_DIRS})
target_link_libraries(gme ${ZLIB_LIBRARIES})
# [ZMusic] Switch to modern target for better transitive handling.
target_link_libraries(gme PRIVATE ZLIB::ZLIB)
# Is not to be installed though
set(PKG_CONFIG_ZLIB -lz) # evaluated in libgme.pc.in
@ -177,7 +177,10 @@ else()
message("ZLib library not found, disabling support for compressed formats such as VGZ")
endif()
# [ZDoom] Not needed.
# [ZMusic] Interface include directories
target_include_directories(gme INTERFACE ..)
# [ZMusic] Not needed.
if( FALSE )
# The version is the release. The "soversion" is the API version. As long
# as only build fixes are performed (i.e. no backwards-incompatible changes

View file

@ -1,21 +1,4 @@
cmake_minimum_required( VERSION 2.8.7 )
use_fast_math()
require_stricmp()
require_strnicmp()
if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -fomit-frame-pointer" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
endif()
include_directories( oplsynth )
file( GLOB HEADER_FILES
oplsynth/*.h
)
add_library( oplsynth STATIC
${HEADER_FILES}
add_library(oplsynth OBJECT
fmopl.cpp
musicblock.cpp
nukedopl3.cpp
@ -23,5 +6,26 @@ add_library( oplsynth STATIC
OPL3.cpp
oplio.cpp
dosbox/opl.cpp
)
file(GLOB HEADER_FILES oplsynth/*.h)
target_sources(oplsynth PRIVATE ${HEADER_FILES})
target_include_directories(oplsynth INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE oplsynth)
set_target_properties(oplsynth
PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
use_fast_math(oplsynth)
require_stricmp(oplsynth PRIVATE)
require_strnicmp(oplsynth PRIVATE)
if(COMPILER_IS_GNUC_COMPATIBLE)
target_compile_options(oplsynth
PRIVATE
"-Wall" "-Wextra" "-Wno-unused-parameter" "-fomit-frame-pointer"
)
target_link_libraries( oplsynth )
endif()

View file

@ -1,15 +1,9 @@
cmake_minimum_required( VERSION 2.8.7 )
make_release_only()
use_fast_math()
# we play with out own sequencer
add_definitions(-DOPNMIDI_DISABLE_MIDI_SEQUENCER)
add_library(opn OBJECT)
# Disable OPNMIDI's experimental yet emulator (using of it has some issues and missing notes in playback)
add_definitions(-DOPNMIDI_DISABLE_GX_EMULATOR)
add_library( opn STATIC
target_sources(opn
PRIVATE
opnmidi_load.cpp
opnmidi_private.cpp
opnmidi.cpp
@ -39,5 +33,16 @@ add_library( opn STATIC
chips/mamefm/emu2149.c
chips/mame/mame_ym2612fm.c
wopn/wopn_file.c
)
target_link_libraries( opn )
)
target_compile_definitions(opn
PRIVATE
# we play with out own sequencer
OPNMIDI_DISABLE_MIDI_SEQUENCER
# Disable OPNMIDI's experimental yet emulator (using of it has some issues and missing notes in playback)
OPNMIDI_DISABLE_GX_EMULATOR
)
target_include_directories(opn PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
use_fast_math(opn)

View file

@ -1,19 +1,4 @@
cmake_minimum_required( VERSION 2.8.7 )
use_fast_math()
require_stricmp()
if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-unused-function -Wno-unused-variable" )
endif()
include_directories( timidity )
file( GLOB HEADER_FILES
timidity/*.h
)
add_library( timidity STATIC
${HEADER_FILES}
add_library(timidity OBJECT
common.cpp
instrum.cpp
instrum_dls.cpp
@ -23,5 +8,25 @@ add_library( timidity STATIC
playmidi.cpp
resample.cpp
timidity.cpp
)
file(GLOB HEADER_FILES timidity/*.h)
target_sources(timidity PRIVATE ${HEADER_FILES})
target_include_directories(timidity INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE timidity)
set_target_properties(timidity
PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
use_fast_math(timidity)
require_stricmp(timidity PRIVATE)
if(COMPILER_IS_GNUC_COMPATIBLE)
target_compile_options(timidity
PRIVATE
"-Wno-unused-function" "-Wno-unused-variable"
)
target_link_libraries( timidity )
endif()

View file

@ -1,18 +1,4 @@
cmake_minimum_required( VERSION 2.8.7 )
use_fast_math()
if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
endif()
include_directories( timiditypp )
file( GLOB HEADER_FILES
timiditypp/*.h
)
add_library( timidityplus STATIC
${HEADER_FILES}
add_library(timidityplus OBJECT
fft4g.cpp
reverb.cpp
common.cpp
@ -34,5 +20,17 @@ add_library( timidityplus STATIC
smplfile.cpp
sndfont.cpp
tables.cpp
)
target_link_libraries( timidityplus )
)
target_include_directories(timidityplus INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE timiditypp)
set_target_properties(timidityplus
PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
file(GLOB HEADER_FILES timiditypp/*.h)
target_sources(timidityplus PRIVATE ${HEADER_FILES})
use_fast_math(timidityplus)

View file

@ -1,25 +1,29 @@
cmake_minimum_required( VERSION 2.8.7 )
use_fast_math()
require_stricmp()
require_strnicmp()
if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -fomit-frame-pointer" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
endif()
include_directories( wildmidi )
file( GLOB HEADER_FILES
wildmidi/*.h
)
add_library( wildmidi STATIC
${HEADER_FILES}
add_library(wildmidi OBJECT
file_io.cpp
gus_pat.cpp
reverb.cpp
wildmidi_lib.cpp
wm_error.cpp
)
file(GLOB HEADER_FILES wildmidi/*.h)
target_sources(wildmidi PRIVATE ${HEADER_FILES})
set_target_properties(wildmidi
PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
target_include_directories(wildmidi INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE wildmidi)
use_fast_math(wildmidi)
require_stricmp(wildmidi PRIVATE)
require_strnicmp(wildmidi PRIVATE)
if(COMPILER_IS_GNUC_COMPATIBLE)
target_compile_options(wildmidi
PRIVATE
"-Wall" "-Wextra" "-Wno-unused-parameter" "-fomit-frame-pointer"
)
target_link_libraries( wildmidi )
endif()

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.7)
cmake_minimum_required(VERSION 2.8.7...3.19)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
make_release_only()
@ -133,11 +133,14 @@ if(MINGW)
set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif()
add_library(${ZLIBNAME} STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
add_library(${ZLIBNAME} OBJECT ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
set_target_properties(${ZLIBNAME} PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
set_target_properties(${ZLIBNAME} PROPERTIES SOVERSION 1)
# [ZMusic] Set target include directories
target_include_directories(${ZLIBNAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT CYGWIN)
# This property causes shared libraries on Linux to have the full version
# encoded into their final filename. We disable this on Cygwin because