Commit 4524357c by Maarten L. Hekkelman

zlib, again (use the zlib from boost in Windows)

parent 0b05b6f6
......@@ -9,4 +9,6 @@ test/rename-compound-test
tools/update-dictionary-script
data/
CMakeSettings.json
msvc/
\ No newline at end of file
msvc/
Testing/
......@@ -182,7 +182,9 @@ if(NOT BUILD_SHARED_LIBS)
endif()
find_package(Boost 1.70.0 REQUIRED COMPONENTS system iostreams regex date_time program_options)
find_package(ZLIB REQUIRED)
if(NOT MSVC AND Boost_USE_STATIC_LIBS)
find_package(ZLIB REQUIRED)
endif()
# Create a revision file, containing the current git version info
......@@ -209,7 +211,7 @@ if(RECREATE_SYMOP_DATA)
add_executable(symop-map-generator "${CMAKE_SOURCE_DIR}/tools/symop-map-generator.cpp")
target_link_libraries(symop-map-generator Threads::Threads ${Boost_LIBRARIES} std::filesystem ZLIB::ZLIB)
target_link_libraries(symop-map-generator Threads::Threads ${Boost_LIBRARIES} std::filesystem ${ZLIB_LIBRARIES})
if(Boost_INCLUDE_DIR)
target_include_directories(symop-map-generator PUBLIC ${Boost_INCLUDE_DIR})
endif()
......@@ -282,7 +284,7 @@ target_include_directories(cifpp
${CMAKE_BINARY_DIR}
)
target_link_libraries(cifpp Threads::Threads ${Boost_LIBRARIES} std::filesystem ZLIB::ZLIB)
target_link_libraries(cifpp Threads::Threads ${Boost_LIBRARIES} std::filesystem ${ZLIB_LIBRARIES})
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_link_options(cifpp PRIVATE -undefined dynamic_lookup)
......@@ -446,7 +448,7 @@ if(CIFPP_BUILD_TESTS)
${CMAKE_CURRENT_BINARY_DIR} # for config.h
)
target_link_libraries(${CIFPP_TEST} PRIVATE Threads::Threads cifpp ${Boost_LIBRARIES} std::filesystem ZLIB::ZLIB)
target_link_libraries(${CIFPP_TEST} PRIVATE Threads::Threads cifpp ${Boost_LIBRARIES} std::filesystem ${ZLIB_LIBRARIES})
if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions
......
......@@ -2141,15 +2141,15 @@ class File
File();
File(std::istream &is, bool validate = false);
File(const std::string &path, bool validate = false);
File(const std::filesystem::path &path, bool validate = false);
File(File &&rhs);
File(const File &rhs) = delete;
File &operator=(const File &rhs) = delete;
~File();
void load(const std::string &p);
void save(const std::string &p);
void load(const std::filesystem::path &p);
void save(const std::filesystem::path &p);
void load(std::istream &is);
void save(std::ostream &os);
......
......@@ -162,8 +162,8 @@ class CompoundFactory
static CompoundFactory &instance();
static void clear();
void setDefaultDictionary(const std::string &inDictFile);
void pushDictionary(const std::string &inDictFile);
void setDefaultDictionary(const std::filesystem::path &inDictFile);
void pushDictionary(const std::filesystem::path &inDictFile);
void popDictionary();
bool isKnownPeptide(const std::string &res_name) const;
......
......@@ -397,7 +397,7 @@ class File : public std::enable_shared_from_this<File>
{
public:
File();
File(const std::string &path);
File(const std::filesystem::path &path);
File(const char *data, size_t length); // good luck trying to find out what it is...
~File();
......@@ -406,8 +406,8 @@ class File : public std::enable_shared_from_this<File>
cif::Datablock& createDatablock(const std::string &name);
void load(const std::string &path);
void save(const std::string &path);
void load(const std::filesystem::path &path);
void save(const std::filesystem::path &path);
Structure *model(size_t nr = 1);
......
......@@ -3399,7 +3399,7 @@ File::File(std::istream &is, bool validate)
load(is);
}
File::File(const std::string &path, bool validate)
File::File(const std::filesystem::path &path, bool validate)
: File()
{
try
......@@ -3452,7 +3452,7 @@ void File::append(Datablock *e)
}
}
void File::load(const std::string &p)
void File::load(const std::filesystem::path &p)
{
fs::path path(p);
......@@ -3482,7 +3482,7 @@ void File::load(const std::string &p)
}
}
void File::save(const std::string &p)
void File::save(const std::filesystem::path &p)
{
fs::path path(p);
......
......@@ -268,7 +268,7 @@ class CompoundFactoryImpl : public std::enable_shared_from_this<CompoundFactoryI
public:
CompoundFactoryImpl(std::shared_ptr<CompoundFactoryImpl> next);
CompoundFactoryImpl(const std::string &file, std::shared_ptr<CompoundFactoryImpl> next);
CompoundFactoryImpl(const std::filesystem::path &file, std::shared_ptr<CompoundFactoryImpl> next);
virtual ~CompoundFactoryImpl()
{
......@@ -362,7 +362,7 @@ CompoundFactoryImpl::CompoundFactoryImpl(std::shared_ptr<CompoundFactoryImpl> ne
mKnownBases.insert(key);
}
CompoundFactoryImpl::CompoundFactoryImpl(const std::string &file, std::shared_ptr<CompoundFactoryImpl> next)
CompoundFactoryImpl::CompoundFactoryImpl(const std::filesystem::path &file, std::shared_ptr<CompoundFactoryImpl> next)
: mNext(next)
{
cif::File cifFile(file);
......@@ -677,10 +677,10 @@ void CompoundFactory::clear()
sInstance.reset();
}
void CompoundFactory::setDefaultDictionary(const std::string &inDictFile)
void CompoundFactory::setDefaultDictionary(const std::filesystem::path &inDictFile)
{
if (not fs::exists(inDictFile))
throw std::runtime_error("file not found: " + inDictFile);
throw std::runtime_error("file not found: " + inDictFile.string());
try
{
......@@ -693,10 +693,10 @@ void CompoundFactory::setDefaultDictionary(const std::string &inDictFile)
}
}
void CompoundFactory::pushDictionary(const std::string &inDictFile)
void CompoundFactory::pushDictionary(const std::filesystem::path &inDictFile)
{
if (not fs::exists(inDictFile))
throw std::runtime_error("file not found: " + inDictFile);
throw std::runtime_error("file not found: " + inDictFile.string());
// ifstream file(inDictFile);
// if (not file.is_open())
......
......@@ -59,8 +59,8 @@ struct FileImpl
void load_data(const char *data, size_t length);
void load(const std::string &p);
void save(const std::string &p);
void load(const std::filesystem::path &path);
void save(const std::filesystem::path &path);
};
void FileImpl::load_data(const char *data, size_t length)
......@@ -112,10 +112,8 @@ void FileImpl::load_data(const char *data, size_t length)
std::cerr << "Invalid mmCIF file" << (cif::VERBOSE ? "." : " use --verbose option to see errors") << std::endl;
}
void FileImpl::load(const std::string &p)
void FileImpl::load(const std::filesystem::path &path)
{
fs::path path(p);
std::ifstream inFile(path, std::ios_base::in | std::ios_base::binary);
if (not inFile.is_open())
throw std::runtime_error("No such file: " + path.string());
......@@ -185,18 +183,13 @@ void FileImpl::load(const std::string &p)
std::cerr << "Invalid mmCIF file" << (cif::VERBOSE ? "." : " use --verbose option to see errors") << std::endl;
}
void FileImpl::save(const std::string &p)
void FileImpl::save(const std::filesystem::path &path)
{
fs::path path(p);
std::ofstream outFile(p, std::ios_base::out | std::ios_base::binary);
std::ofstream outFile(path, std::ios_base::out | std::ios_base::binary);
io::filtering_stream<io::output> out;
if (path.extension() == ".gz")
{
out.push(io::gzip_compressor());
path = path.stem();
}
out.push(outFile);
......@@ -1732,7 +1725,7 @@ File::File(const char *data, size_t length)
mImpl->load_data(data, length);
}
File::File(const std::string &File)
File::File(const std::filesystem::path &File)
: mImpl(new FileImpl)
{
load(File);
......@@ -1753,12 +1746,12 @@ cif::Datablock& File::createDatablock(const std::string &name)
return *mImpl->mDb;
}
void File::load(const std::string &p)
void File::load(const std::filesystem::path &p)
{
mImpl->load(p);
}
void File::save(const std::string &file)
void File::save(const std::filesystem::path &file)
{
mImpl->save(file);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment