diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dbe1360e..2e4bc5f74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,8 +212,8 @@ add_library(gemmi_cpp src/align.cpp src/assembly.cpp src/calculate.cpp src/crd.cpp src/ddl.cpp src/eig3.cpp src/gz.cpp src/intensit.cpp src/json.cpp src/mmcif.cpp src/mmread_gz.cpp src/mtz.cpp src/mtz2cif.cpp - src/pdb.cpp src/polyheur.cpp src/read_cif.cpp src/resinfo.cpp - src/riding_h.cpp src/sprintf.cpp src/to_mmcif.cpp + src/pdb.cpp src/polyheur.cpp src/read_cif.cpp src/read_map.cpp + src/resinfo.cpp src/riding_h.cpp src/sprintf.cpp src/to_mmcif.cpp src/to_pdb.cpp src/monlib.cpp src/topo.cpp src/xds_ascii.cpp) add_library(gemmi::gemmi_cpp ALIAS gemmi_cpp) set_property(TARGET gemmi_cpp PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/fortran/gemmi.yaml b/fortran/gemmi.yaml index 10c64993c..ddbfee60b 100644 --- a/fortran/gemmi.yaml +++ b/fortran/gemmi.yaml @@ -13,7 +13,6 @@ splicer_code: c: CXX_definitions: | // for read_ccp4_map() and read_ccp4_mask() - #define GEMMI_READ_MAP_IMPLEMENTATION #include "gemmi/read_map.hpp" declarations: diff --git a/include/gemmi/read_map.hpp b/include/gemmi/read_map.hpp index 979c6a30e..24c056f9e 100644 --- a/include/gemmi/read_map.hpp +++ b/include/gemmi/read_map.hpp @@ -2,48 +2,16 @@ // // Functions for reading possibly gzipped CCP4 map files. // Trivial wrappers that can make compilation faster. -// -// The definitions are guarded by #ifdef *_IMPLEMENTATION. -// If you use this header in your program, you need in exactly one file: -// #define GEMMI_READ_MAP_IMPLEMENTATION -// #include -#ifndef GEMMI_GZREAD_MAP_HPP_ -#define GEMMI_GZREAD_MAP_HPP_ +#ifndef GEMMI_READ_MAP_HPP_ +#define GEMMI_READ_MAP_HPP_ #include "ccp4.hpp" // for Ccp4 namespace gemmi { -Ccp4 read_ccp4_map(const std::string& path, bool setup); -Ccp4 read_ccp4_mask(const std::string& path, bool setup); - -} // namespace gemmi - -#endif - - -#ifdef GEMMI_READ_MAP_IMPLEMENTATION - -#include "gz.hpp" // for MaybeGzipped - -namespace gemmi { - -Ccp4 read_ccp4_map(const std::string& path, bool setup) { - Ccp4 ccp4; - ccp4.read_ccp4(MaybeGzipped(path)); - if (setup) - ccp4.setup(NAN); - return ccp4; -} - -Ccp4 read_ccp4_mask(const std::string& path, bool setup) { - Ccp4 ccp4; - ccp4.read_ccp4(MaybeGzipped(path)); - if (setup) - ccp4.setup(-1); - return ccp4; -} +GEMMI_DLL Ccp4 read_ccp4_map(const std::string& path, bool setup); +GEMMI_DLL Ccp4 read_ccp4_mask(const std::string& path, bool setup); } // namespace gemmi diff --git a/python/ccp4.cpp b/python/ccp4.cpp index 3f74251a4..9aa352580 100644 --- a/python/ccp4.cpp +++ b/python/ccp4.cpp @@ -1,12 +1,11 @@ // Copyright 2018 Global Phasing Ltd. #include "gemmi/ccp4.hpp" +#include "gemmi/util.hpp" // for cat +#include "gemmi/read_map.hpp" // for read_ccp4_map, read_ccp4_mask #include "common.h" #include -#define GEMMI_READ_MAP_IMPLEMENTATION -#include "gemmi/read_map.hpp" // defines read_ccp4_map, read_ccp4_mask - namespace py = pybind11; using namespace gemmi; diff --git a/src/read_map.cpp b/src/read_map.cpp new file mode 100644 index 000000000..0278650c5 --- /dev/null +++ b/src/read_map.cpp @@ -0,0 +1,24 @@ +// Copyright 2021 Global Phasing Ltd. + +#include "gemmi/read_map.hpp" +#include "gemmi/gz.hpp" // for MaybeGzipped + +namespace gemmi { + +Ccp4 read_ccp4_map(const std::string& path, bool setup) { + Ccp4 ccp4; + ccp4.read_ccp4(MaybeGzipped(path)); + if (setup) + ccp4.setup(NAN); + return ccp4; +} + +Ccp4 read_ccp4_mask(const std::string& path, bool setup) { + Ccp4 ccp4; + ccp4.read_ccp4(MaybeGzipped(path)); + if (setup) + ccp4.setup(-1); + return ccp4; +} + +} // namespace gemmi