Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake include error when building new project. #8687

Closed
spnda opened this issue Feb 17, 2021 · 5 comments
Closed

CMake include error when building new project. #8687

spnda opened this issue Feb 17, 2021 · 5 comments
Labels

Comments

@spnda
Copy link
Contributor

@spnda spnda commented Feb 17, 2021

Version

Happens on master, and on most PRs I try out. Has happened for quite a while aswell.

Expected result

CMake should build fine after generating cache.

Actual result

CMake fails to find ..\script\ai\ai_includes.hpp and ..\script\api\game\game_includes.hpp file.

Steps to reproduce

git clone https://github.com/OpenTTD/OpenTTD.git

If the folder name remains OpenTTD, the program will generate cache and build fine (VS 2019).
If I should rename it to OpenTTD - somethingorother and have not generated cache or built before, it will fail asking for said files (sometimes one, sometimes both). Seems to nearly never happen with just spaces.

@TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Feb 21, 2021

I have been trying to reproduce this problem, but I cannot. Having spaces in folder names works perfectly fine for me. And I tried some weird shit :D Both on Linux and Windows, not a problem for me. Which makes these issues a bit difficult :P

One thing in what you describe does trigger me: you talk about "rename it to". Do you mean you were trying to rename the folder OpenTTD is in, and then trying to rerun CMake in the build-folder? As there is one thing CMake doesn't take kind to, is if you change the path of the build-folder. It also prints this on the top of the screen when it detects this happened btw. Is this what was happening for you?

If not, we need some more context and information next time it happens. Like the exact error when running in verbose-mode cmake --build . -v to get a bit of an idea what is going on exactly.

@spnda
Copy link
Contributor Author

@spnda spnda commented Feb 22, 2021

First of all, spaces don't seem to be the problem. It seems to be an issue with some special characters in folder names. I think I mentioned this back then when I tried using C++ inside the folder name.
Running the following batch script, you can create a copy of the project which cannot build and errors out on those include errors.

@echo off
git clone https://github.com/OpenTTD/OpenTTD.git
rename "OpenTTD" "OpenTTD - cmake error"

Running that, then opening the folder with VS, generating cache with VS and then building with VS reproduces the error.

I cannot build the project with cmake --build . -v because I am not sure how to generate cache. Therefore, I'll just paste relevant parts of the VS output (yes, this is MSVC).

  [265/742] Generating game/game_includes.hpp
  CMake Error at E:/Projects/C/OpenTTD/OpenTTD - cmake error/cmake/scripts/SquirrelIncludes.cmake:36 (file):
    file STRINGS file "E:/Projects/C/OpenTTD/OpenTTD - cmake
    error/out/build/x64-Debug (default)/src/script/api/||" cannot be read.

  [278/742] Generating ai/ai_includes.hpp
  CMake Error at E:/Projects/C/OpenTTD/OpenTTD - cmake error/cmake/scripts/SquirrelIncludes.cmake:36 (file):
    file STRINGS file "E:/Projects/C/OpenTTD/OpenTTD - cmake
    error/out/build/x64-Debug (default)/src/script/api/||" cannot be read.

  [699/742] Building CXX object CMakeFiles\openttd.dir\src\ai\ai_instance.cpp.obj
  FAILED: CMakeFiles/openttd.dir/src/ai/ai_instance.cpp.obj 
  "E:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x64\cl.exe"  /nologo /TP -DPERSONAL_DIR=\"OpenTTD\" -DTTD_ENDIAN=TTD_LITTLE_ENDIAN -DUNICODE -DWITH_ASSERT -DWITH_LIBLZMA -DWITH_LZO -DWITH_PERSONAL_DIR -DWITH_PNG -DWITH_SSE -DWITH_UNISCRIBE -DWITH_ZLIB -D_SQ64 -D_UNICODE -I..\..\..\src -I..\..\..\src\3rdparty\squirrel\include -Igenerated -Igenerated\script\api -I..\..\..\src\script\api -Igenerated\script -Igenerated\script\api\ai -I..\..\..\src\script\api\ai -Igenerated\script\api\game -I..\..\..\src\script\api\game -Igenerated\script\api\template -I..\..\..\src\script\api\template -ID:\Tools\vcpkg\installed\x64-windows\include /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MTd /Zi /Ob0 /Od /RTC1 /Zc:rvalueCast /MP -D_DEBUG /W3 -std:c++17 /showIncludes /FoCMakeFiles\openttd.dir\src\ai\ai_instance.cpp.obj /FdCMakeFiles\openttd.dir\ /FS -c ..\..\..\src\ai\ai_instance.cpp
E:\Projects\C\OpenTTD\OpenTTD - cmake error\src\ai\ai_instance.cpp(28): fatal error C1083: Cannot open include file: '../script/api/ai/ai_includes.hpp': No such file or directory
@glx22
Copy link
Contributor

@glx22 glx22 commented Feb 22, 2021

Yes generation failed, so includes are missing. I'll take a look

@TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Feb 22, 2021

I am seeing those || again. I had that the few times I tried MSVC .. they mostly are not there, but sometimes are.

My solution was to ignore the || in the FOR loop of those 2 scripts, but I never upstreamed that, as I couldn't figure out WHY they were added and what they mean.

Maybe a space in the folder is a clue? I dunno ..

@glx22 glx22 mentioned this issue Feb 22, 2021
@glx22
Copy link
Contributor

@glx22 glx22 commented Feb 22, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants