1
0
Fork 0
mirror of https://github.com/gwm17/catima.git synced 2024-11-22 18:28:51 -05:00

Removed single use external dependence on fmt library in convert.h and modified cmake config to only build single static library by default

This commit is contained in:
Gordon McCann 2022-06-08 10:29:19 -04:00
parent 56c624f24b
commit 2b990bd1e3
2 changed files with 9 additions and 27 deletions

View File

@ -6,7 +6,7 @@ option(BUILD_SHARED_LIBS "build as shared library" OFF)
option(PYTHON_MODULE "compile the Catima python module(requires numpy and cython installed)" OFF) option(PYTHON_MODULE "compile the Catima python module(requires numpy and cython installed)" OFF)
option(TESTS "build tests" OFF) option(TESTS "build tests" OFF)
option(EXAMPLES "build examples" OFF) option(EXAMPLES "build examples" OFF)
option(APPS "build catima applications" ON) option(APPS "build catima applications" OFF)
option(GLOBAL "build with global, sources are required" OFF) option(GLOBAL "build with global, sources are required" OFF)
option(REACTIONS "enable/disable nuclear reaction rate" ON) option(REACTIONS "enable/disable nuclear reaction rate" ON)
option(STORE_SPLINES "store splines, if disables splines are always recreated" ON) option(STORE_SPLINES "store splines, if disables splines are always recreated" ON)
@ -32,6 +32,7 @@ MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
################################ ################################
######### compiler flags ########### ######### compiler flags ###########
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
MESSAGE(STATUS "install prefix: " ${CMAKE_INSTALL_PREFIX}) MESSAGE(STATUS "install prefix: " ${CMAKE_INSTALL_PREFIX})
@ -49,29 +50,6 @@ if(GSL_INTEGRATION OR GSL_INTERPOLATION)
list(APPEND EXTRA_LIBS ${GSL_LIBRARIES} ) list(APPEND EXTRA_LIBS ${GSL_LIBRARIES} )
endif() endif()
#find_package(nurex QUIET)
#if(nurex_FOUND)
#message(STATUS "nurex library found")
#set(NUREX ON)
#list(APPEND EXTRA_LIBS nurex::nurex)
#endif(nurex_FOUND)
find_package(fmt QUIET)
function(check_fmt)
if(NOT fmt_FOUND)
message("fmt library not found, trying to dowload")
include(FetchContent)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 8.1.1
)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(FMT_INSTALL ON)
FetchContent_MakeAvailable(fmt)
endif(NOT fmt_FOUND)
endfunction(check_fmt)
configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/build_config.in" configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/build_config.in"
"${CMAKE_CURRENT_BINARY_DIR}/include/catima/build_config.h") "${CMAKE_CURRENT_BINARY_DIR}/include/catima/build_config.h")

View File

@ -12,6 +12,8 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Modifed by GWM to remove unecessary fmt dependance (only place used in entire library)
*/ */
#ifndef CONVERT_H #ifndef CONVERT_H
@ -22,7 +24,6 @@
#include <fstream> #include <fstream>
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include "fmt/format.h"
using namespace catima; using namespace catima;
@ -52,7 +53,9 @@ bool save_mocadi(const char* filename, const Projectile p, const Layers &layers,
fw.open(filename, std::ios::out); fw.open(filename, std::ios::out);
if (!fw.is_open()) { return false;} if (!fw.is_open()) { return false;}
fw<<"epax 2\natima-1.0\noption listmode root\n"; fw<<"epax 2\natima-1.0\noption listmode root\n";
std::string beam = fmt::format("BEAM\n100000\n{}, 0, {}, {}\n2\n{}, {}, 0, 0, 0\n2\n{}, {}, 0, 0, 0\n1\n0, 0, 0, 0, 0\n",p.T,p.A,p.Z,psx.sigma_x,1000*psx.sigma_a, psy.sigma_x,1000*psy.sigma_a); std::string beam = "BEAM\n100000\n" + std::to_string(p.T) + ", 0, " + std::to_string(p.A) + ", " + std::to_string(p.Z) + "\n2\n" +
std::to_string(psx.sigma_x) + ", " + std::to_string(1000*psx.sigma_a) + ", 0, 0, 0\n2\n" +
std::to_string(psy.sigma_x) + ", " + std::to_string(1000*psy.sigma_a) + ", 0, 0, 0\n1\n0, 0, 0, 0, 0";
fw<<beam; fw<<beam;
int c = 0; int c = 0;
for (auto& m: layers.get_materials()){ for (auto& m: layers.get_materials()){
@ -65,7 +68,8 @@ bool save_mocadi(const char* filename, const Projectile p, const Layers &layers,
else{ else{
z = materialdb_id(m); z = materialdb_id(m);
} }
std::string mstr = fmt::format("*******\nMATTER\n{}, {}, {}\n2,{}\n0.\n0.,0.,0.\n1,1,0\n0,0,0,0\n",a,z,m.density()*1000,m.thickness_cm()); std::string mstr = "*******\nMATTER\n" + std::to_string(a) + ", " + std::to_string(z) + ", " + std::to_string(m.density()*1000.0) +
"\n" + "2,"+std::to_string(m.thickness_cm()) + "\n0.\n0.,0.,0.\n1,1,0\n0,0,0,0\n";
fw<<mstr; fw<<mstr;
c++; c++;
} }