Skip to content

Commit

Permalink
cmake & meson updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ilg-ul committed Nov 10, 2024
1 parent 971cda2 commit 7b816ce
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
14 changes: 12 additions & 2 deletions assets/sources/CMakeLists-liquid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ set(common_options
$<$<C_COMPILER_ID:GNU,Clang,AppleClang>:-ffunction-sections>
$<$<C_COMPILER_ID:GNU,Clang,AppleClang>:-fdata-sections>

# debug & gcc might need
# '-fno-omit-frame-pointer',
# $<$<C_COMPILER_ID:MSVC>:> # Add MSVC options here.

# Optional, comment it out to disable link time optimizations.
Expand All @@ -108,12 +110,20 @@ if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin")
add_link_options(
-Wl,-dead_strip
)
else()
elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
# macOS always uses the Apple linker, regardless of the compiler.
add_link_options(
$<$<C_COMPILER_ID:GNU>:-Wl,--gc-sections>
$<$<C_COMPILER_ID:GNU,Clang,AppleClang>:-Wl,--gc-sections>

$<$<C_COMPILER_ID:GNU,Clang,AppleClang>:-static>

# $<$<C_COMPILER_ID:MSVC>:> # Add MSVC options here.
)
elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
add_link_options(
# clang refers libc++ and libunwind
$<$<C_COMPILER_ID:GNU>:-Wl,--gc-sections>
)
endif()

# -----------------------------------------------------------------------------
Expand Down
41 changes: 24 additions & 17 deletions assets/sources/meson-liquid.build
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,31 @@ endif
common_options = []

if compiler.get_id() == 'gcc' or compiler.get_id().contains('clang')
if compiler.get_id() == 'gcc'
common_options += [
'-static-libgcc',
'-static-libstdc++',
]
endif
common_options += [
'-fmessage-length=0',
'-fsigned-char'
'-fsigned-char',
]
# This is used in conjunction with linker `--gc-sections`.
common_options += [
'-ffunction-sections',
'-fdata-sections'
'-fdata-sections',
]

if get_option('buildtype') == 'release' or get_option('buildtype') == 'debugoptimized'
# Optional, comment it out to disable link time optimizations.
# Optional, comment it out to disable link time optimizations.
common_options += [
'-flto'
'-flto',
]
endif
if get_option('buildtype').contains('debug')
common_options += [
'-fno-omit-frame-pointer'
'-fno-omit-frame-pointer',
]
endif
elif compiler.get_id() == 'msvc'
Expand All @@ -119,27 +125,28 @@ linker_options = common_options
if build_machine.system() == 'darwin'
# macOS always uses the Apple linker, regarless of the compiler.
linker_options += [
'-Wl,-dead_strip'
'-Wl,-dead_strip',
]
else # Linux or Windows
if compiler.get_id() == 'gcc'
elif build_machine.system() == 'windows'
if compiler.get_id() == 'gcc' or compiler.get_id().contains('clang')
# TODO: clang with gold might need it too.
linker_options += [
'-Wl,--gc-sections'
'-Wl,--gc-sections',

'-static',
]
elif compiler.get_id() == 'msvc'
linker_options += [
# Add MSVC options here.
]
endif
endif

if compiler.get_id() == 'gcc'
# Required, otherwise system shared libraries are used.
linker_options += [
'-static-libgcc',
'-static-libstdc++',
]
elif build_machine.system() == 'linux'
if compiler.get_id() == 'gcc'
# TODO: clang with gold might need it too.
linker_options += [
'-Wl,--gc-sections',
]
endif
endif

# -----------------------------------------------------------------------------
Expand Down

0 comments on commit 7b816ce

Please sign in to comment.