From 6691dca4ca7ea0a89210d1976f09da069b69d140 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 28 May 2019 14:11:08 +0200 Subject: [PATCH] #4448 Clean up ResInsight Qt5-checks --- ApplicationCode/CMakeLists.txt | 60 +++++++------------ .../WellPathImportSsihub/CMakeLists.txt | 40 ++++--------- CMakeLists.txt | 24 ++------ ThirdParty/Qwt/src/CMakeLists.txt | 23 +++---- ThirdParty/expressionparser/CMakeLists.txt | 10 ++-- ThirdParty/nightcharts/CMakeLists.txt | 11 ++-- 6 files changed, 53 insertions(+), 115 deletions(-) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index f76aa79436..551c01a0cd 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -5,19 +5,6 @@ project (ApplicationCode) # Open GL find_package( OpenGL ) -if (RESINSIGHT_BUILD_WITH_QT5) - find_package(Qt5 COMPONENTS Core QUIET) -endif(RESINSIGHT_BUILD_WITH_QT5) - -if (Qt5Core_FOUND) - find_package(Qt5 CONFIG REQUIRED Core Gui OpenGL Network Script Widgets) - set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Script Qt5::Widgets) -else() - set (QT_COMPONENTS_REQUIRED QtCore QtGui QtMain QtOpenGl QtNetwork QtScript) - find_package(Qt4 COMPONENTS ${QT_COMPONENTS_REQUIRED} REQUIRED) - include(${QT_USE_FILE}) -endif(Qt5Core_FOUND) - # NB: The generated file is written to Cmake binary folder to avoid source tree pollution # This folder is added to include_directories CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RiaVersionInfo.h.cmake @@ -98,6 +85,7 @@ list( APPEND CPP_SOURCES ${UNIT_TEST_FILES} ) +option(RESINSIGHT_ENABLE_GRPC "Enable the gRPC scripting framework" OFF) if (RESINSIGHT_ENABLE_GRPC) list( APPEND REFERENCED_CMAKE_FILES GrpcInterface/CMakeLists.cmake @@ -250,15 +238,6 @@ set ( QT_MOC_HEADERS SocketInterface/RiaSocketServer.h ) -if (Qt5Core_FOUND) - qt5_wrap_cpp(MOC_SOURCE_FILES ${QT_MOC_HEADERS} ) - qt5_wrap_ui( FORM_FILES_CPP ${QT_UI_FILES} ) -else() - qt4_wrap_cpp(MOC_SOURCE_FILES ${QT_MOC_HEADERS} ) - qt4_wrap_ui( FORM_FILES_CPP ${QT_UI_FILES} ) -endif() - - # NOTE! Resources in subfolders must append to QRC_FILES using the following statement # set( QRC_FILES # ${QRC_FILES} @@ -271,18 +250,19 @@ set( QRC_FILES Resources/ResInsight.qrc ) -# Runs RCC on specified files -if ( NOT CMAKE_AUTOMOC) - if (Qt5Core_FOUND) - qt5_add_resources( QRC_FILES_CPP - ${QRC_FILES} - ) - else() - qt4_add_resources( QRC_FILES_CPP - ${QRC_FILES} - ) - endif(Qt5Core_FOUND) -endif(NOT CMAKE_AUTOMOC) +if (RESINSIGHT_BUILD_WITH_QT5) + find_package(Qt5 COMPONENTS REQUIRED Core Gui OpenGL Network Script Widgets) + set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Network Qt5::Script Qt5::Widgets) + qt5_wrap_cpp(MOC_SOURCE_FILES ${QT_MOC_HEADERS}) + qt5_wrap_ui(FORM_FILES_CPP ${QT_UI_FILES}) + qt5_add_resources(QRC_FILES_CPP ${QRC_FILES}) +else() + find_package(Qt4 COMPONENTS QtCore QtGui QtMain QtOpenGl QtNetwork QtScript REQUIRED) + include(${QT_USE_FILE}) + qt4_wrap_cpp(MOC_SOURCE_FILES ${QT_MOC_HEADERS}) + qt4_wrap_ui(FORM_FILES_CPP ${QT_UI_FILES}) + qt4_add_resources(QRC_FILES_CPP ${QRC_FILES}) +endif(RESINSIGHT_BUILD_WITH_QT5) # Adding resource (RC) files for Windows if ( MSVC ) @@ -486,7 +466,7 @@ endif() if (MSVC) # Qt DLLs - if (Qt5Core_FOUND) + if (RESINSIGHT_BUILD_WITH_QT5) message(STATUS "Creating post build step for copying Qt DLLs") foreach (qtlib ${QT_LIBRARIES}) add_custom_command(TARGET ResInsight POST_BUILD @@ -494,11 +474,11 @@ if (MSVC) ) endforeach(qtlib) else() - set (QTLIBLIST QtCore4 QtCored4 QtGui4 QtGuid4 QtOpenGl4 QtOpenGld4 QtNetwork4 QtNetworkd4 QtScript4 QtScriptd4 QtScriptTools4 QtScriptToolsd4) - foreach (qtlib ${QTLIBLIST}) - list(APPEND RI_DLL_FILENAMES ${QT_BINARY_DIR}/${qtlib}.dll) + set (QTLIBLIST QtCore QtGui QtGui QtOpenGl QtNetwork QtScript QtScriptTools) + foreach (qtlib ${QTLIBLIST}) + list(APPEND RI_DLL_FILENAMES ${QT_BINARY_DIR}/$,${qtlib}d4.dll,${qtlib}4.dll>) endforeach( qtlib ) - endif() + endif(RESINSIGHT_BUILD_WITH_QT5) # Odb Dlls if (RESINSIGHT_USE_ODB_API) # Find all the dlls @@ -595,7 +575,7 @@ if (RESINSIGHT_PRIVATE_INSTALL) set (RESINSIGHT_FILES ${RI_DLL_FILENAMES}) - if(Qt5_FOUND AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt) + if(RESINSIGHT_BUILD_WITH_QT5 AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt) get_target_property(_qt5_qmake_location Qt5::qmake IMPORTED_LOCATION) execute_process( diff --git a/ApplicationCode/WellPathImportSsihub/CMakeLists.txt b/ApplicationCode/WellPathImportSsihub/CMakeLists.txt index 70912c0815..1af067baf2 100644 --- a/ApplicationCode/WellPathImportSsihub/CMakeLists.txt +++ b/ApplicationCode/WellPathImportSsihub/CMakeLists.txt @@ -2,35 +2,20 @@ cmake_minimum_required (VERSION 2.8.12) project (WellPathImportSsihub) -if (RESINSIGHT_BUILD_WITH_QT5) - find_package(Qt5 COMPONENTS Core QUIET) -endif(RESINSIGHT_BUILD_WITH_QT5) - -if (Qt5Core_FOUND) - find_package(Qt5 CONFIG REQUIRED Core Network) -else() - find_package(Qt4 COMPONENTS QtCore QtNetwork REQUIRED) - include(${QT_USE_FILE}) -endif(Qt5Core_FOUND) - # These headers need to go through Qt's MOC compiler -set( QT_MOC_HEADERS +set( MOC_HEADER_FILES RiuWellImportWizard.h ) - -set( QT_UI_FILES -) - -if ( NOT CMAKE_AUTOMOC ) - if (Qt5Core_FOUND) - qt5_wrap_cpp(MOC_SOURCE_FILES ${QT_MOC_HEADERS} ) - qt5_wrap_ui( FORM_FILES_CPP ${QT_UI_FILES} ) - else() - qt4_wrap_cpp(MOC_SOURCE_FILES ${QT_MOC_HEADERS} ) - qt4_wrap_ui( FORM_FILES_CPP ${QT_UI_FILES} ) - endif() -endif() +if (RESINSIGHT_BUILD_WITH_QT5) + find_package(Qt5 COMPONENTS REQUIRED Core Network) + set(QT_LIBRARIES Qt5::Core Qt5::Network) + qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) +else() + find_package(Qt4 COMPONENTS QtCore QtNetwork REQUIRED) + include(${QT_USE_FILE}) + qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) +endif(RESINSIGHT_BUILD_WITH_QT5) include_directories( ${CMAKE_CURRENT_BINARY_DIR} @@ -38,7 +23,6 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../FileInterface ) - add_library( ${PROJECT_NAME} RimWellPathImport.h RimWellPathImport.cpp @@ -58,10 +42,6 @@ add_library( ${PROJECT_NAME} ${HEADER_FILES} ) -if (Qt5Core_FOUND) - set(QT_LIBRARIES Qt5::Core Qt5::Network) -endif() - target_link_libraries ( ${PROJECT_NAME} cafUserInterface cafPdmCvf CommonCode ${QT_LIBRARIES} ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44918e5bca..8f13bd28f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,27 +253,13 @@ list(APPEND THIRD_PARTY_LIBRARIES ################################################################################ # Qt ################################################################################ -option(RESINSIGHT_BUILD_WITH_QT5 "Use Qt5 folder" OFF) -if (RESINSIGHT_BUILD_WITH_QT5) - message(STATUS "Attempting to build with Qt5") - find_package(Qt5 COMPONENTS Core QUIET) -else() - message(STATUS "Attempting to build with Qt4") -endif(RESINSIGHT_BUILD_WITH_QT5) +option(RESINSIGHT_BUILD_WITH_QT5 "Use Qt5" OFF) -if (Qt5Core_FOUND) - message(STATUS "Found Qt5") - find_package (Qt5 CONFIG REQUIRED Core Widgets OpenGL Network Script ScriptTools) +if (RESINSIGHT_BUILD_WITH_QT5) + find_package(Qt5 COMPONENTS REQUIRED Core Gui OpenGL Network Script ScriptTools Widgets) else() - if (RESINSIGHT_BUILD_WITH_QT5) - message(WARNING "Could not find Qt5. Trying with Qt4") - endif(RESINSIGHT_BUILD_WITH_QT5) - find_package(Qt4 COMPONENTS QtCore QtGui QtMain REQUIRED) - if (QT_VERSION_MINOR LESS 6) - message(FATAL_ERROR "Qt 4.6 is required, please specify qmake for variable QT_QMAKE_EXECUTABLE") - endif() - include(${QT_USE_FILE}) -endif(Qt5Core_FOUND) + find_package(Qt4 COMPONENTS QtCore QtGui QtMain QtOpenGl QtNetwork QtScript QtScriptTools REQUIRED) +endif(RESINSIGHT_BUILD_WITH_QT5) # Open GL find_package( OpenGL ) diff --git a/ThirdParty/Qwt/src/CMakeLists.txt b/ThirdParty/Qwt/src/CMakeLists.txt index d27119a9e0..ac87cd9133 100644 --- a/ThirdParty/Qwt/src/CMakeLists.txt +++ b/ThirdParty/Qwt/src/CMakeLists.txt @@ -7,13 +7,6 @@ if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") endif() -if (RESINSIGHT_BUILD_WITH_QT5) - find_package(Qt5 COMPONENTS Concurrent Core OpenGL PrintSupport Widgets REQUIRED) -else() - find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL qtmain REQUIRED) - include(${QT_USE_FILE}) -endif(RESINSIGHT_BUILD_WITH_QT5) - # Adapted from src.pri file in Qwt's source catalog for Qwt 6.1.0 # Compiles static library # Some bits removed (at least SVG) @@ -275,15 +268,15 @@ qwt_thermo.h qwt_wheel.h ) - - -set(MOC_SOURCE_FILES) if (RESINSIGHT_BUILD_WITH_QT5) - qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) + find_package(Qt5 COMPONENTS REQUIRED Concurrent Core Gui OpenGL PrintSupport Widgets) + set(QT_LIBRARIES Qt5::Concurrent Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::PrintSupport Qt5::Widgets) + qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) else() - qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) + find_package(Qt4 COMPONENTS QtCore QtGui QtMain QtOpenGl REQUIRED) + include(${QT_USE_FILE}) + qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) endif(RESINSIGHT_BUILD_WITH_QT5) - add_library(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES} ${MOC_SOURCE_FILES}) @@ -292,9 +285,7 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ) -if (RESINSIGHT_BUILD_WITH_QT5) - target_link_libraries(${PROJECT_NAME} Qt5::Concurrent Qt5::Core Qt5::OpenGL Qt5::PrintSupport Qt5::Widgets) -endif(RESINSIGHT_BUILD_WITH_QT5) +target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES}) if (COMMAND caf_apply_cotire) caf_apply_cotire("${PROJECT_NAME}") diff --git a/ThirdParty/expressionparser/CMakeLists.txt b/ThirdParty/expressionparser/CMakeLists.txt index 80a5ebe01f..b9a92abd87 100644 --- a/ThirdParty/expressionparser/CMakeLists.txt +++ b/ThirdParty/expressionparser/CMakeLists.txt @@ -7,10 +7,12 @@ if(MSVC) message(STATUS "MSVC: Enabled increased number of sections in object files") endif() + if (RESINSIGHT_BUILD_WITH_QT5) - find_package(Qt5 COMPONENTS Core REQUIRED) + find_package(Qt5 COMPONENTS REQUIRED Core) + set(QT_LIBRARIES Qt5::Core) else() - find_package(Qt4 COMPONENTS QtCore REQUIRED) + find_package(Qt4 COMPONENTS QtCore REQUIRED) include(${QT_USE_FILE}) endif(RESINSIGHT_BUILD_WITH_QT5) @@ -35,8 +37,6 @@ if(MSVC) ${CMAKE_CURRENT_SOURCE_DIR} ) -if (RESINSIGHT_BUILD_WITH_QT5) - target_link_libraries(${PROJECT_NAME} Qt5::Core) -endif(RESINSIGHT_BUILD_WITH_QT5) +target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES}) source_group("" FILES ${PROJECT_FILES}) diff --git a/ThirdParty/nightcharts/CMakeLists.txt b/ThirdParty/nightcharts/CMakeLists.txt index ec5c1773d8..a3f1597974 100644 --- a/ThirdParty/nightcharts/CMakeLists.txt +++ b/ThirdParty/nightcharts/CMakeLists.txt @@ -3,10 +3,13 @@ cmake_minimum_required (VERSION 2.8.12) project (nightcharts) if (RESINSIGHT_BUILD_WITH_QT5) - find_package(Qt5 COMPONENTS Core Widgets REQUIRED) + find_package(Qt5 COMPONENTS REQUIRED Core Widgets) + set(QT_LIBRARIES Qt5::Core Qt5::Widgets) + qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) else() - find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED) + find_package(Qt4 COMPONENTS QtCore QtWidgets) include(${QT_USE_FILE}) + qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) endif(RESINSIGHT_BUILD_WITH_QT5) list (APPEND MAIN_SOURCE_FILES @@ -26,8 +29,6 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ) -if (RESINSIGHT_BUILD_WITH_QT5) - target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets) -endif(RESINSIGHT_BUILD_WITH_QT5) +target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES}) source_group("" FILES ${PROJECT_FILES})