summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--cmake/FindGettext.cmake26
-rw-r--r--include/sysconf.h.cmake4
-rw-r--r--language/CMakeLists.txt2
-rw-r--r--modules/CMakeLists.txt4
-rw-r--r--modules/third/language/CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt13
-rw-r--r--src/language.cpp6
-rw-r--r--src/module.cpp6
-rw-r--r--src/win32/anope_windows.h2
10 files changed, 31 insertions, 42 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 943d27458..486851dbc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/cmake/FindGettext.cmake b/cmake/FindGettext.cmake
deleted file mode 100644
index b0f4f9486..000000000
--- a/cmake/FindGettext.cmake
+++ /dev/null
@@ -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()
diff --git a/include/sysconf.h.cmake b/include/sysconf.h.cmake
index aa9cf866d..848df3f52 100644
--- a/include/sysconf.h.cmake
+++ b/include/sysconf.h.cmake
@@ -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
diff --git a/language/CMakeLists.txt b/language/CMakeLists.txt
index a5135a273..3c98d266a 100644
--- a/language/CMakeLists.txt
+++ b/language/CMakeLists.txt
@@ -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)
diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt
index 28fab4171..2d479c39b 100644
--- a/modules/CMakeLists.txt
+++ b/modules/CMakeLists.txt
@@ -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})
diff --git a/modules/third/language/CMakeLists.txt b/modules/third/language/CMakeLists.txt
index 835b4ee4f..b20982cfc 100644
--- a/modules/third/language/CMakeLists.txt
+++ b/modules/third/language/CMakeLists.txt
@@ -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)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d957fb6df..9c15c62dc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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()
diff --git a/src/language.cpp b/src/language.cpp
index 8c39941b4..219bf846c 100644
--- a/src/language.cpp
+++ b/src/language.cpp
@@ -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;
diff --git a/src/module.cpp b/src/module.cpp
index 2881c4e82..6c85284ce 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -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);
diff --git a/src/win32/anope_windows.h b/src/win32/anope_windows.h
index 71d2e35db..7417b0f23 100644
--- a/src/win32/anope_windows.h
+++ b/src/win32/anope_windows.h
@@ -29,7 +29,7 @@
# define DllExport __declspec(dllimport)
#endif
-#if GETTEXT_FOUND
+#if HAVE_LOCALIZATION
/* Undefine some functions libintl defines */
# undef snprintf
# undef vsnprintf