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.

ConfigureChecks.cmake 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. macro( qt_message )
  12. message( STATUS "${ARGN}" )
  13. endmacro( )
  14. set( QT_VERSION "3" )
  15. # qt prefix directory
  16. if( NOT DEFINED QT_PREFIX_DIR )
  17. if( NOT $ENV{TQTDIR} STREQUAL "" )
  18. set( QT_PREFIX_DIR "$ENV{TQTDIR}" )
  19. qt_message( " QT_PREFIX_DIR is set to TQTDIR" )
  20. else( )
  21. set( QT_PREFIX_DIR "/usr" )
  22. endif( )
  23. endif( )
  24. qt_message( " QT_PREFIX_DIR : ${QT_PREFIX_DIR}" )
  25. # qt headers
  26. if( NOT DEFINED TQT_INCLUDE_DIR )
  27. if( QT_PREFIX_DIR STREQUAL "/usr" )
  28. if( EXISTS "${QT_PREFIX_DIR}/include/tqt${QT_VERSION}" )
  29. set( TQT_INCLUDE_DIR "${QT_PREFIX_DIR}/include/tqt${QT_VERSION}" )
  30. else( )
  31. set( TQT_INCLUDE_DIR "${QT_PREFIX_DIR}/include/qt${QT_VERSION}" )
  32. endif( )
  33. else( )
  34. set( TQT_INCLUDE_DIR "${QT_PREFIX_DIR}/include" )
  35. endif( )
  36. endif( )
  37. qt_message( " TQT_INCLUDE_DIR: ${TQT_INCLUDE_DIR}" )
  38. # qt library path
  39. if( NOT DEFINED TQT_LIBRARY_DIR )
  40. set( TQT_LIBRARY_DIR "${QT_PREFIX_DIR}/lib${LIB_SUFFIX}" )
  41. endif( )
  42. qt_message( " TQT_LIBRARY_DIR: ${TQT_LIBRARY_DIR}" )
  43. # qt library name
  44. if( NOT DEFINED TQT_LIBRARIES )
  45. set( TQT_LIBRARIES qt-mt )
  46. endif( )
  47. # qt tools
  48. if( NOT DEFINED QT_BINARY_DIR )
  49. set( QT_BINARY_DIR "${QT_PREFIX_DIR}/bin" )
  50. endif( )
  51. qt_message( " QT_BINARY_DIR : ${QT_BINARY_DIR}" )
  52. # find moc
  53. if( DEFINED MOC_EXECUTABLE )
  54. if( IS_DIRECTORY "${MOC_EXECUTABLE}" OR NOT EXISTS "${MOC_EXECUTABLE}" )
  55. tde_message_fatal( "moc was NOT found.\n MOC_EXECUTABLE may not be set correctly." )
  56. endif( )
  57. else( )
  58. find_program( MOC_EXECUTABLE NAMES tqmoc moc-qt3 moc HINTS "${QT_BINARY_DIR}" )
  59. if( NOT MOC_EXECUTABLE )
  60. tde_message_fatal( "moc was NOT found.\n Please check if your Qt${QT_VERSION} is correctly installed." )
  61. endif( )
  62. endif( )
  63. # attempt to run moc, to check which qt version is using
  64. execute_process( COMMAND ${MOC_EXECUTABLE} -v ERROR_VARIABLE __output
  65. RESULT_VARIABLE __result ERROR_STRIP_TRAILING_WHITESPACE )
  66. if( __result EQUAL 1 )
  67. string( REGEX MATCH "^.*Qt (.+)\\)$" __dummy "${__output}" )
  68. set( __version "${CMAKE_MATCH_1}" )
  69. if( NOT __version )
  70. tde_message_fatal( "Invalid response from moc:\n ${__output}" )
  71. endif( )
  72. else( )
  73. tde_message_fatal( "Unable to run moc!\n Qt${VERSION} are correctly installed?\n LD_LIBRARY_PATH are correctly set?" )
  74. endif( )
  75. qt_message( " MOC_EXECUTABLE: ${MOC_EXECUTABLE} (using Qt ${CMAKE_MATCH_1})" )
  76. if( QT_VERSION STREQUAL "3" AND NOT "${CMAKE_MATCH_1}" VERSION_LESS "4" )
  77. tde_message_fatal( "Strange, you want TQt3, but your moc using Qt>=4." )
  78. endif( )
  79. # find uic (only for Qt3)
  80. if( DEFINED UIC_EXECUTABLE )
  81. if( IS_DIRECTORY "${UIC_EXECUTABLE}" OR NOT EXISTS "${UIC_EXECUTABLE}" )
  82. tde_message_fatal( "uic was NOT found.\n MOC_EXECUTABLE may not be set correctly" )
  83. endif( )
  84. else( )
  85. find_program( UIC_EXECUTABLE NAMES tquic uic-qt3 uic HINTS "${QT_BINARY_DIR}" )
  86. if( NOT UIC_EXECUTABLE )
  87. tde_message_fatal( "uic was NOT found.\n Please check if your Qt${QT_VERSION} is correctly installed." )
  88. endif( )
  89. endif( )
  90. qt_message( " UIC_EXECUTABLE: ${UIC_EXECUTABLE}" )
  91. # definitions
  92. set( QT_DEFINITIONS "-DTQT_NO_ASCII_CAST -DTQT_NO_STL -DTQT_NO_COMPAT -DTQT_NO_TRANSLATION -DTQT_THREAD_SUPPORT -D_REENTRANT" )
  93. tde_save( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  94. set( CMAKE_REQUIRED_INCLUDES ${TQT_INCLUDE_DIR} )
  95. set( CMAKE_REQUIRED_LIBRARIES -L${TQT_LIBRARY_DIR} ${TQT_LIBRARIES} )
  96. # check if TQt3 is usable
  97. check_cxx_source_compiles("
  98. #include <qapplication.h>
  99. int main(int argc, char **argv) { QApplication app(argc, argv); return 0; } "
  100. HAVE_USABLE_QT${QT_VERSION} )
  101. if( NOT HAVE_USABLE_QT${QT_VERSION} )
  102. # Unset the Qt detection variable
  103. unset( HAVE_USABLE_QT${QT_VERSION} CACHE )
  104. # Reset libraries
  105. set( TQT_LIBRARIES tqt-mt )
  106. set( CMAKE_REQUIRED_LIBRARIES -L${TQT_LIBRARY_DIR} ${TQT_LIBRARIES} )
  107. qt_message( "Looking for native TQt3..." )
  108. check_cxx_source_compiles("
  109. #include <ntqapplication.h>
  110. int main(int argc, char **argv) { TQApplication app(argc, argv); return 0; } "
  111. HAVE_USABLE_QT${QT_VERSION} )
  112. endif( )
  113. if( NOT HAVE_USABLE_QT${QT_VERSION} )
  114. tde_message_fatal( "Unable to build a simple Qt${QT_VERSION} test." )
  115. endif( )
  116. # check if Qt3 is patched for compatibility with TQt
  117. check_cxx_source_compiles("
  118. #include <qobjectlist.h>
  119. #include <qobject.h>
  120. int main(int, char**) { QObject::objectTreesListObject(); return 0; } "
  121. HAVE_PATCHED_QT3 )
  122. if( NOT HAVE_PATCHED_QT3 )
  123. # Unset the Qt detection variable
  124. unset( HAVE_PATCHED_QT3 CACHE )
  125. # Reset libraries
  126. set( TQT_LIBRARIES tqt-mt )
  127. set( CMAKE_REQUIRED_LIBRARIES -L${TQT_LIBRARY_DIR} ${TQT_LIBRARIES} )
  128. qt_message( "Looking for patched native TQt3..." )
  129. check_cxx_source_compiles("
  130. #include <ntqobjectlist.h>
  131. #include <ntqobject.h>
  132. int main(int, char**) { TQObject::objectTreesListObject(); return 0; } "
  133. HAVE_PATCHED_QT3 )
  134. endif( )
  135. if( NOT HAVE_PATCHED_QT3 )
  136. tde_message_fatal( "Your Qt3 is not patched for compatibility with tqtinterface." )
  137. endif( )
  138. tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )