link in libstudxml as object files

This commit is contained in:
Thomas Fussell 2017-04-11 16:04:17 -04:00
parent 077e181617
commit a7cd2c9ee5
5 changed files with 20 additions and 21 deletions

View File

@ -95,7 +95,7 @@ if(NOT BIN_DEST_DIR)
endif()
if(NOT STATIC)
add_library(xlnt SHARED ${XLNT_HEADERS} ${XLNT_SOURCES})
add_library(xlnt SHARED ${XLNT_HEADERS} ${XLNT_SOURCES} $<TARGET_OBJECTS:libstudxml>)
target_compile_definitions(xlnt PRIVATE XLNT_SHARED=1)
if(MSVC)
@ -119,7 +119,7 @@ if(NOT STATIC)
)
endif()
else()
add_library(xlnt STATIC ${XLNT_HEADERS} ${XLNT_SOURCES})
add_library(xlnt STATIC ${XLNT_HEADERS} ${XLNT_SOURCES} $<TARGET_OBJECTS:libstudxml>)
target_compile_definitions(xlnt PUBLIC XLNT_STATIC=1)
if(MSVC)
@ -127,9 +127,9 @@ else()
endif()
endif()
target_link_libraries(xlnt PRIVATE libstudxml)
target_include_directories(xlnt PUBLIC ${XLNT_INCLUDE_DIR})
target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR})
target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/libstudxml)
if(MSVC)
set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\" /MP")

View File

@ -961,7 +961,7 @@ rijndael_key rijndael_setup(const std::vector<std::uint8_t> &key_data)
throw std::runtime_error("");
}
skey.Nr = 10 + ((key_data.size()/8)-2)*2;
skey.Nr = 10 + ((static_cast<int>(key_data.size())/8)-2)*2;
auto key = key_data.data();
/* setup the forward key */
@ -1461,9 +1461,9 @@ std::vector<std::uint8_t> aes_cbc_decrypt(
{
rijndael_ecb_decrypt(ct, temporary.data(), expanded_key);
for (auto x = 0; x < 16; x++)
for (auto x = std::size_t(0); x < 16; x++)
{
auto tmpy = temporary[x] ^ iv[x];
auto tmpy = static_cast<std::uint8_t>(temporary[x] ^ iv[x]);
iv[x] = ct[x];
pt[x] = tmpy;
}

View File

@ -26,6 +26,7 @@
#include <detail/crypto/aes.hpp>
#include <detail/crypto/base64.hpp>
#include <detail/crypto/sha.hpp>
#include <detail/crypto/xlsx_crypto.hpp>
#include <detail/pole.hpp>
#include <detail/xlsx_consumer.hpp>
#include <detail/xlsx_producer.hpp>
@ -199,7 +200,7 @@ static std::string encode_base64(const std::vector<std::uint8_t> &input)
static std::vector<std::uint8_t> decode_base64(const std::string &input)
{
int numEq = 0;
std::size_t numEq = 0;
auto in_end = input.data() + input.size();
while (*--in_end == '=') ++numEq;
auto decoded_length = ((6 * input.size()) / 8) - numEq;
@ -209,10 +210,10 @@ static std::vector<std::uint8_t> decode_base64(const std::string &input)
auto output_iterator = output.begin();
int i = 0, j = 0;
unsigned char a3[3];
unsigned char a4[4];
std::uint8_t a3[3];
std::uint8_t a4[4];
auto b64_lookup = [](unsigned char c)
auto b64_lookup = [](std::uint8_t c) -> std::uint8_t
{
if(c >='A' && c <='Z') return c - 'A';
if(c >='a' && c <='z') return c - 71;
@ -229,7 +230,7 @@ static std::vector<std::uint8_t> decode_base64(const std::string &input)
break;
}
a4[i++] = *(input_iterator++);
a4[i++] = static_cast<std::uint8_t>(*(input_iterator++));
if (i == 4)
{
@ -238,9 +239,9 @@ static std::vector<std::uint8_t> decode_base64(const std::string &input)
a4[i] = b64_lookup(a4[i]);
}
a3[0] = (a4[0] << 2) + ((a4[1] & 0x30) >> 4);
a3[1] = ((a4[1] & 0xf) << 4) + ((a4[2] & 0x3c) >> 2);
a3[2] = ((a4[2] & 0x3) << 6) + a4[3];
a3[0] = static_cast<std::uint8_t>(a4[0] << 2) + static_cast<std::uint8_t>((a4[1] & 0x30) >> 4);
a3[1] = static_cast<std::uint8_t>((a4[1] & 0xf) << 4) + static_cast<std::uint8_t>((a4[2] & 0x3c) >> 2);
a3[2] = static_cast<std::uint8_t>((a4[2] & 0x3) << 6) + static_cast<std::uint8_t>(a4[3]);
for (i = 0; i < 3; i++)
{
@ -263,9 +264,9 @@ static std::vector<std::uint8_t> decode_base64(const std::string &input)
a4[j] = b64_lookup(a4[j]);
}
a3[0] = (a4[0] << 2) + ((a4[1] & 0x30) >> 4);
a3[1] = ((a4[1] & 0xf) << 4) + ((a4[2] & 0x3c) >> 2);
a3[2] = ((a4[2] & 0x3) << 6) + a4[3];
a3[0] = static_cast<std::uint8_t>(a4[0] << 2) + static_cast<std::uint8_t>((a4[1] & 0x30) >> 4);
a3[1] = static_cast<std::uint8_t>((a4[1] & 0xf) << 4) + static_cast<std::uint8_t>((a4[2] & 0x3c) >> 2);
a3[2] = static_cast<std::uint8_t>((a4[2] & 0x3) << 6) + static_cast<std::uint8_t>(a4[3]);
for (j = 0; j < i - 1; j++)
{

View File

@ -44,8 +44,7 @@ set(CXXTEST_PYTHON_TESTGEN_EXECUTABLE ${CXXTEST_ROOT_DIR}/bin/cxxtestgen)
add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER})
target_link_libraries(xlnt.test
PRIVATE xlnt
PRIVATE libstudxml)
PRIVATE xlnt)
target_include_directories(xlnt.test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../source

View File

@ -43,7 +43,7 @@ set(EXPAT
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok_impl.h
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok.h)
add_library(libstudxml STATIC ${LIBSTUDXML} ${GENX} ${EXPAT})
add_library(libstudxml OBJECT ${LIBSTUDXML} ${GENX} ${EXPAT})
target_compile_definitions(libstudxml
PUBLIC LIBSTUDXML_STATIC_LIB=1
@ -51,7 +51,6 @@ target_compile_definitions(libstudxml
target_include_directories(libstudxml
PUBLIC ${LIBSTUDXML_ROOT_DIR}
PUBLIC ${EXPAT_INCLUDE_DIRS})
target_link_libraries(libstudxml PRIVATE ${EXPAT_LIBRARIES})
# Prevent warning C4996 caused by strcpy, strncpy, sprintf in genx
# TODO: would it be better to define this only in genx.c?