The Trinity Qt Interface
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

212 lines
6.3 KiB

  1. #################################################
  2. #
  3. # (C) 2010-2011 Serghei Amelian
  4. # serghei (DOT) amelian (AT) gmail.com
  5. #
  6. # Improvements and feedback are welcome
  7. #
  8. # This file is released under GPL >= 2
  9. #
  10. #################################################
  11. ##### setup architecture flags ##################
  12. tde_setup_architecture_flags( )
  13. include(TestBigEndian)
  14. test_big_endian(WORDS_BIGENDIAN)
  15. tde_setup_largefiles( )
  16. macro( qt_message )
  17. message( STATUS "${ARGN}" )
  18. endmacro( )
  19. set( QT_VERSION "3" )
  20. # qt prefix directory
  21. if( NOT DEFINED QT_PREFIX_DIR )
  22. if( NOT $ENV{TQTDIR} STREQUAL "" )
  23. set( QT_PREFIX_DIR "$ENV{TQTDIR}" )
  24. qt_message( " QT_PREFIX_DIR is set to TQTDIR" )
  25. else( )
  26. set( QT_PREFIX_DIR "/usr" )
  27. endif( )
  28. endif( )
  29. qt_message( " QT_PREFIX_DIR : ${QT_PREFIX_DIR}" )
  30. # qt headers
  31. if( NOT DEFINED TQT_INCLUDE_DIR )
  32. if( QT_PREFIX_DIR STREQUAL "/usr" )
  33. if( EXISTS "${QT_PREFIX_DIR}/include/tqt${QT_VERSION}" )
  34. set( TQT_INCLUDE_DIR "${QT_PREFIX_DIR}/include/tqt${QT_VERSION}" )
  35. else( )
  36. set( TQT_INCLUDE_DIR "${QT_PREFIX_DIR}/include/qt${QT_VERSION}" )
  37. endif( )
  38. else( )
  39. set( TQT_INCLUDE_DIR "${QT_PREFIX_DIR}/include" )
  40. endif( )
  41. endif( )
  42. qt_message( " TQT_INCLUDE_DIR: ${TQT_INCLUDE_DIR}" )
  43. # qt library path
  44. if( NOT DEFINED TQT_LIBRARY_DIR )
  45. set( TQT_LIBRARY_DIR "${QT_PREFIX_DIR}/lib${LIB_SUFFIX}" )
  46. endif( )
  47. qt_message( " TQT_LIBRARY_DIR: ${TQT_LIBRARY_DIR}" )
  48. # qt library name
  49. if( NOT DEFINED TQT_LIBRARIES )
  50. set( TQT_LIBRARIES qt-mt )
  51. endif( )
  52. # qt tools
  53. if( NOT DEFINED QT_BINARY_DIR )
  54. set( QT_BINARY_DIR "${QT_PREFIX_DIR}/bin" )
  55. endif( )
  56. qt_message( " QT_BINARY_DIR : ${QT_BINARY_DIR}" )
  57. # find moc
  58. if( DEFINED MOC_EXECUTABLE )
  59. if( IS_DIRECTORY "${MOC_EXECUTABLE}" OR NOT EXISTS "${MOC_EXECUTABLE}" )
  60. tde_message_fatal( "moc was NOT found.\n MOC_EXECUTABLE may not be set correctly." )
  61. endif( )
  62. else( )
  63. find_program( MOC_EXECUTABLE NAMES tqmoc moc-qt3 moc HINTS "${QT_BINARY_DIR}" )
  64. if( NOT MOC_EXECUTABLE )
  65. tde_message_fatal( "moc was NOT found.\n Please check if your Qt${QT_VERSION} is correctly installed." )
  66. endif( )
  67. endif( )
  68. # attempt to run moc, to check which qt version is using
  69. execute_process( COMMAND ${MOC_EXECUTABLE} -v ERROR_VARIABLE __output
  70. RESULT_VARIABLE __result ERROR_STRIP_TRAILING_WHITESPACE )
  71. if( __result EQUAL 1 )
  72. string( REGEX MATCH "^.*Qt (.+)\\)$" __dummy "${__output}" )
  73. set( __version "${CMAKE_MATCH_1}" )
  74. if( NOT __version )
  75. tde_message_fatal( "Invalid response from moc:\n ${__output}" )
  76. endif( )
  77. else( )
  78. tde_message_fatal( "Unable to run moc!\n Qt${VERSION} are correctly installed?\n LD_LIBRARY_PATH are correctly set?" )
  79. endif( )
  80. qt_message( " MOC_EXECUTABLE: ${MOC_EXECUTABLE} (using Qt ${CMAKE_MATCH_1})" )
  81. if( QT_VERSION STREQUAL "3" AND NOT "${CMAKE_MATCH_1}" VERSION_LESS "4" )
  82. tde_message_fatal( "Strange, you want TQt3, but your moc using Qt>=4." )
  83. endif( )
  84. # find uic (only for Qt3)
  85. if( DEFINED UIC_EXECUTABLE )
  86. if( IS_DIRECTORY "${UIC_EXECUTABLE}" OR NOT EXISTS "${UIC_EXECUTABLE}" )
  87. tde_message_fatal( "uic was NOT found.\n MOC_EXECUTABLE may not be set correctly" )
  88. endif( )
  89. else( )
  90. find_program( UIC_EXECUTABLE NAMES tquic uic-qt3 uic HINTS "${QT_BINARY_DIR}" )
  91. if( NOT UIC_EXECUTABLE )
  92. tde_message_fatal( "uic was NOT found.\n Please check if your Qt${QT_VERSION} is correctly installed." )
  93. endif( )
  94. endif( )
  95. qt_message( " UIC_EXECUTABLE: ${UIC_EXECUTABLE}" )
  96. tde_save( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  97. set( CMAKE_REQUIRED_INCLUDES ${TQT_INCLUDE_DIR} )
  98. set( CMAKE_REQUIRED_LIBRARIES -L${TQT_LIBRARY_DIR} ${TQT_LIBRARIES} )
  99. # check if TQt3 is usable
  100. check_cxx_source_compiles("
  101. #include <qapplication.h>
  102. int main(int argc, char **argv) { QApplication app(argc, argv); return 0; } "
  103. HAVE_USABLE_QT${QT_VERSION} )
  104. if( NOT HAVE_USABLE_QT${QT_VERSION} )
  105. # Unset the Qt detection variable
  106. unset( HAVE_USABLE_QT${QT_VERSION} CACHE )
  107. # Reset libraries
  108. set( TQT_LIBRARIES tqt-mt )
  109. set( CMAKE_REQUIRED_LIBRARIES -L${TQT_LIBRARY_DIR} ${TQT_LIBRARIES} )
  110. qt_message( "Looking for native TQt3..." )
  111. check_cxx_source_compiles("
  112. #include <ntqapplication.h>
  113. int main(int argc, char **argv) { TQApplication app(argc, argv); return 0; } "
  114. HAVE_USABLE_QT${QT_VERSION} )
  115. endif( )
  116. if( NOT HAVE_USABLE_QT${QT_VERSION} )
  117. tde_message_fatal( "Unable to build a simple Qt${QT_VERSION} test." )
  118. endif( )
  119. # check if Qt3 is patched for compatibility with TQt
  120. check_cxx_source_compiles("
  121. #include <qobjectlist.h>
  122. #include <qobject.h>
  123. int main(int, char**) { QObject::objectTreesListObject(); return 0; } "
  124. HAVE_PATCHED_QT3 )
  125. if( NOT HAVE_PATCHED_QT3 )
  126. # Unset the Qt detection variable
  127. unset( HAVE_PATCHED_QT3 CACHE )
  128. # Reset libraries
  129. set( TQT_LIBRARIES tqt-mt )
  130. set( CMAKE_REQUIRED_LIBRARIES -L${TQT_LIBRARY_DIR} ${TQT_LIBRARIES} )
  131. qt_message( "Looking for patched native TQt3..." )
  132. check_cxx_source_compiles("
  133. #include <ntqobjectlist.h>
  134. #include <ntqobject.h>
  135. int main(int, char**) { TQObject::objectTreesListObject(); return 0; } "
  136. HAVE_PATCHED_QT3 )
  137. endif( )
  138. if( NOT HAVE_PATCHED_QT3 )
  139. tde_message_fatal( "Your Qt3 is not patched for compatibility with tqtinterface." )
  140. endif( )
  141. tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  142. ##### check for OpenGL
  143. execute_process(
  144. COMMAND ${PKG_CONFIG_EXECUTABLE} ${TQT_LIBRARIES} --variable=qt_config
  145. OUTPUT_VARIABLE TQT_CONF_VARS
  146. OUTPUT_STRIP_TRAILING_WHITESPACE
  147. )
  148. MESSAGE(STATUS "List of qt_config variables: ${TQT_CONF_VARS}")
  149. string( REGEX MATCH " opengl " OPENGL_ENABLED " ${TQT_CONF_VARS} " )
  150. if( OPENGL_ENABLED )
  151. check_include_file( "OpenGL/glu.h" HAVE_GLU_OPENGL )
  152. check_include_file( "GL/glu.h" HAVE_GLU_GL )
  153. tde_save( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  154. set( CMAKE_REQUIRED_INCLUDES ${TQT_INCLUDE_DIR} )
  155. set( CMAKE_REQUIRED_LIBRARIES -L${TQT_LIBRARY_DIR} ${TQT_LIBRARIES} )
  156. check_cxx_source_compiles("
  157. #include <cstdlib>
  158. #include <ntqgl.h>
  159. int main( int, char** )
  160. {
  161. (void) new TQGLWidget( (TQWidget*)0, \"qgl\" ) ;
  162. return EXIT_SUCCESS ;
  163. }"
  164. TQGLWIDGET )
  165. tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  166. if( ( HAVE_GLU_OPENGL OR HAVE_GLU_GL ) AND TQGLWIDGET )
  167. set( HAVE_OPENGL 1 )
  168. else()
  169. tde_message_fatal( "OpenGL has been requested, but neither the OpenGL headers or tqt3 with OpenGL support have been found on your system" )
  170. endif()
  171. endif( OPENGL_ENABLED )