🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
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.

305 lines
11 KiB

  1. # PhysicsFS; a portable, flexible file i/o abstraction.
  2. #
  3. # Please see the file LICENSE.txt in the source's root directory.
  4. # The CMake project file is meant to get this compiling on all sorts of
  5. # platforms quickly, and serve as the way Unix platforms and Linux distros
  6. # package up official builds, but you don't _need_ to use this; we have
  7. # built PhysicsFS to (hopefully) be able to drop into your project and
  8. # compile, using preprocessor checks for platform-specific bits instead of
  9. # testing in here.
  10. cmake_minimum_required(VERSION 2.8.4)
  11. project(PhysicsFS)
  12. set(PHYSFS_VERSION 3.0.2)
  13. # Increment this if/when we break backwards compatibility.
  14. set(PHYSFS_SOVERSION 1)
  15. # I hate that they define "WIN32" ... we're about to move to Win64...I hope!
  16. if(WIN32 AND NOT WINDOWS)
  17. set(WINDOWS TRUE)
  18. endif()
  19. include_directories(./src)
  20. if(APPLE)
  21. set(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework IOKit -framework Foundation")
  22. set(PHYSFS_M_SRCS src/physfs_platform_apple.m)
  23. endif()
  24. if(CMAKE_COMPILER_IS_GNUCC)
  25. # Don't use -rpath.
  26. set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE)
  27. endif()
  28. if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
  29. add_definitions(-erroff=E_EMPTY_TRANSLATION_UNIT)
  30. add_definitions(-xldscope=hidden)
  31. endif()
  32. if(HAIKU)
  33. # We add this explicitly, since we don't want CMake to think this
  34. # is a C++ project unless we're on Haiku.
  35. set(PHYSFS_CPP_SRCS src/physfs_platform_haiku.cpp)
  36. find_library(BE_LIBRARY be)
  37. find_library(ROOT_LIBRARY root)
  38. set(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY})
  39. endif()
  40. if(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
  41. set(WINRT TRUE)
  42. endif()
  43. if(WINRT)
  44. set(PHYSFS_CPP_SRCS src/physfs_platform_winrt.cpp)
  45. endif()
  46. if(UNIX AND NOT WINDOWS AND NOT APPLE) # (MingW and such might be UNIX _and_ WINDOWS!)
  47. find_library(PTHREAD_LIBRARY pthread)
  48. if(PTHREAD_LIBRARY)
  49. set(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${PTHREAD_LIBRARY})
  50. endif()
  51. endif()
  52. # Almost everything is "compiled" here, but things that don't apply to the
  53. # build are #ifdef'd out. This is to make it easy to embed PhysicsFS into
  54. # another project or bring up a new build system: just compile all the source
  55. # code and #define the things you want.
  56. set(PHYSFS_SRCS
  57. src/physfs.c
  58. src/physfs_byteorder.c
  59. src/physfs_unicode.c
  60. src/physfs_platform_posix.c
  61. src/physfs_platform_unix.c
  62. src/physfs_platform_windows.c
  63. src/physfs_platform_os2.c
  64. src/physfs_platform_qnx.c
  65. src/physfs_archiver_dir.c
  66. src/physfs_archiver_unpacked.c
  67. src/physfs_archiver_grp.c
  68. src/physfs_archiver_hog.c
  69. src/physfs_archiver_7z.c
  70. src/physfs_archiver_mvl.c
  71. src/physfs_archiver_qpak.c
  72. src/physfs_archiver_wad.c
  73. src/physfs_archiver_zip.c
  74. src/physfs_archiver_slb.c
  75. src/physfs_archiver_iso9660.c
  76. src/physfs_archiver_vdf.c
  77. ${PHYSFS_CPP_SRCS}
  78. ${PHYSFS_M_SRCS}
  79. )
  80. # Archivers ...
  81. # These are (mostly) on by default now, so these options are only useful for
  82. # disabling them.
  83. option(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" TRUE)
  84. if(NOT PHYSFS_ARCHIVE_ZIP)
  85. add_definitions(-DPHYSFS_SUPPORTS_ZIP=0)
  86. endif()
  87. option(PHYSFS_ARCHIVE_7Z "Enable 7zip support" TRUE)
  88. if(NOT PHYSFS_ARCHIVE_7Z)
  89. add_definitions(-DPHYSFS_SUPPORTS_7Z=0)
  90. endif()
  91. option(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE)
  92. if(NOT PHYSFS_ARCHIVE_GRP)
  93. add_definitions(-DPHYSFS_SUPPORTS_GRP=0)
  94. endif()
  95. option(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" TRUE)
  96. if(NOT PHYSFS_ARCHIVE_WAD)
  97. add_definitions(-DPHYSFS_SUPPORTS_WAD=0)
  98. endif()
  99. option(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" TRUE)
  100. if(NOT PHYSFS_ARCHIVE_HOG)
  101. add_definitions(-DPHYSFS_SUPPORTS_HOG=0)
  102. endif()
  103. option(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" TRUE)
  104. if(NOT PHYSFS_ARCHIVE_MVL)
  105. add_definitions(-DPHYSFS_SUPPORTS_MVL=0)
  106. endif()
  107. option(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" TRUE)
  108. if(NOT PHYSFS_ARCHIVE_QPAK)
  109. add_definitions(-DPHYSFS_SUPPORTS_QPAK=0)
  110. endif()
  111. option(PHYSFS_ARCHIVE_SLB "Enable I-War / Independence War SLB support" TRUE)
  112. if(NOT PHYSFS_ARCHIVE_SLB)
  113. add_definitions(-DPHYSFS_SUPPORTS_SLB=0)
  114. endif()
  115. option(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE)
  116. if(NOT PHYSFS_ARCHIVE_ISO9660)
  117. add_definitions(-DPHYSFS_SUPPORTS_ISO9660=0)
  118. endif()
  119. option(PHYSFS_ARCHIVE_VDF "Enable Gothic I/II VDF archive support" TRUE)
  120. if(NOT PHYSFS_ARCHIVE_VDF)
  121. add_definitions(-DPHYSFS_SUPPORTS_VDF=0)
  122. endif()
  123. option(PHYSFS_BUILD_STATIC "Build static library" TRUE)
  124. if(PHYSFS_BUILD_STATIC)
  125. add_library(physfs-static STATIC ${PHYSFS_SRCS})
  126. # Don't rename this on Windows, since DLLs will also produce an import
  127. # library named "physfs.lib" which would conflict; Unix tend to like the
  128. # same library name with a different extension for static libs, but
  129. # Windows can just have a separate name.
  130. if(NOT MSVC)
  131. set_target_properties(physfs-static PROPERTIES OUTPUT_NAME "physfs")
  132. endif()
  133. if(WINRT)
  134. # Ignore LNK4264 warnings; we don't author any WinRT components, just consume them, so we're okay in a static library.
  135. set_target_properties(physfs-static PROPERTIES VS_WINRT_COMPONENT True)
  136. set_target_properties(physfs-static PROPERTIES STATIC_LIBRARY_FLAGS "/ignore:4264")
  137. endif()
  138. set(PHYSFS_LIB_TARGET physfs-static)
  139. set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs-static")
  140. endif()
  141. option(PHYSFS_BUILD_SHARED "Build shared library" TRUE)
  142. if(PHYSFS_BUILD_SHARED)
  143. add_library(physfs SHARED ${PHYSFS_SRCS})
  144. set_target_properties(physfs PROPERTIES MACOSX_RPATH 1)
  145. set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
  146. set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
  147. if(WINRT)
  148. set_target_properties(physfs PROPERTIES VS_WINRT_COMPONENT True)
  149. endif()
  150. target_link_libraries(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS})
  151. set(PHYSFS_LIB_TARGET physfs)
  152. set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs")
  153. endif()
  154. if(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
  155. message(FATAL "Both shared and static libraries are disabled!")
  156. endif()
  157. # CMake FAQ says I need this...
  158. if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC AND NOT WINDOWS)
  159. set_target_properties(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1)
  160. set_target_properties(physfs-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
  161. endif()
  162. option(PHYSFS_BUILD_TEST "Build stdio test program." TRUE)
  163. mark_as_advanced(PHYSFS_BUILD_TEST)
  164. if(PHYSFS_BUILD_TEST)
  165. find_path(READLINE_H readline/readline.h)
  166. find_path(HISTORY_H readline/history.h)
  167. if(READLINE_H AND HISTORY_H)
  168. find_library(CURSES_LIBRARY NAMES curses ncurses)
  169. set(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
  170. find_library(READLINE_LIBRARY readline)
  171. if(READLINE_LIBRARY)
  172. set(HAVE_SYSTEM_READLINE TRUE)
  173. set(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY})
  174. include_directories(SYSTEM ${READLINE_H} ${HISTORY_H})
  175. add_definitions(-DPHYSFS_HAVE_READLINE=1)
  176. endif()
  177. endif()
  178. add_executable(test_physfs test/test_physfs.c)
  179. target_link_libraries(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
  180. set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
  181. endif()
  182. install(TARGETS ${PHYSFS_INSTALL_TARGETS}
  183. RUNTIME DESTINATION bin
  184. LIBRARY DESTINATION lib${LIB_SUFFIX}
  185. ARCHIVE DESTINATION lib${LIB_SUFFIX})
  186. install(FILES src/physfs.h DESTINATION include)
  187. find_package(Doxygen)
  188. if(DOXYGEN_FOUND)
  189. set(PHYSFS_OUTPUT_DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
  190. configure_file(
  191. "${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile"
  192. "${PHYSFS_OUTPUT_DOXYFILE}"
  193. COPYONLY
  194. )
  195. file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n\n# Below auto-generated by cmake...\n\n")
  196. file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "PROJECT_NUMBER = \"${PHYSFS_VERSION}\"\n")
  197. file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "OUTPUT_DIRECTORY = \"${CMAKE_CURRENT_BINARY_DIR}/docs\"\n")
  198. file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n# End auto-generated section.\n\n")
  199. set(PHYSFS_TARGETNAME_DOCS "docs" CACHE STRING "Name of 'docs' build target")
  200. add_custom_target(
  201. ${PHYSFS_TARGETNAME_DOCS}
  202. ${DOXYGEN_EXECUTABLE} "${PHYSFS_OUTPUT_DOXYFILE}"
  203. WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  204. COMMENT "Building documentation in 'docs' directory..."
  205. )
  206. else()
  207. message(STATUS "Doxygen not found. You won't be able to build documentation.")
  208. endif()
  209. if(UNIX)
  210. set(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.bz2")
  211. set(PHYSFS_TARGETNAME_DIST "dist" CACHE STRING "Name of 'dist' build target")
  212. add_custom_target(
  213. ${PHYSFS_TARGETNAME_DIST}
  214. hg archive -t tbz2 "${PHYSFS_TARBALL}"
  215. WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  216. COMMENT "Building source tarball '${PHYSFS_TARBALL}'..."
  217. )
  218. set(PHYSFS_TARGETNAME_UNINSTALL "uninstall" CACHE STRING "Name of 'uninstall' build target")
  219. add_custom_target(
  220. ${PHYSFS_TARGETNAME_UNINSTALL}
  221. "${CMAKE_CURRENT_SOURCE_DIR}/extras/uninstall.sh"
  222. WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
  223. COMMENT "Uninstall the project..."
  224. )
  225. endif()
  226. if(NOT MSVC)
  227. configure_file(
  228. "extras/physfs.pc.in"
  229. "extras/physfs.pc"
  230. @ONLY
  231. )
  232. install(
  233. FILES "${CMAKE_CURRENT_BINARY_DIR}/extras/physfs.pc"
  234. DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
  235. )
  236. endif()
  237. macro(message_bool_option _NAME _VALUE)
  238. if(${_VALUE})
  239. message(STATUS " ${_NAME}: enabled")
  240. else()
  241. message(STATUS " ${_NAME}: disabled")
  242. endif()
  243. endmacro()
  244. message(STATUS "PhysicsFS will build with the following options:")
  245. message_bool_option("ZIP support" PHYSFS_ARCHIVE_ZIP)
  246. message_bool_option("7zip support" PHYSFS_ARCHIVE_7Z)
  247. message_bool_option("GRP support" PHYSFS_ARCHIVE_GRP)
  248. message_bool_option("WAD support" PHYSFS_ARCHIVE_WAD)
  249. message_bool_option("HOG support" PHYSFS_ARCHIVE_HOG)
  250. message_bool_option("MVL support" PHYSFS_ARCHIVE_MVL)
  251. message_bool_option("QPAK support" PHYSFS_ARCHIVE_QPAK)
  252. message_bool_option("SLB support" PHYSFS_ARCHIVE_SLB)
  253. message_bool_option("VDF support" PHYSFS_ARCHIVE_VDF)
  254. message_bool_option("ISO9660 support" PHYSFS_ARCHIVE_ISO9660)
  255. message_bool_option("Build static library" PHYSFS_BUILD_STATIC)
  256. message_bool_option("Build shared library" PHYSFS_BUILD_SHARED)
  257. message_bool_option("Build stdio test program" PHYSFS_BUILD_TEST)
  258. if(PHYSFS_BUILD_TEST)
  259. message_bool_option(" Use readline in test program" HAVE_SYSTEM_READLINE)
  260. endif()
  261. # end of CMakeLists.txt ...