NOISSUE reorganize build system to allow avoiding the bundle utilities

This commit is contained in:
Petr Mrázek 2017-05-06 03:11:38 +02:00
parent e5147e6b65
commit 2b3e87b7d1

View File

@ -41,37 +41,6 @@ add_custom_target(version echo "Version: ${MultiMC_RELEASE_VERSION_NAME}")
######## Configure header ######## ######## Configure header ########
configure_file("${PROJECT_SOURCE_DIR}/BuildConfig.cpp.in" "${PROJECT_BINARY_DIR}/BuildConfig.cpp") configure_file("${PROJECT_SOURCE_DIR}/BuildConfig.cpp.in" "${PROJECT_BINARY_DIR}/BuildConfig.cpp")
######## Packaging/install paths setup ########
if(UNIX AND APPLE)
set(BINARY_DEST_DIR MultiMC.app/Contents/MacOS)
set(PLUGIN_DEST_DIR MultiMC.app/Contents/MacOS)
set(QTCONF_DEST_DIR MultiMC.app/Contents/Resources)
set(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.app")
set(MACOSX_BUNDLE_BUNDLE_NAME "MultiMC")
set(MACOSX_BUNDLE_INFO_STRING "MultiMC Minecraft launcher and management utility.")
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.multimc.MultiMC5")
set(MACOSX_BUNDLE_BUNDLE_VERSION "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_HOTFIX}.${MultiMC_VERSION_BUILD}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_HOTFIX}.${MultiMC_VERSION_BUILD}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_HOTFIX}.${MultiMC_VERSION_BUILD}")
set(MACOSX_BUNDLE_ICON_FILE MultiMC.icns)
set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2015-2017 MultiMC Contributors")
elseif(UNIX)
set(BINARY_DEST_DIR bin)
set(PLUGIN_DEST_DIR plugins)
set(QTCONF_DEST_DIR .)
set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC")
elseif(WIN32)
set(BINARY_DEST_DIR .)
set(PLUGIN_DEST_DIR .)
set(QTCONF_DEST_DIR .)
set(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.exe")
endif()
# directories to look for dependencies
set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
################################ FILES ################################ ################################ FILES ################################
######## Sources and headers ######## ######## Sources and headers ########
@ -330,96 +299,197 @@ target_link_libraries(MultiMC MultiMC_gui ${QUAZIP_LIBRARIES} hoedown MultiMC_ra
################################ INSTALLATION AND PACKAGING ################################ ################################ INSTALLATION AND PACKAGING ################################
######## Install ######## ######## Packaging/install paths setup ########
#### Executable #### # How to install the build results
if(APPLE AND UNIX) ## OSX set(MultiMC_LAYOUT "auto" CACHE STRING "The layout for MultiMC installation (auto, win-bundle, lin-bundle, mac-bundle, lin-nodeps)")
install(TARGETS MultiMC set_property(CACHE MultiMC_LAYOUT PROPERTY STRINGS auto win-bundle lin-bundle mac-bundle lin-nodeps)
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime
)
elseif(UNIX) ## LINUX and similar if(MultiMC_LAYOUT STREQUAL "auto")
install(TARGETS MultiMC if(UNIX AND APPLE)
BUNDLE DESTINATION . COMPONENT Runtime set(MultiMC_LAYOUT_REAL "mac-bundle")
RUNTIME DESTINATION bin COMPONENT Runtime elseif(UNIX)
) set(MultiMC_LAYOUT_REAL "lin-bundle")
install(PROGRAMS package/linux/MultiMC DESTINATION .) elseif(WIN32)
set(MultiMC_LAYOUT_REAL "win-bundle")
elseif(WIN32) ## WINDOWS else()
install(TARGETS MultiMC message(FATAL_ERROR "Cannot choose a sensible install layout for your platform.")
BUNDLE DESTINATION . COMPONENT Runtime endif()
LIBRARY DESTINATION . COMPONENT Runtime else()
RUNTIME DESTINATION . COMPONENT Runtime set(MultiMC_LAYOUT_REAL ${MultiMC_LAYOUT})
)
endif() endif()
#### Java bits #### if(MultiMC_LAYOUT_REAL STREQUAL "mac-bundle")
set(BINARY_DEST_DIR "MultiMC.app/Contents/MacOS")
set(LIBRARY_DEST_DIR "MultiMC.app/Contents/MacOS")
set(PLUGIN_DEST_DIR "MultiMC.app/Contents/MacOS")
set(RESOURCES_DEST_DIR "MultiMC.app/Contents/Resources")
set(BUNDLE_DEST_DIR ".")
# Apps to bundle
set(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.app")
# Mac bundle settings
set(MACOSX_BUNDLE_BUNDLE_NAME "MultiMC")
set(MACOSX_BUNDLE_INFO_STRING "MultiMC Minecraft launcher and management utility.")
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.multimc.MultiMC5")
set(MACOSX_BUNDLE_BUNDLE_VERSION "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_HOTFIX}.${MultiMC_VERSION_BUILD}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_HOTFIX}.${MultiMC_VERSION_BUILD}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_HOTFIX}.${MultiMC_VERSION_BUILD}")
set(MACOSX_BUNDLE_ICON_FILE MultiMC.icns)
set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2015-2017 MultiMC Contributors")
# directories to look for dependencies
set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# install as bundle
set(INSTALL_BUNDLE TRUE)
# Add the icon
install(FILES resources/MultiMC.icns DESTINATION ${RESOURCES_DEST_DIR})
elseif(MultiMC_LAYOUT_REAL STREQUAL "lin-bundle")
set(BINARY_DEST_DIR "bin")
set(LIBRARY_DEST_DIR "bin")
set(PLUGIN_DEST_DIR "plugins")
set(BUNDLE_DEST_DIR ".")
set(RESOURCES_DEST_DIR ".")
# Apps to bundle
set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC")
# directories to look for dependencies
set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# install as bundle
set(INSTALL_BUNDLE TRUE)
# Set RPATH
SET_TARGET_PROPERTIES(MultiMC PROPERTIES INSTALL_RPATH "$ORIGIN/")
# Install basic runner script
install(PROGRAMS package/linux/MultiMC DESTINATION ${BUNDLE_DEST_DIR})
elseif(MultiMC_LAYOUT_REAL STREQUAL "lin-nodeps")
set(BINARY_DEST_DIR "bin")
set(LIBRARY_DEST_DIR "bin")
set(PLUGIN_DEST_DIR "plugins")
set(BUNDLE_DEST_DIR ".")
set(RESOURCES_DEST_DIR ".")
# do not install as bundle
set(INSTALL_BUNDLE FALSE)
# Set RPATH
SET_TARGET_PROPERTIES(MultiMC PROPERTIES INSTALL_RPATH "$ORIGIN/")
# Install basic runner script
install(PROGRAMS package/linux/MultiMC DESTINATION ${BUNDLE_DEST_DIR})
elseif(MultiMC_LAYOUT_REAL STREQUAL "win-bundle")
set(BINARY_DEST_DIR ".")
set(LIBRARY_DEST_DIR ".")
set(PLUGIN_DEST_DIR ".")
set(BUNDLE_DEST_DIR ".")
set(RESOURCES_DEST_DIR ".")
# Apps to bundle
set(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.exe")
# directories to look for dependencies
set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# install as bundle
set(INSTALL_BUNDLE TRUE)
else()
message(FATAL_ERROR "No sensible install layout set.")
endif()
######## Install base files ########
#### Executable ####
install(TARGETS MultiMC
BUNDLE DESTINATION ${BUNDLE_DEST_DIR} COMPONENT Runtime
LIBRARY DESTINATION ${LIBRARY_DEST_DIR} COMPONENT Runtime
RUNTIME DESTINATION ${BINARY_DEST_DIR} COMPONENT Runtime
)
#### jars needed for testing java and launching Minecraft ####
install_jar(JavaCheck "${BINARY_DEST_DIR}/jars") install_jar(JavaCheck "${BINARY_DEST_DIR}/jars")
install_jar(NewLaunch "${BINARY_DEST_DIR}/jars") install_jar(NewLaunch "${BINARY_DEST_DIR}/jars")
#### Dist package logic #### #### Shared libraries and dependencies ####
if(NOT INSTALL_BUNDLE)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") # Just our own stuff
# Image formats # FIXME: this does not fix RPATH.
install( install(
DIRECTORY "${QT_PLUGINS_DIR}/imageformats" FILES
DESTINATION ${PLUGIN_DEST_DIR} $<TARGET_FILE:MultiMC_gui>
COMPONENT Runtime $<TARGET_FILE:MultiMC_logic>
REGEX "tga|tiff|mng" EXCLUDE $<TARGET_FILE:MultiMC_rainbow>
) $<TARGET_FILE:MultiMC_iconfix>
# Icon engines $<TARGET_FILE:MultiMC_unpack200>
install( $<TARGET_FILE:MultiMC_nbt++>
DIRECTORY "${QT_PLUGINS_DIR}/iconengines" DESTINATION
DESTINATION ${PLUGIN_DEST_DIR} ${LIBRARY_DEST_DIR}
COMPONENT Runtime
REGEX "fontawesome" EXCLUDE
)
# Platform plugins
install(
DIRECTORY "${QT_PLUGINS_DIR}/platforms"
DESTINATION ${PLUGIN_DEST_DIR}
COMPONENT Runtime
REGEX "minimal|linuxfb|offscreen" EXCLUDE
) )
else() else()
# Image formats # Bundle stuff
install( if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
DIRECTORY "${QT_PLUGINS_DIR}/imageformats" # Image formats
DESTINATION ${PLUGIN_DEST_DIR} install(
COMPONENT Runtime DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
REGEX "tga|tiff|mng" EXCLUDE DESTINATION ${PLUGIN_DEST_DIR}
REGEX "d\\." EXCLUDE COMPONENT Runtime
REGEX "_debug\\." EXCLUDE REGEX "tga|tiff|mng" EXCLUDE
) )
# Icon engines # Icon engines
install( install(
DIRECTORY "${QT_PLUGINS_DIR}/iconengines" DIRECTORY "${QT_PLUGINS_DIR}/iconengines"
DESTINATION ${PLUGIN_DEST_DIR} DESTINATION ${PLUGIN_DEST_DIR}
COMPONENT Runtime COMPONENT Runtime
REGEX "fontawesome" EXCLUDE REGEX "fontawesome" EXCLUDE
REGEX "d\\." EXCLUDE )
REGEX "_debug\\." EXCLUDE # Platform plugins
) install(
# Platform plugins DIRECTORY "${QT_PLUGINS_DIR}/platforms"
install( DESTINATION ${PLUGIN_DEST_DIR}
DIRECTORY "${QT_PLUGINS_DIR}/platforms" COMPONENT Runtime
DESTINATION ${PLUGIN_DEST_DIR} REGEX "minimal|linuxfb|offscreen" EXCLUDE
COMPONENT Runtime )
REGEX "minimal|linuxfb|offscreen" EXCLUDE else()
REGEX "d\\." EXCLUDE # Image formats
REGEX "_debug\\." EXCLUDE install(
DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
DESTINATION ${PLUGIN_DEST_DIR}
COMPONENT Runtime
REGEX "tga|tiff|mng" EXCLUDE
REGEX "d\\." EXCLUDE
REGEX "_debug\\." EXCLUDE
)
# Icon engines
install(
DIRECTORY "${QT_PLUGINS_DIR}/iconengines"
DESTINATION ${PLUGIN_DEST_DIR}
COMPONENT Runtime
REGEX "fontawesome" EXCLUDE
REGEX "d\\." EXCLUDE
REGEX "_debug\\." EXCLUDE
)
# Platform plugins
install(
DIRECTORY "${QT_PLUGINS_DIR}/platforms"
DESTINATION ${PLUGIN_DEST_DIR}
COMPONENT Runtime
REGEX "minimal|linuxfb|offscreen" EXCLUDE
REGEX "d\\." EXCLUDE
REGEX "_debug\\." EXCLUDE
)
endif()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/install_prereqs.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/install_prereqs.cmake"
@ONLY
) )
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/install_prereqs.cmake" COMPONENT Runtime)
endif() endif()
# ICNS file for OS X
if(APPLE)
install(FILES resources/MultiMC.icns DESTINATION MultiMC.app/Contents/Resources)
endif()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/install_prereqs.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/install_prereqs.cmake"
@ONLY
)
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/install_prereqs.cmake" COMPONENT Runtime)