Fixed: Compilation of object_viewer_qt with Qt 5

This commit is contained in:
kervala 2016-01-06 12:33:05 +01:00
parent 6ed0ec2bc8
commit 91c7db45c3
4 changed files with 64 additions and 22 deletions

View file

@ -181,13 +181,14 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
IF(WITH_QT) IF(WITH_QT)
OPTION(WITH_STUDIO "Build Core Studio" OFF ) OPTION(WITH_STUDIO "Build Core Studio" OFF )
ENDIF(WITH_QT) ENDIF(WITH_QT)
### ###
# Features # Features
### ###
OPTION(WITH_LOGGING "With Logging" ON ) OPTION(WITH_LOGGING "With Logging" ON )
OPTION(WITH_COVERAGE "With Code Coverage Support" OFF) OPTION(WITH_COVERAGE "With Code Coverage Support" OFF)
OPTION(WITH_PCH "With Precompiled Headers" ON ) OPTION(WITH_PCH "With Precompiled Headers" ON )
OPTION(WITH_LOW_MEMORY "With low memory (use the least of RAM)" OFF)
OPTION(FINAL_VERSION "Build in Final Version mode" ON ) OPTION(FINAL_VERSION "Build in Final Version mode" ON )
# Default to static building on Windows. # Default to static building on Windows.
@ -226,7 +227,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON ) OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON )
OPTION(WITH_ASSIMP "Use assimp exporter" OFF) OPTION(WITH_ASSIMP "Use assimp exporter" OFF)
### ###
# GUI toolkits # GUI toolkits
### ###
@ -295,10 +296,10 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
OPTION(WITH_LIBOVR "With LibOVR support" OFF) OPTION(WITH_LIBOVR "With LibOVR support" OFF)
OPTION(WITH_LIBVR "With LibVR support" OFF) OPTION(WITH_LIBVR "With LibVR support" OFF)
OPTION(WITH_PERFHUD "With NVIDIA PerfHUD support" OFF) OPTION(WITH_PERFHUD "With NVIDIA PerfHUD support" OFF)
OPTION(WITH_SSE2 "With SSE2" ON ) OPTION(WITH_SSE2 "With SSE2" ON )
OPTION(WITH_SSE3 "With SSE3" ON ) OPTION(WITH_SSE3 "With SSE3" ON )
IF(NOT MSVC) IF(NOT MSVC)
OPTION(WITH_GCC_FPMATH_BOTH "With GCC -mfpmath=both" OFF) OPTION(WITH_GCC_FPMATH_BOTH "With GCC -mfpmath=both" OFF)
ENDIF(NOT MSVC) ENDIF(NOT MSVC)
@ -373,7 +374,7 @@ MACRO(NL_SETUP_BUILD)
ELSEIF(HOST_CPU MATCHES "i.86") ELSEIF(HOST_CPU MATCHES "i.86")
SET(HOST_CPU "x86") SET(HOST_CPU "x86")
ENDIF(HOST_CPU MATCHES "(amd|AMD)64") ENDIF(HOST_CPU MATCHES "(amd|AMD)64")
# Determine target CPU # Determine target CPU
# If not specified, use the same CPU as host # If not specified, use the same CPU as host
@ -808,7 +809,11 @@ MACRO(NL_SETUP_BUILD)
ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64") ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
ENDIF(APPLE) ENDIF(APPLE)
ADD_PLATFORM_FLAGS("-D_REENTRANT -pipe -fno-strict-aliasing") ADD_PLATFORM_FLAGS("-D_REENTRANT -fno-strict-aliasing")
IF(NOT WITH_LOW_MEMORY)
ADD_PLATFORM_FLAGS("-pipe")
ENDIF()
IF(WITH_COVERAGE) IF(WITH_COVERAGE)
ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage") ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage")
@ -1083,7 +1088,7 @@ MACRO(SETUP_EXTERNAL)
ENDIF(APPLE) ENDIF(APPLE)
ENDIF(WIN32) ENDIF(WIN32)
# Android and iOS have pthread # Android and iOS have pthread
IF(ANDROID OR IOS) IF(ANDROID OR IOS)
SET(CMAKE_USE_PTHREADS_INIT 1) SET(CMAKE_USE_PTHREADS_INIT 1)
SET(Threads_FOUND TRUE) SET(Threads_FOUND TRUE)

