vkoskiv / c-ray

c-ray is a small, simple path tracer written in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Do not force the compiler version

madmann91 opened this issue · comments

The most recent commits break the build on my system. I have gcc in version 10, so the line set(CMAKE_C_COMPILER "gcc-9") breaks everything for me. I believe it would be better to set that per-build, if required with the CMake GUI, instead of forcing a specific version by default. Alternatively, it is possible to use the following example to detect if inter-procedural optimization is supported by the compiler (starting from CMake 3.9.6):

check_ipo_supported(RESULT result OUTPUT output)
if(result)
  set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
  message(WARNING "IPO is not supported: ${output}")
endif()

(reference: https://cmake.org/cmake/help/v3.9/module/CheckIPOSupported.html)

Actually that set(CMAKE_C_COMPILER "gcc-9") is in there by accident. I just added it for testing, and indeed one should just do cmake . -DCMAKE_C_COMPILER=<compiler> instead. The helper scripts in the rebuild directory do just this.

And yeah, after seeing the massive performance boost from a little tweak to CMakeLists.txt, I was a bit anxious to commit it in as quickly as possible. I'll apply that check you outlined shortly.

I think requiring CMake 3.9 and newer is fine, all my experiments with running this on ancient hardware use plain shell scripts for the build system anyway.