CMakeLists.txt 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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(CMAKE_PACKAGE_QTGUI TRUE)
  21. set(SRCS
  22. AddCacheEntry.cxx
  23. AddCacheEntry.h
  24. CMakeSetup.cxx
  25. CMakeSetupDialog.cxx
  26. CMakeSetupDialog.h
  27. FirstConfigure.cxx
  28. FirstConfigure.h
  29. QCMake.cxx
  30. QCMake.h
  31. QCMakeCacheView.cxx
  32. QCMakeCacheView.h
  33. QCMakeWidgets.cxx
  34. QCMakeWidgets.h
  35. QMacInstallDialog.cxx
  36. QMacInstallDialog.h
  37. )
  38. QT4_WRAP_UI(UI_SRCS
  39. CMakeSetupDialog.ui
  40. Compilers.ui
  41. CrossCompiler.ui
  42. AddCacheEntry.ui
  43. MacInstallDialog.ui
  44. )
  45. QT4_WRAP_CPP(MOC_SRCS
  46. AddCacheEntry.h
  47. Compilers.h
  48. CMakeSetupDialog.h
  49. FirstConfigure.h
  50. QCMake.h
  51. QCMakeCacheView.h
  52. QCMakeWidgets.h
  53. QMacInstallDialog.h
  54. )
  55. QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc)
  56. set(SRCS ${SRCS} ${UI_SRCS} ${MOC_SRCS} ${RC_SRCS})
  57. if(WIN32)
  58. set(SRCS ${SRCS} CMakeSetup.rc)
  59. endif()
  60. if(APPLE)
  61. set(SRCS ${SRCS} CMakeSetup.icns)
  62. set(MACOSX_BUNDLE_ICON_FILE CMakeSetup.icns)
  63. set_source_files_properties(CMakeSetup.icns PROPERTIES
  64. MACOSX_PACKAGE_LOCATION Resources)
  65. endif()
  66. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  67. include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  68. add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS})
  69. target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES})
  70. if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4)
  71. if(APPLE)
  72. set_target_properties(cmake-gui PROPERTIES
  73. OUTPUT_NAME ${CMAKE_BUNDLE_NAME})
  74. endif()
  75. set(CMAKE_INSTALL_DESTINATION_ARGS
  76. BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}")
  77. endif()
  78. install(TARGETS cmake-gui RUNTIME DESTINATION bin ${CMAKE_INSTALL_DESTINATION_ARGS})
  79. if(UNIX)
  80. # install a desktop file so CMake appears in the application start menu
  81. # with an icon
  82. install(FILES CMake.desktop DESTINATION share/applications )
  83. install(FILES CMakeSetup32.png DESTINATION share/pixmaps )
  84. install(FILES cmakecache.xml DESTINATION share/mime/packages )
  85. endif()
  86. if(APPLE)
  87. set(CMAKE_POSTFLIGHT_SCRIPT
  88. "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
  89. set(CMAKE_POSTUPGRADE_SCRIPT
  90. "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
  91. configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postflight.sh.in"
  92. "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
  93. configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in"
  94. "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
  95. install(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" cmake-gui
  96. WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
  97. endif()
  98. if(APPLE OR WIN32)
  99. # install rules for including 3rd party libs such as Qt
  100. # if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation
  101. set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/cmake-gui${CMAKE_EXECUTABLE_SUFFIX}")
  102. if(APPLE)
  103. set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}")
  104. endif()
  105. install(CODE "
  106. include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\")
  107. set(BU_CHMOD_BUNDLE_ITEMS ON)
  108. fixup_bundle(\"${fixup_exe}\" \"\" \"${QT_LIBRARY_DIR};${QT_BINARY_DIR}\")
  109. ")
  110. endif()
  111. configure_file("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in"
  112. "${QtDialog_BINARY_DIR}/QtDialogCPack.cmake" @ONLY)