2023-05-16 19:10:02 +00:00
cmake_minimum_required ( VERSION 3.21 )
## Main build script. It all begins here.
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
##
# NOTE: we need to set these first
# Normally, these would be passed in on command line during the configuration step, but it's too annoying to rememeber to do that.
#
# See: https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_ARCHITECTURES.html
# See: https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html
if ( APPLE )
2023-05-25 09:57:00 +00:00
set ( CMAKE_OSX_ARCHITECTURES "x86_64h;arm64" CACHE STRING "macOS architecture(s) to build for." )
2023-05-25 09:43:39 +00:00
set ( CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "minimum macOS versions to build for." )
2021-11-03 14:45:42 +00:00
endif ( )
2023-05-16 19:10:02 +00:00
set ( CMAKE_CXX_STANDARD_REQUIRED true )
set ( CMAKE_C_STANDARD_REQUIRED true )
set ( CMAKE_CXX_STANDARD 17 )
set ( CMAKE_C_STANDARD 11 )
2021-11-03 14:45:42 +00:00
2023-05-16 19:10:02 +00:00
# Include some common functionality for building Qt apps (from `cmake` folder)
include ( QtCommon )
2020-05-28 21:17:50 +00:00
2023-05-16 19:10:02 +00:00
set ( BUILD_NUMBER 0 CACHE STRING "Build number from the CI, if any. 0 means custom/local build." )
2022-06-06 20:08:31 +00:00
2023-05-16 19:10:02 +00:00
project ( Launcher VERSION 6.0.0. ${ BUILD_NUMBER } )
fix_project_version ( )
2020-05-28 21:17:50 +00:00
2023-05-16 19:10:02 +00:00
enable_testing ( )
include ( GetGitRevisionDescription )
get_git_head_revision ( GIT_REFSPEC GIT_COMMIT )
message ( STATUS "Git commit: ${GIT_COMMIT}" )
message ( STATUS "Git refspec: ${GIT_REFSPEC}" )
# Yes, current directory is on the search path of .cpp files
2014-04-06 17:43:09 +00:00
set ( CMAKE_INCLUDE_CURRENT_DIR ON )
2013-01-11 01:25:40 +00:00
2023-05-16 19:10:02 +00:00
# Automatically handle Qt code generation
set ( CMAKE_AUTOMOC ON )
# This means the application does not show up on the dock and does not have a global menu (see cmake/QtCommon.cmake)
set ( MACOSX_IS_UIELEMENT 0 )
2015-09-28 18:53:46 +00:00
2016-05-01 01:49:46 +00:00
# Output all executables and shared libs in the main build folder, not in subfolders.
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ PROJECT_BINARY_DIR } )
if ( UNIX )
2018-07-15 12:51:05 +00:00
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ PROJECT_BINARY_DIR } )
2016-05-01 01:49:46 +00:00
endif ( )
2016-03-12 23:44:37 +00:00
set ( CMAKE_JAVA_TARGET_OUTPUT_DIR ${ PROJECT_BINARY_DIR } /jars )
2014-01-11 01:06:22 +00:00
2013-02-21 18:35:33 +00:00
######## Set compiler flags ########
2015-09-05 16:46:57 +00:00
include ( GenerateExportHeader )
2016-02-18 23:57:46 +00:00
if ( UNIX AND APPLE )
2018-07-15 12:51:05 +00:00
set ( CMAKE_CXX_FLAGS " -stdlib=libc++ ${CMAKE_CXX_FLAGS}" )
2016-02-18 23:57:46 +00:00
endif ( )
2013-02-21 16:32:13 +00:00
2018-01-22 03:28:07 +00:00
##################################### Set Application options #####################################
######## Set URLs ########
2021-10-12 23:59:25 +00:00
set ( Launcher_NEWS_RSS_URL "https://multimc.org/rss.xml" CACHE STRING "URL to fetch Launcher's news RSS feed from." )
2018-01-22 03:28:07 +00:00
######## Set version numbers ########
2023-05-15 00:13:59 +00:00
set ( Launcher_VERSION_MAJOR 6 )
set ( Launcher_VERSION_MINOR 0 )
2022-06-11 11:21:44 +00:00
set ( Launcher_VERSION_HOTFIX 0 )
2018-01-22 03:28:07 +00:00
# Build number
2021-10-12 23:59:25 +00:00
set ( Launcher_VERSION_BUILD -1 CACHE STRING "Build number. -1 for no build number." )
2018-01-22 03:28:07 +00:00
# Build platform.
2021-10-12 23:59:25 +00:00
set ( Launcher_BUILD_PLATFORM "" CACHE STRING "A short string identifying the platform that this build was built for. Only used by the notification system and to display in the about dialog." )
2018-01-22 03:28:07 +00:00
# Channel list URL
2021-10-12 23:59:25 +00:00
set ( Launcher_UPDATER_BASE "" CACHE STRING "Base URL for the updater." )
2018-01-22 03:28:07 +00:00
# Notification URL
2021-10-12 23:59:25 +00:00
set ( Launcher_NOTIFICATION_URL "" CACHE STRING "URL for checking for notifications." )
2018-01-22 03:28:07 +00:00
2020-07-18 14:18:02 +00:00
# The metadata server
2021-10-12 23:59:25 +00:00
set ( Launcher_META_URL "https://meta.multimc.org/v1/" CACHE STRING "URL to fetch Launcher's meta files from." )
2020-07-18 14:18:02 +00:00
2018-01-22 03:28:07 +00:00
# paste.ee API key
2021-10-12 23:59:25 +00:00
set ( Launcher_PASTE_EE_API_KEY "utLvciUouSURFzfjPxLBf5W4ISsUX4pwBDF7N1AfZ" CACHE STRING "API key you can get from paste.ee when you register an account" )
2018-01-22 03:28:07 +00:00
2021-07-01 18:49:38 +00:00
# Imgur API Client ID
2021-10-12 23:59:25 +00:00
set ( Launcher_IMGUR_CLIENT_ID "5b97b0713fba4a3" CACHE STRING "Client ID you can get from Imgur when you register an application" )
2021-07-01 18:49:38 +00:00
2018-01-22 03:28:07 +00:00
# Google analytics ID
2021-10-12 23:59:25 +00:00
set ( Launcher_ANALYTICS_ID "UA-87731965-2" CACHE STRING "ID you can get from Google analytics" )
2018-01-22 03:28:07 +00:00
2021-06-18 11:24:20 +00:00
# Bug tracker URL
2021-10-12 23:59:25 +00:00
set ( Launcher_BUG_TRACKER_URL "" CACHE STRING "URL for the bug tracker." )
2021-06-18 11:24:20 +00:00
# Discord URL
2021-10-12 23:59:25 +00:00
set ( Launcher_DISCORD_URL "" CACHE STRING "URL for the Discord guild." )
2021-06-18 11:24:20 +00:00
# Subreddit URL
2021-10-12 23:59:25 +00:00
set ( Launcher_SUBREDDIT_URL "" CACHE STRING "URL for the subreddit." )
2021-06-18 11:24:20 +00:00
2021-10-12 23:59:25 +00:00
# Use the secrets library or a public stub?
option ( Launcher_EMBED_SECRETS "Determines whether to embed secrets. Secrets are separate and non-public." OFF )
2021-07-26 19:44:11 +00:00
2023-05-16 19:10:02 +00:00
#### Custom target to feed the version to github actions.
2023-05-16 09:54:02 +00:00
add_custom_target ( ga_version echo ::set-output name=version:: ${ PROJECT_VERSION_MAJOR } . ${ PROJECT_VERSION_MINOR } . ${ PROJECT_VERSION_PATCH } . ${ PROJECT_VERSION_TWEAK } )
2018-01-22 03:28:07 +00:00
2018-01-27 22:53:10 +00:00
################################ 3rd Party Libs ################################
# Find the required Qt parts
2023-05-16 09:54:02 +00:00
find_package ( Qt6 REQUIRED COMPONENTS Core Widgets Concurrent Network Test Xml )
2023-06-01 07:46:37 +00:00
SET ( CMAKE_POSITION_INDEPENDENT_CODE ON )
2018-01-27 22:53:10 +00:00
2021-10-12 23:59:25 +00:00
####################################### Secrets #######################################
if ( Launcher_EMBED_SECRETS )
add_subdirectory ( secrets )
2023-05-16 19:10:02 +00:00
set ( RESOURCE_FOLDER "secrets" )
2021-10-12 23:59:25 +00:00
else ( )
add_subdirectory ( notsecrets )
2023-05-16 19:10:02 +00:00
set ( RESOURCE_FOLDER "notsecrets" )
2021-10-12 23:59:25 +00:00
endif ( )
2018-01-22 03:28:07 +00:00
####################################### Install layout #######################################
2023-05-16 19:10:02 +00:00
set ( COMPANY "${Launcher_Copyright}" )
set ( COPYRIGHT "Copyright 2015-2023 ${Launcher_Copyright}" )
set ( IDENTIFIER "org.multimc.${Launcher_Name}" )
set ( DESCRIPTION "${Launcher_Name}: Minecraft launcher and management utility." )
2018-01-22 03:28:07 +00:00
2023-05-16 19:10:02 +00:00
# How to install the build results
if ( UNIX AND APPLE )
2021-10-12 23:59:25 +00:00
set ( BINARY_DEST_DIR "${Launcher_Name}.app/Contents/MacOS" )
set ( LIBRARY_DEST_DIR "${Launcher_Name}.app/Contents/MacOS" )
set ( JARS_DEST_DIR "${Launcher_Name}.app/Contents/MacOS/jars" )
2018-01-22 03:28:07 +00:00
2018-07-15 12:51:05 +00:00
set ( BUNDLE_DEST_DIR "." )
2018-01-22 03:28:07 +00:00
2018-07-15 12:51:05 +00:00
# Add the icon
2023-05-16 19:10:02 +00:00
install ( FILES ${ Launcher_Branding_ICNS } DESTINATION "${Launcher_Name}.app/Contents/Resources" RENAME ${ Launcher_Name } .icns )
2018-01-22 03:28:07 +00:00
2023-05-16 19:10:02 +00:00
elseif ( UNIX )
2018-07-15 12:51:05 +00:00
set ( BINARY_DEST_DIR "bin" )
set ( LIBRARY_DEST_DIR "bin" )
set ( JARS_DEST_DIR "bin/jars" )
2018-01-22 03:28:07 +00:00
2023-05-16 19:10:02 +00:00
set ( BUNDLE_DEST_DIR "." )
2018-01-22 03:28:07 +00:00
2018-07-15 12:51:05 +00:00
# Install basic runner script
2021-10-12 23:59:25 +00:00
configure_file ( launcher/Launcher.in "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" @ONLY )
install ( PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" DESTINATION ${ BUNDLE_DEST_DIR } RENAME ${ Launcher_Name } )
2018-01-22 03:28:07 +00:00
2023-05-16 19:10:02 +00:00
elseif ( WIN32 )
2018-07-15 12:51:05 +00:00
set ( BINARY_DEST_DIR "." )
set ( LIBRARY_DEST_DIR "." )
set ( JARS_DEST_DIR "jars" )
2018-01-22 03:28:07 +00:00
2023-05-16 19:10:02 +00:00
set ( BUNDLE_DEST_DIR "." )
2018-01-22 03:28:07 +00:00
else ( )
2023-05-16 19:10:02 +00:00
message ( FATAL_ERROR "Cannot choose a sensible install layout for your platform." )
2018-01-22 03:28:07 +00:00
endif ( )
2014-01-08 00:27:40 +00:00
################################ Included Libs ################################
2015-02-12 21:01:20 +00:00
include ( ExternalProject )
set_directory_properties ( PROPERTIES EP_BASE External )
2015-09-28 19:20:27 +00:00
option ( NBT_BUILD_SHARED "Build NBT shared library" ON )
option ( NBT_USE_ZLIB "Build NBT library with zlib support" OFF )
option ( NBT_BUILD_TESTS "Build NBT library tests" OFF ) #FIXME: fix unit tests.
2021-10-12 23:59:25 +00:00
set ( NBT_NAME Launcher_nbt++ )
2018-01-22 03:28:07 +00:00
set ( NBT_DEST_DIR ${ LIBRARY_DEST_DIR } )
2016-04-10 13:53:05 +00:00
add_subdirectory ( libraries/libnbtplusplus )
2014-01-08 00:27:40 +00:00
2016-11-20 11:04:29 +00:00
add_subdirectory ( libraries/ganalytics ) # google analytics library
2017-01-01 18:59:46 +00:00
add_subdirectory ( libraries/systeminfo ) # system information library
2016-04-10 13:53:05 +00:00
add_subdirectory ( libraries/hoedown ) # markdown parser
add_subdirectory ( libraries/launcher ) # java based launcher part for Minecraft
add_subdirectory ( libraries/javacheck ) # java compatibility checker
add_subdirectory ( libraries/xz-embedded ) # xz compression
2023-05-29 12:33:27 +00:00
add_subdirectory ( libraries/zlib ) # a suitable copy of zlib
2017-05-06 15:22:14 +00:00
add_subdirectory ( libraries/quazip ) # zip manipulation library
2016-04-10 13:53:05 +00:00
add_subdirectory ( libraries/rainbow ) # Qt extension for colors
add_subdirectory ( libraries/iconfix ) # fork of Qt's QIcon loader
2016-10-30 01:37:38 +00:00
add_subdirectory ( libraries/LocalPeer ) # fork of a library from Qt solutions
2017-09-27 13:39:13 +00:00
add_subdirectory ( libraries/classparser ) # google analytics library
2021-02-06 14:58:03 +00:00
add_subdirectory ( libraries/optional-bare )
2021-04-17 16:46:11 +00:00
add_subdirectory ( libraries/tomlc99 ) # toml parser
2021-07-22 18:15:20 +00:00
add_subdirectory ( libraries/katabasis ) # An OAuth2 library that tried to do too much
2015-03-01 21:20:57 +00:00
2015-02-11 18:56:06 +00:00
############################### Built Artifacts ###############################
2020-07-18 14:18:02 +00:00
add_subdirectory ( buildconfig )
2018-01-22 03:28:07 +00:00
# NOTE: this must always be last to appease the CMake deity of quirky install command evaluation order.
2021-07-25 17:11:59 +00:00
add_subdirectory ( launcher )