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

197 lines
6.7 KiB

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(INKSCAPE_PATH "inkscape" CACHE PATH "Path to the Inkscape binary")
  37. set(BLENDER_PATH "blender" CACHE PATH "Path to the Blender binary")
  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 0)
  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 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. # Create install target
  118. install(DIRECTORY "${PACKAGE_INSTALL_DIR}/" DESTINATION . COMPONENT "package" USE_SOURCE_PERMISSIONS FILES_MATCHING PATTERN "*")
  119. # Create clean-build target
  120. add_custom_target(clean-build
  121. COMMAND git clean -fdX
  122. WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
  123. # Create cpack target
  124. add_custom_target(cpack
  125. COMMAND "${CMAKE_COMMAND}" --build . --target package
  126. WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
  127. DEPENDS antkeeper-source
  128. VERBATIM)
  129. # Create dist target
  130. add_custom_target(dist DEPENDS cpack)
  131. # Configure CPack variables
  132. set(CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
  133. set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
  134. set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
  135. set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
  136. set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_PLATFORM}")
  137. set(CPACK_PACKAGE_DESCRIPTION "")
  138. set(CPACK_PACKAGE_CONTACT "Christopher J. Howard <cjhoward@cjhoward.org>")
  139. set(CPACK_COMPONENTS_ALL "package")
  140. # Configure .tgz and .zip distribution packages
  141. set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
  142. #set(CPACK_ARCHIVE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.zip")
  143. #set(CPACK_ARCHIVE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.zip")
  144. # Configure .deb distribution package
  145. set(CPACK_DEB_COMPONENT_INSTALL ON)
  146. set(CPACK_DEBIAN_PACKAGE_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
  147. set(CPACK_DEBIAN_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.deb")
  148. set(CPACK_DEBIAN_PACKAGE_DEPENDS "")
  149. # Configure NSIS installer package
  150. #set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/data/icons/app-icon.ico")
  151. #set(CPACK_PACKAGE_INSTALL_DIRECTORY "App")
  152. # Build distribution packages according to target platform
  153. set(CPACK_GENERATOR "")
  154. if(PACKAGE_PLATFORM MATCHES "linux")
  155. set(CPACK_GENERATOR "TGZ;DEB")
  156. add_custom_command(TARGET dist
  157. COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIST_DIR}
  158. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}-package.tar.gz" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.tar.gz"
  159. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_DEBIAN_PACKAGE_FILE_NAME}" "${PACKAGE_DIST_DIR}")
  160. elseif(PACKAGE_PLATFORM MATCHES "win")
  161. set(CPACK_GENERATOR "ZIP;NSIS")
  162. add_custom_command(TARGET dist
  163. COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIST_DIR}
  164. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}-package.zip" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.zip"
  165. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}.exe" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.exe")
  166. elseif(PACKAGE_PLATFORM MATCHES "osx")
  167. set(CPACK_GENERATOR "ZIP;NSIS")
  168. add_custom_command(TARGET dist
  169. COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIST_DIR}
  170. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}-package.zip" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.zip")
  171. endif()
  172. # Include CPack macro
  173. include(CPack)