Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "libvgm" target, all sub-libraries combined. #68

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ find_package(Sanitizers)
option(BUILD_LIBAUDIO "build audio output library" ON)
option(BUILD_LIBEMU "build sound emulation library" ON)
option(BUILD_LIBPLAYER "build player library" ON)
option(BUILD_LIBVGM "build unified libvgm library" ON)
option(BUILD_TESTS "build test programs" OFF)
option(BUILD_PLAYER "build player application" ON)
option(BUILD_VGM2WAV "build sample vgm2wav application" ON)
Expand All @@ -116,30 +117,35 @@ option(USE_SANITIZERS "use sanitizers" ON)
# --- main library ---
add_subdirectory(utils)
if(USE_SANITIZERS)
add_sanitizers(utils)
add_sanitizers(vgm-utils_objlib)
endif(USE_SANITIZERS)

if(BUILD_LIBAUDIO)
add_subdirectory(audio)
if(USE_SANITIZERS)
add_sanitizers(vgm-audio)
add_sanitizers(vgm-audio_objlib)
endif(USE_SANITIZERS)
endif()

if(BUILD_LIBEMU)
add_subdirectory(emu)
if(USE_SANITIZERS)
add_sanitizers(vgm-emu)
add_sanitizers(vgm-emu_objlib)
endif(USE_SANITIZERS)
endif()

if(BUILD_LIBPLAYER)
add_subdirectory(player)
if(USE_SANITIZERS)
add_sanitizers(vgm-player)
add_sanitizers(vgm-player_objlib)
endif(USE_SANITIZERS)
endif()

if(BUILD_LIBVGM)
add_subdirectory(vgm)
# sanitizers are included via being added to objlib targets
endif()


# --- additional stuff ---
if(BUILD_TESTS)
Expand Down
19 changes: 11 additions & 8 deletions audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,30 +144,33 @@ if(AUDIODRV_LIBAO)
set(AUDIO_PC_REQUIRES ${AUDIO_PC_REQUIRES} "ao")
endif()

add_library(${PROJECT_NAME}_objlib OBJECT ${AUDIO_FILES})
set_target_properties(${PROJECT_NAME}_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${PROJECT_NAME}_objlib PUBLIC ${AUDIO_DEFS})
target_include_directories(${PROJECT_NAME}_objlib PRIVATE ${AUDIO_INCLUDES})
target_link_libraries(${PROJECT_NAME}_objlib PRIVATE ${AUDIO_LIBS})

