Skip to content

Commit

Permalink
Merge pull request #378 from wwmayer/qt5_port
Browse files Browse the repository at this point in the history
Qt5 port
  • Loading branch information
wwmayer committed Dec 14, 2016
2 parents 411e30b + deddc4b commit e5c6bf5
Show file tree
Hide file tree
Showing 33 changed files with 491 additions and 119 deletions.
89 changes: 58 additions & 31 deletions CMakeLists.txt
Expand Up @@ -70,6 +70,9 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION)
OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION)
ENDIF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION)

# Switch to build FreeCAD with Qt5
OPTION(BUILD_QT5 "Build with Qt5." OFF)

# Enabled C++11 for Freecad 0.17 and later
IF(FREECAD_VERSION VERSION_GREATER 0.16)
OPTION(BUILD_ENABLE_CXX11 "Enable C++11 support." ON)
Expand Down Expand Up @@ -674,41 +677,65 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

# -------------------------------- Qt --------------------------------

# sets ${QT_LIBRARIES}

# If using MacPorts, help the Qt4 finder.
if(MACPORTS_PREFIX)
if(NOT QT_QMAKE_EXECUTABLE)
set(QT_QMAKE_EXECUTABLE ${MACPORTS_PREFIX}/libexec/qt4/bin/qmake)
if (NOT BUILD_QT5)
# If using MacPorts, help the Qt4 finder.
if(MACPORTS_PREFIX)
if(NOT QT_QMAKE_EXECUTABLE)
set(QT_QMAKE_EXECUTABLE ${MACPORTS_PREFIX}/libexec/qt4/bin/qmake)
endif()
endif()
endif()

SET(QT_MIN_VERSION 4.5.0)
set(QT_USE_QTNETWORK TRUE)
set(QT_USE_QTXML TRUE)
if(BUILD_GUI)
set(QT_USE_QTOPENGL TRUE)
set(QT_USE_QTSVG TRUE)
set(QT_USE_QTUITOOLS TRUE)
set(QT_USE_QTWEBKIT TRUE)
endif(BUILD_GUI)

find_package(Qt4)# REQUIRED

include(${QT_USE_FILE})

IF(NOT QT4_FOUND)
MESSAGE(FATAL_ERROR "========================\n"
"Qt4 libraries not found.\n"
"========================\n")
ENDIF(NOT QT4_FOUND)
SET(QT_MIN_VERSION 4.5.0)
set(QT_USE_QTNETWORK TRUE)
set(QT_USE_QTXML TRUE)
if(BUILD_GUI)
set(QT_USE_QTOPENGL TRUE)
set(QT_USE_QTSVG TRUE)
set(QT_USE_QTUITOOLS TRUE)
set(QT_USE_QTWEBKIT TRUE)
endif(BUILD_GUI)

find_package(Qt4)# REQUIRED

include(${QT_USE_FILE})

IF(NOT QT4_FOUND)
MESSAGE(FATAL_ERROR "========================\n"
"Qt4 libraries not found.\n"
"========================\n")
ENDIF(NOT QT4_FOUND)

IF(NOT QT_QTWEBKIT_FOUND)
MESSAGE("========================================================\n"
"Qt Webkit not found, will not build browser integration.\n"
"========================================================\n")
ENDIF(NOT QT_QTWEBKIT_FOUND)

elseif (BUILD_QT5)
find_package(Qt5Network)
find_package(Qt5Xml)
if(BUILD_GUI)
find_package(Qt5Widgets)
find_package(Qt5PrintSupport)
find_package(Qt5OpenGL)
find_package(Qt5Svg)
find_package(Qt5UiTools)
find_package(Qt5Network)
find_package(Qt5Concurrent)
if (NOT WIN32)
# Disable for Windows for now since building the Qt sources always fails
find_package(Qt5WebKitWidgets)
endif()
endif(BUILD_GUI)

IF(NOT QT_QTWEBKIT_FOUND)
MESSAGE("========================================================\n"
"Qt Webkit not found, will not build browser integration.\n"
"========================================================\n")
ENDIF(NOT QT_QTWEBKIT_FOUND)
IF(NOT Qt5Core_FOUND)
MESSAGE(FATAL_ERROR "========================\n"
"Qt5 libraries not found.\n"
"========================\n")
ENDIF(NOT Qt5Core_FOUND)

include(Qt4Macros)
endif (NOT BUILD_QT5)

# This is a special version of the built in macro qt4_wrap_cpp
# It is required since moc'ed files are now included instead of being added to projects directly
Expand Down
17 changes: 17 additions & 0 deletions src/App/CMakeLists.txt
Expand Up @@ -50,6 +50,23 @@ set(FreeCADApp_LIBS
${QT_QTXML_LIBRARY}
)

