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

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