mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-19 00:04:04 +01:00
cmake: version generation fixes and some tweaks
This commit is contained in:
parent
25b95c61ae
commit
38ace8cf7e
@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.5)
|
||||
project(vgmstream C)
|
||||
enable_language(CXX)
|
||||
|
||||
# TODO defautl out-of-source-builds not working properly?
|
||||
# (like "cmake .." from ./build subdir creates makefiles on ./, unless using "cmake -S ..")
|
||||
get_directory_property(hasParent PARENT_DIRECTORY)
|
||||
if(hasParent)
|
||||
set(VGM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
|
||||
@ -12,6 +14,13 @@ set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(CMAKE_MODULE_PATH ${VGM_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH})
|
||||
include(vgmstream)
|
||||
|
||||
# Defaults for Windows, otherwise may be Program Files/vgmstream
|
||||
if(WIN32)
|
||||
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
SET(CMAKE_INSTALL_PREFIX ${VGM_SOURCE_DIR} CACHE PATH "..." FORCE)
|
||||
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
endif()
|
||||
|
||||
function(set_mpeg onoff useForce)
|
||||
if(useForce)
|
||||
set(USE_FORCE_ FORCE)
|
||||
@ -51,7 +60,7 @@ endif()
|
||||
# Build choices
|
||||
option(BUILD_CLI "Build vgmstream CLI" ON)
|
||||
if(WIN32)
|
||||
if(NOT MINGW)
|
||||
if(MSVC)
|
||||
option(BUILD_FB2K "Build foobar2000 component" ON)
|
||||
set(FB2K_SDK_PATH CACHE PATH "Path to foobar2000 SDK")
|
||||
set(WTL_INCLUDE_PATH CACHE PATH "Path to WTL include directory")
|
||||
@ -65,6 +74,26 @@ else()
|
||||
option(BUILD_AUDACIOUS "Build Audacious plugin" ON)
|
||||
endif()
|
||||
|
||||
# Autodetect some paths
|
||||
if(MSVC AND NOT FB2K_SDK_PATH AND IS_DIRECTORY "${VGM_SOURCE_DIR}/dependencies/foobar/")
|
||||
set(FB2K_SDK_PATH "${VGM_SOURCE_DIR}/dependencies/foobar/" CACHE PATH "..." FORCE)
|
||||
endif()
|
||||
if(MSVC AND NOT WTL_INCLUDE_PATH AND IS_DIRECTORY "${VGM_SOURCE_DIR}/dependencies/wtl/")
|
||||
set(WTL_INCLUDE_PATH "${VGM_SOURCE_DIR}/dependencies/wtl/" CACHE PATH "..." FORCE)
|
||||
endif()
|
||||
|
||||
# Set autogenerated version
|
||||
if(MSVC)
|
||||
set(VGM_VERSION_GENERATOR version-make.bat)
|
||||
else()
|
||||
set(VGM_VERSION_GENERATOR version-make.sh)
|
||||
endif()
|
||||
add_custom_command(OUTPUT ${VGM_SOURCE_DIR}/version.h
|
||||
COMMAND "${VGM_SOURCE_DIR}/${VGM_VERSION_GENERATOR}"
|
||||
DEPENDS ${VGM_SOURCE_DIR}/${VGM_VERSION_GENERATOR})
|
||||
add_custom_target(version_h ALL DEPENDS ${VGM_SOURCE_DIR}/version.h)
|
||||
|
||||
# FFmpeg detection
|
||||
if(USE_FFMPEG)
|
||||
find_package(FFmpeg)
|
||||
if(NOT FFMPEG_LIBRARIES)
|
||||
@ -91,33 +120,9 @@ if(WIN32)
|
||||
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
||||
endif(MINGW)
|
||||
|
||||
# Update the version
|
||||
set(CMAKE_EXECUTABLE_SUFFIX .exe)
|
||||
if(MSVC)
|
||||
file(TO_NATIVE_PATH "${VGM_BINARY_DIR}/version.h" VERSION_H_PATH)
|
||||
add_custom_command(OUTPUT ${VGM_BINARY_DIR}/version.h
|
||||
COMMAND "${VGM_SOURCE_DIR}/version-make.bat"
|
||||
ARGS ${VERSION_H_PATH}
|
||||
DEPENDS ${VGM_SOURCE_DIR}/version-make.bat)
|
||||
add_custom_target(version_h DEPENDS ${VGM_BINARY_DIR}/version.h)
|
||||
else()
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags
|
||||
WORKING_DIRECTORY ${VGM_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE VGMSTREAM_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
else()
|
||||
# Update the version
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags
|
||||
WORKING_DIRECTORY ${VGM_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE VGMSTREAM_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
# Find the relevant packages
|
||||
if(USE_MPEG)
|
||||
@ -136,8 +141,11 @@ else()
|
||||
# If building the CLI, we need to include AO as well
|
||||
if(BUILD_CLI)
|
||||
find_package(AO)
|
||||
if(NOT AO_FOUND)
|
||||
message(FATAL_ERROR "Cannot build vgmstream123 without libao")
|
||||
if(AO_FOUND)
|
||||
set(USE_V123 ON)
|
||||
else (AO_FOUND)
|
||||
#TODO: add proper separate option
|
||||
set(USE_V123 OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -279,7 +287,8 @@ if(WIN32)
|
||||
message(STATUS " Winamp plugin: ${BUILD_WINAMP}")
|
||||
message(STATUS " XMPlay plugin: ${BUILD_XMPLAY}")
|
||||
else()
|
||||
message(STATUS "CLI/vgmstream123: ${BUILD_CLI}")
|
||||
message(STATUS " CLI: ${BUILD_CLI}")
|
||||
message(STATUS " vgmstream123: ${USE_V123}")
|
||||
message(STATUS " JSON dumping: ${USE_JANSSON}")
|
||||
message(STATUS "Audacious plugin: ${BUILD_AUDACIOUS}")
|
||||
endif()
|
||||
|
@ -56,7 +56,7 @@ install(TARGETS vgmstream_cli
|
||||
|
||||
# TODO: Make it so vgmstream123 can build with Windows (this probably needs a libao.dll included with vgmstream, though)
|
||||
|
||||
if(NOT WIN32)
|
||||
if(NOT WIN32 AND AO_FOUND)
|
||||
# vgmstream123
|
||||
|
||||
add_executable(vgmstream123
|
||||
|
Loading…
x
Reference in New Issue
Block a user