CMake Refactor

This commit is contained in:
Lukas Cone 2020-01-11 17:34:51 +01:00
parent 10ab263092
commit 087ed737ca
9 changed files with 60 additions and 57 deletions

View File

@ -10,6 +10,10 @@ if(MINGW)
message(FATAL_ERROR "Cannot currently build with MinGW")
endif()
set(VGM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
set(VGM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH})
include(vgmstream)
@ -56,12 +60,12 @@ if(WIN32)
# Update the version
set(CMAKE_EXECUTABLE_SUFFIX .exe)
if(MSVC)
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/version.h" VERSION_H_PATH)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/version.h
COMMAND "${CMAKE_SOURCE_DIR}/version.bat"
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/version.h" VERSION_H_PATH)
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/version.h
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/version.bat"
ARGS ${VERSION_H_PATH} VERSION
DEPENDS ${CMAKE_SOURCE_DIR}/version.bat)
add_custom_target(version_h DEPENDS ${CMAKE_BINARY_DIR}/version.h)
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/version.bat)
add_custom_target(version_h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/version.h)
else()
find_package(Git)
if(GIT_FOUND)
@ -171,7 +175,7 @@ if(USE_FDKAAC)
endif()
if(USE_MAIATRAC3PLUS)
if(MAIATRAC3PLUS_PATH)
add_subdirectory(${MAIATRAC3PLUS_PATH}/MaiAT3PlusDecoder ${CMAKE_BINARY_DIR}/maitrac3plus)
add_subdirectory(${MAIATRAC3PLUS_PATH}/MaiAT3PlusDecoder ${CMAKE_CURRENT_BINARY_DIR}/maitrac3plus)
else()
message(FATAL_ERROR "Path to MAIATRAC3+ must be set. (Use MAIATRAC3PLUS_PATH)")
endif()

View File

@ -17,8 +17,8 @@ if(WIN32)
# Make sure that the binary directory is included (for version.h), as well as the getopt library include directory
target_include_directories(vgmstream_cli PRIVATE
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/ext_libs/Getopt)
${VGM_SOURCE_DIR}
${VGM_SOURCE_DIR}/ext_libs/Getopt)
# Include the version string
if(MSVC)
@ -44,7 +44,7 @@ endif()
# Install the CLI program
install(TARGETS vgmstream_cli
RUNTIME DESTINATION bin)
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
# TODO: Make it so vgmstream123 can build with Windows (this probably needs a libao.dll included with vgmstream, though)
@ -70,5 +70,5 @@ if(NOT WIN32)
# Install vgmstream123
install(TARGETS vgmstream123
RUNTIME DESTINATION bin)
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif()

View File

