CMake minimum version?
Closed this issue · 23 comments
Hi, just trying to build it now and, after following the previous steps listed in the REAME file without errors, I get to cmake ..
with this result:
cmake --build . -j 8 --config RelWithDebInfo
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenGL: /usr/lib/libOpenGL.so
Linux
/usr/lib/libOpenGL.so/usr/lib/libGLX.so/usr/lib/libGLU.sopthreaddlz
StratusEngine
CMake Error at Tests/CMakeLists.txt:20 (include):
include could not find requested file:
/tmp/ramdisk/StratusGFX/Tests/..//ThirdParty/lib/cmake/Catch2/Catch.cmake
CMake Error at Tests/UnitTests/CMakeLists.txt:25 (catch_discover_tests):
Unknown CMake command "catch_discover_tests".
-- Configuring incomplete, errors occurred!
See also "/tmp/ramdisk/StratusGFX/build/CMakeFiles/CMakeOutput.log".
make: Makefile: No such file or directory
make: *** No rule to make target 'Makefile'. Stop.
CMake is version 3.25.0, which one is the one it was been tested with?
This is an unusual system, PowerPC CPU and Void Linux, so I do not expect you to find a solution, just to document the situation.
If there is some simple test I could do, please let me know.
Edit: that file exists, it’s just under a directory called lib64
insted of lib
, I do not know why but I’ve seen similar problems before:
$ find .. -name Catch.cmake
../ThirdParty/lib64/cmake/Catch2/Catch.cmake
../Catch2/extras/Catch.cmake
I can get through that bump with a symbolic link:
cd ../ThirdParty/
ln -s lib64 lib
cd ../build/
cmake ..
Then I get stuck somewhere else, maybe GCC 10 is too old:
[ 1%] Building CXX object Source/Engine/CMakeFiles/StratusEngine.dir/StratusGpuCommandBuffer.cpp.o
[ 2%] Building CXX object Source/Engine/CMakeFiles/StratusEngine.dir/StratusGpuBuffer.cpp.o
[ 4%] Building CXX object Source/Engine/CMakeFiles/StratusEngine.dir/StratusGpuMaterialBuffer.cpp.o
[ 5%] Building CXX object Source/Engine/CMakeFiles/StratusEngine.dir/StratusPipeline.cpp.o
[ 7%] Building CXX object Source/Engine/CMakeFiles/StratusEngine.dir/StratusMath.cpp.o
[ 8%] Building CXX object Source/Engine/CMakeFiles/StratusEngine.dir/StratusGraphicsDriver.cpp.o
[ 10%] Building CXX object Source/Engine/CMakeFiles/StratusEngine.dir/StratusRenderComponents.cpp.o
[ 11%] Building CXX object Source/Engine/CMakeFiles/StratusEngine.dir/StratusRendererBackend.cpp.o
In file included from /tmp/ramdisk/StratusGFX/Source/Engine/StratusGraphicsDriver.cpp:2:
/tmp/ramdisk/StratusGFX/Source/Engine/StratusGpuBuffer.h:349:14: error: 'list' in namespace 'std' does not name a template type
349 | std::list<uint32_t> freeIndices_;
| ^~~~
In file included from /tmp/ramdisk/StratusGFX/Source/Engine/StratusGraphicsDriver.cpp:2:
/tmp/ramdisk/StratusGFX/Source/Engine/StratusGpuBuffer.h:13:1: note: 'std::list' is defined in header '<list>'; did you forget to '#include <list>'?
12 | #include "StratusLog.h"
+++ |+#include <list>
13 |
[…]
The ellipsis […] represents the other errors afterwards.
Hi, this is an issue someone else ran into on Linux as well. The branch with some potential changes is here: https://github.com/KTStephano/StratusGFX/tree/pr52.
Let me know how it goes if you happen to give the pr52 branch a try. These changes will be merged into master soon once testing is done.
@AlbertoGP some new changes have been merged into master that might fix this. You will need to clone from scratch and follow the new build instructions.
Following the updated README from scratch, libassimp-devel installed, after cmake -Bbuild -S. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=OFF
I get this:
CMake Warning (dev) at /usr/lib64/cmake/assimp-5.0/assimpTargets.cmake:54 (if):
if given arguments:
"ON"
An argument named "ON" appears in a conditional statement. Policy CMP0012
is not set: if() recognizes numbers and boolean constants. Run "cmake
--help-policy CMP0012" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
Call Stack (most recent call first):
/usr/lib64/cmake/assimp-5.0/assimp-config.cmake:1 (include)
Source/Engine/CMakeLists.txt:47 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at Source/Engine/CMakeLists.txt:52 (find_package):
By not providing "Findmeshoptimizer.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"meshoptimizer", but CMake did not find one.
Could not find a package configuration file provided by "meshoptimizer"
with any of the following names:
meshoptimizerConfig.cmake
meshoptimizer-config.cmake
Add the installation prefix of "meshoptimizer" to CMAKE_PREFIX_PATH or set
"meshoptimizer_DIR" to a directory containing one of the above files. If
"meshoptimizer" provides a separate development package or SDK, be sure it
has been installed.
There is no file named Findmeshoptimizer.cmake
or meshoptimizer*.cmake
. There is a cmake template at meshoptimizer/config.cmake.in
, I don’t know whether that’s useful.
@AlbertoGP When you ran dependency_build.py were there any errors? If none what does your StratusGFX/ThirdParty folder look like?
Oh, I had forgotten to run that script this time.
Trying again from scratch starting with a fresh git clone.
No errors at all when running python3 ./dependency_build.py
, just that GCC note about the order of aggregates having changed in GCC 5, this one is GCC 10.
The difference is that now there are more CMake-related files for meshoptimizer:
$ find . -iname "*meshopt*.cmake"
./ThirdParty/lib64/cmake/meshoptimizer/meshoptimizerConfigVersion.cmake
./ThirdParty/lib64/cmake/meshoptimizer/meshoptimizerConfig.cmake
./ThirdParty/lib64/cmake/meshoptimizer/meshoptimizerTargets-release.cmake
./ThirdParty/lib64/cmake/meshoptimizer/meshoptimizerTargets.cmake
./meshoptimizer/build/meshoptimizerConfigVersion.cmake
./meshoptimizer/build/meshoptimizerConfig.cmake
./meshoptimizer/build/CMakeFiles/Export/24e1f82d1b5bf01632e04e6a7ae9f13d/meshoptimizerTargets.cmake
./meshoptimizer/build/CMakeFiles/Export/24e1f82d1b5bf01632e04e6a7ae9f13d/meshoptimizerTargets-release.cmake
StratusGFX/ThirdParty contains bin contrib include lib64 share
.
The error message is exactly the same as above, same line numbers (54:assimpTargets.cmake and 52:CMakeLists.txt) and everything.
The file is indeed there at meshoptimizerConfig.cmake
but CMake fails to find it.
I’ve tried setting meshoptimizer_DIR
as the error message says, but it fails in exactly the same way:
cmake -Bbuild -S. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=OFF -Dmeshoptimizer_DIR=ThirdParty/lib64/cmake/meshoptimizer
Also tried with a slash at the end, and with ./
and ../
(in case it was relative to build/
) at the beginning of the path.
Then I tried ../..
in case it is relative to build/CMakeFiles
and yes, it works:
$ cmake -Bbuild -S. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=OFF -Dmeshoptimizer_DIR=../../ThirdParty/lib64/cmake/meshoptimizer/
Linux
CMake Warning (dev) at /usr/lib64/cmake/assimp-5.0/assimpTargets.cmake:54 (if):
if given arguments:
"ON"
An argument named "ON" appears in a conditional statement. Policy CMP0012
is not set: if() recognizes numbers and boolean constants. Run "cmake
--help-policy CMP0012" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
Call Stack (most recent call first):
/usr/lib64/cmake/assimp-5.0/assimp-config.cmake:1 (include)
Source/Engine/CMakeLists.txt:47 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
/usr/lib/libOpenGL.so/usr/lib/libGLX.so/usr/lib/libGLU.sopthreaddlzSDL2::SDL2libassimp.so.5meshoptimizer::meshoptimizer
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/ramdisk/StratusGFX/build
Now compiling with cmake --build build/ -j 8
I get warnings and errors but that’s in StratusGFX:
StratusGFX/Source/Engine/StratusGpuBuffer.cpp:123:21: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
123 | (void *)(offset + i * totalSizeBytes) // one-time offset before reading first element
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[…]
StratusGFX/Source/Engine/StratusResourceManager.cpp: In function 'void stratus::PrintMatType(const aiMaterial*, aiTextureType)':
/tmp/ramdisk/StratusGFX/Source/Engine/StratusResourceManager.cpp:327:14: error: 'aiTextureType_SHEEN' was not declared in this scope; did you mean 'aiTextureType_NONE'?
327 | {aiTextureType_SHEEN, "Sheen"},
| ^~~~~~~~~~~~~~~~~~~
| aiTextureType_NONE
[…]
I would guess these are not related to CMake. I can list them in another issue if that’s fine with you.
@AlbertoGP There is a new change in the main branch you can pull. It adds the lib64 paths to cmake search. Can you see if that clears up the mesh optimizer issue?
@AlbertoGP For the second error, if you comment out StratusGFX/Source/Engine/StratusResourceManager.cpp:327 and it compiles then I'll remove that line and merge it into main. It's possible that TextureType_SHEEN was removed in the version of assimp on your system but luckily it's not needed to have.
About the last error message above, aiTextureType_SHEEN
is defined in assimp/include/assimp/material.h
, which is included from assimp/include/assimp/pbrmaterial.h
, which is included from Source/Engine/StratusResourceManager.cpp
so it should not be a problem.
Ok, git pull
, then cmake -Bbuild -S. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=OFF
yes CMake works. The compilation error is not affected.
@AlbertoGP Awesome! And with cmake --build build/ -j 8
did that also succeed?
@AlbertoGP sorry just re-read your message. There is another update in main which removes some of the debug texture types including sheen.
I think that #include <assimp/pbrmaterial.h>
was taking it from the libassimp-devel
system package because when I replaced <assimp/pbrmaterial.h>
in StartusResourceManager.cpp
with <assimp/material.h>
and <assimp/GltfMaterial.h>
it failed to find this last one.
The system package is libassimp-5.0.1
which I guess is older.
Removing it (the devel one, since libassimp is needed for another installed program) causes CMake to fail.
I do not understand the error message though because it says “By not providing "Findassimp.cmake" in CMAKE_MODULE_PATH …” but this file is there:
./assimp/cmake-modules/Findassimp.cmake
Re-installed libassimp-devel
, did git pull
and got the update, similar issue: I think it’s my libassimp
package.
/tmp/ramdisk/StratusGFX/Source/Engine/StratusResourceManager.cpp:328:14: error: 'aiTextureType_CLEARCOAT' was not declared in this scope; did you mean 'aiTextureType_LIGHTMAP'?
328 | {aiTextureType_CLEARCOAT, "Clearcoat"},
| ^~~~~~~~~~~~~~~~~~~~~~~
| aiTextureType_LIGHTMAP
After that there are some strange error messages about unordered_map.h
: this looks more and more like the packages in my system are just too old. I write this here just for reference in case others have the same problem:
StratusGFX/Source/Engine/StratusResourceManager.cpp:331:9: error: no matching function for call to 'std::unordered_map<int, std::__cxx11::basic_string<char> >::unordered_map(<brace-enclosed initializer list>)'
331 | };
| ^
[…]
263 | unordered_map(initializer_list<value_type> __l,
| ^~~~~~~~~~~~~
/usr/include/c++/10.2/bits/unordered_map.h:263:7: note: candidate expects 4 arguments, 13 provided
@AlbertoGP I merged in another change into main which includes more assimp material headers on top of pbrmaterial.h. Maybe that will help?
Also does your system's compiler support C++17?
Also does your system's compiler support C++17?
Yes it does, but it is not the default: that happened in GCC 11 and this one is 10: https://gcc.gnu.org/projects/cxx-status.html#cxx17
I'll add -std=c++17
to CPPFLAGS
and try again.
@AlbertoGP Ok if that doesn't work with the latest code you can comment out the lines in StratusResourceManager.cpp so that it looks like this:
static void PrintMatType(const aiMaterial * aimat, const aiTextureType type) {
// static const std::unordered_map<int, std::string> conversion = {
// {aiTextureType_DIFFUSE, "Diffuse"},
// {aiTextureType_SPECULAR, "Specular"},
// {aiTextureType_AMBIENT, "Ambient"},
// {aiTextureType_EMISSIVE, "Emissive"},
// {aiTextureType_OPACITY, "Opacity"},
// {aiTextureType_HEIGHT, "Height"},
// {aiTextureType_NORMALS, "Normals"},
// {aiTextureType_BASE_COLOR, "Base Color"},
// //{aiTextureType_NORMAL_CAMERA, "Normal Camera"},
// {aiTextureType_EMISSION_COLOR, "Emission Color"},
// {aiTextureType_METALNESS, "Metalness"},
// //{aiTextureType_AMBIENT_OCCLUSION, "Ambient Occlusion"},
// //{aiTextureType_DIFFUSE_ROUGHNESS, "Diffuse Roughness"},
// //{aiTextureType_SHEEN, "Sheen"},
// {aiTextureType_CLEARCOAT, "Clearcoat"},
// {aiTextureType_TRANSMISSION, "Transmission"},
// {aiTextureType_UNKNOWN, "Unknown/Other"}
// };
// if (conversion.find(type) == conversion.end()) return;
// const auto count = aimat->GetTextureCount(type);
// std::stringstream out;
// out << count;
// if (count > 0) {
// aiString str;
// aimat->GetTexture(type, 0, &str);
// std::string file = str.C_Str();
// out << ": " << conversion.find(type)->second << ", " << file;
// }
// out << std::endl;
// STRATUS_LOG << out.str();
}
Thanks for the hints, it still misses other definitions such as AI_MATKEY_METALLIC_FACTOR
so I guess those are differences between libassimp
v4 and v5. I need to do other things now but I’ll try later to install libassimp 4.1.0 (that’s the version under StratusGFX/assimp/
) and try again.
For the C++17 issues, the solution was to start from scratch and add CXXFLAGS
to CMake at this step:
CXXFLAGS=-std=c++17 cmake -Bbuild -S. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=OFF
That’s not needed for the final cmake --build build/ -j 8
.
@AlbertoGP Ok yeah maybe see if you can install assimp v4.1.0 on your system, maybe even built from source?
Something I can't figure out is why I'm able to use assimp v5 on my local Pop_OS system but it breaks on yours. That's very strange. I'm not sure what's going on
@AlbertoGP Slight update to this. Main has some new changes with refactored build steps. The dependency script can now be used as
python3 ./dependency_build.py --assimp
which will force it to build assimp from source and store it in StratusGFX/ThirdParty. Maybe that will help fix the issue.
python3 ./dependency_build.py --assimp
Yes, this works! It now compiles the whole thing, including the examples. Of course GCC still needs the -std=c++17
option.
Running cd Bin; ./Ex01_StratusGFX
, the one that does not need the big asset files, fails with error messages about the shaders, things like “parameter in offset must be a constant expression”. This could be again a version problem. Maybe my GLSL compiler does not support version 460, I have no idea, will have to dig a bit more.
Awesome I'm glad that worked!
Feel free to open a new issue with the shader error. Hopefully your gpu supports version 460. You can also copy the console output and attach it here for me to check if you want.