mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-03 18:09:13 +03:00
Implement use_static_cpp flag for Linux
This commit is contained in:
@@ -14,11 +14,25 @@ function(linux_options)
|
|||||||
Not implemented as compiler selection is managed by CMake. Look to
|
Not implemented as compiler selection is managed by CMake. Look to
|
||||||
doc/cmake.rst for examples.
|
doc/cmake.rst for examples.
|
||||||
]]
|
]]
|
||||||
|
option(GODOTCPP_USE_STATIC_CPP "Link libgcc and libstdc++ statically for better portability" ON)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
#[===========================[ Target Generation ]===========================]
|
#[===========================[ Target Generation ]===========================]
|
||||||
function(linux_generate)
|
function(linux_generate)
|
||||||
|
set(STATIC_CPP "$<BOOL:${GODOTCPP_USE_STATIC_CPP}>")
|
||||||
|
|
||||||
target_compile_definitions(godot-cpp PUBLIC LINUX_ENABLED UNIX_ENABLED)
|
target_compile_definitions(godot-cpp PUBLIC LINUX_ENABLED UNIX_ENABLED)
|
||||||
|
|
||||||
|
# gersemi: off
|
||||||
|
target_link_options(
|
||||||
|
godot-cpp
|
||||||
|
PUBLIC
|
||||||
|
$<${STATIC_CPP}:
|
||||||
|
-static-libgcc
|
||||||
|
-static-libstdc++
|
||||||
|
>
|
||||||
|
)
|
||||||
|
# gersemi: on
|
||||||
|
|
||||||
common_compiler_flags()
|
common_compiler_flags()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from SCons.Variables import BoolVariable
|
|||||||
|
|
||||||
def options(opts):
|
def options(opts):
|
||||||
opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler - only effective when targeting Linux", False))
|
opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler - only effective when targeting Linux", False))
|
||||||
|
opts.Add(BoolVariable("use_static_cpp", "Link libgcc and libstdc++ statically for better portability", True))
|
||||||
|
|
||||||
|
|
||||||
def exists(env):
|
def exists(env):
|
||||||
@@ -37,6 +38,10 @@ def generate(env):
|
|||||||
env.Append(CCFLAGS=["-march=rv64gc"])
|
env.Append(CCFLAGS=["-march=rv64gc"])
|
||||||
env.Append(LINKFLAGS=["-march=rv64gc"])
|
env.Append(LINKFLAGS=["-march=rv64gc"])
|
||||||
|
|
||||||
|
# Link statically for portability
|
||||||
|
if env["use_static_cpp"]:
|
||||||
|
env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])
|
||||||
|
|
||||||
env.Append(CPPDEFINES=["LINUX_ENABLED", "UNIX_ENABLED"])
|
env.Append(CPPDEFINES=["LINUX_ENABLED", "UNIX_ENABLED"])
|
||||||
|
|
||||||
# Refer to https://github.com/godotengine/godot/blob/master/platform/linuxbsd/detect.py
|
# Refer to https://github.com/godotengine/godot/blob/master/platform/linuxbsd/detect.py
|
||||||
|
|||||||
Reference in New Issue
Block a user