CMakeLists.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
  2. qt5_wrap_cpp(MOC_HEADERS
  3. qhotkey.h
  4. qhotkey_p.h)
  5. set(LIBS
  6. Qt5::Core
  7. Qt5::Widgets)
  8. set(SRC_FILES
  9. qhotkey.cpp)
  10. if(APPLE)
  11. set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
  12. set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
  13. set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
  14. set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
  15. find_library(CARBON_LIBRARY Carbon)
  16. mark_as_advanced(CARBON_LIBRARY)
  17. set(SRC_FILES ${SRC_FILES} qhotkey_mac.cpp)
  18. set(LIBS ${LIBS} ${CARBON_LIBRARY})
  19. elseif(WIN32)
  20. set(SRC_FILES ${SRC_FILES} qhotkey_win.cpp)
  21. else()
  22. find_package(X11 REQUIRED)
  23. find_package(Qt5X11Extras REQUIRED)
  24. include_directories(${X11_INCLUDE_DIR})
  25. set(LIBS ${LIBS} ${X11_LIBRARIES} Qt5::X11Extras)
  26. set(SRC_FILES ${SRC_FILES} qhotkey_x11.cpp)
  27. endif()
  28. add_library(qhotkey ${SRC_FILES} ${MOC_HEADERS})
  29. add_library(QHotkey::QHotkey ALIAS qhotkey)
  30. target_link_libraries(qhotkey ${LIBS})
  31. target_include_directories(qhotkey
  32. PUBLIC
  33. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
  34. $<INSTALL_INTERFACE:include>)