CMakeLists.txt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. cmake_minimum_required(VERSION 3.19)
  2. project(QWindowKit VERSION 1.4.0.0 LANGUAGES CXX)
  3. # ----------------------------------
  4. # Build Options
  5. # ----------------------------------
  6. option(QWINDOWKIT_BUILD_STATIC "Build static libraries" OFF)
  7. option(QWINDOWKIT_BUILD_WIDGETS "Build widgets module" ON)
  8. option(QWINDOWKIT_BUILD_QUICK "Build quick module" OFF)
  9. option(QWINDOWKIT_BUILD_EXAMPLES "Build examples" OFF)
  10. option(QWINDOWKIT_BUILD_DOCUMENTATIONS "Build documentations" OFF)
  11. option(QWINDOWKIT_INSTALL "Install library" ON)
  12. option(QWINDOWKIT_ENABLE_QT_WINDOW_CONTEXT "Enable Qt Window Context anyway" OFF)
  13. option(QWINDOWKIT_ENABLE_WINDOWS_SYSTEM_BORDERS "Enable system borders on Windows" ON)
  14. option(QWINDOWKIT_ENABLE_STYLE_AGENT "Enable building style agent" ON)
  15. #[[
  16. Detailed Introcuction to Configure Options:
  17. `QWINDOWKIT_BUILD_DOCUMENTATIONS`
  18. - If you have installed `Doxygen`, you can ENABLE this option so that the documentations
  19. will also be built and installed.
  20. - If not, you can read the comments in `qdoc` style in `cpp` files to get detailed usages
  21. of the public APIs.
  22. `QWINDOWKIT_ENABLE_WINDOWS_SYSTEM_BORDERS`
  23. - If you don't want the system borders on Windows 10/11, you can DISABLE this option.
  24. - If so, the Windows 10 top border issue will disappear. However, part of the client edge
  25. area will be occupied as the resizing margins.
  26. `QWINDOWKIT_ENABLE_QT_WINDOW_CONTEXT`
  27. - If you want to use pure Qt emulated frameless implementation, you can ENABLE this option.
  28. - If so, all system native features will be lost.
  29. `QWINDOWKIT_ENABLE_STYLE_AGENT`
  30. - Select whether to exclude the style component by DISABLING this option according to your
  31. requirements and your Qt version.
  32. #]]
  33. # ----------------------------------
  34. # CMake Settings
  35. # ----------------------------------
  36. if(MSVC)
  37. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /manifest:no")
  38. set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /manifest:no")
  39. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /manifest:no")
  40. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
  41. if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
  42. set(CMAKE_DEBUG_POSTFIX "d")
  43. endif()
  44. elseif(MINGW)
  45. set(CMAKE_STATIC_LIBRARY_PREFIX "")
  46. set(CMAKE_SHARED_LIBRARY_PREFIX "")
  47. endif()
  48. if(QWINDOWKIT_INSTALL)
  49. include(GNUInstallDirs)
  50. include(CMakePackageConfigHelpers)
  51. endif()
  52. # ----------------------------------
  53. # Project Variables
  54. # ----------------------------------
  55. set(QWINDOWKIT_VERSION ${PROJECT_VERSION})
  56. set(QWINDOWKIT_INSTALL_NAME ${PROJECT_NAME})
  57. # ----------------------------------
  58. # Find basic dependencies
  59. # ----------------------------------
  60. find_package(qmsetup QUIET)
  61. if(NOT TARGET qmsetup::library)
  62. # Modify this variable according to your project structure
  63. set(_source_dir ${CMAKE_CURRENT_SOURCE_DIR}/qmsetup)
  64. # Import install function
  65. include("${_source_dir}/cmake/modules/private/InstallPackage.cmake")
  66. # Install package in place
  67. set(_package_path)
  68. qm_install_package(qmsetup
  69. SOURCE_DIR ${_source_dir}
  70. BUILD_TYPE Release
  71. RESULT_PATH _package_path
  72. )
  73. # Find package again
  74. find_package(qmsetup REQUIRED PATHS ${_package_path})
  75. # Update import path
  76. set(qmsetup_DIR ${_package_path} CACHE PATH "" FORCE)
  77. endif()
  78. qm_import(Filesystem)
  79. qm_init_directories()
  80. # ----------------------------------
  81. # Add source modules
  82. # ----------------------------------
  83. add_subdirectory(src)
  84. if(QWINDOWKIT_BUILD_EXAMPLES)
  85. add_subdirectory(examples)
  86. endif()