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

392 lines
14 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
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 a build/<platform> directory.")
  4. endif()
  5. cmake_minimum_required(VERSION 3.25)
  6. set(APPLICATION_NAME "Antkeeper")
  7. set(APPLICATION_VERSION "0.0.1")
  8. set(APPLICATION_AUTHOR "C. J. Howard")
  9. # Slugify application name
  10. string(TOLOWER ${APPLICATION_NAME} APPLICATION_SLUG)
  11. string(REPLACE " " "-" APPLICATION_SLUG ${APPLICATION_SLUG})
  12. # Create superbuild project
  13. project(${APPLICATION_SLUG}-superbuild VERSION ${APPLICATION_VERSION})
  14. set(APPLICATION_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
  15. set(APPLICATION_VERSION_MINOR ${PROJECT_VERSION_MINOR})
  16. set(APPLICATION_VERSION_PATCH ${PROJECT_VERSION_PATCH})
  17. # Setup package variables
  18. set(PACKAGE_NAME ${APPLICATION_NAME})
  19. set(PACKAGE_VERSION ${APPLICATION_VERSION})
  20. set(PACKAGE_VERSION_MAJOR ${APPLICATION_VERSION_MAJOR})
  21. set(PACKAGE_VERSION_MINOR ${APPLICATION_VERSION_MINOR})
  22. set(PACKAGE_VERSION_PATCH ${APPLICATION_VERSION_PATCH})
  23. get_filename_component(PACKAGE_PLATFORM ${CMAKE_BINARY_DIR} NAME CACHE)
  24. if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  25. set(PACKAGE_BUILD_TYPE debug)
  26. else()
  27. set(PACKAGE_BUILD_TYPE release)
  28. endif()
  29. set(PACKAGE_FILENAME ${APPLICATION_SLUG}-${PACKAGE_VERSION}-${PACKAGE_PLATFORM})
  30. set(PACKAGE_INSTALL_DIR ${CMAKE_SOURCE_DIR}/bin/${PACKAGE_BUILD_TYPE}/${PACKAGE_FILENAME})
  31. set(PACKAGE_DIST_DIR ${CMAKE_SOURCE_DIR}/dist/${PACKAGE_BUILD_TYPE})
  32. # Create output directories
  33. file(MAKE_DIRECTORY ${PACKAGE_INSTALL_DIR})
  34. file(MAKE_DIRECTORY ${PACKAGE_DIST_DIR})
  35. # Check for architecture mismatches
  36. if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
  37. if (PACKAGE_PLATFORM MATCHES "64$")
  38. message(FATAL_ERROR "Compiler architecture is 32-bit but target architecture is 64-bit.")
  39. endif()
  40. else()
  41. if (PACKAGE_PLATFORM MATCHES "32$")
  42. message(FATAL_ERROR "Compiler architecture is 64-bit but target architecture is 32-bit.")
  43. endif()
  44. endif()
  45. # Options
  46. set(BLENDER "blender" CACHE FILEPATH "Path to Blender executable")
  47. # Set compiler and linker flags
  48. if(MSVC)
  49. set(CMAKE_CXX_FLAGS "/MP /GR- /GS- /EHsc /D_WIN32_WINNT=0x0501 /DWINVER=0x0501")
  50. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /MTd")
  51. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /MT /O2")
  52. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /nologo")
  53. set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF /INCREMENTAL:NO")
  54. elseif(CMAKE_COMPILER_IS_GNUCC)
  55. set(CMAKE_CXX_FLAGS "")
  56. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g")
  57. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3")
  58. endif()
  59. set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
  60. set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
  61. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
  62. # Setup module directories
  63. set(MODULE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/modules")
  64. set(MODULE_BUILD_DIR "${PROJECT_BINARY_DIR}/modules/build")
  65. set(MODULE_INSTALL_DIR "${CMAKE_BINARY_DIR}/modules/install")
  66. # Include ExternalProject_Add macro
  67. include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
  68. # Build SDL2 module
  69. ExternalProject_Add(SDL2
  70. SOURCE_DIR ${MODULE_SOURCE_DIR}/SDL2
  71. BINARY_DIR ${MODULE_BUILD_DIR}/SDL2
  72. INSTALL_DIR ${MODULE_INSTALL_DIR}
  73. CMAKE_ARGS
  74. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  75. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  76. "-DCMAKE_C_FLAGS='${CMAKE_C_FLAGS}'"
  77. "-DCMAKE_C_FLAGS_DEBUG='${CMAKE_C_FLAGS_DEBUG}'"
  78. "-DCMAKE_C_FLAGS_RELEASE='${CMAKE_C_FLAGS_RELEASE}'"
  79. "-DSDL_ASSERTIONS=disabled"
  80. "-DSDL_ATOMIC=OFF"
  81. "-DSDL_AUDIO=OFF"
  82. "-DSDL_CPUINFO=OFF"
  83. "-DSDL_DIRECTX=OFF"
  84. "-DSDL_EVENTS=ON"
  85. "-DSDL_FILE=OFF"
  86. "-DSDL_FILESYSTEM=OFF"
  87. "-DSDL_FORCE_STATIC_VCRT=ON"
  88. "-DSDL_HAPTIC=OFF"
  89. "-DSDL_HIDAPI=ON"
  90. "-DSDL_JOYSTICK=ON"
  91. "-DSDL_LIBC=ON"
  92. "-DSDL_LOADSO=ON"
  93. "-DSDL_LOCALE=OFF"
  94. "-DSDL_MISC=OFF"
  95. "-DSDL_OPENGL=ON"
  96. "-DSDL_OPENGLES=OFF"
  97. "-DSDL_POWER=OFF"
  98. "-DSDL_RENDER=OFF"
  99. "-DSDL_SENSOR=OFF"
  100. "-DSDL_SHARED=OFF"
  101. "-DSDL_STATIC=ON"
  102. "-DSDL_TEST=OFF"
  103. "-DSDL_THREADS=ON"
  104. "-DSDL_TIMERS=OFF"
  105. "-DSDL_VIDEO=ON"
  106. "-DSDL_VULKAN=OFF"
  107. "-DSDL_WASAPI=OFF"
  108. BUILD_ALWAYS 0)
  109. # Build OpenAL Soft module
  110. ExternalProject_Add(openal-soft
  111. SOURCE_DIR ${MODULE_SOURCE_DIR}/openal-soft
  112. BINARY_DIR ${MODULE_BUILD_DIR}/openal-soft
  113. INSTALL_DIR ${MODULE_INSTALL_DIR}
  114. CMAKE_ARGS
  115. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  116. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  117. "-DCMAKE_C_FLAGS='${CMAKE_C_FLAGS}'"
  118. "-DCMAKE_C_FLAGS_DEBUG='${CMAKE_C_FLAGS_DEBUG}'"
  119. "-DCMAKE_C_FLAGS_RELEASE='${CMAKE_C_FLAGS_RELEASE}'"
  120. "-DCMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}'"
  121. "-DCMAKE_CXX_FLAGS_DEBUG='${CMAKE_CXX_FLAGS_DEBUG}'"
  122. "-DCMAKE_CXX_FLAGS_RELEASE='${CMAKE_CXX_FLAGS_RELEASE}'"
  123. "-DLIBTYPE=STATIC"
  124. "-DFORCE_STATIC_VCRT=ON"
  125. "-DALSOFT_UTILS=OFF"
  126. "-DALSOFT_EXAMPLES=OFF"
  127. BUILD_ALWAYS 0)
  128. # Build EnTT module
  129. ExternalProject_Add(entt
  130. SOURCE_DIR ${MODULE_SOURCE_DIR}/entt
  131. BINARY_DIR ${MODULE_BUILD_DIR}/entt
  132. INSTALL_DIR ${MODULE_INSTALL_DIR}
  133. CMAKE_ARGS
  134. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  135. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  136. "-DCMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}'"
  137. "-DCMAKE_CXX_FLAGS_DEBUG='${CMAKE_CXX_FLAGS_DEBUG}'"
  138. "-DCMAKE_CXX_FLAGS_RELEASE='${CMAKE_CXX_FLAGS_RELEASE}'"
  139. BUILD_ALWAYS 0)
  140. # Build nlohmann-json module
  141. ExternalProject_Add(nlohmann-json
  142. SOURCE_DIR ${MODULE_SOURCE_DIR}/nlohmann
  143. BINARY_DIR ${MODULE_BUILD_DIR}/nlohmann
  144. INSTALL_DIR ${MODULE_INSTALL_DIR}
  145. CMAKE_ARGS
  146. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  147. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  148. "-DCMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}'"
  149. "-DCMAKE_CXX_FLAGS_DEBUG='${CMAKE_CXX_FLAGS_DEBUG}'"
  150. "-DCMAKE_CXX_FLAGS_RELEASE='${CMAKE_CXX_FLAGS_RELEASE}'"
  151. BUILD_ALWAYS 0)
  152. # Build dr_wav module
  153. ExternalProject_Add(dr_wav
  154. SOURCE_DIR ${MODULE_SOURCE_DIR}/dr_wav
  155. BINARY_DIR ${MODULE_BUILD_DIR}/dr_wav
  156. INSTALL_DIR ${MODULE_INSTALL_DIR}
  157. CMAKE_ARGS
  158. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  159. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  160. "-DCMAKE_C_FLAGS='${CMAKE_C_FLAGS}'"
  161. "-DCMAKE_C_FLAGS_DEBUG='${CMAKE_C_FLAGS_DEBUG}'"
  162. "-DCMAKE_C_FLAGS_RELEASE='${CMAKE_C_FLAGS_RELEASE}'"
  163. BUILD_ALWAYS 0)
  164. # Build stb module
  165. ExternalProject_Add(stb
  166. SOURCE_DIR ${MODULE_SOURCE_DIR}/stb
  167. BINARY_DIR ${MODULE_BUILD_DIR}/stb
  168. INSTALL_DIR ${MODULE_INSTALL_DIR}
  169. CMAKE_ARGS
  170. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  171. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  172. "-DCMAKE_C_FLAGS='${CMAKE_C_FLAGS}'"
  173. "-DCMAKE_C_FLAGS_DEBUG='${CMAKE_C_FLAGS_DEBUG}'"
  174. "-DCMAKE_C_FLAGS_RELEASE='${CMAKE_C_FLAGS_RELEASE}'"
  175. BUILD_ALWAYS 0)
  176. # Build TinyEXR module
  177. ExternalProject_Add(tinyexr
  178. SOURCE_DIR ${MODULE_SOURCE_DIR}/tinyexr
  179. BINARY_DIR ${MODULE_BUILD_DIR}/tinyexr
  180. INSTALL_DIR ${MODULE_INSTALL_DIR}
  181. CMAKE_ARGS
  182. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  183. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  184. "-DCMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}'"
  185. "-DCMAKE_CXX_FLAGS_DEBUG='${CMAKE_CXX_FLAGS_DEBUG}'"
  186. "-DCMAKE_CXX_FLAGS_RELEASE='${CMAKE_CXX_FLAGS_RELEASE}'"
  187. "-DTINYEXR_BUILD_SAMPLE=OFF"
  188. "-DTINYEXR_USE_MINIZ=OFF"
  189. "-DTINYEXR_USE_STB_ZLIB=ON"
  190. BUILD_ALWAYS 0)
  191. # Build glad module
  192. ExternalProject_Add(glad
  193. SOURCE_DIR ${MODULE_SOURCE_DIR}/glad
  194. BINARY_DIR ${MODULE_BUILD_DIR}/glad
  195. INSTALL_DIR ${MODULE_INSTALL_DIR}
  196. CMAKE_ARGS
  197. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  198. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  199. "-DCMAKE_C_FLAGS='${CMAKE_C_FLAGS}'"
  200. "-DCMAKE_C_FLAGS_DEBUG='${CMAKE_C_FLAGS_DEBUG}'"
  201. "-DCMAKE_C_FLAGS_RELEASE='${CMAKE_C_FLAGS_RELEASE}'"
  202. BUILD_ALWAYS 0)
  203. # Build cxxopts module
  204. ExternalProject_Add(cxxopts
  205. SOURCE_DIR ${MODULE_SOURCE_DIR}/cxxopts
  206. BINARY_DIR ${MODULE_BUILD_DIR}/cxxopts
  207. INSTALL_DIR ${MODULE_INSTALL_DIR}
  208. CMAKE_ARGS
  209. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  210. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  211. "-DCMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}'"
  212. "-DCMAKE_CXX_FLAGS_DEBUG='${CMAKE_CXX_FLAGS_DEBUG}'"
  213. "-DCMAKE_CXX_FLAGS_RELEASE='${CMAKE_CXX_FLAGS_RELEASE}'"
  214. "-DCXXOPTS_BUILD_EXAMPLES=OFF"
  215. "-DCXXOPTS_BUILD_TESTS=OFF"
  216. BUILD_ALWAYS 0)
  217. # Build PhysicsFS module
  218. ExternalProject_Add(physfs
  219. SOURCE_DIR ${MODULE_SOURCE_DIR}/physfs
  220. BINARY_DIR ${MODULE_BUILD_DIR}/physfs
  221. INSTALL_DIR ${MODULE_INSTALL_DIR}
  222. CMAKE_ARGS
  223. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  224. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  225. "-DCMAKE_C_FLAGS='${CMAKE_C_FLAGS}'"
  226. "-DCMAKE_C_FLAGS_DEBUG='${CMAKE_C_FLAGS_DEBUG}'"
  227. "-DCMAKE_C_FLAGS_RELEASE='${CMAKE_C_FLAGS_RELEASE}'"
  228. "-DPHYSFS_ARCHIVE_ZIP=ON"
  229. "-DPHYSFS_ARCHIVE_7Z=OFF"
  230. "-DPHYSFS_ARCHIVE_GRP=OFF"
  231. "-DPHYSFS_ARCHIVE_WAD=OFF"
  232. "-DPHYSFS_ARCHIVE_HOG=OFF"
  233. "-DPHYSFS_ARCHIVE_MVL=OFF"
  234. "-DPHYSFS_ARCHIVE_QPAK=OFF"
  235. "-DPHYSFS_ARCHIVE_SLB=OFF"
  236. "-DPHYSFS_ARCHIVE_ISO9660=OFF"
  237. "-DPHYSFS_ARCHIVE_VDF=OFF"
  238. "-DPHYSFS_BUILD_STATIC=ON"
  239. "-DPHYSFS_BUILD_SHARED=OFF"
  240. "-DPHYSFS_BUILD_TEST=OFF"
  241. "-DPHYSFS_BUILD_DOCS=OFF"
  242. BUILD_ALWAYS 0)
  243. # Build FreeType module
  244. ExternalProject_Add(freetype
  245. SOURCE_DIR ${MODULE_SOURCE_DIR}/freetype
  246. BINARY_DIR ${MODULE_BUILD_DIR}/freetype
  247. INSTALL_DIR ${MODULE_INSTALL_DIR}
  248. CMAKE_ARGS
  249. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  250. "-DCMAKE_INSTALL_PREFIX=${MODULE_INSTALL_DIR}"
  251. "-DCMAKE_C_FLAGS='${CMAKE_C_FLAGS}'"
  252. "-DCMAKE_C_FLAGS_DEBUG='${CMAKE_C_FLAGS_DEBUG}'"
  253. "-DCMAKE_C_FLAGS_RELEASE='${CMAKE_C_FLAGS_RELEASE}'"
  254. "-DBUILD_SHARED_LIBS=false"
  255. "-DFT_DISABLE_ZLIB=ON"
  256. "-DFT_DISABLE_BZIP2=ON"
  257. "-DFT_DISABLE_PNG=ON"
  258. "-DFT_DISABLE_HARFBUZZ=ON"
  259. "-DFT_DISABLE_BROTLI=ON"
  260. BUILD_ALWAYS 0)
  261. # Build antkeeper-source module
  262. ExternalProject_Add(antkeeper-source
  263. DEPENDS SDL2 openal-soft entt nlohmann-json dr_wav stb tinyexr glad physfs freetype
  264. SOURCE_DIR ${MODULE_SOURCE_DIR}/antkeeper-source
  265. BINARY_DIR ${MODULE_BUILD_DIR}/antkeeper-source
  266. INSTALL_DIR ${PACKAGE_INSTALL_DIR}
  267. CMAKE_ARGS
  268. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  269. "-DCMAKE_INSTALL_PREFIX=${PACKAGE_INSTALL_DIR}"
  270. "-DPACKAGE_PLATFORM=${PACKAGE_PLATFORM}"
  271. "-DCMAKE_PREFIX_PATH=${MODULE_INSTALL_DIR}"
  272. "-DAPPLICATION_NAME=${APPLICATION_NAME}"
  273. "-DAPPLICATION_VERSION=${APPLICATION_VERSION}"
  274. "-DAPPLICATION_AUTHOR=${APPLICATION_AUTHOR}"
  275. "-DCMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}'"
  276. "-DCMAKE_CXX_FLAGS_DEBUG='${CMAKE_CXX_FLAGS_DEBUG}'"
  277. "-DCMAKE_CXX_FLAGS_RELEASE='${CMAKE_CXX_FLAGS_RELEASE}'"
  278. "-DCMAKE_EXE_LINKER_FLAGS='${CMAKE_EXE_LINKER_FLAGS}'"
  279. "-DCMAKE_EXE_LINKER_FLAGS_DEBUG='${CMAKE_EXE_LINKER_FLAGS_DEBUG}'"
  280. "-DCMAKE_EXE_LINKER_FLAGS_RELEASE='${CMAKE_EXE_LINKER_FLAGS_RELEASE}'"
  281. BUILD_ALWAYS 1)
  282. # Build antkeeper-data module (if exists)
  283. if(EXISTS ${MODULE_SOURCE_DIR}/antkeeper-data/CMakeLists.txt)
  284. ExternalProject_Add(antkeeper-data
  285. DEPENDS antkeeper-source
  286. SOURCE_DIR ${MODULE_SOURCE_DIR}/antkeeper-data
  287. BINARY_DIR ${MODULE_BUILD_DIR}/antkeeper-data
  288. INSTALL_DIR ${PACKAGE_INSTALL_DIR}
  289. CMAKE_ARGS
  290. "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
  291. "-DCMAKE_INSTALL_PREFIX=${PACKAGE_INSTALL_DIR}"
  292. "-DPACKAGE_PLATFORM=${PACKAGE_PLATFORM}"
  293. "-DCMAKE_PREFIX_PATH=${MODULE_INSTALL_DIR}"
  294. "-DAPPLICATION_NAME=${APPLICATION_NAME}"
  295. "-DAPPLICATION_VERSION=${APPLICATION_VERSION}"
  296. "-DAPPLICATION_AUTHOR=${APPLICATION_AUTHOR}"
  297. "-DBLENDER=${BLENDER}"
  298. BUILD_ALWAYS 1)
  299. endif()
  300. # Create install target
  301. install(DIRECTORY "${PACKAGE_INSTALL_DIR}/" DESTINATION . COMPONENT "package" USE_SOURCE_PERMISSIONS FILES_MATCHING PATTERN "*")
  302. # Create clean-build target
  303. add_custom_target(clean-build
  304. COMMAND git clean -fdX
  305. WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
  306. # Create cpack target
  307. add_custom_target(cpack
  308. COMMAND "${CMAKE_COMMAND}" --build . --target package
  309. WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
  310. DEPENDS antkeeper-source
  311. VERBATIM)
  312. # Create dist target
  313. add_custom_target(dist DEPENDS cpack)
  314. # Configure CPack variables
  315. set(CPACK_PACKAGE_NAME "${APPLICATION_NAME}")
  316. set(CPACK_PACKAGE_VERSION_MAJOR "${APPLICATION_VERSION_MAJOR}")
  317. set(CPACK_PACKAGE_VERSION_MINOR "${APPLICATION_VERSION_MINOR}")
  318. set(CPACK_PACKAGE_VERSION_PATCH "${APPLICATION_VERSION_PATCH}")
  319. set(CPACK_PACKAGE_FILE_NAME "${APPLICATION_SLUG}-${PACKAGE_VERSION}-${PACKAGE_PLATFORM}")
  320. set(CPACK_PACKAGE_DESCRIPTION "")
  321. set(CPACK_PACKAGE_CONTACT "${APPLICATION_AUTHOR}")
  322. set(CPACK_COMPONENTS_ALL "package")
  323. # Configure .tgz and .zip distribution packages
  324. set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
  325. #set(CPACK_ARCHIVE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.zip")
  326. #set(CPACK_ARCHIVE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.zip")
  327. # Configure .deb distribution package
  328. set(CPACK_DEB_COMPONENT_INSTALL ON)
  329. set(CPACK_DEBIAN_PACKAGE_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
  330. set(CPACK_DEBIAN_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.deb")
  331. set(CPACK_DEBIAN_PACKAGE_DEPENDS "")
  332. # Configure NSIS installer package
  333. #set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/data/icons/app-icon.ico")
  334. #set(CPACK_PACKAGE_INSTALL_DIRECTORY "App")
  335. # Build distribution packages according to target platform
  336. set(CPACK_GENERATOR "")
  337. if(PACKAGE_PLATFORM MATCHES "linux")
  338. set(CPACK_GENERATOR "TGZ;DEB")
  339. add_custom_command(TARGET dist
  340. COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIST_DIR}
  341. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}-package.tar.gz" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.tar.gz"
  342. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_DEBIAN_PACKAGE_FILE_NAME}" "${PACKAGE_DIST_DIR}")
  343. elseif(PACKAGE_PLATFORM MATCHES "win")
  344. set(CPACK_GENERATOR "ZIP;NSIS")
  345. add_custom_command(TARGET dist
  346. COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIST_DIR}
  347. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}-package.zip" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.zip"
  348. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}.exe" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.exe")
  349. elseif(PACKAGE_PLATFORM MATCHES "osx")
  350. set(CPACK_GENERATOR "ZIP;NSIS")
  351. add_custom_command(TARGET dist
  352. COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIST_DIR}
  353. COMMAND ${CMAKE_COMMAND} -E copy "${CPACK_PACKAGE_FILE_NAME}-package.zip" "${PACKAGE_DIST_DIR}/${PACKAGE_FILENAME}.zip")
  354. endif()
  355. # Include CPack macro
  356. include(CPack)