#include "TSystem.h" #include "TString.h" namespace SetACLiC { // This adds --enable-cxx11 so that C++11 warnings // are not shown when building libs and exes. static const TString stdform = "-std=c++11"; Bool_t SetCXX11(Bool_t set = kTRUE) { //const TString compiler = gSystem->GetBuildCompiler(); const TString compiler = "clang++-mp-3.2"; TString options_sl, options_exe; options_sl = TString(gSystem->GetMakeSharedLib()); options_exe = TString(gSystem->GetMakeExe()); Bool_t already_cxx11_sl = options_sl.Contains(stdform); Bool_t already_cxx11_exe = options_exe.Contains(stdform); const Int_t len = stdform.Length(); if(set) { if(!already_cxx11_sl) { //options_sl = options_sl.ReplaceAll(" -c ", " "+stdform+" -c "); options_sl = options_sl.ReplaceAll(compiler, compiler+" "+stdform); gSystem->SetMakeSharedLib(options_sl.Data()); } if(!already_cxx11_exe) { //options_exe = options_exe.ReplaceAll(" -c ", " "+stdform+" -c "); options_exe = options_exe.ReplaceAll(compiler, compiler+" "+stdform); gSystem->SetMakeExe(options_exe.Data()); } } else // This means unset { while(options_sl.Contains(stdform)) { Int_t where = options_sl.Index(stdform); options_sl = options_sl.Remove(where,len); gSystem->SetMakeSharedLib(options_sl.Data()); } while(options_exe.Contains(stdform)) { Int_t where = options_exe.Index(stdform); options_exe = options_exe.Remove(where,len); gSystem->SetMakeExe(options_exe.Data()); } } return options_sl.Contains(stdform) && options_exe.Contains(stdform); } Bool_t SetVerbose(Bool_t set = kTRUE) { const TString compiler = gSystem->GetBuildCompiler(); const TString verbose_switch = " -v "; const Int_t vs_length = verbose_switch.Length(); TString options_sl = gSystem->GetMakeSharedLib(); TString options_exe = gSystem->GetMakeExe(); Bool_t verbose_sl = options_sl.Contains(verbose_switch); Bool_t verbose_exe = options_exe.Contains(verbose_switch); if(set) { if(!verbose_sl) { options_sl = options_sl.ReplaceAll(compiler, compiler+verbose_switch); gSystem->SetMakeSharedLib(options_sl.Data()); } if(!verbose_exe) { options_exe = options_exe.ReplaceAll(compiler, compiler+verbose_switch); gSystem->SetMakeExe(options_exe.Data()); } } else // If unset { while(options_sl.Contains(verbose_switch)) { Int_t where = options_sl.Index(verbose_switch); options_sl = options_sl.Remove(where,vs_length); gSystem->SetMakeSharedLib(options_sl.Data()); } while(options_exe.Contains(verbose_switch)) { Int_t where = options_exe.Index(verbose_switch); options_exe = options_exe.Remove(where,vs_length); gSystem->SetMakeExe(options_exe.Data()); } } return options_sl.Contains(verbose_switch) && options_exe.Contains(verbose_switch); } } // Namespace SetACLiC