2023-04-08 23:28:39 -04:00
cmake_minimum_required ( VERSION 3.16 )
2023-04-14 12:19:03 -04:00
if ( APPLE )
2023-04-14 12:33:54 -04:00
# Build a Universal binary on macOS
# This requires that the found Qt library is compiled as Universal binaries.
2023-04-14 12:19:03 -04:00
set ( CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE )
endif ( )
2023-04-17 07:50:39 -04:00
set ( APP_VERSION_MAJOR 2 )
2023-04-16 19:20:43 -04:00
set ( APP_VERSION_MINOR 1 )
2023-04-17 07:50:39 -04:00
set ( APP_VERSION_PATCH 0 )
2023-04-16 19:20:43 -04:00
set ( APP_VERSION "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}" )
# Generate a header file with the version number
configure_file (
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / c o n f i g . h . i n "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c o n f i g . h "
)
# Include the binary directory for the generated header file
include_directories ( "${CMAKE_CURRENT_BINARY_DIR}" )
project ( gpt4all VERSION ${ APP_VERSION } LANGUAGES CXX )
2023-04-08 23:28:39 -04:00
set ( CMAKE_AUTOMOC ON )
set ( CMAKE_AUTORCC ON )
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
2023-04-09 22:22:48 -04:00
find_package ( Qt6 6.2 COMPONENTS Quick Svg REQUIRED )
2023-04-08 23:28:39 -04:00
set ( GGML_BUILD_EXAMPLES ON CACHE BOOL "ggml: build examples" FORCE )
add_subdirectory ( ggml )
qt_add_executable ( chat
m a i n . c p p
g p t j . h g p t j . c p p
l l m . h l l m . c p p
2023-04-13 22:15:40 -04:00
l l m o d e l . h
2023-04-08 23:28:39 -04:00
)
qt_add_qml_module ( chat
U R I g p t 4 a l l - c h a t
V E R S I O N 1 . 0
Q M L _ F I L E S m a i n . q m l
2023-04-10 23:34:34 -04:00
R E S O U R C E S
i c o n s / s e n d _ m e s s a g e . s v g
i c o n s / s t o p _ g e n e r a t i n g . s v g
i c o n s / r e g e n e r a t e . s v g
i c o n s / l o g o . s v g
2023-04-11 08:54:57 -04:00
i c o n s / c o p y . s v g
2023-04-16 01:14:30 -04:00
i c o n s / s e t t i n g s . s v g
2023-04-12 22:12:01 -04:00
i c o n s / l o g o - 1 6 . p n g
i c o n s / l o g o - 3 2 . p n g
i c o n s / l o g o - 4 8 . p n g
2023-04-13 06:49:47 -04:00
i c o n s / l o g o - 6 4 . p n g
i c o n s / l o g o - 2 5 6 . p n g
i c o n s / f a v i c o n . i c o
i c o n s / f a v i c o n . i c n s
2023-04-08 23:28:39 -04:00
)
set_target_properties ( chat PROPERTIES
2023-04-13 04:59:48 -04:00
M A C O S X _ B U N D L E _ G U I _ I D E N T I F I E R g p t 4 a l l . c h a t
2023-04-08 23:28:39 -04:00
M A C O S X _ B U N D L E _ B U N D L E _ V E R S I O N $ { P R O J E C T _ V E R S I O N }
M A C O S X _ B U N D L E _ S H O R T _ V E R S I O N _ S T R I N G $ { P R O J E C T _ V E R S I O N _ M A J O R } . $ { P R O J E C T _ V E R S I O N _ M I N O R }
M A C O S X _ B U N D L E T R U E
W I N 3 2 _ E X E C U T A B L E T R U E
)
target_compile_definitions ( chat
P R I V A T E $ < $ < O R : $ < C O N F I G : D e b u g > , $ < C O N F I G : R e l W i t h D e b I n f o > > : Q T _ Q M L _ D E B U G > )
target_link_libraries ( chat
P R I V A T E Q t 6 : : Q u i c k Q t 6 : : S v g )
target_link_libraries ( chat
P R I V A T E g g m l g g m l _ u t i l s )
2023-04-10 15:03:00 -04:00
2023-04-12 22:12:01 -04:00
set ( COMPONENT_NAME_MAIN ${ PROJECT_NAME } )
2023-04-10 15:03:00 -04:00
set ( CMAKE_INSTALL_PREFIX ${ CMAKE_BINARY_DIR } /install )
install ( TARGETS chat DESTINATION bin COMPONENT ${ COMPONENT_NAME_MAIN } )
set ( CPACK_GENERATOR "IFW" )
2023-04-16 22:10:26 -04:00
set ( BUNDLED_MODEL_NAME "ggml-gpt4all-j-v1.2-jazzy.bin" )
2023-04-10 16:33:14 -04:00
if ( ${ CMAKE_SYSTEM_NAME } MATCHES Linux )
2023-04-10 23:34:34 -04:00
set ( LINUXDEPLOYQT "/home/atreat/dev/linuxdeployqt/build/tools/linuxdeployqt/linuxdeployqt" )
2023-04-10 16:33:14 -04:00
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/deploy-qt-linux.cmake.in"
" $ { C M A K E _ B I N A R Y _ D I R } / c m a k e / d e p l o y - q t - l i n u x . c m a k e " @ O N L Y )
set ( CPACK_PRE_BUILD_SCRIPTS ${ CMAKE_BINARY_DIR } /cmake/deploy-qt-linux.cmake )
set ( CPACK_IFW_ROOT "~/Qt/Tools/QtInstallerFramework/4.5" )
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES Windows )
2023-04-10 15:03:00 -04:00
find_program ( WINDEPLOYQT windeployqt HINTS ${ _qt_bin_dir } )
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/deploy-qt-windows.cmake.in"
" $ { C M A K E _ B I N A R Y _ D I R } / c m a k e / d e p l o y - q t - w i n d o w s . c m a k e " @ O N L Y )
set ( CPACK_PRE_BUILD_SCRIPTS ${ CMAKE_BINARY_DIR } /cmake/deploy-qt-windows.cmake )
set ( CPACK_IFW_ROOT "C:/Qt/Tools/QtInstallerFramework/4.5" )
2023-04-12 15:31:21 -04:00
set ( CPACK_IFW_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icons/favicon.ico" )
2023-04-10 16:33:14 -04:00
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES Darwin )
2023-04-10 17:13:22 -04:00
find_program ( MACDEPLOYQT macdeployqt HINTS ${ _qt_bin_dir } )
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/deploy-qt-mac.cmake.in"
" $ { C M A K E _ B I N A R Y _ D I R } / c m a k e / d e p l o y - q t - m a c . c m a k e " @ O N L Y )
set ( CPACK_PRE_BUILD_SCRIPTS ${ CMAKE_BINARY_DIR } /cmake/deploy-qt-mac.cmake )
set ( CPACK_IFW_ROOT "~/Qt/Tools/QtInstallerFramework/4.5" )
2023-04-12 15:31:21 -04:00
set ( CPACK_IFW_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icons/favicon.icns" )
2023-04-10 16:33:14 -04:00
endif ( )
2023-04-10 15:03:00 -04:00
2023-04-13 04:59:48 -04:00
set ( CPACK_PACKAGE_VERSION_MAJOR ${ PROJECT_VERSION_MAJOR } )
set ( CPACK_PACKAGE_VERSION_MINOR ${ PROJECT_VERSION_MINOR } )
SET ( CPACK_PACKAGE_VERSION_PATCH ${ PROJECT_VERSION_PATCH } )
2023-04-11 12:16:49 -04:00
set ( CPACK_PACKAGE_HOMEPAGE_URL "https://gpt4all.io" )
2023-04-12 15:31:21 -04:00
set ( CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icons/logo-48.png" )
2023-04-11 12:16:49 -04:00
set ( CPACK_RESOURCE_FILE_LICENSE ${ CMAKE_CURRENT_SOURCE_DIR } /LICENSE )
set ( CPACK_RESOURCE_FILE_README ${ CMAKE_CURRENT_SOURCE_DIR } /README.md )
2023-04-17 07:50:39 -04:00
set ( CPACK_PACKAGE_EXECUTABLES "GPT4All" )
set ( CPACK_CREATE_DESKTOP_LINKS "GPT4All" )
set ( CPACK_IFW_PACKAGE_NAME "GPT4All" )
set ( CPACK_IFW_PACKAGE_TITLE "GPT4All Installer" )
2023-04-16 19:20:43 -04:00
set ( CPACK_IFW_PACKAGE_PUBLISHER "Nomic, Inc." )
set ( CPACK_IFW_PRODUCT_URL "https://gpt4all.io" )
2023-04-10 15:03:00 -04:00
set ( CPACK_IFW_PACKAGE_WIZARD_STYLE "Aero" )
2023-04-12 22:12:01 -04:00
set ( CPACK_IFW_PACKAGE_LOGO "${CMAKE_CURRENT_SOURCE_DIR}/icons/logo-48.png" )
2023-04-12 15:31:21 -04:00
set ( CPACK_IFW_PACKAGE_WINDOW_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icons/logo-32.png" )
2023-04-10 15:03:00 -04:00
set ( CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST OFF )
2023-04-11 12:16:49 -04:00
2023-04-10 15:03:00 -04:00
include ( CPack )
include ( CPackIFW )
cpack_add_component ( ${ COMPONENT_NAME_MAIN } DOWNLOADED )
cpack_ifw_configure_component ( ${ COMPONENT_NAME_MAIN } ESSENTIAL FORCED_INSTALLATION )
2023-04-16 19:20:43 -04:00
cpack_ifw_configure_component ( ${ COMPONENT_NAME_MAIN } VERSION ${ APP_VERSION } )
2023-04-10 15:03:00 -04:00
cpack_ifw_configure_component ( ${ COMPONENT_NAME_MAIN } LICENSES "GPL-3.0 LICENSE" ${ CPACK_RESOURCE_FILE_LICENSE } )
2023-04-12 16:42:17 -04:00
cpack_ifw_configure_component ( ${ COMPONENT_NAME_MAIN } SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/cmake/installerscript.qs" )
2023-04-13 05:49:00 -04:00
cpack_ifw_configure_component ( ${ COMPONENT_NAME_MAIN } REPLACES "gpt4all-chat" ) #Was used in very earliest prototypes
2023-04-10 15:03:00 -04:00
2023-04-10 23:34:34 -04:00
if ( ${ CMAKE_SYSTEM_NAME } MATCHES Linux )
2023-04-11 14:36:50 -04:00
cpack_ifw_add_repository ( "GPT4AllRepository" URL "https://gpt4all.io/installer_repos/linux/repository" )
2023-04-10 23:34:34 -04:00
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES Windows )
2023-04-13 05:49:00 -04:00
#To sign the target on windows have to create a batch script add use it as a custom target and then use CPACK_IFW_EXTRA_TARGETS to set this extra target
2023-04-11 14:36:50 -04:00
cpack_ifw_add_repository ( "GPT4AllRepository" URL "https://gpt4all.io/installer_repos/windows/repository" )
2023-04-10 23:34:34 -04:00
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES Darwin )
2023-04-13 04:48:42 -04:00
#Use this in future https://cmake.org/cmake/help/latest/cpack_gen/ifw.html#variable:CPACK_IFW_PACKAGE_SIGNING_IDENTITY
2023-04-11 14:36:50 -04:00
cpack_ifw_add_repository ( "GPT4AllRepository" URL "https://gpt4all.io/installer_repos/mac/repository" )
2023-04-10 23:34:34 -04:00
endif ( )