From c3e4ce53cbcd5a1d2e2327a3e1a1f2760780ba87 Mon Sep 17 00:00:00 2001
From: Valerio Mariani <Valerio Mariani>
Date: Wed, 15 Aug 2012 11:31:42 +0200
Subject: [PATCH] Build config file for ArchLinux using the clang compiler

---
 build_configs/buildconfig_arch_clang        | 10 -----
 modules/base/src/CMakeLists.txt             |  2 +
 modules/base/src/boost_filesystem_helper.cc | 22 +++++++++++
 modules/base/src/boost_filesystem_helper.hh | 44 +++++++++++++++++++++
 modules/io/src/mol/entity_io_crd_handler.cc |  7 +---
 modules/io/src/mol/pdb_writer.cc            |  8 ++--
 modules/io/src/mol/sdf_writer.cc            |  7 +---
 modules/mol/alg/src/lddt.cc                 |  8 ++--
 tools/molck/main.cc                         | 14 ++-----
 9 files changed, 82 insertions(+), 40 deletions(-)
 delete mode 100644 build_configs/buildconfig_arch_clang
 create mode 100644 modules/base/src/boost_filesystem_helper.cc
 create mode 100644 modules/base/src/boost_filesystem_helper.hh

diff --git a/build_configs/buildconfig_arch_clang b/build_configs/buildconfig_arch_clang
deleted file mode 100644
index b77971c56..000000000
--- a/build_configs/buildconfig_arch_clang
+++ /dev/null
@@ -1,10 +0,0 @@
-set(PYTHON_BINARY "/usr/bin/python2"  CACHE PATH "")
-set(CMAKE_C_COMPILER "/usr/bin/clang" CACHE PATH "")
-set(CMAKE_CXX_COMPILER "/usr/bin/clang++" CACHE PATH "")
-set(CMAKE_AR "/usr/bin/llvm-ar" CACHE PATH "")
-set(CMAKE_LINKER "/usr/bin/llvm-ld" CACHE PATH "")
-set(CMAKE_NM "/usr/bin/llvm-inm" CACHE PATH "")
-set(CMAKE_OBJDUMP "/usr/bin/llvm-objdump" CACHE PATH "")
-set(CMAKE_RANLIB "/usr/bin/llvm-ranlib" CACHE PATH "")
-set(CMAKE_CXX_FLAGS_RELEASE "-Wno-array-bounds -pthread -O3 -DNDEBUG -Wno-parentheses -Wno-constant-logical-operand -fcolor-diagnostics" CACHE STRING "")
-set(CMAKE_CXX_FLAGS_DEBUG "-Wno-array-bounds -g -pthread -Wno-parentheses -Wno-constant-logical-operand -fcolor-diagnostics" CACHE STRING "")
diff --git a/modules/base/src/CMakeLists.txt b/modules/base/src/CMakeLists.txt
index 6bc47461f..e6691bc1d 100644
--- a/modules/base/src/CMakeLists.txt
+++ b/modules/base/src/CMakeLists.txt
@@ -8,6 +8,7 @@ string_ref.cc
 platform.cc
 message.cc
 test_utils/compare_files.cc
+boost_filesystem_helper.cc
 )
 
 set(OST_BASE_HEADERS
@@ -30,6 +31,7 @@ string_ref.hh
 pod_vector.hh
 fixed_string.hh
 tri_matrix.hh
+boost_filesystem_helper.hh
 )
 
 set(OST_EXPORT_HELPERS
diff --git a/modules/base/src/boost_filesystem_helper.cc b/modules/base/src/boost_filesystem_helper.cc
new file mode 100644
index 000000000..b235b0498
--- /dev/null
+++ b/modules/base/src/boost_filesystem_helper.cc
@@ -0,0 +1,22 @@
+//------------------------------------------------------------------------------
+// This file is part of the OpenStructure project <www.openstructure.org>
+//
+// Copyright (C) 2008-2011 by the OpenStructure authors
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License as published by the Free
+// Software Foundation; either version 3.0 of the License, or (at your option)
+// any later version.
+// This library is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+// details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+//------------------------------------------------------------------------------
+/*
+  Author: Valerio Mariani
+*/
+
diff --git a/modules/base/src/boost_filesystem_helper.hh b/modules/base/src/boost_filesystem_helper.hh
new file mode 100644
index 000000000..5418253fd
--- /dev/null
+++ b/modules/base/src/boost_filesystem_helper.hh
@@ -0,0 +1,44 @@
+//------------------------------------------------------------------------------
+// This file is part of the OpenStructure project <www.openstructure.org>
+//
+// Copyright (C) 2008-2011 by the OpenStructure authors
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License as published by the Free
+// Software Foundation; either version 3.0 of the License, or (at your option)
+// any later version.
+// This library is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+// details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+//------------------------------------------------------------------------------
+/*
+  Author: Valerio Mariani
+*/
+
+#ifndef OST_BOOST_FILESYSTEM_HELPER_HH
+#define OST_BOOST_FILESYSTEM_HELPER_HH
+
+#include <boost/filesystem/path.hpp>
+
+namespace {
+
+inline
+String BFPathToString(const boost::filesystem::path& path)
+{
+#if BOOST_FILESYSTEM_VERSION==3 || BOOST_VERSION<103400
+  return path.string();
+#else
+  return path.file_string();
+#endif
+}
+
+}
+
+
+
+#endif // OST_BOOST_FILESYSTEM_HELPER
diff --git a/modules/io/src/mol/entity_io_crd_handler.cc b/modules/io/src/mol/entity_io_crd_handler.cc
index 0f08c72e0..d27feab99 100644
--- a/modules/io/src/mol/entity_io_crd_handler.cc
+++ b/modules/io/src/mol/entity_io_crd_handler.cc
@@ -33,6 +33,7 @@
 #include <ost/conop/conop.hh>
 #include <ost/mol/xcs_editor.hh>
 #include <ost/profile.hh>
+#include <ost/boost_filesystem_helper.hh>
 
 #include <ost/io/io_exception.hh>
 #include <ost/io/swap_util.hh>
@@ -244,11 +245,7 @@ CRDWriter::CRDWriter(std::ostream& ostream, bool ext) :
 {}
 
 CRDWriter::CRDWriter(const boost::filesystem::path& filename, bool ext) :
-#if BOOST_FILESYSTEM_VERSION==3 || BOOST_VERSION<103400
-  outfile_(filename.string().c_str()),
-#else
-  outfile_(filename.file_string().c_str()),
-#endif
+  outfile_(BFPathToString(filename).c_str()),
   outstream_(outfile_), ext_(ext), atom_count_(0), res_count_(0)
 {}
 
diff --git a/modules/io/src/mol/pdb_writer.cc b/modules/io/src/mol/pdb_writer.cc
index 28c18cd36..3df6a4917 100644
--- a/modules/io/src/mol/pdb_writer.cc
+++ b/modules/io/src/mol/pdb_writer.cc
@@ -28,6 +28,8 @@
 #include <boost/filesystem/convenience.hpp>
 #include <boost/algorithm/string.hpp>
 
+#include <ost/base.hh>
+#include <ost/boost_filesystem_helper.hh>
 #include <ost/io/io_exception.hh>
 #include <ost/mol/atom_handle.hh>
 #include <ost/mol/residue_handle.hh>
@@ -349,11 +351,7 @@ PDBWriter::PDBWriter(std::ostream& stream, const IOProfile& profile):
 
 PDBWriter::PDBWriter(const boost::filesystem::path& filename, 
                      const IOProfile& profile):
-#if BOOST_FILESYSTEM_VERSION==3  || BOOST_VERSION<103400
-  outfile_(filename.string().c_str()), outstream_(outfile_), 
-#else
-  outfile_(filename.file_string().c_str()), outstream_(outfile_), 
-#endif  
+  outfile_(BFPathToString(filename).c_str()), outstream_(outfile_),
   mol_count_(0), line_(80), multi_model_(false), 
   charmm_style_(profile.dialect=="CHARMM"), is_pqr_(false),
   profile_(profile), filename_("")
diff --git a/modules/io/src/mol/sdf_writer.cc b/modules/io/src/mol/sdf_writer.cc
index 973224e48..45bc1867a 100644
--- a/modules/io/src/mol/sdf_writer.cc
+++ b/modules/io/src/mol/sdf_writer.cc
@@ -22,6 +22,7 @@
 
 #include "sdf_writer.hh"
 
+#include <ost/boost_filesystem_helper.hh>
 #include <ost/mol/atom_view.hh>
 #include <ost/mol/residue_view.hh>
 #include <ost/mol/chain_view.hh>
@@ -140,11 +141,7 @@ SDFWriter::SDFWriter(const String& filename)
 }
 
 SDFWriter::SDFWriter(const boost::filesystem::path& filename): 
-#if BOOST_FILESYSTEM_VERSION==3 || BOOST_VERSION<103400
-  outfile_(filename.string().c_str()), 
-#else
-  outfile_(filename.file_string().c_str()), 
-#endif
+  outfile_(BFPathToString(filename).c_str()),
   ostr_(outfile_), counter_(0), atom_indices_() {}
 
 void SDFWriter::Write(const mol::EntityView& ent) {
diff --git a/modules/mol/alg/src/lddt.cc b/modules/mol/alg/src/lddt.cc
index fdd70d953..8ef174b67 100644
--- a/modules/mol/alg/src/lddt.cc
+++ b/modules/mol/alg/src/lddt.cc
@@ -23,6 +23,8 @@
 #include <boost/program_options.hpp>
 #include <boost/filesystem/fstream.hpp>
 #include <boost/filesystem/convenience.hpp>
+#include <ost/base.hh>
+#include <ost/boost_filesystem_helper.hh>
 #include <ost/mol/alg/local_dist_diff_test.hh>
 #include <ost/mol/alg/filter_clashes.hh>
 #include <ost/io/mol/pdb_reader.hh>
@@ -284,11 +286,7 @@ int main (int argc, char **argv)
 
     boost::filesystem::path pathstring(files[i]);
 
-    #if BOOST_FILESYSTEM_VERSION==3 || BOOST_VERSION<103400
-    String filestring=pathstring.string();
-    #else
-    String filestring=pathstring.file_string();
-    #endif      
+    String filestring=BFPathToString(pathstring);
     std::cout << "File: " << files[i] << std::endl; 
     std::pair<int,int> cov = compute_coverage(v,glob_dist_list);
     std::cout << "Coverage: " << (float(cov.first)/float(cov.second)) << " (" << cov.first << " out of " << cov.second << " residues)" << std::endl;
diff --git a/tools/molck/main.cc b/tools/molck/main.cc
index 07baf9496..dab69250c 100644
--- a/tools/molck/main.cc
+++ b/tools/molck/main.cc
@@ -2,6 +2,8 @@
 #include <boost/program_options.hpp>
 #include <boost/filesystem/path.hpp>
 #include <boost/filesystem/convenience.hpp>
+#include <ost/base.hh>
+#include <ost/boost_filesystem_helper.hh>
 #include <ost/platform.hh>
 #include <ost/conop/model_check.hh>
 #include <ost/conop/conop.hh>
@@ -74,11 +76,7 @@ CompoundLibPtr load_compound_lib(const String& custom_path)
     share_path/="openstructure";
     share_path/="compounds.chemlib";
 
-    #if BOOST_FILESYSTEM_VERSION==3 || BOOST_VERSION<103400
-    String share_path_string=share_path.string();
-    #else
-    String share_path_string=share_path.file_string();
-    #endif       
+    String share_path_string=BFPathToString(share_path);
       
     if (fs::exists(share_path_string)) {
       return CompoundLib::Load(share_path_string);
@@ -375,11 +373,7 @@ int main(int argc, char *argv[])
       fs::path input_filename = input_file_path.stem();
  
 
-      #if BOOST_FILESYSTEM_VERSION==3 || BOOST_VERSION<103400
-      String input_filename_string=input_filename.string();
-      #else
-      String input_filename_string=input_filename.file_string();
-      #endif       
+      String input_filename_string=BFPathToString(input_filename);
 
       size_t replstart =output_blueprint_string.find('%');	
 
-- 
GitLab