CMakeLists.txt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. find_package(Qt5Widgets QUIET)
  14. if (Qt5Widgets_FOUND)
  15. include_directories(${Qt5Widgets_INCLUDE_DIRS})
  16. add_definitions(${Qt5Widgets_DEFINITONS})
  17. macro(qt4_wrap_ui)
  18. qt5_wrap_ui(${ARGN})
  19. endmacro()
  20. macro(qt4_wrap_cpp)
  21. qt5_wrap_cpp(${ARGN})
  22. endmacro()
  23. macro(qt4_add_resources)
  24. qt5_add_resources(${ARGN})
  25. endmacro()
  26. set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES})
  27. # Remove this when the minimum version of Qt is 4.6.
  28. add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
  29. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
  30. else()
  31. set(QT_MIN_VERSION "4.4.0")
  32. find_package(Qt4 REQUIRED)
  33. if(NOT QT4_FOUND)
  34. message(SEND_ERROR "Failed to find Qt 4.4 or greater.")
  35. return()
  36. endif()
  37. include(${QT_USE_FILE})
  38. endif()
  39. set(SRCS
  40. AddCacheEntry.cxx
  41. AddCacheEntry.h
  42. CMakeSetup.cxx
  43. CMakeSetupDialog.cxx
  44. CMakeSetupDialog.h
  45. FirstConfigure.cxx
  46. FirstConfigure.h
  47. QCMake.cxx
  48. QCMake.h
  49. QCMakeCacheView.cxx
  50. QCMakeCacheView.h
  51. QCMakeWidgets.cxx
  52. QCMakeWidgets.h
  53. QMacInstallDialog.cxx
  54. QMacInstallDialog.h
  55. )
  56. QT4_WRAP_UI(UI_SRCS
  57. CMakeSetupDialog.ui
  58. Compilers.ui
  59. CrossCompiler.ui
  60. AddCacheEntry.ui
  61. MacInstallDialog.ui
  62. )
  63. QT4_WRAP_CPP(MOC_SRCS
  64. AddCacheEntry.h
  65. Compilers.h
  66. CMakeSetupDialog.h
  67. FirstConfigure.h
  68. QCMake.h
  69. QCMakeCacheView.h
  70. QCMakeWidgets.h
  71. QMacInstallDialog.h
  72. )
  73. QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc)
  74. set(SRCS ${SRCS} ${UI_SRCS} ${MOC_SRCS} ${RC_SRCS})
  75. if(WIN32)
  76. set(SRCS ${SRCS} CMakeSetup.rc)
  77. endif()
  78. if(APPLE)
  79. set(SRCS ${SRCS} CMakeSetup.icns)
  80. set(MACOSX_BUNDLE_ICON_FILE CMakeSetup.icns)
  81. set_source_files_properties(CMakeSetup.icns PROPERTIES
  82. MACOSX_PACKAGE_LOCATION Resources)
  83. endif()
  84. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  85. add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS})
  86. target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES})
  87. if(APPLE)
  88. set_target_properties(cmake-gui PROPERTIES
  89. OUTPUT_NAME ${CMAKE_BUNDLE_NAME})
  90. endif()
  91. set(CMAKE_INSTALL_DESTINATION_ARGS
  92. BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}")
  93. install(TARGETS cmake-gui RUNTIME DESTINATION bin ${CMAKE_INSTALL_DESTINATION_ARGS})
  94. if(UNIX)
  95. # install a desktop file so CMake appears in the application start menu
  96. # with an icon
  97. install(FILES CMake.desktop DESTINATION share/applications )
  98. install(FILES CMakeSetup32.png DESTINATION share/pixmaps )
  99. install(FILES cmakecache.xml DESTINATION share/mime/packages )
  100. endif()
  101. if(APPLE)
  102. set(CMAKE_POSTFLIGHT_SCRIPT
  103. "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
  104. set(CMAKE_POSTUPGRADE_SCRIPT
  105. "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
  106. configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postflight.sh.in"
  107. "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
  108. configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in"
  109. "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
  110. install(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" cmake-gui
  111. WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
  112. endif()
  113. if(APPLE OR WIN32)
  114. # install rules for including 3rd party libs such as Qt
  115. # if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation
  116. set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/cmake-gui${CMAKE_EXECUTABLE_SUFFIX}")
  117. if(APPLE)
  118. set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}")
  119. endif()
  120. install(CODE "
  121. include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\")
  122. set(BU_CHMOD_BUNDLE_ITEMS ON)
  123. fixup_bundle(\"${fixup_exe}\" \"\" \"${QT_LIBRARY_DIR};${QT_BINARY_DIR}\")
  124. ")
  125. endif()
  126. set(CMAKE_PACKAGE_QTGUI TRUE)
  127. configure_file("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in"
  128. "${QtDialog_BINARY_DIR}/QtDialogCPack.cmake" @ONLY)