diff --git a/.gitignore b/.gitignore index c749ab0d..c49fffa2 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,5 @@ release # IDEs / Editors .vscode/ +.cache/ +compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index eaa40bfc..a9d7377d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ -cmake_minimum_required(VERSION 3.0.0) -project(dramsim3) +cmake_minimum_required(VERSION 3.10) +project(dramsim3 CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(default_build_type "Release") if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) @@ -14,9 +17,14 @@ endif() add_library(inih INTERFACE) target_include_directories(inih INTERFACE ext/headers) -add_library(format INTERFACE) -target_include_directories(format INTERFACE ext/fmt/include) -target_compile_definitions(format INTERFACE FMT_HEADER_ONLY=1) +find_package(fmt) +if(NOT fmt_FOUND) + message(STATUS "External fmt package not found, using internal one") + add_library(fmt INTERFACE) + target_include_directories(fmt INTERFACE ext/fmt/include) + target_compile_definitions(fmt INTERFACE FMT_HEADER_ONLY=1) + add_library(fmt::fmt-header-only ALIAS fmt) +endif(NOT fmt_FOUND) # argparsing library, only used in main program not the library add_library(args INTERFACE) @@ -26,7 +34,7 @@ add_library(json INTERFACE) target_include_directories(json INTERFACE ext/headers) # Main DRAMSim Lib -add_library(dramsim3 SHARED +add_library(dramsim3 src/bankstate.cc src/channel_state.cc src/command_queue.cc @@ -78,11 +86,8 @@ endif (ADDR_TRACE) target_include_directories(dramsim3 INTERFACE src) target_compile_options(dramsim3 PRIVATE -Wall) -target_link_libraries(dramsim3 PRIVATE inih format) +target_link_libraries(dramsim3 PRIVATE inih fmt::fmt-header-only) set_target_properties(dramsim3 PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR} - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO ) @@ -91,21 +96,18 @@ add_executable(dramsim3main src/main.cc src/cpu.cc) target_link_libraries(dramsim3main PRIVATE dramsim3 args) target_compile_options(dramsim3main PRIVATE) set_target_properties(dramsim3main PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO ) # Unit testing -add_library(Catch INTERFACE) -target_include_directories(Catch INTERFACE ext/headers) +find_package(Catch2 3 REQUIRED) add_executable(dramsim3test EXCLUDE_FROM_ALL tests/test_config.cc tests/test_dramsys.cc tests/test_hmcsys.cc # IDK somehow this can literally crush your computer ) -target_link_libraries(dramsim3test Catch dramsim3) +target_link_libraries(dramsim3test Catch2::Catch2WithMain dramsim3) target_include_directories(dramsim3test PRIVATE src/) # We have to use this custome command because there's a bug in cmake diff --git a/src/command_queue.cc b/src/command_queue.cc index f121d28f..21045d46 100644 --- a/src/command_queue.cc +++ b/src/command_queue.cc @@ -115,7 +115,7 @@ bool CommandQueue::WillAcceptCommand(int rank, int bankgroup, int bank) const { } bool CommandQueue::QueueEmpty() const { - for (const auto q : queues_) { + for (const auto &q : queues_) { if (!q.empty()) { return false; } diff --git a/src/common.cc b/src/common.cc index 5be3303c..6420db45 100644 --- a/src/common.cc +++ b/src/common.cc @@ -1,5 +1,5 @@ #include "common.h" -#include "fmt/format.h" +#include #include #include #include diff --git a/src/simple_stats.cc b/src/simple_stats.cc index 4c2c6f14..0f8e9ee2 100644 --- a/src/simple_stats.cc +++ b/src/simple_stats.cc @@ -1,6 +1,6 @@ #include -#include "fmt/format.h" +#include #include "simple_stats.h" namespace dramsim3 { @@ -476,4 +476,4 @@ void SimpleStats::UpdateFinalStats() { return; } -} // namespace dramsim3 \ No newline at end of file +} // namespace dramsim3 diff --git a/tests/test_config.cc b/tests/test_config.cc index 2fe26bfc..d2d1e6e1 100644 --- a/tests/test_config.cc +++ b/tests/test_config.cc @@ -1,5 +1,5 @@ #define CATCH_CONFIG_MAIN -#include "catch.hpp" +#include #include "configuration.h" TEST_CASE("Address Mapping", "[config]") { diff --git a/tests/test_dramsys.cc b/tests/test_dramsys.cc index 2007e5dc..7cde6b77 100644 --- a/tests/test_dramsys.cc +++ b/tests/test_dramsys.cc @@ -1,4 +1,4 @@ -#include "catch.hpp" +#include #include "configuration.h" #include "dram_system.h" diff --git a/tests/test_hmcsys.cc b/tests/test_hmcsys.cc index 09a741d9..05f7fafb 100644 --- a/tests/test_hmcsys.cc +++ b/tests/test_hmcsys.cc @@ -1,4 +1,4 @@ -#include "catch.hpp" +#include #include "configuration.h" #include "memory_system.h"