Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@ if(Thesis_REQUIRE_MPI)
endif()
set(Thesis_ENABLE_MPI ${MPI_FOUND})

find_package(Git)
if(GIT_FOUND AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.git)
execute_process(
COMMAND ${GIT_EXECUTABLE} log --pretty=format:%H -n 1
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE Thesis_COMMIT_HASH)
else()
set(Thesis_COMMIT_HASH "Not a git repository")
endif()
message(STATUS "Thesis version: ${PROJECT_VERSION}")
message(STATUS "Thesis commit: ${Thesis_COMMIT_HASH}")

add_subdirectory(src)
add_subdirectory(bin)
5 changes: 0 additions & 5 deletions bin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
add_executable(3DThesis Main.cpp)
target_link_libraries(3DThesis LINK_PUBLIC Thesis)

if(Thesis_ENABLE_MPI)
target_link_libraries(3DThesis LINK_PUBLIC MPI::MPI_CXX)
endif()

Comment thread
gknapp1 marked this conversation as resolved.
install(TARGETS 3DThesis DESTINATION ${CMAKE_INSTALL_BINDIR})
8 changes: 5 additions & 3 deletions bin/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ inline void run(int argc, char * argv[])

// Output simulation time
auto stop_sim = high_resolution_clock::now();
if (sim.print)
std::cout << "Execution time (s): " << (duration<double, std::milli>(stop_sim - start_sim).count())/1000.0 << "\n\n";//(stop_sim - start_sim) / double(CLOCKS_PER_SEC) << "\n\n";

if (sim.print) {
std::cout << "Version: " << Out::version() << "\n";
std::cout << "Commit hash: " << Out::commitHash() << "\n";
std::cout << "Execution time (s): " << (duration<double, std::milli>(stop_sim - start_sim).count())/1000.0 << "\n\n";//(stop_sim - start_sim) / double(CLOCKS_PER_SEC) << "\n\n";
}
// Start output clock
auto start_out = high_resolution_clock::now();

Expand Down
6 changes: 5 additions & 1 deletion src/Out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "Out.h"
#include "DataStructs.h"
#include "ThesisConfig.h"

void Out::Progress(const Simdat& sim, const int itert) {
static int prog_print_last = 0;
Expand All @@ -44,4 +45,7 @@ void Out::Point_Progress(const Simdat& sim, const int p) {
std::cout << "% of Points: " << 10 * prog_print_last << "%" << "\n";
}
return;
}
}

std::string Out::version() { return Thesis_VERSION; }
std::string Out::commitHash() { return Thesis_COMMIT_HASH; }
Comment thread
gknapp1 marked this conversation as resolved.
7 changes: 6 additions & 1 deletion src/Out.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <cstdint>
#include <deque>
#include <string>

using std::vector;
using std::string;
Comment thread
gknapp1 marked this conversation as resolved.
Expand All @@ -24,4 +25,8 @@ namespace Out {
void Progress(const Simdat&, const int);
// Writes the progress of points to the console
void Point_Progress(const Simdat&, const int);
}

// Functions for printing the version.
std::string version();
std::string commitHash();
}
4 changes: 4 additions & 0 deletions src/ThesisConfig.h.cmakein
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#pragma once

#define Thesis_VERSION "@PROJECT_VERSION@"

#define Thesis_COMMIT_HASH "@Thesis_COMMIT_HASH@"

#cmakedefine Thesis_ENABLE_MPI