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

199 lines
6.8 KiB

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(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 glfw module
  74. ExternalProject_Add(glfw
  75. SOURCE_DIR ${MODULE_SOURCE_DIR}/glfw
  76. BINARY_DIR ${MODULE_BUILD_DIR}/glfw
  77. INSTALL_DIR ${MODULE_INSTALL_DIR}
  78. CMAKE_ARGS
  79. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  80. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  81. "-DBUILD_SHARED_LIBS=ON"
  82. "-DGLFW_BUILD_EXAMPLES=OFF"
  83. "-DGLFW_BUILD_TESTS=OFF"
  84. "-DGLFW_BUILD_DOCS=OFF"
  85. "-DGLFW_INSTALL=ON"
  86. "-DGLFW_VULKAN_STATIC=OFF"
  87. BUILD_ALWAYS 0)
  88. # Build VMQ module
  89. ExternalProject_Add(vmq
  90. SOURCE_DIR ${MODULE_SOURCE_DIR}/vmq
  91. BINARY_DIR ${MODULE_BUILD_DIR}/vmq
  92. INSTALL_DIR ${MODULE_INSTALL_DIR}
  93. CMAKE_ARGS
  94. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  95. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  96. "-DBUILD_EXAMPLES=OFF"
  97. BUILD_ALWAYS 0)
  98. # Build EnTT module
  99. ExternalProject_Add(entt
  100. SOURCE_DIR ${MODULE_SOURCE_DIR}/entt
  101. BINARY_DIR ${MODULE_BUILD_DIR}/entt
  102. INSTALL_DIR ${MODULE_INSTALL_DIR}
  103. CMAKE_ARGS
  104. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  105. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  106. BUILD_ALWAYS 0)
  107. # Build antkeeper-source module
  108. ExternalProject_Add(antkeeper-source
  109. DEPENDS vmq entt
  110. SOURCE_DIR ${MODULE_SOURCE_DIR}/antkeeper-source
  111. BINARY_DIR ${MODULE_BUILD_DIR}/antkeeper-source
  112. INSTALL_DIR ${PACKAGE_INSTALL_DIR}
  113. CMAKE_ARGS
  114. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  115. "-DCMAKE_INSTALL_PREFIX=${PACKAGE_INSTALL_DIR}"
  116. "-DPACKAGE_PLATFORM=${PACKAGE_PLATFORM}"
  117. "-DCMAKE_PREFIX_PATH=${MODULE_INSTALL_DIR}"
  118. BUILD_ALWAYS 1)
  119. # Create install target
  120. install(DIRECTORY "${PACKAGE_INSTALL_DIR}/" DESTINATION . COMPONENT "package" USE_SOURCE_PERMISSIONS FILES_MATCHING PATTERN "*")
  121. # Create clean-build target
  122. add_custom_target(clean-build
  123. COMMAND git clean -fdX
  124. WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
  125. # Create cpack target
  126. add_custom_target(cpack
  127. COMMAND "${CMAKE_COMMAND}" --build . --target package
  128. WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
  129. DEPENDS antkeeper-source
  130. VERBATIM)
  131. # Create dist target
  132. add_custom_target(dist DEPENDS cpack)
  133. # Configure CPack variables
  134. set(CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
  135. set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
  136. set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
  137. set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
  138. set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_PLATFORM}")
  139. set(CPACK_PACKAGE_DESCRIPTION "")
  140. set(CPACK_PACKAGE_CONTACT "Christopher J. Howard <cjhoward@cjhoward.org>")
  141. set(CPACK_COMPONENTS_ALL "package")
  142. # Configure .tgz and .zip distribution packages
  143. set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
  144. #set(CPACK_ARCHIVE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.zip")
  145. #set(CPACK_ARCHIVE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.zip")
  146. # Configure .deb distribution package
  147. set(CPACK_DEB_COMPONENT_INSTALL ON)
  148. set(CPACK_DEBIAN_PACKAGE_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
  149. set(CPACK_DEBIAN_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.deb")
  150. set(CPACK_DEBIAN_PACKAGE_DEPENDS "")
  151. # Configure NSIS installer package
  152. #set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/data/icons/app-icon.ico")
  153. #set(CPACK_PACKAGE_INSTALL_DIRECTORY "App")
  154. # Build distribution packages according to target platform
  155. set(CPACK_GENERATOR "")
  156. if(PACKAGE_PLATFORM MATCHES "linux")
  157. set(CPACK_GENERATOR "TGZ;DEB")
  158. add_custom_command(TARGET dist
  159. COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIST_DIR}
  160. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}-package.tar.gz" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.tar.gz"
  161. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_DEBIAN_PACKAGE_FILE_NAME}" "${PACKAGE_DIST_DIR}")
  162. elseif(PACKAGE_PLATFORM MATCHES "win")
  163. set(CPACK_GENERATOR "ZIP;NSIS")
  164. add_custom_command(TARGET dist
  165. COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIST_DIR}
  166. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}-package.zip" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.zip"
  167. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}.exe" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.exe")
  168. elseif(PACKAGE_PLATFORM MATCHES "osx")
  169. set(CPACK_GENERATOR "ZIP;NSIS")
  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.zip" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.zip")
  173. endif()
  174. # Include CPack macro
  175. include(CPack)