Shared cmake folder
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.

108 lines
2.8KB

  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( tqt_message )
  12. message( STATUS "${ARGN}" )
  13. endmacro( )
  14. pkg_search_module( TQT tqt )
  15. if( NOT TQT_FOUND )
  16. tde_message_fatal( "Unable to find tqt!\n Try adding the directory in which the tqt.pc file is located\nto the PKG_CONFIG_PATH variable." )
  17. endif( )
  18. mark_as_advanced(
  19. TMOC_EXECUTABLE
  20. MOC_EXECUTABLE
  21. UIC_EXECUTABLE
  22. )
  23. # tmoc_executable
  24. tde_execute_process(
  25. COMMAND pkg-config tqt --variable=tmoc_executable
  26. OUTPUT_VARIABLE TMOC_EXECUTABLE
  27. CACHE FILEPATH "TQt tmoc executable path"
  28. OUTPUT_STRIP_TRAILING_WHITESPACE )
  29. if( NOT EXISTS ${TMOC_EXECUTABLE} )
  30. tde_message_fatal( "tmoc is not found!\n tqt is correctly installed?" )
  31. endif( )
  32. tqt_message( " tmoc path: ${TMOC_EXECUTABLE}" )
  33. # moc_executable
  34. tde_execute_process(
  35. COMMAND pkg-config tqt --variable=moc_executable
  36. OUTPUT_VARIABLE MOC_EXECUTABLE
  37. CACHE FILEPATH "TQt moc executable path"
  38. OUTPUT_STRIP_TRAILING_WHITESPACE )
  39. if( NOT EXISTS ${MOC_EXECUTABLE} )
  40. tde_message_fatal( "Path to moc is not set.\n tqt is correctly installed?" )
  41. endif( )
  42. tqt_message( " moc path: ${MOC_EXECUTABLE}" )
  43. # uic_executable
  44. tde_execute_process(
  45. COMMAND pkg-config tqt --variable=uic_executable
  46. OUTPUT_VARIABLE UIC_EXECUTABLE
  47. CACHE FILEPATH "TQt uic executable path"
  48. OUTPUT_STRIP_TRAILING_WHITESPACE )
  49. if( NOT EXISTS ${UIC_EXECUTABLE} )
  50. tde_message_fatal( "uic not found!\n tqt is correctly installed?" )
  51. endif( )
  52. tqt_message( " uic path: ${UIC_EXECUTABLE}" )
  53. # tqt-replace script
  54. set( TQT_REPLACE_SCRIPT "${TQT_PREFIX}/bin/tqt-replace" )
  55. if( NOT EXISTS ${TQT_REPLACE_SCRIPT} )
  56. tde_message_fatal( "tqt-replace not found!\n Check tqt installation." )
  57. endif( )
  58. tqt_message( " tqt-replace path: ${TQT_REPLACE_SCRIPT}" )
  59. # check if tqt is usable
  60. tde_save( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  61. set( CMAKE_REQUIRED_INCLUDES ${TQT_INCLUDE_DIRS} )
  62. foreach( _dirs ${TQT_LIBRARY_DIRS} )
  63. list( APPEND CMAKE_REQUIRED_LIBRARIES "-L${_dirs}" )
  64. endforeach()
  65. list( APPEND CMAKE_REQUIRED_LIBRARIES ${TQT_LIBRARIES} )
  66. check_cxx_source_compiles("
  67. #include <tqapplication.h>
  68. int main(int argc, char **argv) { TQApplication app(argc, argv); return 0; } "
  69. HAVE_USABLE_TQT )
  70. if( NOT HAVE_USABLE_TQT )
  71. tde_message_fatal( "Unable to build a simple tqt test." )
  72. endif( )
  73. tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  74. # TQT_CXX_FLAGS
  75. foreach( _flag ${TQT_CFLAGS} ${TQT_CFLAGS_OTHER} )
  76. set( TQT_CXX_FLAGS "${TQT_CXX_FLAGS} ${_flag}" )
  77. endforeach()
  78. # Set compiler flags according to build type
  79. set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DNDEBUG" )
  80. set( CMAKE_C_FLAGS_RELWITHDEBINFO "-DNDEBUG" )