1
0
mirror of https://github.com/anope/anope.git synced 2026-06-27 18:46:39 +02:00

Build vendored libraries as static libraries and link against them.

This avoids rebuilding code we've already built.
This commit is contained in:
Sadie Powell
2026-06-14 12:45:18 +01:00
parent d60c80a4a3
commit f150ee857f
9 changed files with 56 additions and 9 deletions
+3 -2
View File
@@ -1,8 +1,8 @@
# This usage of CMake requires at least version 3.20
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
# Set the project as C++ primarily
project(Anope CXX)
# Set the project as C++ primarily with C for the vendored libraries
project(Anope CXX C)
# Force the locale to C for later uses of things like gcc so the messages come up in English, not the user's default language
set(ENV{LC_ALL} C)
@@ -294,6 +294,7 @@ endif()
add_subdirectory(data)
add_subdirectory(docs)
add_subdirectory(language)
add_subdirectory(vendor)
add_subdirectory(src)
add_subdirectory(modules)
add_subdirectory(include)
+1 -1
View File
@@ -50,7 +50,7 @@ macro(inline_cmake TARGET FILE)
set(CODE "${CODE}\n${CLEAN_LINE}")
endif()
elseif(LINE MATCHES "^/// BEGIN CMAKE$")
message(STATUS "Executing inline CMake code for ${TARGET}")
message(DEBUG "Executing inline CMake code for ${TARGET}")
set(IN_CODE ON)
endif()
endforeach()
+5 -1
View File
@@ -12,10 +12,14 @@
//
// SPDX-License-Identifier: GPL-2.0-only
/// BEGIN CMAKE
/// target_link_libraries(${SO} PRIVATE "vendored_yyjson")
/// END CMAKE
#include <filesystem>
namespace fs = std::filesystem;
#include "yyjson/yyjson.c"
#include "yyjson/yyjson.h"
#include "module.h"
+5 -1
View File
@@ -12,10 +12,14 @@
//
// SPDX-License-Identifier: GPL-2.0-only
/// BEGIN CMAKE
/// target_link_libraries(${SO} PRIVATE "vendored_bcrypt")
/// END CMAKE
#include <climits>
#include <random>
#include "bcrypt/crypt_blowfish.c"
#include "bcrypt/crypt_blowfish.h"
#include "module.h"
#include "modules/encryption.h"
+5 -1
View File
@@ -12,10 +12,14 @@
//
// SPDX-License-Identifier: GPL-2.0-only
/// BEGIN CMAKE
/// target_link_libraries(${SO} PRIVATE "vendored_md5")
/// END CMAKE
#include "module.h"
#include "modules/encryption.h"
#include "md5/md5.c"
#include "md5/md5.h"
class MD5Context final
: public Encryption::Context
+5 -1
View File
@@ -12,10 +12,14 @@
//
// SPDX-License-Identifier: GPL-2.0-only
/// BEGIN CMAKE
/// target_link_libraries(${SO} PRIVATE "vendored_sha1")
/// END CMAKE
#include "module.h"
#include "modules/encryption.h"
#include "sha1/sha1.c"
#include "sha1/sha1.h"
class SHA1Context final
: public Encryption::Context
+5 -1
View File
@@ -12,10 +12,14 @@
//
// SPDX-License-Identifier: GPL-2.0-only
/// BEGIN CMAKE
/// target_link_libraries(${SO} PRIVATE "vendored_sha2")
/// END CMAKE
#include <climits>
#include <random>
#include "sha2/sha2.c"
#include "sha2/sha2.h"
#include "module.h"
#include "modules/encryption.h"
+7 -1
View File
@@ -12,11 +12,17 @@
//
// SPDX-License-Identifier: GPL-2.0-only
/// BEGIN CMAKE
/// target_link_libraries(${SO} PRIVATE "vendored_yyjson")
/// END CMAKE
#include <cmath>
#include "module.h"
#include "modules/rpc.h"
#include "modules/httpd.h"
#include "yyjson/yyjson.c"
#include "yyjson/yyjson.h"
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
+20
View File
@@ -0,0 +1,20 @@
file(GLOB LIBRARIES CONFIGURE_DEPENDS "*")
foreach(LIBRARY IN LISTS LIBRARIES)
if(IS_DIRECTORY ${LIBRARY})
file(GLOB_RECURSE LIBRARY_SOURCES CONFIGURE_DEPENDS
"${LIBRARY}/*.c"
"${LIBRARY}/*.cc"
"${LIBRARY}/*.cpp"
)
if(LIBRARY_SOURCES)
cmake_path(GET LIBRARY FILENAME LIBRARY_NAME)
set(LIBRARY_TARGET "vendored_${LIBRARY_NAME}")
add_library(${LIBRARY_TARGET} STATIC ${LIBRARY_SOURCES})
target_compile_options(${LIBRARY_TARGET} PRIVATE "$<IF:$<BOOL:${MSVC}>,/W0,-w>")
set_target_properties(${LIBRARY_TARGET} PROPERTIES
FOLDER "VendoredLibraries"
PREFIX ""
)
endif()
endif()
endforeach()