I’ve already done that and I mentioned in the first post that there is not a single occurrence of add_definitions (-DURHO3D_OPENGL)
. This is the whole reason why I’m making this thread: I don’t understand how URHO3D_OPENGL is defined without the use of add_definitions()
. What other mechanism is there in CMake that can add global defines?
Here’s the output of make VERBOSE=1
:
[ 47%] Building CXX object Source/Urho3D/CMakeFiles/Urho3D.dir/LuaScript/LuaScriptInstance.cpp.o
cd /home/thecomet/documents/programming/cpp/Urho3D/build_gl/Source/Urho3D && /usr/bin/c++ -DGLEW_NO_GLU -DGLEW_STATIC -DHAVE_SINCOSF -DHAVE_STDINT_H -DTOLUA_RELEASE -DURHO3D_ANGELSCRIPT -DURHO3D_FILEWATCHER -DURHO3D_IS_BUILDING -DURHO3D_LOGGING -DURHO3D_LUA -DURHO3D_NAVIGATION -DURHO3D_NETWORK -DURHO3D_PHYSICS -DURHO3D_PROFILING -DURHO3D_STATIC_DEFINE -DURHO3D_THREADING -DURHO3D_URHO2D -I/home/thecomet/documents/programming/cpp/Urho3D/build_gl/Source/Urho3D -I/home/thecomet/documents/programming/cpp/Urho3D/Source/Urho3D -I/home/thecomet/documents/programming/cpp/Urho3D/build_gl/include/Urho3D/ThirdParty -I/home/thecomet/documents/programming/cpp/Urho3D/build_gl/include/Urho3D/ThirdParty/Bullet -I/home/thecomet/documents/programming/cpp/Urho3D/build_gl/include/Urho3D/ThirdParty/Detour -I/home/thecomet/documents/programming/cpp/Urho3D/build_gl/include/Urho3D/ThirdParty/Lua -Wno-invalid-offsetof -march=native -ffast-math -pthread -fdiagnostics-color=auto -include “/home/thecomet/documents/programming/cpp/Urho3D/build_gl/Source/Urho3D/Precompiled.h” -O3 -DNDEBUG -o CMakeFiles/Urho3D.dir/LuaScript/LuaScriptInstance.cpp.o -c /home/thecomet/documents/programming/cpp/Urho3D/Source/Urho3D/LuaScript/LuaScriptInstance.cpp
I don’t see -DURHO3D_OPENGL
on the command line here. But it’s defined anyway. Why?
What I do see is the file Precompiled.h
being included, and if I search for URHO3D_OPENGL in build_gl/Source/Urho3D/Precompiled.h.gch/Precompiled.h.gch.Release
then I find matches.
So to repeat my initial question: How does URHO3D_OPENGL end up in Precompiled.h?
Here is my output for searching for URHO3D_OPENGL in all cmake files:
$ find . ( -name “CMakeLists.txt” -or -name “*.cmake” ) -exec grep -H “URHO3D_OPENGL” {} ;
./CMakeLists.txt:if (WIN32 AND NOT URHO3D_OPENGL AND NOT URHO3D_VULKAN)
./CMake/Modules/FindUrho3D.cmake:# URHO3D_OPENGL
./CMake/Modules/FindUrho3D.cmake:set (AUTO_DISCOVER_VARS URHO3D_OPENGL URHO3D_VULKAN URHO3D_D3D11 URHO3D_SSE URHO3D_DATABASE_ODBC URHO3D_DATABASE_SQLITE URHO3D_LUAJIT URHO3D_TESTING URHO3D_STATIC_RUNTIME)
./CMake/Modules/Urho3D-CMake-common.cmake: # OpenGL can be manually enabled with -DURHO3D_OPENGL=1, but Windows graphics card drivers are usually better optimized for Direct3D
./CMake/Modules/Urho3D-CMake-common.cmake: # Direct3D can be manually enabled with -DURHO3D_OPENGL=0, but it is likely to fail unless the MinGW-w64 distribution is used due to dependency to Direct3D headers and libs
./CMake/Modules/Urho3D-CMake-common.cmake: option (URHO3D_OPENGL “Use OpenGL as the rendering backend.” ${DEFAULT_OPENGL})
./CMake/Modules/Urho3D-CMake-common.cmake: set (URHO3D_OPENGL 0)
./CMake/Modules/Urho3D-CMake-common.cmake: set (URHO3D_OPENGL 0)
./CMake/Modules/Urho3D-CMake-common.cmake:if (URHO3D_OPENGL)
./CMake/Modules/Urho3D-CMake-common.cmake: set (URHO3D_OPENGL 0)
./CMake/Modules/Urho3D-CMake-common.cmake:if (NOT ANDROID AND NOT ARM AND NOT WEB AND URHO3D_OPENGL)
./CMake/Modules/Urho3D-CMake-common.cmake: if (URHO3D_OPENGL)
./Docs/CMakeLists.txt: if (NOT URHO3D_OPENGL EQUAL DOXYFILE_URHO3D_OPENGL OR ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
./Docs/CMakeLists.txt: set (DOXYFILE_URHO3D_OPENGL ${URHO3D_OPENGL} CACHE INTERNAL “URHO3D_OPENGL build option when Doxyfile was last generated”)
./Docs/CMakeLists.txt: if (URHO3D_OPENGL)
./Source/CMakeLists.txt: if (URHO3D_OPENGL)
./Source/ThirdParty/SDL/CMakeLists.txt:# Urho3D - only make DIRECTX option available on Windows platform when URHO3D_OPENGL OR URHO3D_VULKAN
./Source/ThirdParty/SDL/CMakeLists.txt:# is enabled, i.e. DIRECTX variable must always be ON (not an option) when URHO3D_OPENGL and URHO3D_VULKAN
./Source/ThirdParty/SDL/CMakeLists.txt: if (URHO3D_OPENGL or URHO3D_VULKAN)
./Source/ThirdParty/SDL/CMakeLists.txt:# Urho3D - commented out RENDER_D3D as an option to avoid potential conflict with our URHO3D_OPENGL and URHO3D_D3D11 build options on Windows platform
./Source/ThirdParty/SDL/CMakeLists.txt: if (URHO3D_OPENGL or URHO3D_VULKAN)
./Source/Urho3D/CMakeLists.txt:if (URHO3D_OPENGL)
As you can see, there is no occurrence of add_definitions()
, which makes me confused.