if (BUILD_QT5)
include_directories(
${Qt5Xml_INCLUDE_DIRS}
)
list(APPEND FreeCADApp_LIBS
${Qt5Core_LIBRARIES}
${Qt5Xml_LIBRARIES}
)
else()
include_directories(
${QT_QTCORE_INCLUDE_DIR}
)
list(APPEND FreeCADApp_LIBS
${QT_QTCORE_LIBRARY}
)
endif()

generate_from_xml(DocumentPy)
generate_from_xml(DocumentObjectPy)
generate_from_xml(ExtensionPy)
Expand Down
17 changes: 13 additions & 4 deletions src/Base/CMakeLists.txt
Expand Up @@ -12,7 +12,6 @@ include_directories(
${Boost_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
${XercesC_INCLUDE_DIRS}
${QT_QTCORE_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${PYCXX_INCLUDE_DIR}
)
Expand All @@ -23,7 +22,6 @@ if(MSVC)
${PYTHON_LIBRARIES}
debug ${XercesC_DEBUG_LIBRARIES}
optimized ${XercesC_LIBRARIES}
${QT_QTCORE_LIBRARY}
${ZLIB_LIBRARIES}
debug MSVCRTD.LIB
debug MSVCPRTD.LIB
Expand All @@ -36,7 +34,6 @@ elseif(MINGW)
set(FreeCADBase_LIBS
${PYTHON_LIBRARIES}
${XercesC_LIBRARIES}
${QT_QTCORE_LIBRARY}
${Boost_LIBRARIES}
${ZLIB_LIBRARIES}
Rpcrt4.lib
Expand All @@ -45,12 +42,23 @@ else(MSVC)
set(FreeCADBase_LIBS
${PYTHON_LIBRARIES}
${XercesC_LIBRARIES}
${QT_QTCORE_LIBRARY}
${Boost_LIBRARIES}
${ZLIB_LIBRARIES}
)
endif(MSVC)

if (BUILD_QT5)
include_directories(
${Qt5Core_INCLUDE_DIRS}
)
list(APPEND FreeCADBase_LIBS ${Qt5Core_LIBRARIES})
else()
include_directories(
${QT_QTCORE_INCLUDE_DIR}
)
list(APPEND FreeCADBase_LIBS ${QT_QTCORE_LIBRARY})
endif()

# needed for OpenSUSE
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
list(APPEND FreeCADBase_LIBS -lutil -ldl)
Expand Down Expand Up @@ -148,6 +156,7 @@ set(FreeCADBase_MOC_HDRS
Debugger.h
FutureWatcherProgress.h
)

fc_wrap_cpp(FreeCADBase_MOC_SRCS ${FreeCADBase_MOC_HDRS})

SET(FreeCADBase_UNITAPI_SRCS
Expand Down
34 changes: 29 additions & 5 deletions src/Gui/Application.cpp
Expand Up @@ -1387,11 +1387,38 @@ _qt_msg_handler_old old_qtmsg_handler = 0;
#if QT_VERSION >= 0x050000
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &qmsg)
{
Q_UNUSED(context);
const QChar *msg = qmsg.unicode();
#ifdef FC_DEBUG
switch (type)
{
case QtInfoMsg:
case QtDebugMsg:
Base::Console().Message("%s\n", msg);
break;
case QtWarningMsg:
Base::Console().Warning("%s\n", msg);
break;
case QtCriticalMsg:
Base::Console().Error("%s\n", msg);
break;
case QtFatalMsg:
Base::Console().Error("%s\n", msg);
abort(); // deliberately core dump
}
#ifdef FC_OS_WIN32
if (old_qtmsg_handler)
(*old_qtmsg_handler)(type, context, qmsg);
#endif
#else
// do not stress user with Qt internals but write to log file if enabled
Q_UNUSED(type);
Base::Console().Log("%s\n", msg);
#endif
}
#else
void messageHandler(QtMsgType type, const char *msg)
{
#endif
#ifdef FC_DEBUG
switch (type)
{
Expand All @@ -1410,18 +1437,15 @@ void messageHandler(QtMsgType type, const char *msg)
}
#ifdef FC_OS_WIN32
if (old_qtmsg_handler)
#if QT_VERSION >=0x050000
(*old_qtmsg_handler)(type, context, qmsg);
#else
(*old_qtmsg_handler)(type, msg);
#endif
#endif
#else
// do not stress user with Qt internals but write to log file if enabled
Q_UNUSED(type);
Base::Console().Log("%s\n", msg);
#endif
}
#endif

#ifdef FC_DEBUG // redirect Coin messages to FreeCAD
void messageHandlerCoin(const SoError * error, void * /*userdata*/)
Expand Down

0 comments on commit e5c6bf5

Please sign in to comment.