Multiplayer terminal drawing application
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 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. project (autistdraw 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. # -Wunused-function is pretty annoying here, as everything is static
  6. set (wdisabled "-Wno-unused-function -Wno-implicit-fallthrough")
  7. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Wextra ${wdisabled}")
  8. endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
  9. if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
  10. include_directories (/usr/local/include)
  11. link_directories (/usr/local/lib)
  12. # Need this for SIGWINCH in FreeBSD and OpenBSD respectively;
  13. # our POSIX version macros make it undefined
  14. add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1)
  15. endif ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
  16. # Build options
  17. option (USE_SYSTEM_TERMO "Don't compile our own termo, use the system one" OFF)
  18. # Version
  19. set (project_VERSION_MAJOR "0")
  20. set (project_VERSION_MINOR "1")
  21. set (project_VERSION_PATCH "0")
  22. set (project_VERSION "${project_VERSION_MAJOR}")
  23. set (project_VERSION "${project_VERSION}.${project_VERSION_MINOR}")
  24. set (project_VERSION "${project_VERSION}.${project_VERSION_PATCH}")
  25. # For custom modules
  26. set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
  27. # Dependencies
  28. find_package (LibEV REQUIRED)
  29. find_package (Ncursesw REQUIRED)
  30. if (USE_SYSTEM_TERMO)
  31. find_package (Termo REQUIRED)
  32. else (USE_SYSTEM_TERMO)
  33. add_subdirectory (termo EXCLUDE_FROM_ALL)
  34. # We don't have many good choices when we don't want to install it and want
  35. # to support older versions of CMake; this is a relatively clean approach
  36. # (other possibilities: setting a variable in the parent scope, using a
  37. # cache variable, writing a special config file with build paths in it and
  38. # including it here, or setting a custom property on the targets).
  39. get_directory_property (Termo_INCLUDE_DIRS
  40. DIRECTORY termo INCLUDE_DIRECTORIES)
  41. set (Termo_LIBRARIES termo-static)
  42. endif (USE_SYSTEM_TERMO)
  43. set (project_libraries ${LIBEV_LIBRARIES} ${Termo_LIBRARIES}
  44. ${NCURSESW_LIBRARIES})
  45. include_directories (${LIBEV_INCLUDE_DIRS} ${Termo_INCLUDE_DIRS}
  46. ${NCURSESW_INCLUDE_DIRS})
  47. # -liconv may or may not be a part of libc
  48. foreach (extra iconv)
  49. find_library (extra_lib_${extra} ${extra})
  50. if (extra_lib_${extra})
  51. list (APPEND project_libraries ${extra})
  52. endif (extra_lib_${extra})
  53. endforeach (extra)
  54. # Configuration
  55. include (CheckFunctionExists)
  56. set (CMAKE_REQUIRED_LIBRARIES ${project_libraries})
  57. CHECK_FUNCTION_EXISTS ("resizeterm" HAVE_RESIZETERM)
  58. # Project source files
  59. set (project_sources ${PROJECT_NAME}.c)
  60. set (project_headers ${PROJECT_BINARY_DIR}/config.h)
  61. # Generate a configuration file
  62. configure_file (${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h)
  63. include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
  64. # Build the main executable and link it
  65. add_executable (${PROJECT_NAME} ${project_sources} ${project_headers})
  66. target_link_libraries (${PROJECT_NAME} ${project_libraries})
  67. # The files to be installed
  68. include (GNUInstallDirs)
  69. install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
  70. install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
  71. # CPack
  72. set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Terminal drawing application")
  73. set (CPACK_PACKAGE_VENDOR "Premysl Janouch")
  74. set (CPACK_PACKAGE_CONTACT "Přemysl Janouch <p@janouch.name>")
  75. set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
  76. set (CPACK_PACKAGE_VERSION_MAJOR ${project_VERSION_MAJOR})
  77. set (CPACK_PACKAGE_VERSION_MINOR ${project_VERSION_MINOR})
  78. set (CPACK_PACKAGE_VERSION_PATCH ${project_VERSION_PATCH})
  79. set (CPACK_GENERATOR "TGZ;ZIP")
  80. set (CPACK_PACKAGE_FILE_NAME
  81. "${PROJECT_NAME}-${project_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
  82. set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}-${project_VERSION}")
  83. set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
  84. set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user")
  85. set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${project_VERSION}")
  86. include (CPack)