diff --git a/Fwk/VizFwk/CMakeLists.txt b/Fwk/VizFwk/CMakeLists.txt index a799c645e1..ac730c592b 100644 --- a/Fwk/VizFwk/CMakeLists.txt +++ b/Fwk/VizFwk/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12) project(VizFramework) diff --git a/Fwk/VizFwk/LibGuiQt/CMakeLists.txt b/Fwk/VizFwk/LibGuiQt/CMakeLists.txt index b699af4960..ebbbbd2f2e 100644 --- a/Fwk/VizFwk/LibGuiQt/CMakeLists.txt +++ b/Fwk/VizFwk/LibGuiQt/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12) project(LibGuiQt) @@ -11,8 +11,13 @@ if (CMAKE_COMPILER_IS_GNUCXX) endif() -find_package(Qt4 REQUIRED) -include(${QT_USE_FILE}) +find_package(Qt5Core CONFIG QUIET) +if (Qt5Core_FOUND) + find_package(Qt5 CONFIG REQUIRED Core Gui OpenGL Widgets) +else() + find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) + include(${QT_USE_FILE}) +endif(Qt5Core_FOUND) set(CEE_HEADER_FILES cvfqtBasicAboutDialog.h @@ -41,6 +46,19 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ) +if ( NOT CMAKE_AUTOMOC ) + if (Qt5Core_FOUND) + qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) + + else() + qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) + endif() +endif() + +if (Qt5Core_FOUND) + set(QT_LIBRARIES Qt5::Core Qt5::OpenGL Qt5::Widgets) +endif() + target_link_libraries ( ${PROJECT_NAME} LibCore LibGeometry diff --git a/Fwk/VizFwk/TestApps/Qt/QtMinimal/CMakeLists.txt b/Fwk/VizFwk/TestApps/Qt/QtMinimal/CMakeLists.txt index 414d4f097e..3fd16a9df1 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtMinimal/CMakeLists.txt +++ b/Fwk/VizFwk/TestApps/Qt/QtMinimal/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12) project(QtMinimal) @@ -12,9 +12,17 @@ endif() find_package(OpenGL) -find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) -include(${QT_USE_FILE}) - +find_package(Qt5 CONFIG COMPONENTS Core) +if (Qt5Core_FOUND) + message(STATUS "Found Qt5") + find_package(Qt5 CONFIG REQUIRED Core Gui OpenGL Widgets) +else() + find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) + include(${QT_USE_FILE}) + if (QT4_FOUND) + message(STATUS "Found Qt4") + endif(QT4_FOUND) +endif(Qt5Core_FOUND) include_directories(${LibCore_SOURCE_DIR}) include_directories(${LibGeometry_SOURCE_DIR}) @@ -40,22 +48,36 @@ QMWidget.h # Run MOC on the headers add_definitions(-DCVF_USING_CMAKE) set(MOC_SOURCE_FILES) -qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) +if (Qt5Core_FOUND) + qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets) +else() + qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) +endif() + add_executable(${PROJECT_NAME} ${CEE_SOURCE_FILES} ${MOC_SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} ${CEE_LIBS} ${OPENGL_LIBRARIES} ${QT_LIBRARIES}) - -# Copy Qt Dlls -if (MSVC) - set (QTLIBLIST QtCore QtGui QtOpenGl) - foreach (qtlib ${QTLIBLIST}) - - # Debug - execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}d4.dll ${CMAKE_BINARY_DIR}/Debug/${qtlib}d4.dll) - - # Release - execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll ${CMAKE_BINARY_DIR}/Release/${qtlib}4.dll) - endforeach( qtlib ) -endif(MSVC) +if (Qt5Core_FOUND) + foreach (qtlib ${QT_LIBRARIES}) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + ) + endforeach(qtlib) + # Copy Qt Dlls +else() + # Copy Qt Dlls + if (MSVC) + set (QTLIBLIST QtCore QtGui QtOpenGl) + foreach (qtlib ${QTLIBLIST}) + + # Debug + execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}d4.dll ${CMAKE_BINARY_DIR}/Debug/${qtlib}d4.dll) + + # Release + execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll ${CMAKE_BINARY_DIR}/Release/${qtlib}4.dll) + endforeach( qtlib ) + endif(MSVC) +endif(Qt5Core_FOUND) diff --git a/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMMain.cpp b/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMMain.cpp index 652c929743..5e7a334a62 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMMain.cpp +++ b/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMMain.cpp @@ -39,7 +39,12 @@ #include "QMMainWindow.h" -#include "QtGui/QApplication" +#include +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMMainWindow.h b/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMMainWindow.h index 8fd8db97db..56272b94ba 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMMainWindow.h +++ b/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMMainWindow.h @@ -40,6 +40,7 @@ #include "cvfObject.h" #include "cvfOpenGLContextGroup.h" +#include #if QT_VERSION >= 0x050000 #include #else diff --git a/Fwk/VizFwk/TestApps/Qt/QtMultiView/CMakeLists.txt b/Fwk/VizFwk/TestApps/Qt/QtMultiView/CMakeLists.txt index 56c1a44252..ca75302ae0 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtMultiView/CMakeLists.txt +++ b/Fwk/VizFwk/TestApps/Qt/QtMultiView/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12) project(QtMultiView) @@ -12,9 +12,18 @@ endif() find_package(OpenGL) -find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) -include(${QT_USE_FILE}) +find_package(Qt5 CONFIG COMPONENTS Core) +if (Qt5Core_FOUND) + message(STATUS "Found Qt5") + find_package(Qt5 CONFIG REQUIRED Core Gui OpenGL Widgets) +else() + find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) + include(${QT_USE_FILE}) + if (QT4_FOUND) + message(STATUS "Found Qt4") + endif(QT4_FOUND) +endif(Qt5Core_FOUND) include_directories(${LibCore_SOURCE_DIR}) include_directories(${LibGeometry_SOURCE_DIR}) @@ -42,10 +51,34 @@ QMVWidget.h # Run MOC on the headers add_definitions(-DCVF_USING_CMAKE) set(MOC_SOURCE_FILES) -qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) - +if (Qt5Core_FOUND) + qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets) +else() + qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) +endif() add_executable(${PROJECT_NAME} ${CEE_SOURCE_FILES} ${MOC_SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} ${CEE_LIBS} ${OPENGL_LIBRARIES} ${QT_LIBRARIES}) - +if (Qt5Core_FOUND) + foreach (qtlib ${QT_LIBRARIES}) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + ) + endforeach(qtlib) + # Copy Qt Dlls +else() + # Copy Qt Dlls + if (MSVC) + set (QTLIBLIST QtCore QtGui QtOpenGl) + foreach (qtlib ${QTLIBLIST}) + + # Debug + execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}d4.dll ${CMAKE_BINARY_DIR}/Debug/${qtlib}d4.dll) + + # Release + execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll ${CMAKE_BINARY_DIR}/Release/${qtlib}4.dll) + endforeach( qtlib ) + endif(MSVC) +endif(Qt5Core_FOUND) \ No newline at end of file diff --git a/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVMain.cpp b/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVMain.cpp index 883cc51efe..fe9aac16e9 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVMain.cpp +++ b/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVMain.cpp @@ -39,7 +39,11 @@ #include "QMVMainWindow.h" -#include "QtGui/QApplication" +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif #include "QtOpenGL/qgl.h" diff --git a/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVMainWindow.h b/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVMainWindow.h index 0df049da41..e92294926e 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVMainWindow.h +++ b/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVMainWindow.h @@ -41,8 +41,9 @@ #include "cvfCollection.h" #include "cvfDrawableGeo.h" +#include #if QT_VERSION >= 0x050000 -#include #else #include #endif diff --git a/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/CMakeLists.txt b/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/CMakeLists.txt index 64f32e8be2..7bea23733d 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/CMakeLists.txt +++ b/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12) project(QtSnippetRunner) @@ -12,9 +12,17 @@ endif() find_package(OpenGL) -find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) -include(${QT_USE_FILE}) - +find_package(Qt5 CONFIG COMPONENTS Core) +if (Qt5Core_FOUND) + message(STATUS "Found Qt5") + find_package(Qt5 CONFIG REQUIRED Core Gui OpenGL Widgets) +else() + find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) + include(${QT_USE_FILE}) + if (QT4_FOUND) + message(STATUS "Found Qt4") + endif(QT4_FOUND) +endif(Qt5Core_FOUND) include_directories(${LibCore_SOURCE_DIR}) include_directories(${LibGeometry_SOURCE_DIR}) @@ -24,7 +32,7 @@ include_directories(${LibGuiQt_SOURCE_DIR}) include_directories(${LibUtilities_SOURCE_DIR}) include_directories(${SnippetsBasis_SOURCE_DIR}) -set(CEE_LIBS SnippetsBasis freetype LibFreeType LibUtilities LibGuiQt LibViewing LibRender LibGeometry LibIo LibCore) +set(CEE_LIBS SnippetsBasis freetype LibFreeType LibUtilities LibGuiQt LibViewing LibRender LibGeometry LibIo LibCore opengl32) include_directories(${SnippetsModules_SOURCE_DIR}) set(CEE_LIBS LibStructGrid ${CEE_LIBS}) @@ -52,10 +60,35 @@ QSRSnippetWidget.h # Run MOC on the headers add_definitions(-DCVF_USING_CMAKE) set(MOC_SOURCE_FILES) -qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) +if (Qt5Core_FOUND) + qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets) +else() + qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) +endif() add_executable(${PROJECT_NAME} ${CEE_SOURCE_FILES} ${MOC_SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} ${CEE_LIBS} ${OPENGL_LIBRARIES} ${QT_LIBRARIES}) - +if (Qt5Core_FOUND) + foreach (qtlib ${QT_LIBRARIES}) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + ) + endforeach(qtlib) + # Copy Qt Dlls +else() + # Copy Qt Dlls + if (MSVC) + set (QTLIBLIST QtCore QtGui QtOpenGl) + foreach (qtlib ${QTLIBLIST}) + + # Debug + execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}d4.dll ${CMAKE_BINARY_DIR}/Debug/${qtlib}d4.dll) + + # Release + execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll ${CMAKE_BINARY_DIR}/Release/${qtlib}4.dll) + endforeach( qtlib ) + endif(MSVC) +endif(Qt5Core_FOUND) diff --git a/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRMainWindow.cpp b/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRMainWindow.cpp index efd01f62f1..09de80fe8b 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRMainWindow.cpp +++ b/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRMainWindow.cpp @@ -539,11 +539,11 @@ void QSRMainWindow::slotSaveFrameBufferToFile() if (img.save(fileName)) { - cvf::Trace::show("Image saved to: %s", (const char*)fileName.toAscii()); + cvf::Trace::show("Image saved to: %s", (const char*)fileName.toLatin1()); } else { - cvf::Trace::show("FAILED to saved image: %s", (const char*)fileName.toAscii()); + cvf::Trace::show("FAILED to saved image: %s", (const char*)fileName.toLatin1()); } } diff --git a/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRMainWindow.h b/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRMainWindow.h index 16d08a3bcb..ac5b6e81a1 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRMainWindow.h +++ b/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRMainWindow.h @@ -45,6 +45,7 @@ #include "cvfuTestSnippet.h" #include "cvfuSnippetFactory.h" +#include #if QT_VERSION >= 0x050000 #include #else diff --git a/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRRunPanel.h b/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRRunPanel.h index a8f89ecdd7..47d6918210 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRRunPanel.h +++ b/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRRunPanel.h @@ -43,6 +43,7 @@ #include "cvfuSnippetFactory.h" +#include #if QT_VERSION >= 0x050000 #include #else diff --git a/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRStdInclude.h b/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRStdInclude.h index e34f5d30e0..c25fd79d5b 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRStdInclude.h +++ b/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRStdInclude.h @@ -1,6 +1,14 @@ #pragma once +#include +#include +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif + #include "cvfLibCore.h" #include "cvfLibRender.h" #include "cvfLibGeometry.h" @@ -10,12 +18,7 @@ #include "cvfuSnippetFactory.h" #include "cvfuInputEvents.h" -#include -#if QT_VERSION >= 0x050000 -#include -#else -#include -#endif + // Introduce name of commonly used classes (that are unlikely to create clashes) from the cvf namespace. // We allow the use of using-declarations in this include file since its sole usage is as a precompiled header file. using cvf::ref; diff --git a/Fwk/VizFwk/Tests/LibGuiQt_UnitTests/CMakeLists.txt b/Fwk/VizFwk/Tests/LibGuiQt_UnitTests/CMakeLists.txt index c5ab76c437..b1f02d39cf 100644 --- a/Fwk/VizFwk/Tests/LibGuiQt_UnitTests/CMakeLists.txt +++ b/Fwk/VizFwk/Tests/LibGuiQt_UnitTests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12) project(LibGuiQt_UnitTests) @@ -7,8 +7,17 @@ project(LibGuiQt_UnitTests) find_package(OpenGL) -find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) -include(${QT_USE_FILE}) +find_package(Qt5 CONFIG COMPONENTS Core) +if (Qt5Core_FOUND) + message(STATUS "Found Qt5") + find_package(Qt5 CONFIG REQUIRED Core OpenGL Widgets) +else() + find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) + include(${QT_USE_FILE}) + if (QT4_FOUND) + message(STATUS "Found Qt4") + endif(QT4_FOUND) +endif(Qt5Core_FOUND) include_directories(${LibCore_SOURCE_DIR}) include_directories(${LibIo_SOURCE_DIR}) @@ -27,6 +36,11 @@ cvfqtUtils-Test.cpp LibGuiQt_UnitTests.cpp ) +if (Qt5Core_FOUND) + set(QT_LIBRARIES Qt5::Core Qt5::OpenGL Qt5::Widgets) +endif(Qt5Core_FOUND) + + add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) add_executable(${PROJECT_NAME} ${CEE_SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} ${CEE_LIBS} ${OPENGL_LIBRARIES} ${QT_LIBRARIES} ${CEE_PLATFORM_LIBS}) diff --git a/Fwk/VizFwk/Tests/LibGuiQt_UnitTests/cvfqtUtils-Test.cpp b/Fwk/VizFwk/Tests/LibGuiQt_UnitTests/cvfqtUtils-Test.cpp index 07f7f48c7f..87b661a0ab 100644 --- a/Fwk/VizFwk/Tests/LibGuiQt_UnitTests/cvfqtUtils-Test.cpp +++ b/Fwk/VizFwk/Tests/LibGuiQt_UnitTests/cvfqtUtils-Test.cpp @@ -51,7 +51,7 @@ TEST(UtilsTest, toQString) const cvf::String str("abc"); QString qStr = cvfqt::Utils::toQString(str); - EXPECT_STREQ(str.toAscii().ptr(), (const char*)qStr.toAscii()); + EXPECT_STREQ(str.toAscii().ptr(), (const char*)qStr.toLatin1()); }