From 5ca601353f66020a56e624cadf8b1d5abcc11b4a Mon Sep 17 00:00:00 2001 From: Hubert Jarosz Date: Wed, 10 Aug 2016 23:57:19 +0200 Subject: [PATCH] document adding custom CXXFLAGS to Custom Modules --- reference/custom_modules_in_c++.rst | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/reference/custom_modules_in_c++.rst b/reference/custom_modules_in_c++.rst index d916d8f3..82692609 100644 --- a/reference/custom_modules_in_c++.rst +++ b/reference/custom_modules_in_c++.rst @@ -158,6 +158,19 @@ this module: env.add_source_files(env.modules_sources,"*.cpp") # just add all cpp files to the build +If you want to add custom compiler flags when building your module, you need to clone +`env` first, so it won't add those flags to whole Godot build (which can cause errors). +Example `SCub` with custom flags: + +.. code:: python + + # SCsub + Import('env') + + module_env = env.Clone() + module_env.add_source_files(env.modules_sources,"*.cpp") + module_env.Append(CXXFLAGS=['-O2', '-std=c++11']) + And finally, the configuration file for the module, this is a simple python script that must be named ``config.py``: @@ -174,11 +187,6 @@ python script that must be named ``config.py``: The module is asked if it's ok to build for the specific platform (in this case, True means it will build for every platform). -The second function allows to customize the build process for the -module, like adding special compiler flags, options, etc. (This can be -done in ``SCsub``, but ``configure(env)`` is called at a previous stage). -If unsure, just ignore this. - And that's it. Hope it was not too complex! Your module should look like this: