From 0a03d1c870758499288793f1d5f13b975497879d Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 25 Dec 2015 15:37:07 +0100 Subject: [PATCH] Merge with develop --- code/CMakeLists.txt | 81 +++++++++++-------- code/CMakeModules/PCHSupport.cmake | 25 +++--- code/nel/include/nel/misc/common.h | 3 + code/nel/src/3d/driver/opengl/CMakeLists.txt | 15 ++-- .../3d/driver/opengl/driver_opengl_window.cpp | 6 ++ code/nel/src/misc/common.cpp | 25 ++++++ .../tools/client/client_config_qt/main.cpp | 1 + .../tools/client/client_config_qt/system.cpp | 3 +- 8 files changed, 107 insertions(+), 52 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 7b8d1b670..35fa80538 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -220,41 +220,15 @@ IF(WITH_QT5) FIND_PACKAGE(Qt5LinguistTools) FIND_PACKAGE(Qt5Network) - SET(QT_LIBRARIES Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Xml) - IF(QT_STATIC) ADD_DEFINITIONS(-DQT_STATICPLUGIN) - # Core - IF(APPLE) - FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre) - - FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation) - FIND_LIBRARY(CARBON_FRAMEWORK Carbon) - FIND_LIBRARY(SECURITY_FRAMEWORK Security) - - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${PCRE_LIBRARY} - ${FOUNDATION_FRAMEWORK} - ${CARBON_FRAMEWORK} - ${SECURITY_FRAMEWORK}) - ENDIF() - - # Network - FIND_PACKAGE(OpenSSL REQUIRED) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) - - IF(WIN32) - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${WINSDK_LIBRARY_DIR}/Crypt32.lib - ${WINSDK_LIBRARY_DIR}/WS2_32.Lib) - ENDIF() - - SET(QT_LIBRARIES ${QT_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARY}) + SET(QT_LIBRARIES Qt5::Widgets) # Gui + SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Gui Qt5::OpenGL) + ADD_QT_LIBRARY(PrintSupport) - ADD_QT_LIBRARY(PlatformSupport) IF(WIN32) SET(QT_LIBRARIES ${QT_LIBRARIES} @@ -284,17 +258,21 @@ IF(WITH_QT5) ADD_QT_PLUGIN(printsupport cocoaprintersupport) ADD_QT_PLUGIN(platforms qcocoa) ELSE() - FIND_LIBRARY(OPENGL_LIBRARY GL) + ADD_QT_PLUGIN(platforms qxcb) + ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENGL_LIBRARY}) + ADD_QT_LIBRARY(XcbQpa) + ADD_QT_LIBRARY(PlatformSupport) + SET(QT_LIBRARIES ${QT_LIBRARIES} -lX11-xcb -lXi -lSM -lICE -lxcb) + SET(QT_LIBRARIES ${QT_LIBRARIES} "${QT_LIBRARY_DIR}/libxcb-static.a") + SET(QT_LIBRARIES ${QT_LIBRARIES} -lfontconfig) + ADD_QT_LIBRARY(DBus) ENDIF() ADD_QT_PLUGIN(imageformats qgif) ADD_QT_PLUGIN(imageformats qicns) ADD_QT_PLUGIN(imageformats qico) ADD_QT_PLUGIN(imageformats qjpeg) - ADD_QT_PLUGIN(imageformats qmng) - ADD_QT_PLUGIN(imageformats qwebp) # harfbuzz is needed since Qt 5.3 IF(UNIX) @@ -316,6 +294,25 @@ IF(WITH_QT5) SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIB}) ENDIF() + ADD_QT_PLUGIN(accessible qtaccessiblewidgets) + + SET(QT_LIBRARIES ${QT_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARY}) + + # Network + SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Network Qt5::Xml) + + FIND_PACKAGE(OpenSSL REQUIRED) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) + + IF(WIN32) + SET(QT_LIBRARIES ${QT_LIBRARIES} + ${WINSDK_LIBRARY_DIR}/Crypt32.lib + ${WINSDK_LIBRARY_DIR}/WS2_32.Lib) + ENDIF() + + # Core + SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Core) + # pcre is needed since Qt 5.5 IF(UNIX) SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a") @@ -326,7 +323,23 @@ IF(WITH_QT5) SET(QT_LIBRARIES ${QT_LIBRARIES} ${PCRE_LIB}) ENDIF() - ADD_QT_PLUGIN(accessible qtaccessiblewidgets) + IF(APPLE) + FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre) + + FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation) + FIND_LIBRARY(CARBON_FRAMEWORK Carbon) + FIND_LIBRARY(SECURITY_FRAMEWORK Security) + + SET(QT_LIBRARIES ${QT_LIBRARIES} + ${PCRE_LIBRARY} + ${FOUNDATION_FRAMEWORK} + ${CARBON_FRAMEWORK} + ${SECURITY_FRAMEWORK}) + ELSEIF(UNIX) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -ldl) + ENDIF() + ELSE() + SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core) ENDIF() ELSE() MESSAGE(WARNING "Unable to find Qt 5") diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index dafe72a5a..fa36fd008 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -145,19 +145,22 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) ENDFOREACH() ENDIF() - # Hack to define missing QT_NO_DEBUG with Qt 5.2 - IF(USE_QT5 AND _UPPER_BUILD STREQUAL "RELEASE") - LIST(APPEND GLOBAL_DEFINITIONS " -DQT_NO_DEBUG") - ENDIF() + # Special Qt 5 cases + IF(GLOBAL_DEFINITIONS MATCHES "QT_CORE_LIB") + # Hack to define missing QT_NO_DEBUG with Qt 5.2 + IF(_UPPER_BUILD STREQUAL "RELEASE") + LIST(APPEND GLOBAL_DEFINITIONS " -DQT_NO_DEBUG") + ENDIF() - # Qt5_POSITION_INDEPENDENT_CODE should be true if Qt was compiled with PIE - IF(Qt5_POSITION_INDEPENDENT_CODE AND GLOBAL_DEFINITIONS MATCHES "QT_CORE_LIB") - SET(_USE_PIE ON) - ENDIF() + # Qt5_POSITION_INDEPENDENT_CODE should be true if Qt was compiled with PIE + IF(Qt5_POSITION_INDEPENDENT_CODE) + SET(_USE_PIE ON) + ENDIF() - IF(_USE_PIE) - LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIE}") - LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIC}") + IF(_USE_PIE) + LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIE}") + LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIC}") + ENDIF() ENDIF() LIST(APPEND _FLAGS " ${GLOBAL_DEFINITIONS}") diff --git a/code/nel/include/nel/misc/common.h b/code/nel/include/nel/misc/common.h index c2a40cc0f..10f6a97e6 100644 --- a/code/nel/include/nel/misc/common.h +++ b/code/nel/include/nel/misc/common.h @@ -349,6 +349,9 @@ std::string formatThousands(const std::string& s); /// The program will be launched in the current directory bool launchProgram (const std::string &programName, const std::string &arguments, bool log = true); +/// This function executes a program and returns output as a string +std::string getCommandOutput(const std::string &command); + /// This function kills a program using his pid (on unix, it uses the kill() POSIX function) bool killProgram(uint32 pid); diff --git a/code/nel/src/3d/driver/opengl/CMakeLists.txt b/code/nel/src/3d/driver/opengl/CMakeLists.txt index 6d8efb929..18b4886ed 100644 --- a/code/nel/src/3d/driver/opengl/CMakeLists.txt +++ b/code/nel/src/3d/driver/opengl/CMakeLists.txt @@ -5,8 +5,11 @@ IF(NOT WIN32) FIND_LIBRARY(CARBON NAMES Carbon) FIND_LIBRARY(COCOA NAMES Cocoa) ELSE() + SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .so) FIND_PACKAGE(X11) FIND_PACKAGE(XF86VidMode) + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES}) ENDIF() ENDIF() @@ -71,12 +74,12 @@ IF(UNIX AND NOT APPLE) TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xext_LIB}) ENDIF() # libraries needed to be linked while linking to static X11 libraries - FIND_LIBRARY(XCB_LIBRARY - NAMES xcb - HINTS ${X11_LIB_SEARCH_PATH}) - IF(XCB_LIBRARY) - TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XCB_LIBRARY}) - ENDIF() +# FIND_LIBRARY(XCB_LIBRARY +# NAMES xcb +# HINTS ${X11_LIB_SEARCH_PATH}) +# IF(XCB_LIBRARY) +# TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XCB_LIBRARY}) +# ENDIF() ENDIF() IF(WITH_PCH) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 36ac67281..3c60da0c0 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -2058,6 +2058,12 @@ bool CDriverGL::getModes(std::vector &modes) #elif defined (NL_OS_UNIX) + if (!_dpy) + { + nlwarning("3D: Unable to list modes because Display is NULL, did you forget to call init() ?"); + return false; + } + bool found = false; int screen = DefaultScreen(_dpy); diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 8eca1d566..d2d2e5cb0 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -23,6 +23,10 @@ # include # include # include + +#define popen _popen +#define pclose _pclose + #elif defined NL_OS_MAC # include #elif defined NL_OS_UNIX @@ -32,6 +36,8 @@ # include #endif +#define MAX_LINE_WIDTH 256 + #include "nel/misc/command.h" #include "nel/misc/path.h" #include "nel/misc/i18n.h" @@ -840,6 +846,25 @@ bool launchProgram(const std::string &programName, const std::string &arguments, } +std::string getCommandOutput(const std::string &command) +{ + FILE *pipe = popen(command.c_str(), "r"); + + if (!pipe) return ""; + + char buffer[MAX_LINE_WIDTH]; + std::string result; + + while (!feof(pipe)) + { + if (fgets(buffer, MAX_LINE_WIDTH, pipe) != NULL) result += buffer; + } + + pclose(pipe); + + return result; +} + /* * Display the bits (with 0 and 1) composing a byte (from right to left) */ diff --git a/code/ryzom/tools/client/client_config_qt/main.cpp b/code/ryzom/tools/client/client_config_qt/main.cpp index 52d3cf7bb..f298426f7 100644 --- a/code/ryzom/tools/client/client_config_qt/main.cpp +++ b/code/ryzom/tools/client/client_config_qt/main.cpp @@ -31,6 +31,7 @@ Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) #elif defined(Q_OS_UNIX) Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) + Q_IMPORT_PLUGIN(QXcbGlxIntegrationPlugin) #endif #endif diff --git a/code/ryzom/tools/client/client_config_qt/system.cpp b/code/ryzom/tools/client/client_config_qt/system.cpp index 6070e4abd..8ef5a930b 100644 --- a/code/ryzom/tools/client/client_config_qt/system.cpp +++ b/code/ryzom/tools/client/client_config_qt/system.cpp @@ -145,6 +145,7 @@ void CSystem::GatherOpenGLInfo() try { NL3D::IDriver *driver = NL3D::CDRU::createGlDriver(); + driver->init(0); GetVideoModes( openglInfo.modes, driver ); driver->release(); } @@ -161,7 +162,7 @@ void CSystem::GetVideoModes( std::vector< CVideoMode > &dst, NL3D::IDriver *driv for( std::vector< NL3D::GfxMode >::iterator itr = modes.begin(); itr != modes.end(); ++itr ) { - if( ( itr->Width >= 800 ) && ( itr->Height >= 600 ) && ( itr->Depth == 32 ) && ( itr->Frequency >= 60 ) ) + if( ( itr->Width >= 800 ) && ( itr->Height >= 600 ) && ( itr->Depth >= 16 ) ) { CVideoMode mode; mode.depth = itr->Depth;