🛠️🐜 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.

212 lines
7.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. # Prevent in-source builds
  2. if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
  3. message(FATAL_ERROR "In-source builds prohibited. Call cmake from the build directory.")
  4. endif()
  5. cmake_minimum_required(VERSION 3.7)
  6. # Get software package name and version
  7. include(${CMAKE_SOURCE_DIR}/modules/antkeeper-source/cmake/project.cmake)
  8. # Setup package variables
  9. set(PACKAGE_NAME ${PROJECT_NAME})
  10. set(PACKAGE_VERSION ${PROJECT_VERSION})
  11. set(PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
  12. set(PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
  13. set(PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
  14. get_filename_component(PACKAGE_PLATFORM ${CMAKE_BINARY_DIR} NAME CACHE)
  15. if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  16. set(PACKAGE_BUILD_TYPE debug)
  17. else()
  18. set(PACKAGE_BUILD_TYPE release)
  19. endif()
  20. set(PACKAGE_FILENAME ${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_PLATFORM})
  21. set(PACKAGE_INSTALL_DIR ${CMAKE_SOURCE_DIR}/bin/${PACKAGE_BUILD_TYPE}/${PACKAGE_FILENAME})
  22. set(PACKAGE_DIST_DIR ${CMAKE_SOURCE_DIR}/dist/${PACKAGE_BUILD_TYPE})
  23. # Check for architecture mismatches
  24. if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
  25. if (PACKAGE_PLATFORM MATCHES "64$")
  26. message(FATAL_ERROR "Compiler architecture is 32-bit but target architecture is 64-bit.")
  27. endif()
  28. else()
  29. if (PACKAGE_PLATFORM MATCHES "32$")
  30. message(FATAL_ERROR "Compiler architecture is 64-bit but target architecture is 32-bit.")
  31. endif()
  32. endif()
  33. # Create superbuild project
  34. project(${PACKAGE_NAME}-superbuild VERSION ${PACKAGE_VERSION})
  35. # Options
  36. set(BLENDER "blender" CACHE FILEPATH "Path to Blender executable")
  37. set(INKSCAPE "inkscape" CACHE FILEPATH "Path to Inkscape executable")
  38. # Setup module directories
  39. set(MODULE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/modules")
  40. set(MODULE_BUILD_DIR "${PROJECT_BINARY_DIR}/modules/build")
  41. set(MODULE_INSTALL_DIR "${CMAKE_BINARY_DIR}/modules/install")
  42. # Include ExternalProject_Add macro
  43. include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
  44. # Build SDL2 module
  45. ExternalProject_Add(SDL2
  46. SOURCE_DIR ${MODULE_SOURCE_DIR}/SDL2
  47. BINARY_DIR ${MODULE_BUILD_DIR}/SDL2
  48. INSTALL_DIR ${MODULE_INSTALL_DIR}
  49. CMAKE_ARGS
  50. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  51. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  52. "-DSDL_ATOMIC=OFF"
  53. "-DSDL_AUDIO=OFF"
  54. "-DSDL_CPUINFO=ON"
  55. "-DSDL_DLOPEN=ON"
  56. "-DSDL_EVENTS=ON"
  57. "-DSDL_FILE=OFF"
  58. "-DSDL_FILESYSTEM=OFF"
  59. "-DSDL_HAPTIC=ON"
  60. "-DSDL_JOYSTICK=ON"
  61. "-DSDL_LOADSO=ON"
  62. "-DSDL_POWER=ON"
  63. "-DSDL_RENDER=OFF"
  64. "-DSDL_SHARED=ON"
  65. "-DSDL_STATIC=OFF"
  66. "-DSDL_STATIC_PIC=OFF"
  67. "-DSDL_TEST=OFF"
  68. "-DSDL_THREADS=OFF"
  69. "-DSDL_TIMERS=ON"
  70. "-DSDL_VIDEO=ON"
  71. "-DVIDEO_VULKAN=OFF"
  72. BUILD_ALWAYS 0)
  73. # Build OpenAL Soft module
  74. ExternalProject_Add(openal-soft
  75. SOURCE_DIR ${MODULE_SOURCE_DIR}/openal-soft
  76. BINARY_DIR ${MODULE_BUILD_DIR}/openal-soft
  77. INSTALL_DIR ${MODULE_INSTALL_DIR}
  78. CMAKE_ARGS
  79. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  80. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  81. "-DLIBTYPE=SHARED"
  82. "-DALSOFT_UTILS=OFF"
  83. "-DALSOFT_EXAMPLES=OFF"
  84. "-DALSOFT_TESTS=OFF"
  85. BUILD_ALWAYS 0)
  86. # Build VMQ module
  87. ExternalProject_Add(vmq
  88. SOURCE_DIR ${MODULE_SOURCE_DIR}/vmq
  89. BINARY_DIR ${MODULE_BUILD_DIR}/vmq
  90. INSTALL_DIR ${MODULE_INSTALL_DIR}
  91. CMAKE_ARGS
  92. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  93. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  94. "-DBUILD_EXAMPLES=OFF"
  95. BUILD_ALWAYS 1)
  96. # Build EnTT module
  97. ExternalProject_Add(entt
  98. SOURCE_DIR ${MODULE_SOURCE_DIR}/entt
  99. BINARY_DIR ${MODULE_BUILD_DIR}/entt
  100. INSTALL_DIR ${MODULE_INSTALL_DIR}
  101. CMAKE_ARGS
  102. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  103. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  104. BUILD_ALWAYS 0)
  105. # Build antkeeper-source module
  106. ExternalProject_Add(antkeeper-source
  107. DEPENDS openal-soft vmq entt
  108. SOURCE_DIR ${MODULE_SOURCE_DIR}/antkeeper-source
  109. BINARY_DIR ${MODULE_BUILD_DIR}/antkeeper-source
  110. INSTALL_DIR ${PACKAGE_INSTALL_DIR}
  111. CMAKE_ARGS
  112. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  113. "-DCMAKE_INSTALL_PREFIX=${PACKAGE_INSTALL_DIR}"
  114. "-DPACKAGE_PLATFORM=${PACKAGE_PLATFORM}"
  115. "-DCMAKE_PREFIX_PATH=${MODULE_INSTALL_DIR}"
  116. BUILD_ALWAYS 1)
  117. # Build antkeeper-data module
  118. ExternalProject_Add(antkeeper-data
  119. DEPENDS antkeeper-source
  120. SOURCE_DIR ${MODULE_SOURCE_DIR}/antkeeper-data
  121. BINARY_DIR ${MODULE_BUILD_DIR}/antkeeper-data
  122. INSTALL_DIR ${PACKAGE_INSTALL_DIR}
  123. CMAKE_ARGS
  124. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  125. "-DCMAKE_INSTALL_PREFIX=${PACKAGE_INSTALL_DIR}"
  126. "-DPACKAGE_PLATFORM=${PACKAGE_PLATFORM}"
  127. "-DCMAKE_PREFIX_PATH=${MODULE_INSTALL_DIR}"
  128. "-DBLENDER=${BLENDER}"
  129. "-DINKSCAPE=${INKSCAPE}"
  130. BUILD_ALWAYS 1)
  131. # Create install target
  132. install(DIRECTORY "${PACKAGE_INSTALL_DIR}/" DESTINATION . COMPONENT "package" USE_SOURCE_PERMISSIONS FILES_MATCHING PATTERN "*")
  133. # Create clean-build target
  134. add_custom_target(clean-build
  135. COMMAND git clean -fdX
  136. WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
  137. # Create cpack target
  138. add_custom_target(cpack
  139. COMMAND "${CMAKE_COMMAND}" --build . --target package
  140. WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
  141. DEPENDS antkeeper-source
  142. VERBATIM)
  143. # Create dist target
  144. add_custom_target(dist DEPENDS cpack)
  145. # Configure CPack variables
  146. set(CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
  147. set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
  148. set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
  149. set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
  150. set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_PLATFORM}")
  151. set(CPACK_PACKAGE_DESCRIPTION "")
  152. set(CPACK_PACKAGE_CONTACT "Christopher J. Howard <cjhoward@cjhoward.org>")
  153. set(CPACK_COMPONENTS_ALL "package")
  154. # Configure .tgz and .zip distribution packages
  155. set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
  156. #set(CPACK_ARCHIVE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.zip")
  157. #set(CPACK_ARCHIVE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.zip")
  158. # Configure .deb distribution package
  159. set(CPACK_DEB_COMPONENT_INSTALL ON)
  160. set(CPACK_DEBIAN_PACKAGE_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
  161. set(CPACK_DEBIAN_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.deb")
  162. set(CPACK_DEBIAN_PACKAGE_DEPENDS "")
  163. # Configure NSIS installer package
  164. #set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/data/icons/app-icon.ico")
  165. #set(CPACK_PACKAGE_INSTALL_DIRECTORY "App")
  166. # Build distribution packages according to target platform
  167. set(CPACK_GENERATOR "")
  168. if(PACKAGE_PLATFORM MATCHES "linux")
  169. set(CPACK_GENERATOR "TGZ;DEB")
  170. add_custom_command(TARGET dist
  171. COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIST_DIR}
  172. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}-package.tar.gz" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.tar.gz"
  173. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_DEBIAN_PACKAGE_FILE_NAME}" "${PACKAGE_DIST_DIR}")
  174. elseif(PACKAGE_PLATFORM MATCHES "win")
  175. set(CPACK_GENERATOR "ZIP;NSIS")
  176. add_custom_command(TARGET dist
  177. COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIST_DIR}
  178. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}-package.zip" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.zip"
  179. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}.exe" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.exe")
  180. elseif(PACKAGE_PLATFORM MATCHES "osx")
  181. set(CPACK_GENERATOR "ZIP;NSIS")
  182. add_custom_command(TARGET dist
  183. COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIST_DIR}
  184. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}-package.zip" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.zip")
  185. endif()
  186. # Include CPack macro
  187. include(CPack)