@ -1,6 +1,6 @@
# qaac doesn't have a Visual Studio project for Windows, so this not only allows things to build for Visual Studio, but also covers other compilers and platforms
configure_file(${QAAC_PATH}/mp4v2/libplatform/config.h.in ${CMAKE_BINARY_DIR}/mp4v2/include/libplatform/config.h COPYONLY)
configure_file(${QAAC_PATH}/mp4v2/libplatform/config.h.in ${VGM_BINARY_DIR}/mp4v2/include/libplatform/config.h COPYONLY)
file(GLOB INCLUDE_HEADERS "${QAAC_PATH}/mp4v2/include/mp4v2/*.h")
file(GLOB LIBPLATFORM_HEADERS "${QAAC_PATH}/mp4v2/libplatform/*.h")
@ -103,7 +103,7 @@ target_compile_definitions(mp4v2 PRIVATE
target_include_directories(mp4v2 PRIVATE
${QAAC_PATH}/mp4v2
${QAAC_PATH}/mp4v2/include
${CMAKE_BINARY_DIR}/mp4v2/include)
${VGM_BINARY_DIR}/mp4v2/include)
# Make sure that whatever compiler we use can handle these features
target_compile_features(mp4v2 PRIVATE

View File

@ -14,7 +14,8 @@ macro(setup_target TARGET)
_WIN32_WINNT=0x501
_CRT_SECURE_NO_WARNINGS)
endif()
target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/ext_includes)
target_include_directories(${TARGET} PRIVATE ${VGM_SOURCE_DIR}/src)
target_include_directories(${TARGET} PRIVATE ${VGM_SOURCE_DIR}/ext_includes)
# Set up position-independent code for all targets
set_target_properties(${TARGET} PROPERTIES
POSITION_INDEPENDENT_CODE TRUE)
@ -29,7 +30,7 @@ macro(setup_target TARGET)
VGM_USE_FDKAAC)
target_include_directories(${TARGET} PRIVATE
${QAAC_PATH}/mp4v2/include
${CMAKE_BINARY_DIR}/mp4v2/include
${VGM_BINARY_DIR}/mp4v2/include
${FDK_AAC_PATH}/libSYS/include
${FDK_AAC_PATH}/libAACdec/include)
if(LINK)
@ -44,7 +45,7 @@ macro(setup_target TARGET)
if(WIN32)
if(LINK)
add_dependencies(${TARGET} libmpg123)
target_link_libraries(${TARGET} ${CMAKE_BINARY_DIR}/ext_libs/libmpg123-0.lib)
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libmpg123-0.lib)
endif()
else()
target_include_directories(${TARGET} PRIVATE ${MPG123_INCLUDE_DIR})
@ -59,7 +60,7 @@ macro(setup_target TARGET)
if(WIN32)
if(LINK)
add_dependencies(${TARGET} libvorbis)
target_link_libraries(${TARGET} ${CMAKE_BINARY_DIR}/ext_libs/libvorbis.lib)
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libvorbis.lib)
endif()
else()
target_include_directories(${TARGET} PRIVATE ${VORBISFILE_INCLUDE_DIRS})
@ -75,9 +76,9 @@ macro(setup_target TARGET)
if(LINK)
add_dependencies(${TARGET} ffmpeg)
target_link_libraries(${TARGET}
${CMAKE_BINARY_DIR}/ext_libs/avcodec.lib
${CMAKE_BINARY_DIR}/ext_libs/avformat.lib
${CMAKE_BINARY_DIR}/ext_libs/avutil.lib)
${VGM_BINARY_DIR}/ext_libs/avcodec.lib
${VGM_BINARY_DIR}/ext_libs/avformat.lib
${VGM_BINARY_DIR}/ext_libs/avutil.lib)
endif()
else()
target_include_directories(${TARGET} PRIVATE ${FFMPEG_INCLUDE_DIRS})
@ -91,7 +92,7 @@ macro(setup_target TARGET)
target_compile_definitions(${TARGET} PRIVATE VGM_USE_G7221)
if(LINK)
add_dependencies(${TARGET} libg7221_decode)
target_link_libraries(${TARGET} ${CMAKE_BINARY_DIR}/ext_libs/libg7221_decode.lib)
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libg7221_decode.lib)
endif()
endif()
@ -99,7 +100,7 @@ macro(setup_target TARGET)
target_compile_definitions(${TARGET} PRIVATE VGM_USE_G719)
if(LINK)
add_dependencies(${TARGET} libg719_decode)
target_link_libraries(${TARGET} ${CMAKE_BINARY_DIR}/ext_libs/libg719_decode.lib)
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libg719_decode.lib)
endif()
endif()
@ -115,7 +116,7 @@ macro(setup_target TARGET)
target_compile_definitions(${TARGET} PRIVATE VGM_USE_ATRAC9)
if(LINK)
add_dependencies(${TARGET} libatrac9)
target_link_libraries(${TARGET} ${CMAKE_BINARY_DIR}/ext_libs/libatrac9.lib)
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libatrac9.lib)
endif()
endif()
@ -124,8 +125,8 @@ macro(setup_target TARGET)
if(LINK)
add_dependencies(${TARGET} libcelt)
target_link_libraries(${TARGET}
${CMAKE_BINARY_DIR}/ext_libs/libcelt-0061.lib
${CMAKE_BINARY_DIR}/ext_libs/libcelt-0110.lib)
${VGM_BINARY_DIR}/ext_libs/libcelt-0061.lib
${VGM_BINARY_DIR}/ext_libs/libcelt-0110.lib)
endif()
endif()
endmacro()
@ -133,19 +134,19 @@ endmacro()
# Installs the DLLs to the given install prefix
macro(install_dlls INSTALL_PREFIX)
# Paths to the DLLs
set(MPEG_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libmpg123-0.dll)
set(VORBIS_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libvorbis.dll)
set(G7221_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libg7221_decode.dll)
set(G719_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libg719_decode.dll)
set(MPEG_DLL ${VGM_SOURCE_DIR}/ext_libs/libmpg123-0.dll)
set(VORBIS_DLL ${VGM_SOURCE_DIR}/ext_libs/libvorbis.dll)
set(G7221_DLL ${VGM_SOURCE_DIR}/ext_libs/libg7221_decode.dll)
set(G719_DLL ${VGM_SOURCE_DIR}/ext_libs/libg719_decode.dll)
set(FFMPEG_DLL
${CMAKE_SOURCE_DIR}/ext_libs/avcodec-vgmstream-58.dll
${CMAKE_SOURCE_DIR}/ext_libs/avformat-vgmstream-58.dll
${CMAKE_SOURCE_DIR}/ext_libs/avutil-vgmstream-56.dll
${CMAKE_SOURCE_DIR}/ext_libs/swresample-vgmstream-3.dll)
set(ATRAC9_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libatrac9.dll)
${VGM_SOURCE_DIR}/ext_libs/avcodec-vgmstream-58.dll
${VGM_SOURCE_DIR}/ext_libs/avformat-vgmstream-58.dll
${VGM_SOURCE_DIR}/ext_libs/avutil-vgmstream-56.dll
${VGM_SOURCE_DIR}/ext_libs/swresample-vgmstream-3.dll)
set(ATRAC9_DLL ${VGM_SOURCE_DIR}/ext_libs/libatrac9.dll)
set(CELT_DLL
${CMAKE_SOURCE_DIR}/ext_libs/libcelt-0061.dll
${CMAKE_SOURCE_DIR}/ext_libs/libcelt-0110.dll)
${VGM_SOURCE_DIR}/ext_libs/libcelt-0061.dll
${VGM_SOURCE_DIR}/ext_libs/libcelt-0110.dll)
# List of DLLs to check for install
set(DLLS

View File

@ -1,5 +1,3 @@
set(VGMSTREAM_EXT_INCLUDES ../ext_includes)
if(MSVC)
if(USE_MPEG)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libmpg123-0.lib ${CMAKE_CURRENT_BINARY_DIR}/libmpg123-0.exp
@ -9,8 +7,8 @@ if(MSVC)
add_custom_target(libmpg123
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libmpg123-0.lib
SOURCES
${VGMSTREAM_EXT_INCLUDES}/fmt123.h
${VGMSTREAM_EXT_INCLUDES}/mpg123.h)
${VGM_SOURCE_DIR}/ext_includes/fmt123.h
${VGM_SOURCE_DIR}/ext_includes/mpg123.h)
endif()
if(USE_VORBIS)
@ -18,8 +16,8 @@ if(MSVC)
COMMAND lib
ARGS /def:${CMAKE_CURRENT_SOURCE_DIR}/libvorbis.def /machine:x86 /out:${CMAKE_CURRENT_BINARY_DIR}/libvorbis.lib
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libvorbis.def)
file(GLOB OGG_HEADERS "${VGMSTREAM_EXT_INCLUDES}/ogg/*.h")
file(GLOB VORBIS_HEADERS "${VGMSTREAM_EXT_INCLUDES}/vorbis/*h")
file(GLOB OGG_HEADERS "${VGM_SOURCE_DIR}/ext_includes/ogg/*.h")
file(GLOB VORBIS_HEADERS "${VGM_SOURCE_DIR}/ext_includes/vorbis/*h")
add_custom_target(libvorbis
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libvorbis.lib
SOURCES
@ -36,7 +34,7 @@ if(MSVC)
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libg7221_decode.def)
add_custom_target(libg7221_decode
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libg7221_decode.lib
SOURCES ${VGMSTREAM_EXT_INCLUDES}/g7221.h)
SOURCES ${VGM_SOURCE_DIR}/ext_includes/g7221.h)
endif()
if(USE_G719)
@ -46,7 +44,7 @@ if(MSVC)
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libg719_decode.def)
add_custom_target(libg719_decode
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libg719_decode.lib
SOURCES ${VGMSTREAM_EXT_INCLUDES}/g719.h)
SOURCES ${VGM_SOURCE_DIR}/ext_includes/g719.h)
endif()
if(USE_FFMPEG)
@ -66,10 +64,10 @@ if(MSVC)
COMMAND lib
ARGS /def:${CMAKE_CURRENT_SOURCE_DIR}/swresample-vgmstream-3.def /machine:x86 /out:${CMAKE_CURRENT_BINARY_DIR}/swresample.lib
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/swresample-vgmstream-3.def)
file(GLOB AVCODEC_HEADERS "${VGMSTREAM_EXT_INCLUDES}/libavcodec/*.h")
file(GLOB AVFORMAT_HEADERS "${VGMSTREAM_EXT_INCLUDES}/libavformat/*.h")
file(GLOB AVUTIL_HEADERS "${VGMSTREAM_EXT_INCLUDES}/libavutil/*.h")
file(GLOB SWRESAMPLE_HEADERS "${VGMSTREAM_EXT_INCLUDES}/libswresample/*.h")
file(GLOB AVCODEC_HEADERS "${VGM_SOURCE_DIR}/ext_includes/libavcodec/*.h")
file(GLOB AVFORMAT_HEADERS "${VGM_SOURCE_DIR}/ext_includes/libavformat/*.h")
file(GLOB AVUTIL_HEADERS "${VGM_SOURCE_DIR}/ext_includes/libavutil/*.h")
file(GLOB SWRESAMPLE_HEADERS "${VGM_SOURCE_DIR}/ext_includes/libswresample/*.h")
add_custom_target(ffmpeg
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/avcodec.lib
@ -94,7 +92,7 @@ if(MSVC)
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libatrac9.def)
add_custom_target(libatrac9
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libatrac9.lib
SOURCES ${VGMSTREAM_EXT_INCLUDES}/libatrac9.h)
SOURCES ${VGM_SOURCE_DIR}/ext_includes/libatrac9.h)
endif()
if(USE_CELT)
@ -106,7 +104,7 @@ if(MSVC)
COMMAND lib
ARGS /def:${CMAKE_CURRENT_SOURCE_DIR}/libcelt-0110.def /machine:x86 /out:${CMAKE_CURRENT_BINARY_DIR}/libcelt-0110.lib
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libcelt-0110.def)
file(GLOB CELT_HEADERS "${VGMSTREAM_EXT_INCLUDES}/celt/*.h")
file(GLOB CELT_HEADERS "${VGM_SOURCE_DIR}/ext_includes/celt/*.h")
add_custom_target(libcelt
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/libcelt-0061.lib

View File

@ -5,10 +5,10 @@ file(GLOB LAYOUT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/layout/*.c")
file(GLOB META_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/meta/*.h")
file(GLOB META_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/meta/*.c")
set(EXT_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/../ext_includes/clHCA.h
${CMAKE_CURRENT_SOURCE_DIR}/../ext_includes/pstdint.h)
${VGM_SOURCE_DIR}/ext_includes/clHCA.h
${VGM_SOURCE_DIR}/ext_includes/pstdint.h)
set(EXT_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/../ext_libs/clHCA.c)
${VGM_SOURCE_DIR}/ext_libs/clHCA.c)
file(GLOB MAIN_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
file(GLOB MAIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.c")
@ -41,8 +41,8 @@ setup_target(libvgmstream)
# Set up the proper include directories
target_include_directories(libvgmstream PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../ext_includes
${VGM_SOURCE_DIR}
${VGM_SOURCE_DIR}/ext_includes
coding
layout
meta)

View File

@ -29,7 +29,7 @@ target_compile_definitions(in_vgmstream PRIVATE
_UNICODE)
# Make sure that the binary directory is included (for version.h)
target_include_directories(in_vgmstream PRIVATE ${CMAKE_BINARY_DIR})
target_include_directories(in_vgmstream PRIVATE ${VGM_SOURCE_DIR})
# Include the version string
if(MSVC)

View File

@ -15,7 +15,7 @@ set_target_properties(xmp-vgmstream PROPERTIES
SUFFIX ".dll")
# Make sure that the binary directory is included (for version.h)
target_include_directories(xmp-vgmstream PRIVATE ${CMAKE_BINARY_DIR})
target_include_directories(xmp-vgmstream PRIVATE ${VGM_SOURCE_DIR})
# Include the version string
if(MSVC)

View File

@ -42,7 +42,7 @@ double fade_seconds = 10.0;
double fade_delay_seconds = 0.0;
double loop_count = 2.0;
int disable_subsongs = 1;
bool xmplay_doneloop = 0;
BOOL xmplay_doneloop = 0;
/* plugin state */
VGMSTREAM * vgmstream = NULL;