CMakeLists.txt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. if(POLICY CMP0020)
  14. cmake_policy(SET CMP0020 NEW) # Drop when CMake >= 2.8.11 required
  15. endif()
  16. find_package(Qt5Widgets QUIET)
  17. if (Qt5Widgets_FOUND)
  18. include_directories(${Qt5Widgets_INCLUDE_DIRS})
  19. add_definitions(${Qt5Widgets_DEFINITONS})
  20. macro(qt4_wrap_ui)
  21. qt5_wrap_ui(${ARGN})
  22. endmacro()
  23. macro(qt4_wrap_cpp)
  24. qt5_wrap_cpp(${ARGN})
  25. endmacro()
  26. macro(qt4_add_resources)
  27. qt5_add_resources(${ARGN})
  28. endmacro()
  29. set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES})
  30. # Remove this when the minimum version of Qt is 4.6.
  31. add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
  32. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
  33. if(WIN32 AND TARGET Qt5::Core)
  34. get_property(_Qt5_Core_LOCATION TARGET Qt5::Core PROPERTY LOCATION)
  35. get_filename_component(Qt_BIN_DIR "${_Qt5_Core_LOCATION}" PATH)
  36. endif()
  37. else()
  38. set(QT_MIN_VERSION "4.4.0")
  39. find_package(Qt4 REQUIRED)
  40. if(NOT QT4_FOUND)
  41. message(SEND_ERROR "Failed to find Qt 4.4 or greater.")
  42. return()
  43. endif()
  44. include(${QT_USE_FILE})
  45. if(WIN32 AND EXISTS "${QT_QMAKE_EXECUTABLE}")
  46. get_filename_component(_Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH)
  47. if(EXISTS "${_Qt_BIN_DIR}/QtCore4.dll")
  48. set(Qt_BIN_DIR ${_Qt_BIN_DIR})
  49. endif()
  50. endif()
  51. endif()
  52. set(SRCS
  53. AddCacheEntry.cxx
  54. AddCacheEntry.h
  55. CMakeSetup.cxx
  56. CMakeSetupDialog.cxx
  57. CMakeSetupDialog.h
  58. FirstConfigure.cxx
  59. FirstConfigure.h
  60. QCMake.cxx
  61. QCMake.h
  62. QCMakeCacheView.cxx
  63. QCMakeCacheView.h
  64. QCMakeWidgets.cxx
  65. QCMakeWidgets.h
  66. QMacInstallDialog.cxx
  67. QMacInstallDialog.h
  68. )
  69. QT4_WRAP_UI(UI_SRCS
  70. CMakeSetupDialog.ui
  71. Compilers.ui
  72. CrossCompiler.ui
  73. AddCacheEntry.ui
  74. MacInstallDialog.ui
  75. )
  76. QT4_WRAP_CPP(MOC_SRCS
  77. AddCacheEntry.h
  78. Compilers.h
  79. CMakeSetupDialog.h
  80. FirstConfigure.h
  81. QCMake.h
  82. QCMakeCacheView.h
  83. QCMakeWidgets.h
  84. QMacInstallDialog.h
  85. )
  86. QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc)
  87. set(SRCS ${SRCS} ${UI_SRCS} ${MOC_SRCS} ${RC_SRCS})
  88. if(WIN32)
  89. set(SRCS ${SRCS} CMakeSetup.rc)
  90. endif()
  91. if(APPLE)
  92. set(SRCS ${SRCS} CMakeSetup.icns)
  93. set(MACOSX_BUNDLE_ICON_FILE CMakeSetup.icns)
  94. set_source_files_properties(CMakeSetup.icns PROPERTIES
  95. MACOSX_PACKAGE_LOCATION Resources)
  96. endif()
  97. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  98. add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS})
  99. target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES})
  100. if(Qt_BIN_DIR)
  101. set_property(TARGET cmake-gui PROPERTY Qt_BIN_DIR ${Qt_BIN_DIR})
  102. endif()
  103. if(APPLE)
  104. set_target_properties(cmake-gui PROPERTIES
  105. OUTPUT_NAME ${CMAKE_BUNDLE_NAME}
  106. MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in"
  107. MACOSX_BUNDLE_SHORT_VERSION_STRING "${CMAKE_BUNDLE_VERSION}"
  108. # TBD: MACOSX_BUNDLE_BUNDLE_VERSION "${CMAKE_BUNDLE_VERSION}"
  109. MACOSX_BUNDLE_COPYRIGHT "Copyright 2000-2013 Kitware, Inc."
  110. )
  111. # Create a symlink in the build tree to provide a "cmake-gui" next
  112. # to the "cmake" executable that refers to the application bundle.
  113. add_custom_command(TARGET cmake-gui POST_BUILD
  114. COMMAND ln -sf ${CMAKE_BUNDLE_NAME}.app/Contents/MacOS/${CMAKE_BUNDLE_NAME}
  115. $<TARGET_FILE_DIR:cmake>/cmake-gui
  116. )
  117. endif()
  118. set(CMAKE_INSTALL_DESTINATION_ARGS
  119. BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}")
  120. install(TARGETS cmake-gui RUNTIME DESTINATION bin ${CMAKE_INSTALL_DESTINATION_ARGS})
  121. if(UNIX)
  122. # install a desktop file so CMake appears in the application start menu
  123. # with an icon
  124. install(FILES CMake.desktop DESTINATION share/applications )
  125. install(FILES CMakeSetup32.png DESTINATION share/pixmaps )
  126. install(FILES cmakecache.xml DESTINATION share/mime/packages )
  127. endif()
  128. if(APPLE)
  129. set(CMAKE_POSTFLIGHT_SCRIPT
  130. "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
  131. set(CMAKE_POSTUPGRADE_SCRIPT
  132. "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
  133. configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postflight.sh.in"
  134. "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
  135. configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in"
  136. "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
  137. install(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" cmake-gui
  138. WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
  139. endif()
  140. if(APPLE OR WIN32)
  141. # install rules for including 3rd party libs such as Qt
  142. # if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation
  143. set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/cmake-gui${CMAKE_EXECUTABLE_SUFFIX}")
  144. if(APPLE)
  145. set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}")
  146. endif()
  147. install(CODE "
  148. include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\")
  149. set(BU_CHMOD_BUNDLE_ITEMS ON)
  150. fixup_bundle(\"${fixup_exe}\" \"\" \"${QT_LIBRARY_DIR};${QT_BINARY_DIR}\")
  151. ")
  152. endif()
  153. set(CMAKE_PACKAGE_QTGUI TRUE)
  154. configure_file("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in"
  155. "${QtDialog_BINARY_DIR}/QtDialogCPack.cmake" @ONLY)