Marzac / le3d

A straightforward and easy to use 3D software renderer for real-time retro graphics.
https://marzac.github.io/le3d/
MIT License
60 stars 6 forks source link

Cmake #2

Closed m0ppers closed 6 years ago

m0ppers commented 6 years ago

Initial CMake setup. I finally understand why it did compile on my HOLD YOUR BREATH m68k Amiga cross compile gcc 🥇 😁 . The enclosing #ifdefs should not be needed when there is a build system in place. I removed some of those and was able to run the cube demo on the mac. I only had to #ifdef the gamepad away (which was linux specific). The rest worked just fine (see screenshot I sent you on twitter :D).

This does not include any special build flags that your build.bat was having. So I would not consider this complete. But I think this might be a solid starting ground.

I tried to compile it using MSVC but it is throwing super nasty errors and I don't have gcc on windows. In theory it should work by adding the LINK_LIBRARIES for windows.

If you can make the source MSVC compatible I think I can sort out the rest.

How to build (and this should work on linux right away):

mkdir build # yeah...out of source build :)
cd build
cmake ..
make -j12
cd ../examples/cube # assets are loaded relatively from here
./../build/examples/cube

In theory you could now start a new project. Then clone/copy le3d into it. Create a CMakeLists.txt for your project and just do add_subdirectory(le3d). Then you simply have to do:

add_executable(my-cool-le3d-project
   main.cpp
   awesome.cpp
)

target_link_libraries(my-cool-le3d-project
  le3d_LIBRARIES
)
target_include_directories(my-cool-le3d-project
  le3d_INCLUDE_DIRS
)

That's what it should look like at least. Not yet tested of ;)

m0ppers commented 6 years ago

before we introduce more open ends:

Maybe we should first check if your existing setups work with the current CMake setup because this should work now. If the cmake setup introduced performance problems these should be fixed before merging.

My problem here is a bit that this was actually the first time I ever ran the example :D. I do have a clang mac and a MSVC windows and a gcc amiga. So my problem is that I don't have a reference value here unfortunately and right now I don't have something that could generate one.

I will add a final (blind - as I cannot test it locally right now) commit that SHOULD make it link on windows too.

Maybe you can then verify if it builds on your linux (that should work out of the box) and with your windows cygwin setup and if there aren't any notable regressions (i.e. fps like on my mac ;) ) then this should be merged. Only then should we start thinking about stuff like MSVC I think.

So far I only worked with MSVC on windows. In theory you should simply have to select mingw makefiles as a generator under windows cmake:

cmake -G "MinGW Makefiles"

you can also choose this from the UI.

Marzac commented 6 years ago

Alright. Please redo the pull request using the newly created CMakeBuilding branch. Otherwise, if I do it myself, you won't appear as a contributor to the project.

Maybe we should first check if your existing setups work with the current CMake setup because this should work now. I am going to give it a go, probably this weekend, with the MSYS2 / mingw64 install I have.

FPS issue on the MacOS could also be coming from the time measurement methods in tools/timing.h One can try to run the cube example without the FPS capping and see how it goes.

You can also check if the current example project for vs (in vs directory of the MSVSCompilerSupport) already compiles on your machine.

Have a nice weekend.

m0ppers commented 6 years ago

obsolete now