CMakeLists.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #=============================================================================
  2. # CMake - Cross Platform Makefile Generator
  3. # Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. #
  5. # Distributed under the OSI-approved BSD License (the "License");
  6. # see accompanying file Copyright.txt for details.
  7. #
  8. # This software is distributed WITHOUT ANY WARRANTY; without even the
  9. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. # See the License for more information.
  11. #=============================================================================
  12. project(QtDialog)
  13. set(QT_MIN_VERSION "4.4.0")
  14. find_package(Qt4 REQUIRED)
  15. if(NOT QT4_FOUND)
  16. message(SEND_ERROR "Failed to find Qt 4.4 or greater.")
  17. return()
  18. endif()
  19. include(${QT_USE_FILE})
  20. set(SRCS
  21. AddCacheEntry.cxx
  22. AddCacheEntry.h
  23. CMakeSetup.cxx
  24. CMakeSetupDialog.cxx
  25. CMakeSetupDialog.h
  26. FirstConfigure.cxx
  27. FirstConfigure.h
  28. QCMake.cxx
  29. QCMake.h
  30. QCMakeCacheView.cxx
  31. QCMakeCacheView.h
  32. QCMakeWidgets.cxx
  33. QCMakeWidgets.h
  34. QMacInstallDialog.cxx
  35. QMacInstallDialog.h
  36. )
  37. QT4_WRAP_UI(UI_SRCS
  38. CMakeSetupDialog.ui
  39. Compilers.ui
  40. CrossCompiler.ui
  41. AddCacheEntry.ui
  42. MacInstallDialog.ui
  43. )
  44. QT4_WRAP_CPP(MOC_SRCS
  45. AddCacheEntry.h
  46. Compilers.h
  47. CMakeSetupDialog.h
  48. FirstConfigure.h
  49. QCMake.h
  50. QCMakeCacheView.h
  51. QCMakeWidgets.h
  52. QMacInstallDialog.h
  53. )
  54. QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc)
  55. set(SRCS ${SRCS} ${UI_SRCS} ${MOC_SRCS} ${RC_SRCS})
  56. if(WIN32)
  57. set(SRCS ${SRCS} CMakeSetup.rc)
  58. endif()
  59. if(APPLE)
  60. set(SRCS ${SRCS} CMakeSetup.icns)
  61. set(MACOSX_BUNDLE_ICON_FILE CMakeSetup.icns)
  62. set_source_files_properties(CMakeSetup.icns PROPERTIES
  63. MACOSX_PACKAGE_LOCATION Resources)
  64. endif()
  65. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  66. include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  67. add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS})
  68. target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES})
  69. if(APPLE)
  70. set_target_properties(cmake-gui PROPERTIES
  71. OUTPUT_NAME ${CMAKE_BUNDLE_NAME})
  72. endif()
  73. set(CMAKE_INSTALL_DESTINATION_ARGS
  74. BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}")
  75. install(TARGETS cmake-gui RUNTIME DESTINATION bin ${CMAKE_INSTALL_DESTINATION_ARGS})
  76. if(UNIX)
  77. # install a desktop file so CMake appears in the application start menu
  78. # with an icon
  79. install(FILES CMake.desktop DESTINATION share/applications )
  80. install(FILES CMakeSetup32.png DESTINATION share/pixmaps )
  81. install(FILES cmakecache.xml DESTINATION share/mime/packages )
  82. endif()
  83. if(APPLE)
  84. set(CMAKE_POSTFLIGHT_SCRIPT
  85. "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
  86. set(CMAKE_POSTUPGRADE_SCRIPT
  87. "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
  88. configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postflight.sh.in"
  89. "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
  90. configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in"
  91. "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
  92. install(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" cmake-gui
  93. WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
  94. endif()
  95. if(APPLE OR WIN32)
  96. # install rules for including 3rd party libs such as Qt
  97. # if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation
  98. set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/cmake-gui${CMAKE_EXECUTABLE_SUFFIX}")
  99. if(APPLE)
  100. set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}")
  101. endif()
  102. install(CODE "
  103. include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\")
  104. set(BU_CHMOD_BUNDLE_ITEMS ON)
  105. fixup_bundle(\"${fixup_exe}\" \"\" \"${QT_LIBRARY_DIR};${QT_BINARY_DIR}\")
  106. ")
  107. endif()
  108. set(CMAKE_PACKAGE_QTGUI TRUE)
  109. configure_file("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in"
  110. "${QtDialog_BINARY_DIR}/QtDialogCPack.cmake" @ONLY)