2020-01-02 16:52:30 +00:00
|
|
|
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 )
|
|
|
|
|
2020-01-04 13:07:43 +00:00
|
|
|
if( NOT WIN32 AND NOT APPLE )
|
|
|
|
find_package( Threads )
|
|
|
|
endif()
|
|
|
|
|
2020-01-02 16:52:30 +00:00
|
|
|
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()
|
2020-05-30 08:26:23 +00:00
|
|
|
set( SYS_LIBS ${CMAKE_DL_LIBS} )
|
2020-01-02 16:52:30 +00:00
|
|
|
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
|
2020-01-11 11:47:07 +00:00
|
|
|
../include/*.h
|
2020-01-02 16:52:30 +00:00
|
|
|
)
|
|
|
|
set( all_files
|
|
|
|
${HEADER_FILES}
|
|
|
|
loader/i_module.cpp
|
|
|
|
mididevices/music_base_mididevice.cpp
|
|
|
|
mididevices/music_adlmidi_mididevice.cpp
|
|
|
|
mididevices/music_opl_mididevice.cpp
|
|
|
|
mididevices/music_opnmidi_mididevice.cpp
|
|
|
|
mididevices/music_timiditypp_mididevice.cpp
|
|
|
|
mididevices/music_fluidsynth_mididevice.cpp
|
|
|
|
mididevices/music_softsynth_mididevice.cpp
|
|
|
|
mididevices/music_timidity_mididevice.cpp
|
|
|
|
mididevices/music_wildmidi_mididevice.cpp
|
|
|
|
mididevices/music_wavewriter_mididevice.cpp
|
|
|
|
midisources/midisource.cpp
|
|
|
|
midisources/midisource_mus.cpp
|
|
|
|
midisources/midisource_smf.cpp
|
|
|
|
midisources/midisource_hmi.cpp
|
|
|
|
midisources/midisource_xmi.cpp
|
|
|
|
streamsources/music_dumb.cpp
|
|
|
|
streamsources/music_gme.cpp
|
|
|
|
streamsources/music_libsndfile.cpp
|
|
|
|
streamsources/music_opl.cpp
|
|
|
|
streamsources/music_xa.cpp
|
|
|
|
musicformats/music_stream.cpp
|
|
|
|
musicformats/music_midi.cpp
|
|
|
|
musicformats/music_cd.cpp
|
|
|
|
decoder/sounddecoder.cpp
|
|
|
|
decoder/sndfile_decoder.cpp
|
|
|
|
decoder/mpg123_decoder.cpp
|
|
|
|
zmusic/configuration.cpp
|
|
|
|
zmusic/zmusic.cpp
|
|
|
|
zmusic/critsec.cpp
|
2020-01-11 11:47:07 +00:00
|
|
|
loader/test.c
|
2020-01-02 16:52:30 +00:00
|
|
|
${PLAT_SOURCES}
|
|
|
|
)
|
2020-02-09 10:16:10 +00:00
|
|
|
|
|
|
|
option( BUILD_SHARED_LIBS "Build shared libraries" ON )
|
|
|
|
|
|
|
|
add_library( zmusic ${all_files} )
|
|
|
|
add_library( zmusiclite ${all_files} )
|
2020-01-04 11:20:56 +00:00
|
|
|
target_compile_definitions(zmusiclite PRIVATE ZMUSIC_LITE=1)
|
2020-01-02 16:52:30 +00:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
2020-01-07 11:14:56 +00:00
|
|
|
if(APPLE)
|
|
|
|
set_target_properties(zmusic PROPERTIES MACOSX_RPATH TRUE)
|
|
|
|
set_target_properties(zmusiclite PROPERTIES MACOSX_RPATH TRUE)
|
|
|
|
endif()
|
|
|
|
|
2020-03-02 09:48:06 +00:00
|
|
|
set_target_properties(zmusic zmusiclite PROPERTIES
|
2020-05-30 08:29:38 +00:00
|
|
|
PUBLIC_HEADER ../include/zmusic.h
|
2020-03-02 09:48:06 +00:00
|
|
|
VERSION ${ZMUSIC_VERSION}
|
|
|
|
SOVERSION ${ZMUSIC_VERSION_MAJOR}
|
|
|
|
)
|
|
|
|
|
2020-05-30 08:29:38 +00:00
|
|
|
install(TARGETS zmusic zmusiclite
|
|
|
|
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
|
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
)
|
2020-01-04 15:23:19 +00:00
|
|
|
|
2020-01-02 16:52:30 +00:00
|
|
|
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/.+")
|
|
|
|
source_group("Music Formats\\Win32" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/musicformats/win32/.+")
|
2020-01-11 11:47:07 +00:00
|
|
|
source_group("ZMusic Core" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/zmusic/.+")
|
2020-01-02 16:52:30 +00:00
|
|
|
source_group("Sound Decoding" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/decoder/.+")
|
|
|
|
source_group("Stream Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/streamsources/.+")
|
|
|
|
source_group("Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/.+")
|
2020-01-11 11:47:07 +00:00
|
|
|
source_group("Public Interface" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/../include/.+")
|