Skip to content

Commit 5292199

Browse files
committed
build: clean up NO_GETTEXT cmake support
Make NO_GETTEXT a build option aliased to ENV{NO_GETTEXT} to pass to vcpkg_install.bat to skip building gettext. Turn it off by default when vcpkg is in-use because it's a very long compile. Do not build translations if NO_GETTEXT is set. Add a note about NO_GETTEXT to the docs at the top of CMakeLists.txt. Signed-off-by: Rafael Kitover <[email protected]>
1 parent 55ec81d commit 5292199

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

contrib/buildsystems/CMakeLists.txt

+22-17
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ to the path or pass the path as `-DVCPKG_DIR=/your/clone/of/vcpkg`.
5454
To set the vcpkg arch (target triplet) pass `VCPKG_ARCH` or
5555
`VCPKG_TARGET_TRIPLET` e.g.: `-DVCPKG_ARCH=x64-windows`.
5656
57+
By default for vcpkg, gettext is not built and translations do not
58+
work because gettext is a very long compile. To enable translations
59+
pass `-DNO_GETTEXT=FALSE`.
60+
5761
The Visual Studio default generator changed in v16.6 from its Visual Studio
5862
implemenation to `Ninja` This required changes to many CMake scripts.
5963
@@ -72,6 +76,21 @@ if(NOT WIN32)
7276
set(USE_VCPKG OFF CACHE BOOL FORCE)
7377
endif()
7478

79+
set(gettext_default TRUE)
80+
81+
# Turn off gettext by default when using vcpkg because it's a very
82+
# long compile.
83+
if(NOT USE_VCPKG)
84+
set(gettext_default FALSE)
85+
endif()
86+
87+
build_option(
88+
NO_GETTEXT
89+
BOOL "Set to TRUE/ON to disable internationalization support using gettext and building translations using msgfmt from gettext-tools."
90+
${gettext_default}
91+
ALIASES ENV{NO_GETTEXT}
92+
)
93+
7594
if(NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS)
7695
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
7796
message("settting CMAKE_EXPORT_COMPILE_COMMANDS: ${CMAKE_EXPORT_COMPILE_COMMANDS}")
@@ -195,8 +214,7 @@ find_package(CURL)
195214
find_package(EXPAT)
196215
find_package(Iconv)
197216

198-
#Don't use libintl on Windows Visual Studio and Clang builds
199-
if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
217+
if(NOT NO_GETTEXT)
200218
find_package(Intl)
201219
endif()
202220

@@ -229,18 +247,10 @@ if(WIN32 AND NOT MSVC)#not required for visual studio builds
229247
endif()
230248
endif()
231249

232-
if(NO_GETTEXT)
233-
message(STATUS "msgfmt not used under NO_GETTEXT")
234-
else()
250+
if(NOT NO_GETTEXT)
235251
find_program(MSGFMT_EXE msgfmt)
236252
if(NOT MSGFMT_EXE)
237-
if(USE_VCPKG)
238-
set(MSGFMT_EXE ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe)
239-
endif()
240-
if(NOT EXISTS ${MSGFMT_EXE})
241-
message(WARNING "Text Translations won't be built")
242-
unset(MSGFMT_EXE)
243-
endif()
253+
message(WARNING "msgfmt not available and/or could not be installed, text translations won't be built.")
244254
endif()
245255
endif()
246256

@@ -1056,7 +1066,6 @@ set(NO_PYTHON )
10561066
set(PAGER_ENV "LESS=FRX LV=-c")
10571067
set(DC_SHA1 YesPlease)
10581068
set(RUNTIME_PREFIX true)
1059-
set(NO_GETTEXT )
10601069

10611070
if(NOT CURL_FOUND)
10621071
set(NO_CURL 1)
@@ -1066,10 +1075,6 @@ if(NOT EXPAT_FOUND)
10661075
set(NO_EXPAT 1)
10671076
endif()
10681077

1069-
if(NOT Intl_FOUND)
1070-
set(NO_GETTEXT 1)
1071-
endif()
1072-
10731078
if(NOT PERL_TESTS)
10741079
set(NO_PERL 1)
10751080
endif()

0 commit comments

Comments
 (0)