1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 17:04:47 +02:00

Use the default CMake modules for finding gettext instead of our own.

This commit is contained in:
Sadie Powell
2022-01-12 23:05:25 +00:00
parent a631028660
commit 33b42ce86e
10 changed files with 31 additions and 42 deletions
+8
View File
@@ -159,6 +159,14 @@ endif()
# Find gettext
find_package(Gettext)
find_package(Intl)
if(GETTEXT_FOUND AND Intl_FOUND)
set(HAVE_LOCALIZATION ON)
include_directories(${Intl_INCLUDE_DIRS})
else()
message("Unable to find gettext and libintl; disabling localization")
set(HAVE_LOCALIZATION OFF)
endif()
# Use the following directories as includes
include_directories(${Anope_BINARY_DIR}/include ${Anope_SOURCE_DIR}/include)
-26
View File
@@ -1,26 +0,0 @@
# Find the header files, libs, and executables for gettext
if(NOT WIN32)
find_path(GETTEXT_INCLUDE libintl.h /usr/include /usr/local/include ${EXTRA_INCLUDE})
find_library(GETTEXT_LIBRARY intl PATHS /usr/lib /usr/lib64 ${EXTRA_LIBS})
find_program(GETTEXT_MSGFMT msgfmt PATHS /usr/bin/ /usr/local/bin ${EXTRA_INCLUDE})
if(GETTEXT_INCLUDE AND GETTEXT_MSGFMT)
set(GETTEXT_FOUND TRUE)
if(GETTEXT_LIBRARY)
set(GETTEXT_LIBRARIES ${GETTEXT_LIBRARY})
endif()
endif()
else()
find_path(GETTEXT_INCLUDE libintl.h ${DEFAULT_INCLUDE_DIRS} ${WSDK_PATH}/include $ENV{VCINSTALLDIR}/include gettext/include ${EXTRA_INCLUDE})
find_library(GETTEXT_LIBRARY libintl PATHS ${DEFAULT_LIBRARY_DIRS} ${WSDK_PATH}/lib $ENV{VCINSTALLDIR}/lib gettext/lib ${EXTRA_LIBS})
find_program(GETTEXT_MSGFMT msgfmt PATHS ${DEFAULT_INCLUDE_DIRS} ${WSDK_PATH}/bin $ENV{VCINSTALLDIR}/bin gettext/bin ${EXTRA_INCLUDE})
if(GETTEXT_INCLUDE AND GETTEXT_LIBRARY AND GETTEXT_MSGFMT)
set(GETTEXT_FOUND TRUE)
set(GETTEXT_LIBRARIES ${GETTEXT_LIBRARY})
endif()
endif()
# If we found everything we need set variables correctly for lang/CMakeLists.txt to use
if(GETTEXT_FOUND)
include_directories("${GETTEXT_INCLUDE}")
set(GETTEXT_MSGFMT_EXECUTABLE ${GETTEXT_MSGFMT})
endif()
+2 -2
View File
@@ -14,8 +14,8 @@
#cmakedefine DEBUG_BUILD
#cmakedefine DEFUMASK @DEFUMASK@
#cmakedefine HAVE_UMASK 1
#cmakedefine GETTEXT_FOUND 1
#cmakedefine01 HAVE_UMASK
#cmakedefine01 HAVE_LOCALIZATION
#ifdef _WIN32
# define popen _popen
+1 -1
View File
@@ -1,5 +1,5 @@
# Only do this if gettext is installed
if(GETTEXT_FOUND)
if(HAVE_LOCALIZATION)
# Get all of the .po files
file(GLOB LANG_SRCS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.*.po")
list(SORT LANG_SRCS_PO)
+2 -2
View File
@@ -60,7 +60,7 @@ macro(build_modules SRC)
endif()
set_target_properties(${SO} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" SUFFIX "" LINK_FLAGS "${TEMP_LDFLAGS} ${WIN32_NO_LIBS}" INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
add_dependencies(${SO} ${PROGRAM_NAME})
if(GETTEXT_FOUND)
if(HAVE_LOCALIZATION)
add_dependencies(${SO} module_language)
endif()
target_link_libraries(${SO} ${TEMP_DEPENDENCIES})
@@ -143,7 +143,7 @@ macro(build_subdir)
add_library(${SO} MODULE ${MODULES_SUBDIR_SRCS})
set_target_properties(${SO} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" SUFFIX "" LINK_FLAGS "${SUBDIR_LDFLAGS}" INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
add_dependencies(${SO} ${PROGRAM_NAME})
if(GETTEXT_FOUND)
if(HAVE_LOCALIZATION)
add_dependencies(${SO} module_language)
endif()
target_link_libraries(${SO} ${SUBDIR_EXTRA_DEPENDS})
+1 -1
View File
@@ -1,5 +1,5 @@
# Only do this if gettext is installed
if(GETTEXT_FOUND)
if(HAVE_LOCALIZATION)
# Get all of the .po files
file(GLOB LANG_SRCS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.*.po")
list(SORT LANG_SRCS_PO)
+10 -3
View File
@@ -78,17 +78,24 @@ endif()
# Generate the Anope executable and set it's linker flags, also set it to export it's symbols even though it's not a module
add_executable(${PROGRAM_NAME} ${SRC_SRCS})
set_target_properties(${PROGRAM_NAME} PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS} ${EXTRA_LDFLAGS}" ENABLE_EXPORTS ON INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
# On Windows, also link Anope to the wsock32 and Ws2_32 library, as well as set the version
if(WIN32)
target_link_libraries(${PROGRAM_NAME} wsock32 Ws2_32 ${LINK_LIBS} ${GETTEXT_LIBRARIES} ${WIN32_MEMORY})
target_link_libraries(${PROGRAM_NAME} wsock32 Ws2_32 ${LINK_LIBS} ${WIN32_MEMORY})
set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
else()
target_link_libraries(${PROGRAM_NAME} ${LINK_LIBS} ${GETTEXT_LIBRARIES})
target_link_libraries(${PROGRAM_NAME} ${LINK_LIBS})
endif()
# If being built with localisation we might need to link against libintl.
if(HAVE_LOCALIZATION AND Intl_LIBRARY)
target_link_libraries(${PROGRAM_NAME} ${Intl_LIBRARY})
endif()
# Building the Anope executable requires the version.h header to be generated
add_dependencies(${PROGRAM_NAME} headers)
# Also require the language files if we have gettext
if(GETTEXT_FOUND)
if(HAVE_LOCALIZATION)
add_dependencies(${PROGRAM_NAME} language)
endif()
+3 -3
View File
@@ -15,7 +15,7 @@
#include "config.h"
#include "language.h"
#if GETTEXT_FOUND
#if HAVE_LOCALIZATION
# include <libintl.h>
#endif
@@ -24,7 +24,7 @@ std::vector<Anope::string> Language::Domains;
void Language::InitLanguages()
{
#if GETTEXT_FOUND
#if HAVE_LOCALIZATION
Log(LOG_DEBUG) << "Initializing Languages...";
Languages.clear();
@@ -73,7 +73,7 @@ const char *Language::Translate(const NickCore *nc, const char *string)
return Translate(nc ? nc->language.c_str() : "", string);
}
#if GETTEXT_FOUND
#if HAVE_LOCALIZATION
#if defined(__GLIBC__) && defined(__USE_GNU_GETTEXT)
extern "C" int _nl_msg_cat_cntr;
+3 -3
View File
@@ -11,7 +11,7 @@
#include "language.h"
#include "account.h"
#ifdef GETTEXT_FOUND
#ifdef HAVE_LOCALIZATION
# include <libintl.h>
#endif
@@ -39,7 +39,7 @@ Module::Module(const Anope::string &modname, const Anope::string &, ModType modt
ModuleManager::Modules.push_back(this);
#if GETTEXT_FOUND
#if HAVE_LOCALIZATION
for (unsigned i = 0; i < Language::Languages.size(); ++i)
{
/* Remove .UTF-8 or any other suffix */
@@ -75,7 +75,7 @@ Module::~Module()
if (it != ModuleManager::Modules.end())
ModuleManager::Modules.erase(it);
#if GETTEXT_FOUND
#if HAVE_LOCALIZATION
std::vector<Anope::string>::iterator dit = std::find(Language::Domains.begin(), Language::Domains.end(), this->name);
if (dit != Language::Domains.end())
Language::Domains.erase(dit);
+1 -1
View File
@@ -29,7 +29,7 @@
# define DllExport __declspec(dllimport)
#endif
#if GETTEXT_FOUND
#if HAVE_LOCALIZATION
/* Undefine some functions libintl defines */
# undef snprintf
# undef vsnprintf