1 Commits
Author SHA1 Message Date
Deorder 6dbe006156 Reorganized directories
Readded .editorconfig
C wrapper can be built again
Delphi library can be built again
Initial cleanup of cmake files
2020-08-22 02:48:32 +02:00
48 changed files with 1550 additions and 1974 deletions
+7
View File
@@ -0,0 +1,7 @@
root = true
[*]
end_of_line = crlf
insert_final_newline = true
indent_style = space
indent_size = 2
+2 -1
View File
@@ -134,7 +134,6 @@ ui_*.h
*.jsc
Makefile*
*build-*
vsbuild
# Qt unit tests
target_wrapper.*
@@ -530,3 +529,5 @@ healthchecksdb
MigrationBackup/
# End of https://www.gitignore.io/api/qt,c++,cmake,delphi,qtcreator,visualstudio
**/build
-130
View File
@@ -1,130 +0,0 @@
cmake_minimum_required(VERSION 3.16)
include(CMakePackageConfigHelpers)
project(libbsarch CXX)
find_package(mo2-dds-header CONFIG REQUIRED)
find_package(Qt6 COMPONENTS Core REQUIRED)
get_target_property(SRCS mo2::dds-header SOURCES)
# libbsarch
add_library(libbsarch SHARED)
target_sources(libbsarch
PRIVATE
src/libbsarch.cpp
src/libbsarch.def
PUBLIC
FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch/libbsarch.h
)
target_include_directories(libbsarch PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch)
set_target_properties(libbsarch PROPERTIES DEBUG_POSTFIX "d" CXX_STANDARD 11)
target_link_libraries(libbsarch PUBLIC mo2::dds-header)
target_compile_definitions(libbsarch PRIVATE BSARCH_DLL_EXPORT)
# preprocessor definitions
if(MSVC)
target_compile_options(libbsarch PRIVATE
/W3 /EHsc /MP
$<$<CONFIG:DEBUG>:/MDd /Od>
$<$<CONFIG:RELEASE>:/Zi>
)
endif()
# libbsarch_OOP
add_library(libbsarch_OOP STATIC)
target_sources(libbsarch_OOP
PRIVATE
src/bs_archive_entries.cpp
src/utils/string_convert.cpp
src/utils/convertible_ostream.cpp
src/utils/convertible_string.cpp
src/bs_archive_auto.cpp
src/bs_archive.cpp
PUBLIC
FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch/base_types.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch/bs_archive_auto.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch/bs_archive.h
${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch/bs_archive_entries.h
${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch/libbsarch.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch/libbsarch.h
${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch/utils/convertible_string.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch/utils/convertible_ostream.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch/utils/string_convert.hpp
)
target_include_directories(libbsarch_OOP PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch
${CMAKE_CURRENT_SOURCE_DIR}/include/libbsarch/utils)
target_link_libraries(libbsarch_OOP PUBLIC mo2::dds-header)
set_target_properties(libbsarch_OOP PROPERTIES
DEBUG_POSTFIX "d"
CXX_STANDARD 17
)
if (MSVC)
target_compile_options(libbsarch_OOP PRIVATE /MP)
endif()
# adding Qt support
if(Qt6_FOUND)
message("libbsarch: Qt6 found, enabling Qt support")
target_link_libraries(libbsarch_OOP PUBLIC Qt::Core)
target_compile_definitions(libbsarch PUBLIC "LIBBSARCH_QT_SUPPORT")
target_compile_definitions(libbsarch_OOP PUBLIC "LIBBSARCH_QT_SUPPORT")
endif()
# target_link_libraries(libbsarch_OOP PUBLIC libbsarch)
# install
# finding 32 or 64bits
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# 64 bits
set(lib_delphi "${CMAKE_CURRENT_SOURCE_DIR}/delphi/lib64")
message("libbsarch: using 64bits DLL")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
# 32 bits
set(lib_delphi "${CMAKE_CURRENT_SOURCE_DIR}/delphi/lib")
message("libbsarch: using 32bits DLL")
endif()
install(TARGETS libbsarch libbsarch_OOP EXPORT libbsarchTargets FILE_SET HEADERS)
install(FILES $<TARGET_PDB_FILE:libbsarch> DESTINATION pdb OPTIONAL)
install(EXPORT libbsarchTargets
FILE mo2-libbsarch-targets.cmake
NAMESPACE mo2::
DESTINATION lib/cmake/mo2-libbsarch
)
# install the true DLLs
install(FILES ${lib_delphi}/libbsarch.dll DESTINATION bin CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
install(FILES ${lib_delphi}/libbsarchd.dll DESTINATION bin CONFIGURATIONS Debug)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/mo2-libbsarch-config.cmake"
INSTALL_DESTINATION "lib/cmake/mo2-libbsarch"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/mo2-libbsarch-config-version.cmake"
VERSION "0.0.13"
COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/mo2-libbsarch-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/mo2-libbsarch-config-version.cmake
DESTINATION lib/cmake/mo2-libbsarch
)
-17
View File
@@ -1,17 +0,0 @@
{
"configurePresets": [
{
"binaryDir": "${sourceDir}/vsbuild",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"generator": "Visual Studio 17 2022",
"name": "vs2022-windows"
}
],
"buildPresets": [
{
"name": "vs2022-windows",
"configurePreset": "vs2022-windows"
}
],
"version": 4
}
+2 -4
View File
@@ -1,5 +1,4 @@
# BSArchive DLL and C++ bindings
BSArchive Dynamic Link Library and C++ bindings
## How to build
@@ -10,7 +9,7 @@ BSArchive Dynamic Link Library and C++ bindings
## How to use
With CMake:
With CMake:
Use ``add_subdirectory`` and ``target_link_library``
Then ``#include "libbsarch.h"`` for the C wrapper, or ``#include "bs_archive_auto"`` for the C++ wrapper.
See the example for code use.
@@ -21,5 +20,4 @@ Use `libbsarch.dll` (provided in delphi/lib), `libbsarch.lib` and `libbsarch.h`
## Credits
The original BSArchive can be found at: https://github.com/TES5Edit/TES5Edit/tree/dev/Tools/BSArchive
The version in this project had been modified for better compatibility with C/C++ and
allow the users to allocate their own memory in some cases.
The version in this project had been modified for better compatibility with C/C++ and allow the users to allocate their own memory in some cases.
-24
View File
@@ -1,24 +0,0 @@
@PACKAGE_INIT@
include ( "${CMAKE_CURRENT_LIST_DIR}/mo2-libbsarch-targets.cmake" )
target_link_libraries(mo2::libbsarch PUBLIC mo2::libbsarch_OOP)
# libbsarch is usually be build in Debug or Release/RelWithDebInfo, so we need to map
# missing configurations to avoid issue with CMP0111
list(FIND _LIBBSARCH_CONFIGURATIONS "RELEASE" _LIBBSARCH_HAS_RELEASE)
if (_LIBBSARCH_HAS_RELEASE EQUAL -1)
set_target_properties(mo2::libbsarch PROPERTIES
MAP_IMPORTED_CONFIG_MINSIZEREL RelWithDebInfo
MAP_IMPORTED_CONFIG_RELEASE RelWithDebInfo
)
set_property(TARGET mo2::libbsarch APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL)
set_property(TARGET mo2::libbsarch APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
else()
set_target_properties(mo2::libbsarch PROPERTIES
MAP_IMPORTED_CONFIG_MINSIZEREL Release
MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release
)
set_property(TARGET mo2::libbsarch APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL)
set_property(TARGET mo2::libbsarch APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
endif()
@@ -44,7 +44,7 @@ convertible_ostream::operator std::wostream &()
return std::wcout;
}
#ifdef LIBBSARCH_QT_SUPPORT
#ifdef QT
convertible_ostream::operator QDebug()
{
return qDebug();
@@ -29,7 +29,7 @@ public:
operator std::ostream &();
operator std::wostream &();
#ifdef LIBBSARCH_QT_SUPPORT
#ifdef QT
operator QDebug();
convertible_ostream &operator<<(const QString &rh);
#endif
@@ -40,6 +40,16 @@ convertible_string::convertible_string(wchar_t const *wval_array, bool to_native
this->to_native_path();
}
#ifdef QT
convertible_string::convertible_string(const QString &qsvalue, bool to_native_path)
: str_(to_string(qsvalue))
, auto_convert_to_native_path(to_native_path)
{
if (auto_convert_to_native_path)
this->to_native_path();
}
#endif
/* assignment operators */
convertible_string &convertible_string::operator=(const std::string &value)
{
@@ -64,6 +74,16 @@ convertible_string &convertible_string::operator=(const wchar_t *wvalue)
return *this;
}
#ifdef QT
convertible_string &convertible_string::operator=(const QString &qsvalue)
{
str_ = to_string(qsvalue);
if (auto_convert_to_native_path)
this->to_native_path();
return *this;
}
#endif
/* implicit conversion operators */
convertible_string::operator std::string() const
{
@@ -80,6 +100,12 @@ convertible_string::operator const wchar_t *() const
wcscpy_s(wchar_array, wstr.length() + 1, wstr.c_str());
return wchar_array;
}
#ifdef QT
convertible_string::operator QString() const
{
return to_qstring(str_);
}
#endif
/* Util */
bool convertible_string::remove_substring(const convertible_string &sub_str)
@@ -99,28 +125,4 @@ convertible_string &convertible_string::to_native_path()
str_ = path.make_preferred().string();
return *this;
}
#ifdef LIBBSARCH_QT_SUPPORT
convertible_string::convertible_string(const QString &qsvalue, bool to_native_path)
: str_(to_string(qsvalue))
, auto_convert_to_native_path(to_native_path)
{
if (auto_convert_to_native_path)
this->to_native_path();
}
convertible_string &convertible_string::operator=(const QString &qsvalue)
{
str_ = to_string(qsvalue);
if (auto_convert_to_native_path)
this->to_native_path();
return *this;
}
convertible_string::operator QString() const
{
return to_qstring(str_);
}
#endif
} // namespace libbsarch
@@ -6,12 +6,11 @@
//See https://stackoverflow.com/questions/4804298/how-to-convert-wstring-into-string
#ifdef LIBBSARCH_QT_SUPPORT
#include "string_convert.hpp"
#ifdef QT
#include <QString>
#endif
#include "string_convert.hpp"
namespace libbsarch {
class convertible_string
{
@@ -24,20 +23,23 @@ public:
convertible_string(const char *const val_array, bool to_native_path = true);
convertible_string(const std::wstring &wvalue, bool to_native_path = true);
convertible_string(const wchar_t *const wval_array, bool to_native_path = true);
#ifdef QT
convertible_string(const QString &qsvalue, bool to_native_path = true);
#endif
/* assignment operators */
convertible_string &operator=(const std::string &value);
convertible_string &operator=(const std::wstring &wvalue);
convertible_string &operator=(const wchar_t *wvalue);
#ifdef QT
convertible_string &operator=(const QString &qsvalue);
#endif
/* implicit conversion operators */
operator std::string() const;
operator std::wstring() const;
operator const wchar_t *() const;
#ifdef LIBBSARCH_QT_SUPPORT
convertible_string(const QString &qsvalue, bool to_native_path = true);
convertible_string &operator=(const QString &qsvalue);
#ifdef QT
operator QString() const;
#endif
@@ -5,7 +5,7 @@
#include "string_convert.hpp"
namespace libbsarch {
#ifdef LIBBSARCH_QT_SUPPORT
#ifdef QT
std::wstring to_wstring(const QString &str)
{
#ifdef _MSC_VER
@@ -4,16 +4,15 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#pragma once
#ifdef LIBBSARCH_QT_SUPPORT
#ifdef QT
#include <QDebug>
#endif
#include <codecvt>
#include <locale>
#include <string>
namespace libbsarch {
#ifdef LIBBSARCH_QT_SUPPORT
#ifdef QT
std::wstring to_wstring(const QString &str);
std::string to_string(const QString &str);
QString to_qstring(const std::string &str);

Some files were not shown because too many files have changed in this diff Show More