gpt4all/gpt4all-chat/CMakeLists.txt

227 lines
9.1 KiB
CMake
Raw Normal View History

2023-04-09 03:28:39 +00:00
cmake_minimum_required(VERSION 3.16)
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)
2023-05-05 15:43:25 +00:00
set(APP_VERSION_MINOR 4)
2023-05-10 13:05:39 +00:00
set(APP_VERSION_PATCH 2)
2023-04-16 23:20:43 +00:00
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)
2023-04-09 03:28:39 +00:00
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2023-04-26 15:02:05 +00:00
option(GPT4ALL_LOCALHOST OFF "Build installer for localhost repo")
option(GPT4ALL_AVX_ONLY OFF "Build for avx only")
2023-04-29 16:13:11 +00:00
option(GPT4ALL_OFFLINE_INSTALLER "Build an offline installer" OFF)
# Generate a header file with the version number
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/config.h"
)
2023-05-11 20:46:25 +00:00
find_package(Qt6 6.5 COMPONENTS Core Quick QuickDialogs2 Svg HttpServer REQUIRED)
2023-04-22 03:23:57 +00:00
# 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}")
2023-04-09 03:28:39 +00:00
add_subdirectory(../gpt4all-backend llmodel)
2023-04-09 03:28:39 +00:00
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2023-04-09 03:28:39 +00:00
qt_add_executable(chat
main.cpp
2023-05-01 21:13:20 +00:00
chat.h chat.cpp
chatllm.h chatllm.cpp
chatmodel.h chatlistmodel.h chatlistmodel.cpp
2023-04-19 01:10:06 +00:00
download.h download.cpp
network.h network.cpp
2023-04-09 03:28:39 +00:00
llm.h llm.cpp
2023-05-11 20:46:25 +00:00
server.h server.cpp
sysinfo.h
2023-04-09 03:28:39 +00:00
)
qt_add_qml_module(chat
URI gpt4all
2023-04-09 03:28:39 +00:00
VERSION 1.0
QML_FILES
main.qml
qml/ChatDrawer.qml
qml/ModelDownloaderDialog.qml
2023-04-28 14:54:05 +00:00
qml/NetworkDialog.qml
qml/NewVersionDialog.qml
qml/ThumbsDownDialog.qml
2023-04-23 10:58:07 +00:00
qml/SettingsDialog.qml
2023-04-28 14:54:05 +00:00
qml/StartupDialog.qml
qml/PopupDialog.qml
2023-05-05 14:47:05 +00:00
qml/AboutDialog.qml
qml/Theme.qml
2023-04-11 03:34:34 +00:00
RESOURCES
icons/send_message.svg
icons/stop_generating.svg
icons/regenerate.svg
2023-04-11 12:54:57 +00:00
icons/copy.svg
2023-04-16 05:14:30 +00:00
icons/settings.svg
icons/edit.svg
2023-05-02 00:56:53 +00:00
icons/trash.svg
icons/network.svg
icons/thumbs_up.svg
icons/thumbs_down.svg
icons/logo.svg
2023-04-13 02:12:01 +00:00
icons/logo-32.png
icons/logo-48.png
2023-04-13 10:49:47 +00:00
icons/favicon.ico
icons/favicon.icns
2023-04-09 03:28:39 +00:00
)
set_target_properties(chat PROPERTIES
2023-04-24 02:57:37 +00:00
MACOSX_BUNDLE_GUI_IDENTIFIER gpt4all
2023-04-09 03:28:39 +00:00
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE_ICON_FILE "favicon.icns"
2023-04-09 03:28:39 +00:00
)
2023-04-24 03:42:55 +00:00
if(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
set_target_properties(chat PROPERTIES
OUTPUT_NAME gpt4all
)
endif()
2023-04-09 03:28:39 +00:00
target_compile_definitions(chat
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(chat
2023-05-11 20:46:25 +00:00
PRIVATE Qt6::Quick Qt6::Svg Qt6::HttpServer)
2023-04-09 03:28:39 +00:00
target_link_libraries(chat
PRIVATE llmodel)
2023-04-10 19:03:00 +00:00
2023-04-22 03:23:57 +00:00
set(COMPONENT_NAME_MAIN ${PROJECT_NAME})
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install)
2023-04-21 17:46:50 +00:00
if(NOT (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64"))
add_executable(test_hw test_hw.cpp)
2023-04-22 03:23:57 +00:00
install(TARGETS test_hw DESTINATION bin COMPONENT ${COMPONENT_NAME_MAIN})
2023-04-21 15:23:51 +00:00
endif()
2023-04-10 19:03:00 +00:00
install(TARGETS chat DESTINATION bin COMPONENT ${COMPONENT_NAME_MAIN})
install(TARGETS llmodel DESTINATION lib COMPONENT ${COMPONENT_NAME_MAIN})
2023-04-24 03:38:12 +00:00
install(TARGETS llama DESTINATION lib COMPONENT ${COMPONENT_NAME_MAIN})
2023-04-10 19:03:00 +00:00
set(CPACK_GENERATOR "IFW")
2023-04-22 03:23:57 +00:00
set(CPACK_VERBATIM_VARIABLES YES)
set(CPACK_IFW_VERBOSE ON)
2023-04-17 02:10:26 +00:00
2023-04-10 20:33:14 +00:00
if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
2023-04-22 03:23:57 +00:00
set(LINUXDEPLOYQT "$ENV{HOME}/dev/linuxdeployqt/build/tools/linuxdeployqt/linuxdeployqt")
2023-04-10 20:33:14 +00:00
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/deploy-qt-linux.cmake.in"
"${CMAKE_BINARY_DIR}/cmake/deploy-qt-linux.cmake" @ONLY)
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")
2023-04-22 03:23:57 +00:00
set(CPACK_IFW_TARGET_DIRECTORY "@HomeDir@/${COMPONENT_NAME_MAIN}")
2023-04-10 20:33:14 +00:00
elseif(${CMAKE_SYSTEM_NAME} MATCHES Windows)
2023-04-10 19:03:00 +00:00
find_program(WINDEPLOYQT windeployqt HINTS ${_qt_bin_dir})
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/deploy-qt-windows.cmake.in"
"${CMAKE_BINARY_DIR}/cmake/deploy-qt-windows.cmake" @ONLY)
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")
2023-04-22 03:23:57 +00:00
set(CPACK_IFW_TARGET_DIRECTORY "@HomeDir@\\${COMPONENT_NAME_MAIN}")
2023-04-10 20:33:14 +00:00
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"
"${CMAKE_BINARY_DIR}/cmake/deploy-qt-mac.cmake" @ONLY)
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}")
2023-04-24 02:05:24 +00:00
set(CPACK_BUNDLE_NAME ${COMPONENT_NAME_MAIN})
set(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icons/favicon.icns")
2023-04-10 20:33:14 +00:00
endif()
2023-04-10 19:03:00 +00:00
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})
2023-04-11 16:16:49 +00:00
set(CPACK_PACKAGE_HOMEPAGE_URL "https://gpt4all.io")
2023-04-29 01:40:45 +00:00
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icons/logo-48.png")
2023-04-11 16:16:49 +00:00
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")
2023-04-16 23:20:43 +00:00
set(CPACK_IFW_PACKAGE_PUBLISHER "Nomic, Inc.")
set(CPACK_IFW_PRODUCT_URL "https://gpt4all.io")
2023-04-10 19:03:00 +00:00
set(CPACK_IFW_PACKAGE_WIZARD_STYLE "Aero")
2023-04-29 01:40:45 +00:00
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")
2023-04-10 19:03:00 +00:00
set(CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST OFF)
2023-04-11 16:16:49 +00:00
2023-04-29 01:26:38 +00:00
include(InstallRequiredSystemLibraries)
2023-04-10 19:03:00 +00: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 23:20:43 +00:00
cpack_ifw_configure_component(${COMPONENT_NAME_MAIN} VERSION ${APP_VERSION})
2023-04-22 03:23:57 +00:00
cpack_ifw_configure_component(${COMPONENT_NAME_MAIN} LICENSES "MIT LICENSE" ${CPACK_RESOURCE_FILE_LICENSE})
2023-04-12 20:42:17 +00:00
cpack_ifw_configure_component(${COMPONENT_NAME_MAIN} SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/cmake/installerscript.qs")
2023-04-13 09:49:00 +00:00
cpack_ifw_configure_component(${COMPONENT_NAME_MAIN} REPLACES "gpt4all-chat") #Was used in very earliest prototypes
2023-04-10 19:03:00 +00:00
if (GPT4ALL_LOCALHOST)
cpack_ifw_add_repository("GPT4AllRepository" URL "http://localhost/repository")
2023-04-29 16:13:11 +00:00
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()
2023-04-11 03:34:34 +00:00
endif()