2019-03-17 19:36:55 +01:00
# NOTE: Although this does include a section for handling MinGW, it might not be possible to build the foobar2000 component using MinGW using only CMake, as foobar2000's SDK only includes Visual Studio projects
2019-03-18 00:38:06 +01:00
set ( RESOURCES ${ CMAKE_CURRENT_SOURCE_DIR } /foo_input_vgmstream.rc )
# Setup source groups, mainly for Visual Studio
source_group ( "Resource Files" FILES ${ RESOURCES } )
2019-03-17 19:36:55 +01:00
add_library ( foo_input_vgmstream SHARED
2019-03-18 00:38:06 +01:00
f o o _ f i l e t y p e s . h
f o o _ p r e f s . h
f o o _ v g m s t r e a m . h
r e s o u r c e . h
2019-03-17 19:36:55 +01:00
f o o _ p r e f s . c p p
f o o _ s t r e a m f i l e . c p p
f o o _ v g m s t r e a m . c p p
2019-03-18 00:38:06 +01:00
$ { R E S O U R C E S } )
2019-03-17 19:36:55 +01:00
2019-03-21 03:23:47 +01:00
# Link to the vgmstream library and foobar2000's shared library
target_link_libraries ( foo_input_vgmstream
l i b v g m s t r e a m
$ { F B 2 K _ S D K _ P A T H } / f o o b a r 2 0 0 0 / s h a r e d / s h a r e d . l i b )
2019-03-17 19:36:55 +01:00
setup_target ( foo_input_vgmstream TRUE )
# Remove the prefix and set the suffix to .dll
set_target_properties ( foo_input_vgmstream PROPERTIES
P R E F I X " "
S U F F I X " . d l l " )
# Add the preprocessor definitions
target_compile_definitions ( foo_input_vgmstream PRIVATE
_ _ S T D C _ C O N S T A N T _ M A C R O S
U N I C O D E
_ U N I C O D E )
# Make sure that the binary directory is included (for version.h), as well as foobar2000's include directories and the WTL include directory
target_include_directories ( foo_input_vgmstream PRIVATE
2020-03-08 03:25:31 +01:00
$ { V G M _ B I N A R Y _ D I R }
2019-03-17 19:36:55 +01:00
$ { F B 2 K _ S D K _ P A T H } / f o o b a r 2 0 0 0 / S D K
$ { F B 2 K _ S D K _ P A T H } / f o o b a r 2 0 0 0 / A T L H e l p e r s
$ { F B 2 K _ S D K _ P A T H } / f o o b a r 2 0 0 0 / s h a r e d
$ { F B 2 K _ S D K _ P A T H } / f o o b a r 2 0 0 0
$ { W T L _ I N C L U D E _ P A T H } )
# Add dependencies to foobar2000's SDK
add_dependencies ( foo_input_vgmstream
f b 2 k _ s d k
f b 2 k _ s d k _ h e l p e r s
f b 2 k _ a t l _ h e l p e r s
f b 2 k _ c o m p o n e n t _ c l i e n t
p f c )
# Make sure that whatever compiler we use can handle these features
target_compile_features ( foo_input_vgmstream PRIVATE
c x x _ a u t o _ t y p e
c x x _ n u l l p t r
2019-03-18 05:17:08 +01:00
c x x _ r v a l u e _ r e f e r e n c e s
c x x _ s t a t i c _ a s s e r t
c x x _ v a r i a d i c _ t e m p l a t e s )
2019-03-17 19:36:55 +01:00
# Include the version string
if ( MSVC )
add_dependencies ( foo_input_vgmstream version_h )
elseif ( MINGW )
if ( VGMSTREAM_VERSION )
2021-08-07 20:41:50 +02:00
target_compile_definitions ( foo_input_vgmstream 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 DLL
if ( NOT CMAKE_CXX_COMPILER_ID MATCHES Clang )
set_target_properties ( foo_input_vgmstream 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 ( ${ FB2K_COMPONENT_INSTALL_PREFIX } /foo_input_vgmstream )
# Install the component
install ( TARGETS foo_input_vgmstream
D E S T I N A T I O N $ { F B 2 K _ C O M P O N E N T _ I N S T A L L _ P R E F I X } / f o o _ i n p u t _ v g m s t r e a m )