From db81506ab39530bfee455d14054040b4f43cd945 Mon Sep 17 00:00:00 2001 From: gregory guy Date: Fri, 24 Apr 2020 12:18:37 +0200 Subject: [PATCH] Allow tqtinterface to build without OpenGL support. This should close bug 2645. Some cosmetics here and there. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: gregory guy Signed-off-by: Slávek Banko --- CMakeLists.txt | 80 +++++++++++++++++++---------- ConfigureChecks.cmake | 46 +++++++++++++++-- config.h.cmake | 11 ++++ qtinterface/CMakeLists.txt | 1 + qtinterface/interface_tqt3/tqgl.cpp | 6 +++ 5 files changed, 113 insertions(+), 31 deletions(-) create mode 100644 config.h.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3af09da..a3d0722 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,18 @@ -################################################# -# -# (C) 2010-2011 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# +########################################### +# # +# (C) 2010-2011 Serghei Amelian # +# serghei (DOT) amelian (AT) gmail.com # +# # +# Improvements and feedback are welcome # +# # +# This file is released under GPL >= 2 # +# # +########################################### + +cmake_minimum_required( VERSION 2.8 ) + + +#### general package setup project( tqt ) @@ -17,48 +22,69 @@ set( TQT_MICRO_VERSION 0 ) set( TQT_VERSION "${TQT_MAJOR_VERSION}.${TQT_MINOR_VERSION}.${TQT_MICRO_VERSION}" ) -##### cmake setup ############################### - -cmake_minimum_required( VERSION 2.8 ) +#### include essential cmake modules +include( FindPkgConfig ) +include( CheckFunctionExists ) +include( CheckSymbolExists ) +include( CheckIncludeFile ) +include( CheckLibraryExists ) +include( CheckCSourceCompiles ) include( CheckCXXSourceCompiles ) + include( GNUInstallDirs OPTIONAL ) -##### include our cmake modules ################# +##### include our cmake modules set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ) include( TDEMacros ) -##### install paths setup ####################### +##### install paths setup + +tde_setup_install_path( EXEC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ) +tde_setup_install_path( BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/bin" ) -tde_setup_install_path( EXEC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ) -tde_setup_install_path( BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/bin" ) if( CMAKE_INSTALL_LIBDIR ) - tde_setup_install_path( LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" ) -else( ) - tde_setup_install_path( LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}" ) -endif( ) + tde_setup_install_path( LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" ) + else() + tde_setup_install_path( LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}" ) +endif() + tde_setup_install_path( INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/tqt" ) tde_setup_install_path( PKGCONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/pkgconfig" ) -##### optional stuff ############################ +##### optional stuff option( WITH_ALL_OPTIONS "Enable all optional support" OFF ) -##### user requested modules #################### +##### configure checks -option( BUILD_ALL "Build all" OFF ) +include( ConfigureChecks.cmake ) -##### configure checks ########################## +###### global compiler settings -include( ConfigureChecks.cmake ) +add_definitions( -DHAVE_CONFIG_H ) + +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" ) +set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" ) +set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" ) + + +# tqt.pc and tqtqui.pc definitions +set( QT_DEFINITIONS "-DTQT_NO_ASCII_CAST -DTQT_NO_STL -DTQT_NO_COMPAT -DTQT_NO_TRANSLATION -DTQT_THREAD_SUPPORT -D_REENTRANT" ) -##### tqtinterface sources ###################### + +##### directories add_subdirectory( qtinterface ) + + +##### write configure files + +configure_file( config.h.cmake config.h @ONLY ) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 8cf8d08..7b97d8a 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -109,10 +109,6 @@ endif( ) qt_message( " UIC_EXECUTABLE: ${UIC_EXECUTABLE}" ) -# definitions -set( QT_DEFINITIONS "-DTQT_NO_ASCII_CAST -DTQT_NO_STL -DTQT_NO_COMPAT -DTQT_NO_TRANSLATION -DTQT_THREAD_SUPPORT -D_REENTRANT" ) - - tde_save( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES ) set( CMAKE_REQUIRED_INCLUDES ${TQT_INCLUDE_DIR} ) set( CMAKE_REQUIRED_LIBRARIES -L${TQT_LIBRARY_DIR} ${TQT_LIBRARIES} ) @@ -162,3 +158,45 @@ if( NOT HAVE_PATCHED_QT3 ) endif( ) tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES ) + + +##### check for OpenGL + +include( UsePkgConfig ) + +EXEC_PROGRAM( + ${PKGCONFIG_EXECUTABLE} + ARGS tqt-mt --variable=qt_config + OUTPUT_VARIABLE TQT_CONF_VARS +) +MESSAGE(STATUS "List of qt_config variables: ${TQT_CONF_VARS}") + +string( REGEX MATCH " opengl " OPENGL_ENABLED " ${TQT_CONF_VARS} " ) + +if( OPENGL_ENABLED ) + +check_include_file( "OpenGL/glu.h" HAVE_GLU_OPENGL ) +check_include_file( "GL/glu.h" HAVE_GLU_GL ) + +tde_save( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES ) +set( CMAKE_REQUIRED_INCLUDES ${TQT_INCLUDE_DIR} ) +set( CMAKE_REQUIRED_LIBRARIES -L${TQT_LIBRARY_DIR} ${TQT_LIBRARIES} ) + +check_cxx_source_compiles(" +#include +#include +int main( int, char** ) +{ + (void) new TQGLWidget( (TQWidget*)0, \"qgl\" ) ; + return EXIT_SUCCESS ; +}" +TQGLWIDGET ) + +tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES ) + +if( ( HAVE_GLU_OPENGL OR HAVE_GLU_GL ) AND TQGLWIDGET ) + set( HAVE_OPENGL 1 ) + else() + tde_message_fatal( "OpenGL has been requested, but neither the OpenGL headers or tqt3 with OpenGL support have been found on your system" ) +endif() +endif( OPENGL_ENABLED ) diff --git a/config.h.cmake b/config.h.cmake new file mode 100644 index 0000000..558e25c --- /dev/null +++ b/config.h.cmake @@ -0,0 +1,11 @@ +#define VERSION "@TQT_VERSION@" + +// Defined if you have fvisibility and fvisibility-inlines-hidden support. +#cmakedefine __KDE_HAVE_GCC_VISIBILITY 1 + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@ + +/* Defined if you build with OpenGL */ +#cmakedefine HAVE_OPENGL 1 diff --git a/qtinterface/CMakeLists.txt b/qtinterface/CMakeLists.txt index 480760b..848921c 100644 --- a/qtinterface/CMakeLists.txt +++ b/qtinterface/CMakeLists.txt @@ -20,6 +20,7 @@ include_directories( ${TQT_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${IFACE} ${CMAKE_CURRENT_SOURCE_DIR}/${IFACE}/private + ${CMAKE_BINARY_DIR} ) link_directories( diff --git a/qtinterface/interface_tqt3/tqgl.cpp b/qtinterface/interface_tqt3/tqgl.cpp index 33c8bb6..3ec7177 100644 --- a/qtinterface/interface_tqt3/tqgl.cpp +++ b/qtinterface/interface_tqt3/tqgl.cpp @@ -18,6 +18,12 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include + +#ifdef HAVE_OPENGL #include +#endif