MPD client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. project (nncmpp C)
  2. cmake_minimum_required (VERSION 2.8.5)
  3. # Moar warnings
  4. if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
  5. set (wdisabled "-Wno-unused-function -Wno-implicit-fallthrough")
  6. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra ${wdisabled}")
  7. endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
  8. # Version
  9. set (project_VERSION_MAJOR "0")
  10. set (project_VERSION_MINOR "9")
  11. set (project_VERSION_PATCH "0")
  12. set (project_VERSION "${project_VERSION_MAJOR}")
  13. set (project_VERSION "${project_VERSION}.${project_VERSION_MINOR}")
  14. set (project_VERSION "${project_VERSION}.${project_VERSION_PATCH}")
  15. # For custom modules
  16. set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/liberty/cmake)
  17. # Dependencies
  18. find_package (Ncursesw REQUIRED)
  19. find_package (PkgConfig REQUIRED)
  20. find_package (Unistring REQUIRED)
  21. pkg_check_modules (curl REQUIRED libcurl)
  22. include (AddThreads)
  23. find_package (Termo QUIET NO_MODULE)
  24. option (USE_SYSTEM_TERMO
  25. "Don't compile our own termo library, use the system one" ${Termo_FOUND})
  26. if (USE_SYSTEM_TERMO)
  27. if (NOT Termo_FOUND)
  28. message (FATAL_ERROR "System termo library not found")
  29. endif (NOT Termo_FOUND)
  30. else (USE_SYSTEM_TERMO)
  31. add_subdirectory (termo EXCLUDE_FROM_ALL)
  32. # We don't have many good choices when we don't want to install it and want
  33. # to support older versions of CMake; this is a relatively clean approach
  34. # (other possibilities: setting a variable in the parent scope, using a
  35. # cache variable, writing a special config file with build paths in it and
  36. # including it here, or setting a custom property on the targets).
  37. get_directory_property (Termo_INCLUDE_DIRS
  38. DIRECTORY termo INCLUDE_DIRECTORIES)
  39. set (Termo_LIBRARIES termo-static)
  40. endif (USE_SYSTEM_TERMO)
  41. include_directories (${UNISTRING_INCLUDE_DIRS}
  42. ${NCURSESW_INCLUDE_DIRS} ${Termo_INCLUDE_DIRS} ${curl_INCLUDE_DIRS})
  43. link_directories (${curl_LIBRARY_DIRS})
  44. # Configuration
  45. include (CheckFunctionExists)
  46. set (CMAKE_REQUIRED_LIBRARIES ${NCURSESW_LIBRARIES})
  47. CHECK_FUNCTION_EXISTS ("resizeterm" HAVE_RESIZETERM)
  48. # Generate a configuration file
  49. configure_file (${PROJECT_SOURCE_DIR}/config.h.in
  50. ${PROJECT_BINARY_DIR}/config.h)
  51. include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
  52. # Build the main executable and link it
  53. add_executable (${PROJECT_NAME} ${PROJECT_NAME}.c)
  54. target_link_libraries (${PROJECT_NAME} ${UNISTRING_LIBRARIES}
  55. ${NCURSESW_LIBRARIES} termo-static ${curl_LIBRARIES})
  56. add_threads (${PROJECT_NAME})
  57. # Installation
  58. include (GNUInstallDirs)
  59. install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
  60. install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
  61. # Generate documentation from program help
  62. find_program (HELP2MAN_EXECUTABLE help2man)
  63. if (NOT HELP2MAN_EXECUTABLE)
  64. message (FATAL_ERROR "help2man not found")
  65. endif (NOT HELP2MAN_EXECUTABLE)
  66. foreach (page ${PROJECT_NAME})
  67. set (page_output "${PROJECT_BINARY_DIR}/${page}.1")
  68. list (APPEND project_MAN_PAGES "${page_output}")
  69. add_custom_command (OUTPUT ${page_output}
  70. COMMAND ${HELP2MAN_EXECUTABLE} -N
  71. "${PROJECT_BINARY_DIR}/${page}" -o ${page_output}
  72. DEPENDS ${page}
  73. COMMENT "Generating man page for ${page}" VERBATIM)
  74. endforeach (page)
  75. add_custom_target (docs ALL DEPENDS ${project_MAN_PAGES})
  76. foreach (page ${project_MAN_PAGES})
  77. string (REGEX MATCH "\\.([0-9])$" manpage_suffix "${page}")
  78. install (FILES "${page}"
  79. DESTINATION "${CMAKE_INSTALL_MANDIR}/man${CMAKE_MATCH_1}")
  80. endforeach (page)
  81. # CPack
  82. set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "MPD client")
  83. set (CPACK_PACKAGE_VENDOR "Premysl Janouch")
  84. set (CPACK_PACKAGE_CONTACT "Přemysl Janouch <p@janouch.name>")
  85. set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
  86. set (CPACK_PACKAGE_VERSION_MAJOR ${project_VERSION_MAJOR})
  87. set (CPACK_PACKAGE_VERSION_MINOR ${project_VERSION_MINOR})
  88. set (CPACK_PACKAGE_VERSION_PATCH ${project_VERSION_PATCH})
  89. set (CPACK_GENERATOR "TGZ;ZIP")
  90. set (CPACK_PACKAGE_FILE_NAME
  91. "${PROJECT_NAME}-${project_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
  92. set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}-${project_VERSION}")
  93. set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
  94. set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user")
  95. set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${project_VERSION}")
  96. set (CPACK_SET_DESTDIR TRUE)
  97. include (CPack)