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

(Help needed) CMake-Build fails to create correct *.pot file #12

Open
stefanstaffler opened this issue May 3, 2023 · 9 comments
Open

Comments

@stefanstaffler
Copy link

While running a CMake build, I get the following error:

[build] FAILED: src/App.pot
[build] cd <...> && /usr/bin/cmake -E env SOURCE_DATE_EPOCH=1500000000 TZ=UTC <...>/build/_deps/i18ncpp-build/merge/i18n-merge-pot --package=xyz --version= --output=App.pot <...>/build/src/CMakeFiles/App.dir/./app.cpp.o.poc <...>/build/src/CMakeFiles/App.dir/./appwindow.cpp.o.poc <...>/build/src/CMakeFiles/App.dir/./main.cpp.o.poc
[build] terminate called after throwing an instance of 'std::runtime_error'
[build]   what():  Unable to open file

For linking details, I can provide the following of my CMakeLists.txt:

include(FetchContent)
FetchContent_Declare(
    i18ncpp
    GIT_REPOSITORY https://github.com/zauguin/i18n-cpp.git
    GIT_TAG 41f4528
)
FetchContent_MakeAvailable(i18ncpp)

add_executable(App <...>)

<...>

target_use_i18n(App NODOMAIN)

Details about the system installation:

  • Ubuntu 22.04.2 LTS
  • GCC 12.1.0 x86_64-linux-gnu
  • CMake 3.22.1

Some help would be appreciated @zauguin.

@zauguin
Copy link
Owner

zauguin commented May 3, 2023

Which CMake generator are you using?

@stefanstaffler
Copy link
Author

Which CMake generator are you using?

Currently I use ninja with the version 1.10.1.

@zauguin
Copy link
Owner

zauguin commented May 3, 2023

The command line lists multiple .poc files. Do these files exists?

@stefanstaffler
Copy link
Author

stefanstaffler commented May 3, 2023

The command line lists multiple .poc files. Do these files exists?

Those files don't exist and are never created. I only get a .poc file with no name in the root directory of the build folder but this file is empty.

@zauguin
Copy link
Owner

zauguin commented May 3, 2023

That sounds like the matching from source file name to object file name fails. In your add_executable line, when listing the source files, are you specifying any paths or just filenames?

@stefanstaffler
Copy link
Author

The source files are collected using file(GLOB src CONFIGURE_DEPENDS <path>/*.cpp) and one for the headers as well. Then, they are added to the add_executable line with ${src} and ${headers}.

@zauguin
Copy link
Owner

zauguin commented May 4, 2023

That explains a lot, then you are using absolute paths to your source code which breaks the mapping. Does it help it you add RELATIVE "${CMAKE_CURRENT_SOURCE_DIRECTORY}" in front of CONFIGURE_DEPENDS in the file(GLOB command`?

@stefanstaffler
Copy link
Author

stefanstaffler commented May 7, 2023

Adding RELATIVE to the command file hasn't helped. However, listing the source files manually in the add_executable solved the issue.. I also get the *.poc files now but they are all empty.

@zauguin
Copy link
Owner

zauguin commented May 12, 2023

I just noticed your remark that the files are empty, I though this had been resolved. Anyway I looked into it and it seems that the check that the attribute exists break in some clang versions. That's a known issue which has been resolved for clang 17 (https://reviews.llvm.org/D144405), but for older versions it requires a workaround.

The unconditional-attribute branch should fix this (by not checking and just always using the attribute), but it comes with the side-effect of generating lots of warnings for other compilers or if the plugin is not loaded. I'll think if I can come up with a better solution.

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

No branches or pull requests

2 participants