Skip to content

Commit

Permalink
CMake: Add stripping
Browse files Browse the repository at this point in the history
- Strips binaries on gcc/clang
  - Affects Linux binary size: from 14.2mb to 6.1mb for static, and from 3.1mb to 2.6mb for shared
  - Does not affect wasm binary size
- Fix building static linux binaries on Ubuntu 22.10 by renaming a few functions in libcelt that clash with system libopus
- Fix building wasm binaries on systems with Vulkan installed
  • Loading branch information
KatieFrogs committed Jan 24, 2023
1 parent b250b3f commit 2e3694e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ elseif(VGMSTREAM_VERSION)
target_compile_definitions(vgmstream_cli PRIVATE VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")
endif()


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()

# Install the CLI program
install(TARGETS vgmstream_cli
Expand All @@ -80,9 +82,11 @@ if(NOT WIN32 AND BUILD_V123)

# Include the version string
target_compile_definitions(vgmstream123 PRIVATE VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")



if(CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES GNU)
set_target_properties(vgmstream123 PROPERTIES LINK_FLAGS_RELEASE -s)
endif()

# Install vgmstream123
install(TARGETS vgmstream123
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
Expand Down
3 changes: 3 additions & 0 deletions cmake/dependencies/celt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ if(NOT WIN32 AND USE_CELT)
mdct_backward
mdct_init
mdct_clear
clt_mdct_init
clt_mdct_clear
compute_pulse_cache
)

foreach(ver 0061 0110)
Expand Down
1 change: 1 addition & 0 deletions cmake/dependencies/ffmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ if(USE_FFMPEG)
--disable-nvenc
--disable-nvdec
--disable-vdpau
--disable-vulkan
--enable-parser=${FFMPEG_CONF_PARSER}
--enable-demuxer=${FFMPEG_CONF_DEMUXER}
--enable-decoder=${FFMPEG_CONF_DECODER}
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ if(NOT EMSCRIPTEN)
setup_target(libvgmstream_shared TRUE)

target_include_directories(libvgmstream_shared PRIVATE ${libvgmstream_includes})

if(CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES GNU)
set_target_properties(libvgmstream_shared PROPERTIES LINK_FLAGS_RELEASE -s)
endif()
endif()

0 comments on commit 2e3694e

Please sign in to comment.