endif()
endif()
+include("cmake/license.cmake")
+license_add_file("llama.cpp" "LICENSE")
+
#
# 3rd-party
#
add_subdirectory(tools)
endif()
+# Automatically add all files from the 'licenses' directory
+file(GLOB EXTRA_LICENSES "${CMAKE_SOURCE_DIR}/licenses/LICENSE-*")
+
+foreach(FILE_PATH ${EXTRA_LICENSES})
+ get_filename_component(FILE_NAME "${FILE_PATH}" NAME)
+ string(REGEX REPLACE "^LICENSE-" "" NAME "${FILE_NAME}")
+ license_add_file("${NAME}" "${FILE_PATH}")
+endforeach()
+
+if (LLAMA_BUILD_COMMON)
+ license_generate(common)
+endif()
+
#
# install
#
--- /dev/null
+define_property(GLOBAL PROPERTY LICENSE_TEXT
+ BRIEF_DOCS "Embedded licenses"
+ FULL_DOCS "Global string containing all aggregated licenses"
+)
+
+function(license_add_file NAME FILE)
+ if(NOT IS_ABSOLUTE "${FILE}")
+ set(FILE "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}")
+ endif()
+ if(EXISTS "${FILE}")
+ set(TITLE "License for ${NAME}")
+ string(REGEX REPLACE "." "=" UNDERLINE "${TITLE}")
+ file(READ "${FILE}" TEXT)
+ get_property(TMP GLOBAL PROPERTY LICENSE_TEXT)
+ string(APPEND TMP "R\"=L=(${TITLE}\n${UNDERLINE}\n\n${TEXT})=L=\",\n")
+ set_property(GLOBAL PROPERTY LICENSE_TEXT "${TMP}")
+ else()
+ message(WARNING "License file '${FILE}' not found")
+ endif()
+endfunction()
+
+function(license_generate TARGET_NAME)
+ message(STATUS "Generating embedded license file for target: ${TARGET_NAME}")
+ get_property(TEXT GLOBAL PROPERTY LICENSE_TEXT)
+
+ set(CPP_CONTENT "// Generated by CMake\n\n")
+ string(APPEND CPP_CONTENT "const char* LICENSES[] = {\n")
+ string(APPEND CPP_CONTENT "${TEXT}")
+ string(APPEND CPP_CONTENT "nullptr\n")
+ string(APPEND CPP_CONTENT "};\n")
+
+ set(CPP_FILE "${CMAKE_BINARY_DIR}/license.cpp")
+ file(WRITE "${CPP_FILE}" "${CPP_CONTENT}")
+
+ if(TARGET ${TARGET_NAME})
+ target_sources(${TARGET_NAME} PRIVATE "${CPP_FILE}")
+ else()
+ message(FATAL_ERROR "Target '${TARGET_NAME}' does not exist")
+ endif()
+endfunction()
endif ()
target_link_libraries(${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)
-
-
-#
-# copy the license files
-#
-
-# Check if running in GitHub Actions
-if (DEFINED ENV{GITHUB_ACTIONS} AND "$ENV{GITHUB_ACTIONS}" STREQUAL "true")
- message(STATUS "Running inside GitHub Actions - copying license files")
-
- # Copy all files from licenses/ to build/bin/
- file(GLOB LICENSE_FILES "${CMAKE_SOURCE_DIR}/licenses/*")
- foreach(LICENSE_FILE ${LICENSE_FILES})
- get_filename_component(FILENAME ${LICENSE_FILE} NAME)
- add_custom_command(
- POST_BUILD
- TARGET ${TARGET}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${LICENSE_FILE}"
- "$<TARGET_FILE_DIR:llama>/${FILENAME}"
- COMMENT "Copying ${FILENAME} to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
- message(STATUS "Copying ${LICENSE_FILE} to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${FILENAME}")
- endforeach()
-endif()
#include "chat.h"
#include "common.h"
+#include "download.h"
#include "json-schema-to-grammar.h"
#include "log.h"
#include "sampling.h"
-#include "download.h"
#include "preset.h"
// fix problem with std::min and std::max
#define LLAMA_MAX_URL_LENGTH 2084 // Maximum URL Length in Chrome: 2083
+extern const char * LICENSES[];
+
using json = nlohmann::ordered_json;
using namespace common_arg_utils;
exit(0);
}
));
+ add_opt(common_arg(
+ {"--license"},
+ "show source code license and dependencies",
+ [](common_params &) {
+ for (int i = 0; LICENSES[i]; ++i) {
+ printf("%s\n", LICENSES[i]);
+ }
+ exit(0);
+ }
+ ));
add_opt(common_arg(
{"-cl", "--cache-list"},
"show list of models in cache",
-Copyright (c) 1996 - 2025, Daniel Stenberg, daniel@haxx.se, and many contributors, see the THANKS file.
+COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 1996 - 2026, Daniel Stenberg, <daniel@haxx.se>, and many
+contributors, see the THANKS file.
All rights reserved.
-Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+Permission to use, copy, modify, and distribute this software for any purpose
+with or without fee is hereby granted, provided that the above copyright
+notice and this permission notice appear in all copies.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
+NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+OR OTHER DEALINGS IN THE SOFTWARE.
-Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
+Except as contained in this notice, the name of a copyright holder shall not
+be used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization of the copyright holder.
+++ /dev/null
-The MIT License (MIT)
-
-Copyright (c) 2017 yhirose
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
"https://github.com/mackron/miniaudio/raw/669ed3e844524fcd883231b13095baee9f6de304/miniaudio.h": "vendor/miniaudio/miniaudio.h",
"https://raw.githubusercontent.com/yhirose/cpp-httplib/refs/tags/v0.30.0/httplib.h": "vendor/cpp-httplib/httplib.h",
+ "https://raw.githubusercontent.com/yhirose/cpp-httplib/refs/tags/v0.30.0/LICENSE": "vendor/cpp-httplib/LICENSE",
"https://raw.githubusercontent.com/sheredom/subprocess.h/b49c56e9fe214488493021017bf3954b91c7c1f5/subprocess.h": "vendor/sheredom/subprocess.h",
}
set(TARGET cpp-httplib)
+license_add_file("cpp-httplib" "LICENSE")
find_package(Threads REQUIRED)
target_compile_options(${TARGET} PRIVATE -w)
endif()
-target_link_libraries (${TARGET} PRIVATE Threads::Threads)
+target_link_libraries(${TARGET} PRIVATE Threads::Threads)
if (WIN32 AND NOT MSVC)
target_link_libraries(${TARGET} PRIVATE ws2_32)
set(BUILD_SHARED_LIBS ${SAVED_BUILD_SHARED_LIBS})
set(BUILD_TESTING ${SAVED_BUILD_TESTING})
+ license_add_file("BoringSSL" "${boringssl_SOURCE_DIR}/LICENSE")
+
set(CPPHTTPLIB_OPENSSL_SUPPORT TRUE)
target_link_libraries(${TARGET} PUBLIC ssl crypto)
set(BUILD_SHARED_LIBS ${SAVED_BUILD_SHARED_LIBS})
set(BUILD_TESTING ${SAVED_BUILD_TESTING})
+ license_add_file("LibreSSL" "${libressl_SOURCE_DIR}/COPYING")
+
set(CPPHTTPLIB_OPENSSL_SUPPORT TRUE)
target_link_libraries(${TARGET} PUBLIC ssl crypto)
--- /dev/null
+The MIT License (MIT)
+
+Copyright (c) 2017 yhirose
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+