cmake_minimum_required ( VERSION 3.16 )
set ( CMAKE_CXX_STANDARD 20 )
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
if ( APPLE )
option ( BUILD_UNIVERSAL "Build a Universal binary on macOS" OFF )
if ( BUILD_UNIVERSAL )
# Build a Universal binary on macOS
# This requires that the found Qt library is compiled as Universal binaries.
set ( CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE )
else ( )
# Build for the host architecture on macOS
set ( CMAKE_OSX_ARCHITECTURES "${CMAKE_HOST_SYSTEM_PROCESSOR}" CACHE STRING "" FORCE )
endif ( )
endif ( )
set ( APP_VERSION_MAJOR 2 )
set ( APP_VERSION_MINOR 4 )
set ( APP_VERSION_PATCH 5 )
set ( APP_VERSION "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}" )
# Include the binary directory for the generated header file
include_directories ( "${CMAKE_CURRENT_BINARY_DIR}" )
project ( gpt4all VERSION ${ APP_VERSION } LANGUAGES CXX C )
set ( CMAKE_AUTOMOC ON )
set ( CMAKE_AUTORCC ON )
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
option ( GPT4ALL_LOCALHOST OFF "Build installer for localhost repo" )
option ( GPT4ALL_AVX_ONLY OFF "Build for avx only" )
option ( GPT4ALL_OFFLINE_INSTALLER "Build an offline installer" OFF )
# 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 "
)
find_package ( Qt6 6.5 COMPONENTS Core Quick QuickDialogs2 Svg HttpServer Sql Pdf REQUIRED )
# Get the Qt6Core target properties
get_target_property ( Qt6Core_INCLUDE_DIRS Qt6::Core INTERFACE_INCLUDE_DIRECTORIES )
get_target_property ( Qt6Core_LIBRARY_RELEASE Qt6::Core LOCATION_RELEASE )
# Find the qmake binary
find_program ( QMAKE_EXECUTABLE NAMES qmake qmake6 PATHS ${ Qt6Core_INCLUDE_DIRS } /../.. NO_DEFAULT_PATH )
# Get the Qt 6 root directory
get_filename_component ( Qt6_ROOT_DIR "${Qt6Core_LIBRARY_RELEASE}" DIRECTORY )
get_filename_component ( Qt6_ROOT_DIR "${Qt6_ROOT_DIR}/.." ABSOLUTE )
message ( STATUS "qmake binary: ${QMAKE_EXECUTABLE}" )
message ( STATUS "Qt 6 root directory: ${Qt6_ROOT_DIR}" )
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ CMAKE_BINARY_DIR } /bin )
add_subdirectory ( ../gpt4all-backend llmodel )
qt_add_executable ( chat
m a i n . c p p
c h a t . h c h a t . c p p
c h a t l l m . h c h a t l l m . c p p
c h a t m o d e l . h c h a t l i s t m o d e l . h c h a t l i s t m o d e l . c p p
c h a t g p t . h c h a t g p t . c p p
d a t a b a s e . h d a t a b a s e . c p p
d o w n l o a d . h d o w n l o a d . c p p
n e t w o r k . h n e t w o r k . c p p
l o c a l d o c s . h l o c a l d o c s . c p p l o c a l d o c s m o d e l . h l o c a l d o c s m o d e l . c p p
l l m . h l l m . c p p
s e r v e r . h s e r v e r . c p p
s y s i n f o . h
)
qt_add_qml_module ( chat
U R I g p t 4 a l l
V E R S I O N 1 . 0
Q M L _ F I L E S
m a i n . q m l
q m l / C h a t D r a w e r . q m l
q m l / C o l l e c t i o n s D i a l o g . q m l
q m l / L o c a l D o c s . q m l
q m l / M o d e l D o w n l o a d e r D i a l o g . q m l
q m l / N e t w o r k D i a l o g . q m l
q m l / N e w V e r s i o n D i a l o g . q m l
q m l / T h u m b s D o w n D i a l o g . q m l
q m l / S e t t i n g s D i a l o g . q m l
q m l / S t a r t u p D i a l o g . q m l
q m l / P o p u p D i a l o g . q m l
q m l / A b o u t D i a l o g . q m l
q m l / T h e m e . q m l
q m l / M y B u t t o n . q m l
q m l / M y C o m b o B o x . q m l
q m l / M y T e x t F i e l d . q m l
q m l / M y C h e c k B o x . q m l
q m l / M y B u s y I n d i c a t o r . q m l
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 / c o p y . s v g
i c o n s / d b . s v g
i c o n s / s e t t i n g s . s v g
i c o n s / e d i t . s v g
i c o n s / t r a s h . s v g
i c o n s / n e t w o r k . s v g
i c o n s / t h u m b s _ u p . s v g
i c o n s / t h u m b s _ d o w n . s v g
i c o n s / l o g o . s v 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
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
)
set_target_properties ( chat PROPERTIES
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
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
M A C O S X _ B U N D L E _ I C O N _ F I L E " f a v i c o n . i c n s "
)
if ( ${ CMAKE_SYSTEM_NAME } MATCHES Darwin )
set_target_properties ( chat PROPERTIES
O U T P U T _ N A M E g p t 4 a l l
)
endif ( )
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 Q t 6 : : H t t p S e r v e r Q t 6 : : S q l Q t 6 : : P d f )
target_link_libraries ( chat
P R I V A T E l l m o d e l )
set ( COMPONENT_NAME_MAIN ${ PROJECT_NAME } )
set ( CMAKE_INSTALL_PREFIX ${ CMAKE_BINARY_DIR } /install )
if ( NOT ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64" ) )
add_executable ( test_hw test_hw.cpp )
install ( TARGETS test_hw DESTINATION bin COMPONENT ${ COMPONENT_NAME_MAIN } )
endif ( )
install ( TARGETS chat DESTINATION bin COMPONENT ${ COMPONENT_NAME_MAIN } )
install ( TARGETS llmodel DESTINATION lib COMPONENT ${ COMPONENT_NAME_MAIN } )
set ( CPACK_GENERATOR "IFW" )
set ( CPACK_VERBATIM_VARIABLES YES )
set ( CPACK_IFW_VERBOSE ON )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES Linux )
set ( LINUXDEPLOYQT "$ENV{HOME}/dev/linuxdeployqt/build/tools/linuxdeployqt/linuxdeployqt" )
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" )
set ( CPACK_PACKAGE_FILE_NAME "${COMPONENT_NAME_MAIN}-installer-linux" )
set ( CPACK_IFW_TARGET_DIRECTORY "@HomeDir@/${COMPONENT_NAME_MAIN}" )
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES Windows )
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" )
set ( CPACK_IFW_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icons/favicon.ico" )
set ( CPACK_PACKAGE_FILE_NAME "${COMPONENT_NAME_MAIN}-installer-win64" )
set ( CPACK_IFW_TARGET_DIRECTORY "@HomeDir@\\${COMPONENT_NAME_MAIN}" )
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES Darwin )
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" )
set ( CPACK_IFW_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icons/favicon.icns" )
set ( CPACK_PACKAGE_FILE_NAME "${COMPONENT_NAME_MAIN}-installer-darwin" )
set ( CPACK_IFW_TARGET_DIRECTORY "@ApplicationsDir@/${COMPONENT_NAME_MAIN}" )
set ( CPACK_BUNDLE_NAME ${ COMPONENT_NAME_MAIN } )
set ( CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icons/favicon.icns" )
endif ( )
set ( CPACK_PACKAGE_INSTALL_DIRECTORY ${ COMPONENT_NAME_MAIN } )
set ( CPACK_PACKAGE_VERSION_MAJOR ${ PROJECT_VERSION_MAJOR } )
set ( CPACK_PACKAGE_VERSION_MINOR ${ PROJECT_VERSION_MINOR } )
SET ( CPACK_PACKAGE_VERSION_PATCH ${ PROJECT_VERSION_PATCH } )
set ( CPACK_PACKAGE_HOMEPAGE_URL "https://gpt4all.io" )
set ( CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icons/logo-48.png" )
set ( CPACK_RESOURCE_FILE_LICENSE ${ CMAKE_CURRENT_SOURCE_DIR } /LICENSE )
set ( CPACK_RESOURCE_FILE_README ${ CMAKE_CURRENT_SOURCE_DIR } /README.md )
set ( CPACK_PACKAGE_EXECUTABLES "GPT4All" )
set ( CPACK_CREATE_DESKTOP_LINKS "GPT4All" )
set ( CPACK_IFW_PACKAGE_NAME "GPT4All" )
set ( CPACK_IFW_PACKAGE_TITLE "GPT4All Installer" )
set ( CPACK_IFW_PACKAGE_PUBLISHER "Nomic, Inc." )
set ( CPACK_IFW_PRODUCT_URL "https://gpt4all.io" )
set ( CPACK_IFW_PACKAGE_WIZARD_STYLE "Aero" )
set ( CPACK_IFW_PACKAGE_LOGO "${CMAKE_CURRENT_SOURCE_DIR}/icons/logo-48.png" )
set ( CPACK_IFW_PACKAGE_WINDOW_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icons/logo-32.png" )
set ( CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST OFF )
include ( InstallRequiredSystemLibraries )
include ( CPack )
include ( CPackIFW )
cpack_add_component ( ${ COMPONENT_NAME_MAIN } DOWNLOADED )
cpack_ifw_configure_component ( ${ COMPONENT_NAME_MAIN } ESSENTIAL FORCED_INSTALLATION )
cpack_ifw_configure_component ( ${ COMPONENT_NAME_MAIN } VERSION ${ APP_VERSION } )
cpack_ifw_configure_component ( ${ COMPONENT_NAME_MAIN } LICENSES "MIT LICENSE" ${ CPACK_RESOURCE_FILE_LICENSE } )
cpack_ifw_configure_component ( ${ COMPONENT_NAME_MAIN } SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/cmake/installerscript.qs" )
cpack_ifw_configure_component ( ${ COMPONENT_NAME_MAIN } REPLACES "gpt4all-chat" ) #Was used in very earliest prototypes
if ( GPT4ALL_LOCALHOST )
cpack_ifw_add_repository ( "GPT4AllRepository" URL "http://localhost/repository" )
elseif ( GPT4ALL_OFFLINE_INSTALLER )
cpack_ifw_add_repository ( "GPT4AllRepository" URL "file://${CMAKE_BINARY_DIR}/packages" )
else ( )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES Linux )
if ( GPT4ALL_AVX_ONLY )
cpack_ifw_add_repository ( "GPT4AllRepository" URL "https://gpt4all.io/installer_repos/avx_only/linux/repository" )
else ( )
cpack_ifw_add_repository ( "GPT4AllRepository" URL "https://gpt4all.io/installer_repos/linux/repository" )
endif ( )
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES Windows )
#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
if ( GPT4ALL_AVX_ONLY )
cpack_ifw_add_repository ( "GPT4AllRepository" URL "https://gpt4all.io/installer_repos/avx_only/windows/repository" )
else ( )
cpack_ifw_add_repository ( "GPT4AllRepository" URL "https://gpt4all.io/installer_repos/windows/repository" )
endif ( )
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES Darwin )
if ( GPT4ALL_AVX_ONLY )
cpack_ifw_add_repository ( "GPT4AllRepository" URL "https://gpt4all.io/installer_repos/avx_only/mac/repository" )
else ( )
cpack_ifw_add_repository ( "GPT4AllRepository" URL "https://gpt4all.io/installer_repos/mac/repository" )
endif ( )
endif ( )
endif ( )