From e720bbf4ead889a607a11513c4a64cc3ccb3e691 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 10 Oct 2018 22:46:12 +0200 Subject: Improve build instructions --- CMakeLists.txt | 43 ++++++++++++++++++++++++++++++------------- shell.nix | 4 ++-- src/fluid_buffer.cc | 4 +++- src/fluid_buffer.h | 3 ++- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5cbd03..29ad827 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,31 +1,48 @@ cmake_minimum_required(VERSION 3.10) -project(boltzbub) +project(boltzbub LANGUAGES CXX) -set( - CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -std=c++1z -W -Wall -Wextra -Winline -pedantic" +add_library( + boltzbub + src/lbm.cc + src/fluid_buffer.cc + src/boundary_conditions.cc ) -include_directories( - src/ +target_compile_features( + boltzbub + PUBLIC + cxx_std_17 ) -set( - BASE - src/lbm.cc - src/fluid_buffer.cc - src/boundary_conditions.cc +target_include_directories( + boltzbub + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +target_link_libraries( + boltzbub + PRIVATE + stdc++fs ) add_executable( cavity2d cavity2d.cc - ${BASE} +) + +target_link_libraries( + cavity2d + boltzbub ) add_executable( cavity2d_with_obstacles cavity2d_with_obstacles.cc - ${BASE} src/box_obstacle.cc ) + +target_link_libraries( + cavity2d_with_obstacles + boltzbub +) diff --git a/shell.nix b/shell.nix index 087712a..dabe8b5 100644 --- a/shell.nix +++ b/shell.nix @@ -1,12 +1,12 @@ with import {}; -stdenv.mkDerivation rec { +stdenvNoCC.mkDerivation rec { name = "boltzbub-env"; env = buildEnv { name = name; paths = buildInputs; }; buildInputs = [ git - gcc + gcc8 cmake ]; diff --git a/src/fluid_buffer.cc b/src/fluid_buffer.cc index 1f40d2f..9291fdd 100644 --- a/src/fluid_buffer.cc +++ b/src/fluid_buffer.cc @@ -32,7 +32,9 @@ Velocity& FluidBuffer::velocity(Vector pos) { return velocity(pos[0], pos[1]); } -void FluidBuffer::writeAsVTK(const std::string& path) { +void FluidBuffer::writeAsVTK(const std::filesystem::path& path) { + std::filesystem::create_directories(path.parent_path()); + std::ofstream fout; fout.open(path.c_str()); diff --git a/src/fluid_buffer.h b/src/fluid_buffer.h index 72518bb..b0e0936 100644 --- a/src/fluid_buffer.h +++ b/src/fluid_buffer.h @@ -2,6 +2,7 @@ #include #include +#include #include "vector.h" @@ -28,5 +29,5 @@ public: Velocity& velocity(std::size_t x, std::size_t y); Velocity& velocity(Vector pos); - void writeAsVTK(const std::string& path); + void writeAsVTK(const std::filesystem::path& path); }; -- cgit v1.2.3