vgmstream/cli/CMakeLists.txt

95 lines
2.5 KiB
CMake
Raw Normal View History

# CLI
add_executable(vgmstream_cli
vgmstream_cli.c)
2021-08-27 00:24:26 +02:00
if(WIN32)
set_target_properties(vgmstream_cli PROPERTIES
PREFIX ""
OUTPUT_NAME "test")
else()
set_target_properties(vgmstream_cli PROPERTIES
PREFIX ""
OUTPUT_NAME "vgmstream-cli")
endif()
# Link to the vgmstream library
target_link_libraries(vgmstream_cli libvgmstream)
# Link to Jansson, if we have it
if (USE_JANSSON AND JANSSON_FOUND)
target_compile_definitions(vgmstream_cli PRIVATE HAVE_JSON)
target_link_libraries(vgmstream_cli jansson)
endif()
setup_target(vgmstream_cli TRUE)
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
${VGM_BINARY_DIR}
2020-01-11 17:34:51 +01:00
${VGM_SOURCE_DIR}/ext_libs/Getopt)
# Include the version string
if(MSVC)
add_dependencies(vgmstream_cli version_h)
elseif(MINGW)
if(VGMSTREAM_VERSION)
target_compile_definitions(vgmstream_cli PRIVATE VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")
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
LINK_FLAGS "-static-libgcc -static-libstdc++")
endif()
endif()
2019-03-20 03:00:48 +01:00
# Install the DLLs
install_dlls(${CMAKE_INSTALL_PREFIX}/bin)
elseif(VGMSTREAM_VERSION)
# Include the version string
target_compile_definitions(vgmstream_cli PRIVATE VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")
endif()
2019-03-20 03:00:48 +01: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
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)
if(NOT WIN32 AND BUILD_V123)
# vgmstream123
add_executable(vgmstream123
vgmstream123.c)
# Link to the vgmstream library as well as libao
target_link_libraries(vgmstream123
libvgmstream
ao pthread dl)
setup_target(vgmstream123 TRUE)
# Add AO include directory
target_include_directories(vgmstream123 PRIVATE
2021-08-30 11:30:24 +02:00
${LIBAO_INCLUDE})
# Include the version string
target_compile_definitions(vgmstream123 PRIVATE VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")
# Install vgmstream123
install(TARGETS vgmstream123
2020-01-11 17:34:51 +01:00
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif()