Commit 1d2f997e by Maarten L. Hekkelman

export stuff

parent f126b1da
...@@ -98,22 +98,13 @@ find_package(Boost 1.71.0 REQUIRED COMPONENTS system iostreams regex date_time p ...@@ -98,22 +98,13 @@ find_package(Boost 1.71.0 REQUIRED COMPONENTS system iostreams regex date_time p
find_package(ZLIB) find_package(ZLIB)
find_package(BZip2) find_package(BZip2)
include_directories(${Boost_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include) include_directories(${Boost_INCLUDE_DIR})
link_libraries(${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) link_libraries(${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
# Create a revision file, containing the current git version info # Create a revision file, containing the current git version info
find_package(Git) find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git") if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
include(GetGitRevisionDescription)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD OUTPUT_VARIABLE SHORT_SHA OUTPUT_STRIP_TRAILING_WHITESPACE)
set(REVISION ${SHORT_SHA} CACHE STRING "git short sha" FORCE)
# only use the plugin to tie the configure state to the sha to force rebuilds
# of files that depend on version.h
include(GetGitRevisionDescription) include(GetGitRevisionDescription)
get_git_head_revision(REFSPEC COMMITHASH) get_git_head_revision(REFSPEC COMMITHASH)
...@@ -128,6 +119,7 @@ endif() ...@@ -128,6 +119,7 @@ endif()
# generate version.h # generate version.h
include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_BINARY_DIR})
configure_file("${CMAKE_SOURCE_DIR}/src/revision.hpp.in" "${CMAKE_BINARY_DIR}/revision.hpp" @ONLY) configure_file("${CMAKE_SOURCE_DIR}/src/revision.hpp.in" "${CMAKE_BINARY_DIR}/revision.hpp" @ONLY)
# Sources # Sources
set(project_sources set(project_sources
...@@ -171,20 +163,18 @@ include_directories( ...@@ -171,20 +163,18 @@ include_directories(
${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src
) )
add_library(cifpp_obj OBJECT ${project_sources} ${project_headers}) add_library(cifpp SHARED ${project_sources} ${project_headers})
set_target_properties(cifpp_obj PROPERTIES POSITION_INDEPENDENT_CODE 1)
add_library(cifpp SHARED $<TARGET_OBJECTS:cifpp_obj>)
set_target_properties(cifpp PROPERTIES set_target_properties(cifpp PROPERTIES
SOVERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION}
INTERFACE_cifpp_MAJOR_VERSION cifpp_MAJOR_VERSION INTERFACE_cifpp_MAJOR_VERSION cifpp_MAJOR_VERSION
COMPATIBLE_INTERFACE_STRING cifpp_MAJOR_VERSION COMPATIBLE_INTERFACE_STRING cifpp_MAJOR_VERSION
) )
add_library(cifpp_static STATIC $<TARGET_OBJECTS:cifpp_obj>) add_library(cifpp_static STATIC ${project_sources} ${project_headers})
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_link_options(cifpp PRIVATE -undefined dynamic_lookup) target_link_options(cifpp PRIVATE -undefined dynamic_lookup)
target_link_options(cifpp_static PRIVATE -undefined dynamic_lookup)
endif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") endif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# download the components.cif file from CCD # download the components.cif file from CCD
...@@ -224,8 +214,6 @@ include_directories(${Boost_INCLUDE_DIRS}) ...@@ -224,8 +214,6 @@ include_directories(${Boost_INCLUDE_DIRS})
link_libraries(${Boost_LIBRARIES}) link_libraries(${Boost_LIBRARIES})
add_compile_definitions(CACHE_DIR="${SHARE_INSTALL_DIR}/libcifpp" DATA_DIR="${SHARE_INSTALL_DIR}/libcifpp" ) add_compile_definitions(CACHE_DIR="${SHARE_INSTALL_DIR}/libcifpp" DATA_DIR="${SHARE_INSTALL_DIR}/libcifpp" )
configure_file(${PROJECT_SOURCE_DIR}/src/Config-cmake.hpp.in Config.hpp)
generate_export_header(cifpp) generate_export_header(cifpp)
# Install rules # Install rules
...@@ -237,7 +225,6 @@ install(TARGETS cifpp cifpp_static ...@@ -237,7 +225,6 @@ install(TARGETS cifpp cifpp_static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install( install(
DIRECTORY include/cif++ DIRECTORY include/cif++
DESTINATION include DESTINATION include
......
...@@ -106,7 +106,7 @@ namespace cif ...@@ -106,7 +106,7 @@ namespace cif
{ {
// flag for verbose output // flag for verbose output
extern CIFPP_DLL_IMPORT(int) VERBOSE; CIFPP_EXPORT extern int VERBOSE;
// mmCIF mapping // mmCIF mapping
// A CIF data file in this case contains entries (data blocks) which can contain // A CIF data file in this case contains entries (data blocks) which can contain
......
...@@ -45,15 +45,7 @@ ...@@ -45,15 +45,7 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef _MSC_VER #include "cifpp_export.h"
#ifdef CIFPP_BUILD_DLL
#define CIFPP_DLL_IMPORT(type) __declspec(dllexport) type
#else
#define CIFPP_DLL_IMPORT(type) __declspec(dllimport) type
#endif
#else
#define CIFPP_DLL_IMPORT(type) type
#endif
namespace cif namespace cif
{ {
......
...@@ -145,7 +145,7 @@ class Compound ...@@ -145,7 +145,7 @@ class Compound
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Factory class for Compound and Link objects // Factory class for Compound and Link objects
extern CIFPP_DLL_IMPORT(const) std::map<std::string, char> kAAMap, kBaseMap; CIFPP_EXPORT extern const std::map<std::string, char> kAAMap, kBaseMap;
class CompoundFactory class CompoundFactory
{ {
......
...@@ -45,8 +45,8 @@ struct Spacegroup ...@@ -45,8 +45,8 @@ struct Spacegroup
int nr; int nr;
}; };
extern CIFPP_DLL_IMPORT(const Spacegroup) kSpaceGroups[]; CIFPP_EXPORT extern const Spacegroup kSpaceGroups[];
extern CIFPP_DLL_IMPORT(const std::size_t) kNrOfSpaceGroups; CIFPP_EXPORT extern const std::size_t kNrOfSpaceGroups;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -128,8 +128,8 @@ struct SymopDataBlock ...@@ -128,8 +128,8 @@ struct SymopDataBlock
static_assert(sizeof(SymopDataBlock) == sizeof(uint64_t), "Size of SymopData is wrong"); static_assert(sizeof(SymopDataBlock) == sizeof(uint64_t), "Size of SymopData is wrong");
extern CIFPP_DLL_IMPORT(const SymopDataBlock) kSymopNrTable[]; CIFPP_EXPORT extern const SymopDataBlock kSymopNrTable[];
extern CIFPP_DLL_IMPORT(const std::size_t) kSymopNrTableSize; CIFPP_EXPORT extern const std::size_t kSymopNrTableSize;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
......
...@@ -24,10 +24,6 @@ ...@@ -24,10 +24,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if __has_include("Config.hpp")
#include "Config.hpp"
#endif
#include <fstream> #include <fstream>
#include <algorithm> #include <algorithm>
#include <mutex> #include <mutex>
......
...@@ -54,7 +54,7 @@ namespace fs = std::filesystem; ...@@ -54,7 +54,7 @@ namespace fs = std::filesystem;
namespace cif namespace cif
{ {
int VERBOSE = 0; CIFPP_EXPORT int VERBOSE = 0;
static const char* kEmptyResult = ""; static const char* kEmptyResult = "";
......
...@@ -24,10 +24,6 @@ ...@@ -24,10 +24,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if __has_include("Config.hpp")
#include "Config.hpp"
#endif
#include <atomic> #include <atomic>
#include <chrono> #include <chrono>
#include <cmath> #include <cmath>
...@@ -224,18 +220,18 @@ std::string cifIdForNumber(int number) ...@@ -224,18 +220,18 @@ std::string cifIdForNumber(int number)
if (number >= 26 * 26) if (number >= 26 * 26)
{ {
int v = number / (26 * 26); int v = number / (26 * 26);
result += 'A' - 1 + v; result += char('A' - 1 + v);
number %= (26 * 26); number %= (26 * 26);
} }
if (number >= 26) if (number >= 26)
{ {
int v = number / 26; int v = number / 26;
result += 'A' - 1 + v; result += char('A' - 1 + v);
number %= 26; number %= 26;
} }
result += 'A' + number; result += char('A' + number);
} }
assert(not result.empty()); assert(not result.empty());
...@@ -705,21 +701,21 @@ namespace ...@@ -705,21 +701,21 @@ namespace
uint64_t s = static_cast<uint64_t>(std::trunc(t.count())); uint64_t s = static_cast<uint64_t>(std::trunc(t.count()));
if (s > 24 * 60 * 60) if (s > 24 * 60 * 60)
{ {
uint32_t days = s / (24 * 60 * 60); auto days = s / (24 * 60 * 60);
os << days << "d "; os << days << "d ";
s %= 24 * 60 * 60; s %= 24 * 60 * 60;
} }
if (s > 60 * 60) if (s > 60 * 60)
{ {
uint32_t hours = s / (60 * 60); auto hours = s / (60 * 60);
os << hours << "h "; os << hours << "h ";
s %= 60 * 60; s %= 60 * 60;
} }
if (s > 60) if (s > 60)
{ {
uint32_t minutes = s / 60; auto minutes = s / 60;
os << minutes << "m "; os << minutes << "m ";
s %= 60; s %= 60;
} }
...@@ -793,8 +789,6 @@ void Progress::message(const std::string &inMessage) ...@@ -793,8 +789,6 @@ void Progress::message(const std::string &inMessage)
} // namespace cif } // namespace cif
#if USE_RSRC
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// //
// Try to find a named resource. Can be either a local file with this name, // Try to find a named resource. Can be either a local file with this name,
...@@ -1219,8 +1213,6 @@ class basic_istream : public std::basic_istream<CharT, Traits> ...@@ -1219,8 +1213,6 @@ class basic_istream : public std::basic_istream<CharT, Traits>
using istream = basic_istream<char, std::char_traits<char>>; using istream = basic_istream<char, std::char_traits<char>>;
} // namespace mrsrc } // namespace mrsrc
#endif
// -------------------------------------------------------------------- // --------------------------------------------------------------------
namespace cif namespace cif
...@@ -1248,18 +1240,21 @@ std::unique_ptr<std::istream> loadResource(std::filesystem::path name) ...@@ -1248,18 +1240,21 @@ std::unique_ptr<std::istream> loadResource(std::filesystem::path name)
result.reset(file.release()); result.reset(file.release());
} }
#if defined(CACHE_DIR) and defined(DATA_DIR) #if defined(CACHE_DIR)
if (not result and not fs::exists(p)) if (not result and not fs::exists(p))
{ {
for (const char *dir : {CACHE_DIR, DATA_DIR}) auto p2 = fs::path(CACHE_DIR) / p;
{ if (fs::exists(p2))
auto p2 = fs::path(dir) / p; swap(p, p2);
if (fs::exists(p2)) }
{ #endif
swap(p, p2);
break; #if defined(DATA_DIR)
} if (not result and not fs::exists(p))
} {
auto p2 = fs::path(DATA_DIR) / p;
if (fs::exists(p2))
swap(p, p2);
} }
#endif #endif
...@@ -1270,14 +1265,12 @@ std::unique_ptr<std::istream> loadResource(std::filesystem::path name) ...@@ -1270,14 +1265,12 @@ std::unique_ptr<std::istream> loadResource(std::filesystem::path name)
result.reset(file.release()); result.reset(file.release());
} }
#if USE_RSRC if (not result and gResourceData)
if (not result)
{ {
mrsrc::rsrc rsrc(name); mrsrc::rsrc rsrc(name);
if (rsrc) if (rsrc)
result.reset(new mrsrc::istream(rsrc)); result.reset(new mrsrc::istream(rsrc));
} }
#endif
return result; return result;
} }
......
...@@ -24,10 +24,6 @@ ...@@ -24,10 +24,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if __has_include("Config.hpp")
#include "Config.hpp"
#endif
#include <map> #include <map>
#include <mutex> #include <mutex>
#include <numeric> #include <numeric>
...@@ -230,7 +226,7 @@ bool Compound::atomsBonded(const std::string &atomId_1, const std::string &atomI ...@@ -230,7 +226,7 @@ bool Compound::atomsBonded(const std::string &atomId_1, const std::string &atomI
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// a factory class to generate compounds // a factory class to generate compounds
const std::map<std::string, char> kAAMap{ CIFPP_EXPORT const std::map<std::string, char> kAAMap{
{"ALA", 'A'}, {"ALA", 'A'},
{"ARG", 'R'}, {"ARG", 'R'},
{"ASN", 'N'}, {"ASN", 'N'},
...@@ -254,7 +250,7 @@ const std::map<std::string, char> kAAMap{ ...@@ -254,7 +250,7 @@ const std::map<std::string, char> kAAMap{
{"GLX", 'Z'}, {"GLX", 'Z'},
{"ASX", 'B'}}; {"ASX", 'B'}};
const std::map<std::string, char> kBaseMap{ CIFPP_EXPORT const std::map<std::string, char> kBaseMap{
{"A", 'A'}, {"A", 'A'},
{"C", 'C'}, {"C", 'C'},
{"G", 'G'}, {"G", 'G'},
......
...@@ -24,10 +24,6 @@ ...@@ -24,10 +24,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if __has_include("Config.hpp")
#include "Config.hpp"
#endif
#include <map> #include <map>
#include <set> #include <set>
#include <system_error> #include <system_error>
......
...@@ -24,9 +24,6 @@ ...@@ -24,9 +24,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if __has_include("Config.hpp")
#include "Config.hpp"
#endif
#include "cif++/Cif++.hpp" #include "cif++/Cif++.hpp"
#include <map> #include <map>
......
...@@ -26,10 +26,6 @@ ...@@ -26,10 +26,6 @@
// Calculate DSSP-like secondary structure information // Calculate DSSP-like secondary structure information
#if __has_include("Config.hpp")
#include "Config.hpp"
#endif
#include <numeric> #include <numeric>
#include <iomanip> #include <iomanip>
#include <thread> #include <thread>
......
...@@ -36,10 +36,6 @@ ...@@ -36,10 +36,6 @@
#include <boost/iostreams/filter/gzip.hpp> #include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filtering_stream.hpp> #include <boost/iostreams/filtering_stream.hpp>
#if __has_include("Config.hpp")
#include "Config.hpp"
#endif
#include "cif++/Cif2PDB.hpp" #include "cif++/Cif2PDB.hpp"
#include "cif++/CifParser.hpp" #include "cif++/CifParser.hpp"
#include "cif++/PDB2Cif.hpp" #include "cif++/PDB2Cif.hpp"
......
...@@ -24,10 +24,6 @@ ...@@ -24,10 +24,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if __has_include("Config.hpp")
#include "Config.hpp"
#endif
#include <atomic> #include <atomic>
#include <mutex> #include <mutex>
......
...@@ -24,10 +24,6 @@ ...@@ -24,10 +24,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if __has_include("Config.hpp")
#include "Config.hpp"
#endif
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include "cif++/TlsParser.hpp" #include "cif++/TlsParser.hpp"
......
#include "Config.hpp"
#include "../include/cif++/Cif++.hpp" #include "../include/cif++/Cif++.hpp"
#include "../include/cif++/PDB2Cif.hpp" #include "../include/cif++/PDB2Cif.hpp"
......
#if __has_include("../src/Config.hpp")
#include "../src/Config.hpp"
#endif
#include "../include/cif++/Cif++.hpp" #include "../include/cif++/Cif++.hpp"
#include "../include/cif++/PDB2Cif.hpp" #include "../include/cif++/PDB2Cif.hpp"
#include "../include/cif++/Structure.hpp" #include "../include/cif++/Structure.hpp"
......
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