2019-03-21 03:23:47 +01:00
# CLI
2019-03-17 19:36:55 +01:00
add_executable ( vgmstream_cli
v g m s t r e a m _ c l i . c )
2023-01-15 18:24:41 +01:00
set_target_properties ( vgmstream_cli PROPERTIES
P R E F I X " "
O U T P U T _ N A M E " v g m s t r e a m - c l i " )
2021-08-27 00:24:26 +02:00
2019-03-17 19:36:55 +01:00
# Link to the vgmstream library
target_link_libraries ( vgmstream_cli libvgmstream )
2020-09-29 04:10:23 +02:00
# Link to Jansson, if we have it
2021-10-25 10:03:15 +02:00
if ( USE_JANSSON )
2020-09-29 04:10:23 +02:00
target_compile_definitions ( vgmstream_cli PRIVATE HAVE_JSON )
2021-10-25 09:06:59 +02:00
target_include_directories ( vgmstream_cli PRIVATE ${ JANSSON_INCLUDE_DIRS } )
2020-09-29 04:10:23 +02:00
target_link_libraries ( vgmstream_cli jansson )
endif ( )
2019-03-21 03:23:47 +01:00
setup_target ( vgmstream_cli TRUE )
2019-03-17 19:36:55 +01:00
if ( WIN32 )
# Add the preprocessor definitions
target_compile_definitions ( vgmstream_cli PRIVATE _CONSOLE )
# Link to the getopt library
target_link_libraries ( vgmstream_cli getopt )
# 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
2020-01-11 19:14:13 +01:00
$ { V G M _ B I N A R Y _ D I R }
2020-01-11 17:34:51 +01:00
$ { V G M _ S O U R C E _ D I R } / e x t _ l i b s / G e t o p t )
2019-03-17 19:36:55 +01:00
# Include the version string
if ( MSVC )
add_dependencies ( vgmstream_cli version_h )
elseif ( MINGW )
if ( VGMSTREAM_VERSION )
2021-08-07 20:41:50 +02:00
target_compile_definitions ( vgmstream_cli PRIVATE VGMSTREAM_VERSION= "${VGMSTREAM_VERSION}" )
2019-03-17 19:36:55 +01:00
endif ( )
# Also, on MinGW when using GCC, these flags need to be included to prevent requiring MinGW's runtime DLLs from being included, which does unfortunately increase the size of the EXE
if ( NOT CMAKE_CXX_COMPILER_ID MATCHES Clang )
set_target_properties ( vgmstream_cli PROPERTIES
L I N K _ F L A G S " - s t a t i c - l i b g c c - s t a t i c - l i b s t d c + + " )
endif ( )
endif ( )
2019-03-20 03:00:48 +01:00
# Install the DLLs
install_dlls ( ${ CMAKE_INSTALL_PREFIX } /bin )
2019-03-17 19:36:55 +01:00
elseif ( VGMSTREAM_VERSION )
# Include the version string
2021-08-07 20:41:50 +02:00
target_compile_definitions ( vgmstream_cli PRIVATE VGMSTREAM_VERSION= "${VGMSTREAM_VERSION}" )
2019-03-17 19:36:55 +01:00
endif ( )
2019-03-20 03:00:48 +01:00
2023-01-23 03:06:23 +01:00
if ( CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES GNU )
set_target_properties ( vgmstream_cli PROPERTIES LINK_FLAGS_RELEASE -s )
endif ( )
2020-09-29 04:10:23 +02:00
2019-03-20 03:00:48 +01:00
# Install the CLI program
install ( TARGETS vgmstream_cli
2020-01-11 17:34:51 +01:00
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ P R E F I X } / b i n )
2019-03-21 03:23:47 +01:00
# TODO: Make it so vgmstream123 can build with Windows (this probably needs a libao.dll included with vgmstream, though)
2021-09-19 07:46:47 +02:00
if ( NOT WIN32 AND BUILD_V123 )
2019-03-21 03:23:47 +01:00
# vgmstream123
add_executable ( vgmstream123
v g m s t r e a m 1 2 3 . c )
# Link to the vgmstream library as well as libao
target_link_libraries ( vgmstream123
l i b v g m s t r e a m
2021-09-19 07:46:47 +02:00
a o p t h r e a d d l )
2019-03-21 03:23:47 +01:00
setup_target ( vgmstream123 TRUE )
# Add AO include directory
target_include_directories ( vgmstream123 PRIVATE
2021-08-30 11:30:24 +02:00
$ { L I B A O _ I N C L U D E } )
2019-03-21 03:23:47 +01:00
# Include the version string
2021-08-07 20:41:50 +02:00
target_compile_definitions ( vgmstream123 PRIVATE VGMSTREAM_VERSION= "${VGMSTREAM_VERSION}" )
2020-09-29 04:10:23 +02:00
2023-01-23 03:06:23 +01:00
if ( CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES GNU )
set_target_properties ( vgmstream123 PROPERTIES LINK_FLAGS_RELEASE -s )
endif ( )
2019-03-21 03:23:47 +01:00
# Install vgmstream123
install ( TARGETS vgmstream123
2020-01-11 17:34:51 +01:00
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ P R E F I X } / b i n )
2019-03-21 03:23:47 +01:00
endif ( )