As opposed to many other people here I work with Lua primarily. almost all of my code-base for urho3d is in lua. I do use safe lua and I must warn that if you are going to use it, you may get errors which are almost impossible to resolve due to the unnecessary const values in some of the package bindings so its usage is experimental for the most part and as a result of that you may want to familiarise yourself with how tolua++ works and the .pkg format so you can easily fix it. its not that difficult.
If you want a quick test that Safe Lua works, you can try giving incorrect parameter such as a int to a function which expects a vector and it should give you an error, under normal circumstances it will not. This sadly also affects some functions who’s parameters have annotations such as const and causes frivolous errors.
Don’t expect safe lua to cover you for memory issues, if you don’t properly manage memory such as not using :new() when you are passing things created in Lua to C++ structures. Memory management between Urho3D C++ and Lua is tricky but doable if you keep the rules in mind. Safe Lua will mostly provide simple type checking but beyond that its not much use.
Additionally you may want to build in debug mode so you can use gdb to see where things go wrong as opposed to relying on safe lua to do it. if you see pointer related issues its probably because the C++ structures decided to delete something you are still using in Lua, this is often the majority of errors that I get, and its sometimes guess work to determine if everything is deleted properly, but generally if you pass something to a C++ structure then it has control over it and Lua must not interfere otherwise its double deleted.
For GDB I advise creating a script so it should be as simple as running a debug.sh in your project directory. you can execute a script in gdb with gdb -x <script>.cgdb
Personally mine looks like
file "/Projects/Tools/Urho3d/build/bin/Urho3DPlayer"
r '/Projects/<project>/uroh3d.lua' -w -p 'Data;CoreData;urho_ext;' -pp '/Projects/Tools/Urho3d/build/bin/Urho3DPlayer;/Projects/<project>;'
I have an additional local path added urho_ext I use to manage project specific data such as shaders, render paths etc.
Good luck! and if you want better support for lua and can’t have it any other way you can try using sol2 which has a binding converter from tolua++ pkg to its own format. I haven’t tried it but its on my todo list.
For your cmake question:
If I recall correctly the D value is for Debug. so -DURHO3D_SAFE_LUA=1 unpacks to “when building in debug mode build with safe lua”
Personally I would suggest using the cmake gui, which works on both linux and windows for the ease of use as you can simply tick the options you want.