/CMakeLists.txt

https://code.google.com/ · CMake · 136 lines · 98 code · 21 blank · 17 comment · 10 complexity · ec7ced09ccfe84363b59c24036d116ba MD5 · raw file

  1. cmake_minimum_required(VERSION 2.6)
  2. project(flvmeta C)
  3. set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
  4. set(FLVMETA_VERSION "1.1.0")
  5. set(FLVMETA_RELEASE yes)
  6. # check whether we are building a release or a git snapshot
  7. if(NOT FLVMETA_RELEASE)
  8. # check for git
  9. find_program(GIT "git")
  10. mark_as_advanced(GIT)
  11. # check whether we are in a git repository
  12. find_file(DOT_GIT ".git" ${CMAKE_SOURCE_DIR})
  13. mark_as_advanced(DOT_GIT)
  14. if(GIT AND DOT_GIT)
  15. # retrieve current revision
  16. execute_process(
  17. COMMAND "${GIT}" rev-parse --short HEAD
  18. WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
  19. OUTPUT_VARIABLE GIT_RELEASE
  20. OUTPUT_STRIP_TRAILING_WHITESPACE
  21. )
  22. set(FLVMETA_VERSION "${FLVMETA_VERSION}-g${GIT_RELEASE}")
  23. endif(GIT AND DOT_GIT)
  24. endif(NOT FLVMETA_RELEASE)
  25. # generic variables
  26. set(PACKAGE "flvmeta")
  27. set(PACKAGE_NAME ${PACKAGE})
  28. set(PACKAGE_BUGREPORT "flvmeta-discussion@googlegroups.com")
  29. set(PACKAGE_VERSION "${FLVMETA_VERSION}")
  30. set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
  31. # build options
  32. set(
  33. FLVMETA_USE_SYSTEM_LIBYAML FALSE
  34. CACHE BOOL "Link flvmeta to the installed version of libyaml"
  35. )
  36. #platform tests
  37. include(CheckFunctionExists)
  38. include(CheckIncludeFile)
  39. include(CheckTypeSize)
  40. include(TestBigEndian)
  41. check_include_file(sys/types.h HAVE_SYS_TYPES_H)
  42. check_include_file(stdint.h HAVE_STDINT_H)
  43. check_include_file(stddef.h HAVE_STDDEF_H)
  44. check_include_file(inttypes.h HAVE_INTTYPES_H)
  45. check_type_size("double" SIZEOF_DOUBLE)
  46. check_type_size("float" SIZEOF_FLOAT)
  47. check_type_size("long double" SIZEOF_LONG_DOUBLE)
  48. if(WIN32)
  49. add_definitions(-D_FILE_OFFSET_BITS=64)
  50. endif(WIN32)
  51. # MSVC before VS 2010 did not have stdint.h
  52. if(MSVC AND NOT HAVE_STDINT_H)
  53. set(int16_t 1)
  54. set(int32_t 1)
  55. set(int64_t 1)
  56. set(int8_t 1)
  57. set(uint16_t 1)
  58. set(uint32_t 1)
  59. set(uint64_t 1)
  60. set(uint8_t 1)
  61. endif(MSVC AND NOT HAVE_STDINT_H)
  62. test_big_endian(IS_BIGENDIAN)
  63. if(IS_BIGENDIAN)
  64. set(WORDS_BIGENDIAN 1)
  65. endif(IS_BIGENDIAN)
  66. # large file support
  67. check_function_exists("fseeko" HAVE_FSEEKO)
  68. if(HAVE_FSEEKO)
  69. execute_process(
  70. COMMAND getconf LFS_CFLAGS
  71. OUTPUT_VARIABLE LFS_CFLAGS
  72. ERROR_QUIET
  73. )
  74. if(LFS_CFLAGS)
  75. add_definitions(${LFS_CFLAGS})
  76. endif(LFS_CFLAGS)
  77. endif(HAVE_FSEEKO)
  78. # configuration file
  79. configure_file(config-cmake.h.in ${CMAKE_BINARY_DIR}/config.h)
  80. include_directories(${CMAKE_BINARY_DIR})
  81. add_definitions(-DHAVE_CONFIG_H)
  82. # Visual C++ specific configuration
  83. if(MSVC)
  84. # use static library
  85. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
  86. # C runtime deprecation in Visual C++ 2005 and later
  87. add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  88. endif(MSVC)
  89. # installation
  90. set(CPACK_PACKAGE_VENDOR "Marc Noirot <marc.noirot@gmail.com>")
  91. set(CPACK_PACKAGE_VERSION ${FLVMETA_VERSION})
  92. set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING)
  93. set(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README)
  94. set(CPACK_SOURCE_IGNORE_FILES "/*build*;/CVS/;/\\\\.svn/;/\\\\.bzr/;/\\\\.hg/;/\\\\.git/;\\\\.swp$;\\\\.#;/#")
  95. set(CPACK_SOURCE_PACKAGE_FILE_NAME "flvmeta-${PACKAGE_VERSION}-src")
  96. if(WIN32)
  97. if (CMAKE_CL_64)
  98. set(EXECUTABLE_TYPE "64")
  99. else(CMAKE_CL_64)
  100. set(EXECUTABLE_TYPE "32")
  101. endif(CMAKE_CL_64)
  102. set(CPACK_PACKAGE_FILE_NAME "flvmeta-${PACKAGE_VERSION}-win${EXECUTABLE_TYPE}")
  103. set(CPACK_GENERATOR ZIP)
  104. install(FILES ${CMAKE_SOURCE_DIR}/README DESTINATION . RENAME Readme.txt)
  105. install(FILES ${CMAKE_SOURCE_DIR}/COPYING DESTINATION . RENAME License.txt)
  106. install(FILES ${CMAKE_SOURCE_DIR}/NEWS DESTINATION . RENAME Changelog.txt)
  107. else(WIN32)
  108. set(CPACK_PACKAGE_FILE_NAME "flvmeta-${PACKAGE_VERSION}")
  109. endif(WIN32)
  110. include(CPack)
  111. add_subdirectory(src)
  112. add_subdirectory(man)
  113. # tests
  114. #enable_testing()
  115. #add_subdirectory(tests)