Understanding CMakeLists of GZDoom

Need help running G/Q/ZDoom/ECWolf/Zandronum/3DGE/EDuke32/Raze? Did your computer break? Ask here.

Moderator: GZDoom Developers

Forum rules
Contrary to popular belief, we are not all-knowing-all-seeing magical beings!

If you want help you're going to have to provide lots of info. Like what is your hardware, what is your operating system, what version of GZDoom/LZDoom/whatever you're using, what mods you're loading, how you're loading it, what you've already tried for fixing the problem, and anything else that is even remotely relevant to the problem.

We can't magically figure out what it is if you're going to be vague, and if we feel like you're just wasting our time with guessing games we will act like that's what you're really doing and won't help you.
Post Reply
User avatar
RederickDeathwill
Posts: 31
Joined: Sun Sep 06, 2020 4:18 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: São Paulo - Brazil
Contact:

Understanding CMakeLists of GZDoom

Post by RederickDeathwill »

I'm trying to embed a Python interpreter in the GZDoom existing code base and I'm having trouble understanding the CMakeLists.txt. Here's my shell script to compile the source code:

Code: Select all

#!/bin/sh
a='' && [ "$(uname -m)" = x86_64 ] && a=64
c="$(lscpu -p | grep -v '#' | sort -u -t , -k 2,4 | wc -l)" ; [ "$c" -eq 0 ] && c=1
cd ./build &&
rm -f output_sdl/liboutput_sdl.so &&
if [ -d ../fmodapi44464linux ]; then
f="-DFMOD_LIBRARY=../fmodapi44464linux/api/lib/libfmodex${a}-4.44.64.so \
-DFMOD_INCLUDE_DIR=../fmodapi44464linux/api/inc"; else
f='-UFMOD_LIBRARY -UFMOD_INCLUDE_DIR'; fi &&
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/home/ericson/Workspace/ZMusic/build_install ..
cmake .. -DCMAKE_BUILD_TYPE=Release $f &&
make -j$c
The problem is, in order to embed the python interpreter, I need to user the "target_link_libraries" function on gzdoom, but I can't find the "add_executable" part of the CMakesList. There is an "add_custom_target" though, but that's not what I need to link to.

Where is gzdoom? (The final build) on the CMakesList?

Thanks for the help :)
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Understanding CMakeLists of GZDoom

Post by _mental_ »

User avatar
RederickDeathwill
Posts: 31
Joined: Sun Sep 06, 2020 4:18 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: São Paulo - Brazil
Contact:

Re: Understanding CMakeLists of GZDoom

Post by RederickDeathwill »

Thank you! I've managed to make it work. It compiled, and a Hello World worked from Python. I've added this to the "D_DoomMain_Internal" function (It worked upon initialization):

Code: Select all

py::scoped_interpreter guard{}; // start the interpreter and keep it alive
py::print("Hello, World! GZDoom now runs Python :)"); // use the Python API
User avatar
m8f
 
 
Posts: 1461
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Location: Siberia (UTC+7)
Contact:

Re: Understanding CMakeLists of GZDoom

Post by m8f »

Crazy stuff!

I have so many questions! Is it an experiment, or there is some serious plan?
Does it run from C++ side only, or from script side too, somehow?
User avatar
RederickDeathwill
Posts: 31
Joined: Sun Sep 06, 2020 4:18 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: São Paulo - Brazil
Contact:

Re: Understanding CMakeLists of GZDoom

Post by RederickDeathwill »

m8f wrote:Crazy stuff!

I have so many questions! Is it an experiment, or there is some serious plan?
Does it run from C++ side only, or from script side too, somehow?
Well, it is an experiment, I have this dream of scripting Doom with Python for many years, but never had the technical skills to do it. I've had a lot of experience with Python in my job now (Apart from side projects on github) and I'm experimenting with the idea somewhat more seriously now, studying pybind11. I'm somewhat acquainted with Kate Fox's PyDoom, and in my opinion what she was trying to do was not the "ideal" (If there's such a thing) way of doing it. GZDoom is modern, pretty advanced and the product of many many years of community work, there's no reason to try to implement an entirely new source port only in Python. Pybind11 is a pretty fancy and modern solution to embedding Python to an existing C++ codebase, and yeah, that's exactly what I'm trying to do, I want to mess with the internal functions from Python externally without needing to recompile the code, and I'll probably do a lot of things wrong, but anyway, there's no reason not to do it :p

I've pushed a few hours ago this "Hello World" of mine (It's on d_main.cpp), you can clone my fork and test it if you want. I'll post my progress from time to time.
Post Reply

Return to “Technical Issues”