View file

@ -2,18 +2,32 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${LIBXML2_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}
${NEL_INCLUDE_DIR} ${NEL_INCLUDE_DIR})
${QT_INCLUDES})
INCLUDE( ${QT_USE_FILE} ) ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
FILE(GLOB OBJECT_VIEWER_WIDGET_SRC *.cpp *.h) FILE(GLOB OBJECT_VIEWER_WIDGET_SRC *.cpp *.h)
SET(OBJECT_VIEWER_WIDGET_HDR object_viewer_widget.h) SET(OBJECT_VIEWER_WIDGET_HDR object_viewer_widget.h)
SET(QT_USE_QTGUI TRUE) IF(WITH_QT)
SET(QT_USE_QTOPENGL TRUE) INCLUDE_DIRECTORIES(${QT_INCLUDES})
INCLUDE(${QT_USE_FILE})
QT4_WRAP_CPP( OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR} ) SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE)
QT4_WRAP_CPP(OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR})
ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_SHARED)
#ADD_DEFINITIONS(-DQT_NO_DEBUG)
SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY})
ELSE()
QT5_WRAP_CPP(OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR})
ENDIF()
SOURCE_GROUP(QtGeneratedMocSrc FILES ${OBJECT_VIEWER_WIDGET_MOC_SRCS}) SOURCE_GROUP(QtGeneratedMocSrc FILES ${OBJECT_VIEWER_WIDGET_MOC_SRCS})
@ -24,19 +38,13 @@ ADD_LIBRARY(object_viewer_widget_qt MODULE
TARGET_LINK_LIBRARIES(object_viewer_widget_qt TARGET_LINK_LIBRARIES(object_viewer_widget_qt
nelmisc nelmisc
nel3d nel3d
${QT_LIBRARIES} ${QT_LIBRARIES})
${QT_QTOPENGL_LIBRARY})
ADD_DEFINITIONS(-DQT_NO_KEYWORDS ${LIBXML2_DEFINITIONS} ${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_SHARED)
#ADD_DEFINITIONS(-DQT_NO_DEBUG)
NL_DEFAULT_PROPS(object_viewer_widget_qt "NeL, Tools, 3D: Object Viewer Qt Widget") NL_DEFAULT_PROPS(object_viewer_widget_qt "NeL, Tools, 3D: Object Viewer Qt Widget")
NL_ADD_RUNTIME_FLAGS(object_viewer_widget_qt) NL_ADD_RUNTIME_FLAGS(object_viewer_widget_qt)
IF(WITH_PCH) IF(WITH_PCH)
ADD_NATIVE_PRECOMPILED_HEADER(object_viewer_widget_qt ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.h ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.cpp) ADD_NATIVE_PRECOMPILED_HEADER(object_viewer_widget_qt ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.h ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.cpp)
ENDIF(WITH_PCH) ENDIF()
#INSTALL(TARGETS object_viewer_widget_qt RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT runtime BUNDLE DESTINATION /Applications) #INSTALL(TARGETS object_viewer_widget_qt RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT runtime BUNDLE DESTINATION /Applications)

View file

@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "stdpch.h"
#include "object_viewer_widget.h" #include "object_viewer_widget.h"
// STL includes // STL includes
@ -46,7 +47,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Project includes // Project includes
#ifndef USE_QT5
Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget) Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget)
#endif
using namespace NLMISC; using namespace NLMISC;
using namespace NL3D; using namespace NL3D;

View file

@ -20,7 +20,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_STDPCH_H #ifndef NL_STDPCH_H
#define NL_STDPCH_H #define NL_STDPCH_H
#include <nel/misc/types_nl.h> #if defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#undef realloc
#undef free
#endif
#include <qglobal.h>
#ifdef Q_COMPILER_RVALUE_REFS
#undef Q_COMPILER_RVALUE_REFS
#endif
#include <QtCore/QtCore>
#include <QtGui/QtGui>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#define USE_QT5
#endif
#ifdef USE_QT5
#include <QtWidgets/QtWidgets>
#include <QtConcurrent/QtConcurrent>
#endif
#include <map> #include <map>
#include <memory> #include <memory>
@ -28,6 +53,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <string> #include <string>
#include <vector> #include <vector>
#include <nel/misc/types_nl.h>
#include <nel/misc/common.h> #include <nel/misc/common.h>
#endif #endif