0

I have a CMake project that uses gettext, and have installed gettext on my machine through vcpkg. Running vcpkg install gettext:x64-windows gave me this message:

The package gettext:x86-windows provides CMake targets:

    find_package(unofficial-gettext CONFIG REQUIRED)
    target_link_libraries(main PRIVATE unofficial::gettext::libintl)

I added that to my CMakeLists.txt file, and when Visual Studio 2017 tries to generate the CMake cache from it, it says:

1> C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe  -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\Enno\CMakeBuilds\1f25c7de-1ae7-7131-9c5a-889a4e831935\install\x64-Debug"  -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe"  -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe" -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\Enno\source\repos\echeck" returned with exit code: 1
CMake Error at CMakeLists.txt:8 (find_package):
  Could not find a package configuration file provided by
  "unofficial-gettext" with any of the following names:
    unofficial-gettextConfig.cmake
    unofficial-gettext-config.cmake
  Add the installation prefix of "unofficial-gettext" to CMAKE_PREFIX_PATH or
  set "unofficial-gettext_DIR" to a directory containing one of the above
  files.  If "unofficial-gettext" provides a separate development package or
  SDK, be sure it has been installed.

The file exists as C:\vcpkg\installed\x64-windows\share\unofficial-gettext\unofficial-gettext-config.cmake, though.

I've added this to my CMakeSettings_schema.json, but it made no difference: "cmakeCommandArgs": "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake",

I've never seen that unofficial::gettext::libintl syntax before, but since the failure already occurs in the find_package command, I assume that's unrelated for now. What is my mistake here?

2
  • unofficial::gettext::libintl just means that the libintl is part of the unofficial::gettext:: namespace. You'll find similar names in some other libs as well, e.g. Qt5::Widgets or boost::unit_test_framework. This shouldn't change anything for you though. Not sure if your toolchain file is supposed to contain this info, but does adding the prefix path change anything: -D 'CMAKE_PREFIX_PATH=C:\vcpkg\installed\x64-windows'? Commented Nov 10, 2020 at 21:33
  • That made the find_package error go away, but now I see this instead: 1> -- Build files have been written to: C:/Users/Enno/source/repos/echeck 1> Starting CMake target info extraction ... 1> CMake server connection made. 1> Target info extraction done. 1> Configuration failed. Commented Nov 11, 2020 at 15:44

1 Answer 1

1

Currently vcpkg uses a vcpkg owned CMakeLists.txt to build parts of gettext (only libintl). Since it is a vcpkg owned cmake build script vcpkg is free to export targets one of them being unofficial::gettext::libintl to correctly link against libintl in other vcpkg owned cmake builds.
In the future those unofficial namespaced targets will be removed since the build will be changed to the native build of the port (meson/autotools/make) [For gettext this will be done in PR https://github.com/microsoft/vcpkg/pull/11776]. Thus you should not rely on any of them being available since it will lock your built to vcpkg.
For libintl CMake has a FindIntl.cmake which should be used instead. If find_packe(Intl) is not working correctly please open up an issue in vcpkg

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, that was very informative! I realized that FindIntl wasn't working, so when vcpkg suggested using a different package name (unofficial-gettext), I tried that instead, and that's how I came to post this question. I will open an issue with vcpkg later today, and until then, make do without i18n support for Windows users.
It seems that the FindIntl.cmake that's shipping with vcpkg doesn't look for the correct library name. find_library(Intl_LIBRARY "intl" DOC "libintl libraries (if not in the C library)") doesn't find the library, because it is called libintl. I can work around this by adding find_library(Intl_LIBRARY NAMES libintl intl) before the find_package(Intl) command. I opened an issue: github.com/microsoft/vcpkg/issues/14548 - thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.