Fix zip-tool build on Mac

Add the Security and Cocoa frameworks as link dependencies
of the shared updater library.

MD-19678 #time 10m
This commit is contained in:
Robert Knight 2013-08-30 15:43:25 +01:00
parent 2658f1235d
commit b168ed69d7
3 changed files with 11 additions and 12 deletions

View file

@ -106,6 +106,12 @@ target_link_libraries(updatershared
tinythread
)
if(APPLE)
find_library(COCOA_LIBRARY Cocoa)
find_library(SECURITY_LIBRARY Security)
target_link_libraries(updatershared ${SECURITY_LIBRARY} ${COCOA_LIBRARY})
endif()
if (UNIX)
target_link_libraries(updatershared pthread dl)
endif()
@ -116,13 +122,6 @@ endif()
add_executable(updater ${EXE_FLAGS} main.cpp)
if(APPLE)
set_target_properties(
updater
PROPERTIES LINK_FLAGS "-framework Security -framework Cocoa"
)
endif()
target_link_libraries(updater
updatershared
)
@ -133,7 +132,7 @@ endif()
install(TARGETS updater RUNTIME DESTINATION bin)
add_executable(zip-tool zip.cpp)
add_executable(zip-tool zip-tool.cpp)
target_link_libraries(zip-tool updatershared)

View file

@ -160,7 +160,7 @@ void FileUtils::addToZip(const char* archivePath, const char* path, const char*
{
throw IOException("Unable to add new file to zip archive");
}
result = zipWriteInFileInZip(archive, content, length);
result = zipWriteInFileInZip(archive, content, static_cast<unsigned int>(length));
if (result != ZIP_OK)
{
throw IOException("Unable to write file data to zip archive");
@ -536,14 +536,14 @@ void FileUtils::writeFile(const char* path, const char* data, int length) throw
stream.write(data,length);
}
std::string FileUtils::readFile(const char* path)
std::string FileUtils::readFile(const char* path) throw (IOException)
{
std::ifstream inputFile(path, std::ios::in | std::ios::binary);
std::string content;
inputFile.seekg(0, std::ios::end);
content.resize(static_cast<unsigned int>(inputFile.tellg()));
inputFile.seekg(0, std::ios::beg);
inputFile.read(&content[0], content.size());
inputFile.read(&content[0], static_cast<int>(content.size()));
return content;
}

View file

@ -56,7 +56,7 @@ int main(int argc, char** argv)
std::string path = iter->substr(inputDir.size()+1);
std::string content = FileUtils::readFile(iter->c_str());
LOG(Info, "Adding " + path + " to archive " + archivePath);
FileUtils::addToZip(archivePath.c_str(), path.c_str(), content.data(), content.length());
FileUtils::addToZip(archivePath.c_str(), path.c_str(), content.data(), static_cast<int>(content.length()));
}
}
catch (const std::exception& ex)