File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,25 @@ function(linux_options)
1414 Not implemented as compiler selection is managed by CMake. Look to
1515 doc/cmake.rst for examples.
1616 ]]
17+ option (GODOTCPP_USE_STATIC_CPP "Link libgcc and libstdc++ statically for better portability" ON )
1718endfunction ()
1819
1920#[===========================[ Target Generation ]===========================]
2021function (linux_generate)
22+ set (STATIC_CPP "$<BOOL:${GODOTCPP_USE_STATIC_CPP} >" )
23+
2124 target_compile_definitions (godot-cpp PUBLIC LINUX_ENABLED UNIX_ENABLED)
2225
26+ # gersemi: off
27+ target_link_options (
28+ godot-cpp
29+ PUBLIC
30+ $<${STATIC_CPP} :
31+ -static -libgcc
32+ -static -libstdc++
33+ >
34+ )
35+ # gersemi: on
36+
2337 common_compiler_flags()
2438endfunction ()
Original file line number Diff line number Diff line change 55
66def options (opts ):
77 opts .Add (BoolVariable ("use_llvm" , "Use the LLVM compiler - only effective when targeting Linux" , False ))
8+ opts .Add (BoolVariable ("use_static_cpp" , "Link libgcc and libstdc++ statically for better portability" , True ))
89
910
1011def exists (env ):
@@ -37,6 +38,10 @@ def generate(env):
3738 env .Append (CCFLAGS = ["-march=rv64gc" ])
3839 env .Append (LINKFLAGS = ["-march=rv64gc" ])
3940
41+ # Link statically for portability
42+ if env ["use_static_cpp" ]:
43+ env .Append (LINKFLAGS = ["-static-libgcc" , "-static-libstdc++" ])
44+
4045 env .Append (CPPDEFINES = ["LINUX_ENABLED" , "UNIX_ENABLED" ])
4146
4247 # Refer to https://github.com/godotengine/godot/blob/master/platform/linuxbsd/detect.py
You can’t perform that action at this time.
0 commit comments