add_library(${PROJECT_NAME} ${LIBRARY_TYPE} ${AUDIO_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_library(${PROJECT_NAME} ${LIBRARY_TYPE} $<TARGET_OBJECTS:${PROJECT_NAME}_objlib>)
target_compile_definitions(${PROJECT_NAME} PUBLIC ${AUDIO_DEFS})
target_include_directories(${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${LIBVGM_SOURCE_DIR}> $<INSTALL_INTERFACE:${LIBVGM_INSTALL_INCLUDE_DIR}>
PRIVATE ${AUDIO_INCLUDES}
)
target_link_libraries(${PROJECT_NAME} PRIVATE ${AUDIO_LIBS} vgm-utils)
target_link_libraries(${PROJECT_NAME} PRIVATE vgm-utils ${AUDIO_LIBS})

if(WIN32)
# for some Windows Audio APIs, we need WinAPI headers from special directories
if(NOT MSVC)
target_include_directories(${PROJECT_NAME} PRIVATE
target_include_directories(${PROJECT_NAME}_objlib PRIVATE
${LIBVGM_SOURCE_DIR}/libs/include
${LIBVGM_SOURCE_DIR}/libs/include_mingw
)
elseif(MSVC)
target_include_directories(${PROJECT_NAME} PRIVATE
target_include_directories(${PROJECT_NAME}_objlib PRIVATE
${LIBVGM_SOURCE_DIR}/libs/include
${LIBVGM_SOURCE_DIR}/libs/include_vc
)
if(MSVC_VERSION LESS 1400)
target_include_directories(${PROJECT_NAME} PRIVATE
target_include_directories(${PROJECT_NAME}_objlib PRIVATE
${LIBVGM_SOURCE_DIR}/libs/include_vc6
)
endif()
Expand All @@ -187,7 +190,7 @@ pkgcfg_configure("${LIBVGM_SOURCE_DIR}/cmake/libvgm.pc.in" "${CMAKE_CURRENT_BINA
PKGS_PUB vgm-utils
)

install(TARGETS ${PROJECT_NAME}
install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_objlib
EXPORT "${LIBVGM_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand Down
28 changes: 16 additions & 12 deletions emu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(vgm-emu)

set(EMU_PC_CFLAGS)
set(EMU_PC_LDFLAGS)

set(EMU_LIBS)

# Note: If multiple cores are present for a device, the core chosed by default is marked with *.

Expand Down Expand Up @@ -598,22 +598,26 @@ if(SNDEMU_GA20_ALL)
set(EMU_CORE_HEADERS ${EMU_CORE_HEADERS} cores/iremga20.h)
endif()


add_library(${PROJECT_NAME} ${LIBRARY_TYPE} ${EMU_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${PROJECT_NAME} PUBLIC ${EMU_DEFS})
target_include_directories(${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${LIBVGM_SOURCE_DIR}> $<INSTALL_INTERFACE:${LIBVGM_INSTALL_INCLUDE_DIR}>
PRIVATE ${LIBVGM_SOURCE_DIR}/libs/include
)

if(CMAKE_COMPILER_IS_GNUCC OR UNIX)
# link Math library
target_link_libraries(${PROJECT_NAME} PRIVATE m)
set(EMU_LIBS "m")
set(EMU_PC_LDFLAGS "-lm")
endif()


add_library(${PROJECT_NAME}_objlib OBJECT ${EMU_FILES})
set_target_properties(${PROJECT_NAME}_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${PROJECT_NAME}_objlib PUBLIC ${EMU_DEFS})
target_include_directories(${PROJECT_NAME}_objlib PRIVATE ${LIBVGM_SOURCE_DIR}/libs/include)
target_link_libraries(${PROJECT_NAME}_objlib PRIVATE ${EMU_LIBS})

add_library(${PROJECT_NAME} ${LIBRARY_TYPE} $<TARGET_OBJECTS:${PROJECT_NAME}_objlib>)
target_compile_definitions(${PROJECT_NAME} PUBLIC ${EMU_DEFS})
target_include_directories(${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${LIBVGM_SOURCE_DIR}> $<INSTALL_INTERFACE:${LIBVGM_INSTALL_INCLUDE_DIR}>
)
target_link_libraries(${PROJECT_NAME} PRIVATE ${EMU_LIBS})

pkgcfg_configure("${LIBVGM_SOURCE_DIR}/cmake/libvgm.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/vgm-emu.pc"
NAME "LibVGM Emu"
DESC "LibVGM sound chip emulation library"
Expand All @@ -624,7 +628,7 @@ pkgcfg_configure("${LIBVGM_SOURCE_DIR}/cmake/libvgm.pc.in" "${CMAKE_CURRENT_BINA
LDFLAGS_PUB "-l${PROJECT_NAME}"
)

install(TARGETS ${PROJECT_NAME}
install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_objlib
EXPORT "${LIBVGM_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand Down
15 changes: 9 additions & 6 deletions player/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ set(PLAYER_PC_CFLAGS)
set(PLAYER_PC_LDFLAGS)


add_library(${PROJECT_NAME} ${LIBRARY_TYPE} ${PLAYER_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_library(${PROJECT_NAME}_objlib OBJECT ${PLAYER_FILES})
set_target_properties(${PROJECT_NAME}_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${PROJECT_NAME}_objlib PUBLIC ${PLAYER_DEFS})
target_include_directories(${PROJECT_NAME}_objlib PRIVATE ${PLAYER_INCLUDES})
target_link_libraries(${PROJECT_NAME}_objlib PRIVATE ${PLAYER_LIBS})

add_library(${PROJECT_NAME} ${LIBRARY_TYPE} $<TARGET_OBJECTS:${PROJECT_NAME}_objlib>)
target_compile_definitions(${PROJECT_NAME} PUBLIC ${PLAYER_DEFS})
target_include_directories(${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${LIBVGM_SOURCE_DIR}> $<INSTALL_INTERFACE:${LIBVGM_INSTALL_INCLUDE_DIR}>
PRIVATE ${PLAYER_INCLUDES}
)
target_link_libraries(${PROJECT_NAME} PRIVATE ${PLAYER_LIBS} vgm-emu vgm-utils)

target_link_libraries(${PROJECT_NAME} PRIVATE vgm-emu vgm-utils ${PLAYER_LIBS})

pkgcfg_configure("${LIBVGM_SOURCE_DIR}/cmake/libvgm.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/vgm-player.pc"
NAME "LibVGM Player"
Expand All @@ -51,7 +54,7 @@ pkgcfg_configure("${LIBVGM_SOURCE_DIR}/cmake/libvgm.pc.in" "${CMAKE_CURRENT_BINA
PKGS_PRIV ${UTILS_PC_REQUIRES} vgm-emu vgm-utils
)

install(TARGETS ${PROJECT_NAME}
install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_objlib
EXPORT "${LIBVGM_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand Down
15 changes: 9 additions & 6 deletions utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,18 @@ endif()
endif(UTIL_CHARSET_CONV)


add_library(${PROJECT_NAME}_objlib OBJECT ${UTIL_FILES})
set_target_properties(${PROJECT_NAME}_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${PROJECT_NAME}_objlib PUBLIC ${UTIL_DEFS})
target_include_directories(${PROJECT_NAME}_objlib PRIVATE ${UTIL_INCLUDES})
target_link_libraries(${PROJECT_NAME}_objlib PRIVATE ${UTIL_LIBS})

add_library(${PROJECT_NAME} ${LIBRARY_TYPE} ${UTIL_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_library(${PROJECT_NAME} ${LIBRARY_TYPE} $<TARGET_OBJECTS:${PROJECT_NAME}_objlib>)
target_compile_definitions(${PROJECT_NAME} PUBLIC ${UTIL_DEFS})
target_include_directories(${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${LIBVGM_SOURCE_DIR}> $<INSTALL_INTERFACE:${LIBVGM_INSTALL_INCLUDE_DIR}>
PRIVATE ${UTIL_INCLUDES}
)
target_link_libraries(${PROJECT_NAME} PUBLIC ${UTIL_LIBS})

target_link_libraries(${PROJECT_NAME} PRIVATE ${UTIL_LIBS})

pkgcfg_configure("${LIBVGM_SOURCE_DIR}/cmake/libvgm.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/vgm-utils.pc"
NAME "LibVGM Utils"
Expand All @@ -110,7 +112,7 @@ pkgcfg_configure("${LIBVGM_SOURCE_DIR}/cmake/libvgm.pc.in" "${CMAKE_CURRENT_BINA
PKGS_PRIV ${UTIL_PC_PKGS}
)

install(TARGETS ${PROJECT_NAME}
install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_objlib
EXPORT "${LIBVGM_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand All @@ -119,3 +121,4 @@ install(TARGETS ${PROJECT_NAME}
set(LIBVGM_INSTALL_TARGETS ${LIBVGM_INSTALL_TARGETS} "${PROJECT_NAME}" PARENT_SCOPE)
install(FILES ${UTIL_HEADERS} DESTINATION "${LIBVGM_INSTALL_INCLUDE_DIR}/utils")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/vgm-utils.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

23 changes: 23 additions & 0 deletions vgm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### Wrapper library
project(vgm)

add_library(${PROJECT_NAME} ${LIBRARY_TYPE})

target_link_libraries(${PROJECT_NAME} PRIVATE vgm-utils_objlib)

if(BUILD_LIBAUDIO)
target_link_libraries(${PROJECT_NAME} PRIVATE vgm-audio_objlib)
endif()
if(BUILD_LIBEMU)
target_link_libraries(${PROJECT_NAME} PRIVATE vgm-emu_objlib)
endif()
if(BUILD_LIBPLAYER)
target_link_libraries(${PROJECT_NAME} PRIVATE vgm-player_objlib)
endif()

install(TARGETS ${PROJECT_NAME}
EXPORT "${LIBVGM_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)