Move sha256.c to lib/

Precompiled headers don't work if we're not a pure C++ project.
This commit is contained in:
Desour 2023-03-25 21:40:17 +01:00 committed by DS
parent 3120558dd1
commit cdbbac5b6d
9 changed files with 27 additions and 10 deletions

@ -277,6 +277,7 @@ find_package(Lua REQUIRED)
if(NOT USE_LUAJIT)
add_subdirectory(lib/bitop)
endif()
add_subdirectory(lib/sha256)
if(BUILD_UNITTESTS OR BUILD_BENCHMARKS)
add_subdirectory(lib/catch2)

14
lib/sha256/CMakeLists.txt Normal file

@ -0,0 +1,14 @@
project(sha256 C)
add_library(sha256 STATIC sha256.c)
target_include_directories(sha256 INTERFACE .)
INCLUDE(CheckIncludeFiles)
check_include_files(endian.h HAVE_ENDIAN_H)
configure_file(
"${PROJECT_SOURCE_DIR}/cmake_config.h.in"
"${PROJECT_BINARY_DIR}/cmake_config.h"
)
target_include_directories(sha256 PRIVATE "${PROJECT_BINARY_DIR}")

@ -0,0 +1,5 @@
// Filled in by the build system
#pragma once
#cmakedefine HAVE_ENDIAN_H

@ -56,17 +56,13 @@
#include <stdlib.h>
#include <string.h>
#include "util/sha256.h"
#include "sha256/sha256.h"
#if defined(_MSC_VER) && !defined(__clang__) && !defined(__attribute__)
#define __attribute__(a)
#endif
/* pull HAVE_ENDIAN_H from Minetest */
#include "config.h"
#if !HAVE_ENDIAN_H
#undef HAVE_ENDIAN_H
#endif
#include "cmake_config.h" /* HAVE_ENDIAN_H */
/** endian.h **/
/*

@ -565,6 +565,7 @@ if(BUILD_CLIENT)
${GMP_LIBRARY}
${JSON_LIBRARY}
${LUA_BIT_LIBRARY}
sha256
${FREETYPE_LIBRARY}
${PLATFORM_LIBS}
# on Android, Minetest depends on SDL2 directly
@ -637,6 +638,7 @@ if(BUILD_SERVER)
${JSON_LIBRARY}
${LUA_LIBRARY}
${LUA_BIT_LIBRARY}
sha256
${GMP_LIBRARY}
${PLATFORM_LIBS}
)

@ -42,7 +42,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "version.h"
#include "util/hex.h"
#include "util/sha1.h"
#include "util/sha256.h"
#include <sha256/sha256.h>
#include "util/png.h"
#include <cstdio>

@ -13,7 +13,6 @@ set(UTIL_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/quicktune.cpp
${CMAKE_CURRENT_SOURCE_DIR}/serialize.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sha1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sha256.c
${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
${CMAKE_CURRENT_SOURCE_DIR}/srp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timetaker.cpp

@ -50,7 +50,7 @@
#include <mini-gmp.h>
#endif
#include "util/sha256.h"
#include <sha256/sha256.h>
#include "srp.h"
//#define CSRP_USE_SHA1