build: use WinSQLite3 when possible
This commit is contained in:
parent
f364acaec3
commit
f458c053c8
@ -2,9 +2,15 @@ cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(kgg-dec VERSION 0.6.0 LANGUAGES CXX)
|
||||
|
||||
option(USE_WIN_SQLITE3 "Use Windows SQLite3 (MSVC Only)" ${MSVC})
|
||||
|
||||
add_subdirectory(third-party/aes)
|
||||
add_subdirectory(third-party/md5)
|
||||
add_subdirectory(third-party/sqlite3)
|
||||
include(cmake/FindWinSQLite3.cmake)
|
||||
if (NOT WinSQLite3_Found)
|
||||
message("including sqlite3 to the build")
|
||||
add_subdirectory(third-party/sqlite3)
|
||||
endif ()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
@ -27,6 +33,12 @@ target_include_directories(kgg-dec
|
||||
src/tc_tea
|
||||
)
|
||||
|
||||
target_link_libraries(kgg-dec PRIVATE shell32 ole32 libaes libmd5 sqlite3)
|
||||
target_link_libraries(kgg-dec PRIVATE shell32 ole32 libaes libmd5)
|
||||
if (WinSQLite3_Found)
|
||||
target_link_libraries(kgg-dec PRIVATE WinSQLite3)
|
||||
target_include_directories(kgg-dec PRIVATE ${WindowsKitInclude})
|
||||
else ()
|
||||
target_link_libraries(kgg-dec PRIVATE sqlite3)
|
||||
endif ()
|
||||
target_compile_definitions(kgg-dec PRIVATE NOMINMAX)
|
||||
target_compile_definitions(kgg-dec PRIVATE KGGDEC_PROJECT_VERSION="${PROJECT_VERSION}")
|
||||
|
@ -35,7 +35,10 @@
|
||||
"description": "Configure for Visual Studio",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"binaryDir": "${sourceDir}/build/vs2022",
|
||||
"architecture": "x64"
|
||||
"architecture": "x64,version=10.0",
|
||||
"toolset": {
|
||||
"value": "v143"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
|
14
cmake/FindWinSQLite3.cmake
Normal file
14
cmake/FindWinSQLite3.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
set(WinSQLite3_Found FALSE)
|
||||
|
||||
if (MSVC AND USE_WIN_SQLITE3)
|
||||
set(ProgramFiles_x86 "$ENV{ProgramFiles\(x86\)}")
|
||||
file(GLOB WindowsKitLibs "${ProgramFiles_x86}/Windows Kits/10/Lib/10.0.*/um/${CMAKE_VS_PLATFORM_NAME}")
|
||||
find_library(LibWinSQLite3 WinSQLite3 PATHS ${WindowsKitLibs})
|
||||
if (LibWinSQLite3)
|
||||
set(WinSQLite3_Found TRUE)
|
||||
get_filename_component(WindowsKitVersion "${LibWinSQLite3}/../../.." ABSOLUTE)
|
||||
get_filename_component(WindowsKitVersion ${WindowsKitVersion} NAME)
|
||||
set(WindowsKitInclude "${ProgramFiles_x86}/Windows Kits/10/Include/${WindowsKitVersion}/um")
|
||||
message("Using WinSQLite3 from Windows SDK (${WindowsKitVersion}).")
|
||||
endif ()
|
||||
endif ()
|
7
src/common/sqlite3_wrapper.h
Normal file
7
src/common/sqlite3_wrapper.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#if __has_include(<sqlite3.h>)
|
||||
#include <sqlite3.h>
|
||||
#else
|
||||
#include <winsqlite/winsqlite3.h>
|
||||
#endif
|
@ -3,7 +3,7 @@
|
||||
#include <aes.h>
|
||||
#include <endian_helper.h>
|
||||
#include <md5.h>
|
||||
#include <sqlite3.h>
|
||||
#include <sqlite3_wrapper.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@ -11,6 +11,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace Infra {
|
||||
using std::size_t;
|
||||
|
||||
constexpr size_t kPageSize = 0x400;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <sqlite3.h>
|
||||
#include <sqlite3_wrapper.h>
|
||||
|
||||
#include "infra/infra.h"
|
||||
#include "jobs.hpp"
|
||||
#include "utils/cli.h"
|
||||
|
Loading…
Reference in New Issue
Block a user