mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3754 Support both Qt4 and Qt5 in Ceevis build.
This commit is contained in:
parent
237623ef21
commit
a7e76679e1
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
project(VizFramework)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 $<TARGET_FILE:${qtlib}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
|
||||
)
|
||||
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)
|
||||
|
@ -39,7 +39,12 @@
|
||||
|
||||
#include "QMMainWindow.h"
|
||||
|
||||
#include "QtGui/QApplication"
|
||||
#include <QtGlobal>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QApplication>
|
||||
#else
|
||||
#include <QtGui/QApplication>
|
||||
#endif
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "cvfObject.h"
|
||||
#include "cvfOpenGLContextGroup.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QMainWindow>
|
||||
#else
|
||||
|
@ -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 $<TARGET_FILE:${qtlib}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
|
||||
)
|
||||
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)
|
@ -39,7 +39,11 @@
|
||||
|
||||
#include "QMVMainWindow.h"
|
||||
|
||||
#include "QtGui/QApplication"
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QApplication>
|
||||
#else
|
||||
#include <QtGui/QApplication>
|
||||
#endif
|
||||
#include "QtOpenGL/qgl.h"
|
||||
|
||||
|
||||
|
@ -41,8 +41,9 @@
|
||||
#include "cvfCollection.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QMainWindow
|
||||
#include <QMainWindow>
|
||||
#else
|
||||
#include <QtGui/QMainWindow>
|
||||
#endif
|
||||
|
@ -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 $<TARGET_FILE:${qtlib}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
|
||||
)
|
||||
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)
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "cvfuTestSnippet.h"
|
||||
#include "cvfuSnippetFactory.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QMainWindow>
|
||||
#else
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "cvfuSnippetFactory.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QWidget>
|
||||
#else
|
||||
|
@ -1,6 +1,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <glew/GL/glew.h>
|
||||
#include <QtCore/QtCore>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QtWidgets>
|
||||
#else
|
||||
#include <QtGui/QtGui>
|
||||
#endif
|
||||
|
||||
#include "cvfLibCore.h"
|
||||
#include "cvfLibRender.h"
|
||||
#include "cvfLibGeometry.h"
|
||||
@ -10,12 +18,7 @@
|
||||
#include "cvfuSnippetFactory.h"
|
||||
#include "cvfuInputEvents.h"
|
||||
|
||||
#include <QtCore/QtCore>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QtWidgets>
|
||||
#else
|
||||
#include <QtGui/QtGui>
|
||||
#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;
|
||||
|
@ -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})
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user