[rkward/frameworks] /: More fixes and workarouns for MSVC
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Sat Feb 27 12:28:44 UTC 2016
Git commit 65e31c10edc5ce5945114cdfe1bf302b74ef1187 by Thomas Friedrichsmeier.
Committed on 27/02/2016 at 12:28.
Pushed by tfry into branch 'frameworks'.
More fixes and workarouns for MSVC
M +14 -6 CMakeLists.txt
M +1 -1 rkward/CMakeLists.txt
M +2 -1 rkward/main.cpp
M +1 -1 rkward/rbackend/CMakeLists.txt
http://commits.kde.org/rkward/65e31c10edc5ce5945114cdfe1bf302b74ef1187
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 68b29bb..99e01c8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,13 +22,21 @@ INCLUDE(FeatureSummary)
FIND_PACKAGE(Qt5 5.2 CONFIG REQUIRED COMPONENTS Widgets Core Xml Network WebKit Script PrintSupport)
FIND_PACKAGE(KF5 5.2 REQUIRED COMPONENTS CoreAddons DocTools I18n XmlGui TextEditor WidgetsAddons WebKit Parts Config Notifications WindowSystem)
FIND_PACKAGE(Gettext REQUIRED)
-if("${CMAKE_VERSION}" VERSION_GREATER 3.2.3)
- FIND_PACKAGE(Intl REQUIRED)
+
+# FindIntl in cmake is broken for MSVC on Windows, (and only included from 3.2.3 upwards).
+# Borrowing some code from ki18n instead (originally BSD licensed, copyright Copyright 2014 Alex Richardson <arichardson.kde at gmail.com>)
+FIND_PATH(LibIntl_INCLUDE_DIRS NAMES libintl.h)
+FIND_LIBRARY(LibIntl_LIBRARIES NAMES intl libintl)
+INCLUDE(CheckCXXSymbolExists)
+CHECK_CXX_SYMBOL_EXISTS(dngettext libintl.h LibIntl_SYMBOL_FOUND)
+INCLUDE(FindPackageHandleStandardArgs)
+IF(LibIntl_SYMBOL_FOUND)
+ MESSAGE(STATUS "libintl is part of libc, no extra library is required.")
+ SET(LibIntl_LIBRARIES "")
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibIntl REQUIRED_VARS LibIntl_INCLUDE_DIRS)
ELSE()
-# Note: this may or may not work (it does not on Windows), but is worth a try:
- IF(NOT ${Intl_LIBRARIES})
- SET(Intl_LIBRARIES ${GETTEXT_LIBRARIES})
- ENDIF(NOT ${Intl_LIBRARIES})
+ MESSAGE(STATUS "libintl is a separate library.")
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibIntl REQUIRED_VARS LibIntl_INCLUDE_DIRS LibIntl_LIBRARIES)
ENDIF()
IF(FORCE_PRETTY_MAKEFILE)
diff --git a/rkward/CMakeLists.txt b/rkward/CMakeLists.txt
index ce41c8c..03e69ce 100644
--- a/rkward/CMakeLists.txt
+++ b/rkward/CMakeLists.txt
@@ -53,7 +53,7 @@ IF(Q_WS_MAC)
@ONLY)
ENDIF(Q_WS_MAC)
-TARGET_LINK_LIBRARIES(rkward.frontend windows ${RKWARD_ADDLIBS} agents dialogs plugin settings dataeditor core scriptbackends rbackend misc KF5::WindowSystem Qt5::Widgets KF5::XmlGui ${Intl_LIBRARIES})
+TARGET_LINK_LIBRARIES(rkward.frontend windows ${RKWARD_ADDLIBS} agents dialogs plugin settings dataeditor core scriptbackends rbackend misc KF5::WindowSystem Qt5::Widgets KF5::XmlGui ${LibIntl_LIBRARIES})
# wrapper executable
GET_DIRECTORY_PROPERTY(R_EXECUTABLE DIRECTORY rbackend DEFINITION R_EXECUTABLE)
diff --git a/rkward/main.cpp b/rkward/main.cpp
index 5fbc4d6..67f0e2e 100644
--- a/rkward/main.cpp
+++ b/rkward/main.cpp
@@ -124,7 +124,7 @@ int main (int argc, char *argv[]) {
// before initializing the commandline args, remove the ".bin" from "rkward.bin".
// This is so it prints "Usage rkward..." instead of "Usage rkward.bin...", etc.
// it seems safest to keep a copy, since the shell still owns argv
- char *argv_copy[argc];
+ char **argv_copy = new char*[argc];
argv_copy[0] = qstrdup (QString (argv[0]).remove (".frontend").replace (".exe", ".bat").toLocal8Bit ());
for (int i = 1; i < argc; ++i) {
argv_copy[i] = argv[i];
@@ -217,6 +217,7 @@ int main (int argc, char *argv[]) {
qInstallMessageHandler (0);
RKSettingsModuleDebug::debug_file->close ();
+ delete argv_copy;
return status;
}
diff --git a/rkward/rbackend/CMakeLists.txt b/rkward/rbackend/CMakeLists.txt
index c6b6937..52a9fe0 100644
--- a/rkward/rbackend/CMakeLists.txt
+++ b/rkward/rbackend/CMakeLists.txt
@@ -56,7 +56,7 @@ SET (
ADD_DEFINITIONS (-DRKWARD_SPLIT_PROCESS)
LINK_DIRECTORIES(${R_SHAREDLIBDIR})
ADD_EXECUTABLE(rkward.rbackend ${rbackend_BACKEND_SRCS})
-TARGET_LINK_LIBRARIES(rkward.rbackend rkgraphicsdevice.backend ${R_USED_LIBS} ${CMAKE_THREAD_LIBS_INIT} Qt5::Network Qt5::Core ${Intl_LIBRARIES} )
+TARGET_LINK_LIBRARIES(rkward.rbackend rkgraphicsdevice.backend ${R_USED_LIBS} ${CMAKE_THREAD_LIBS_INIT} Qt5::Network Qt5::Core ${LibIntl_LIBRARIES})
IF(WIN32)
# on Widows, we install to the rbackend subdirectory, because 1) LIBEXEC_INSTALL_DIR == BIN_INSTALL_DIR and 2) we don't want the backend to pick up
More information about the rkward-tracker
mailing list