|
| 1 | +# Copyright (c) 2023, RPTU Kaiserslautern-Landau |
| 2 | +# All rights reserved. |
| 3 | +# |
| 4 | +# Redistribution and use in source and binary forms, with or without |
| 5 | +# modification, are permitted provided that the following conditions are |
| 6 | +# met: |
| 7 | +# |
| 8 | +# 1. Redistributions of source code must retain the above copyright notice, |
| 9 | +# this list of conditions and the following disclaimer. |
| 10 | +# |
| 11 | +# 2. Redistributions in binary form must reproduce the above copyright |
| 12 | +# notice, this list of conditions and the following disclaimer in the |
| 13 | +# documentation and/or other materials provided with the distribution. |
| 14 | +# |
| 15 | +# 3. Neither the name of the copyright holder nor the names of its |
| 16 | +# contributors may be used to endorse or promote products derived from |
| 17 | +# this software without specific prior written permission. |
| 18 | +# |
| 19 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 21 | +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 22 | +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER |
| 23 | +# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 24 | +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 25 | +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 26 | +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 27 | +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 28 | +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 29 | +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | +# |
| 31 | +# Authors: |
| 32 | +# Thomas Psota |
| 33 | +# Lukas Steiner |
| 34 | + |
| 35 | +############################################### |
| 36 | +### DRAMSys ### |
| 37 | +############################################### |
| 38 | +cmake_minimum_required(VERSION 3.24.0) |
| 39 | + |
| 40 | +set(PROJECT_NAME "DRAMSys") |
| 41 | + |
| 42 | +project(${PROJECT_NAME} VERSION "5.0") |
| 43 | + |
| 44 | +### Compiler settings ### |
| 45 | +set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ Standard") |
| 46 | +message(STATUS "CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}") |
| 47 | +if(NOT CMAKE_BUILD_TYPE) |
| 48 | + set(CMAKE_BUILD_TYPE Release) |
| 49 | +endif() |
| 50 | +message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") |
| 51 | + |
| 52 | +### CMake settings ### |
| 53 | +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") |
| 54 | +include(build_source_group) |
| 55 | +include(diagnostics_print) |
| 56 | +include(enable_extensions) |
| 57 | +include(FetchContent) |
| 58 | + |
| 59 | +if(ENABLE_COVERAGE) |
| 60 | + include(coverage) |
| 61 | +endif() |
| 62 | + |
| 63 | +if(POLICY CMP0135) |
| 64 | + cmake_policy(SET CMP0135 NEW) |
| 65 | +endif() |
| 66 | + |
| 67 | +# Check if standalone build or being included as submodule |
| 68 | +get_directory_property(DRAMSYS_IS_SUBMODULE PARENT_DIRECTORY) |
| 69 | + |
| 70 | +set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 71 | +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 72 | + |
| 73 | +### Project settings ### |
| 74 | +message(STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}") |
| 75 | +message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}") |
| 76 | +message(STATUS "" ) |
| 77 | + |
| 78 | +if(NOT DRAMSYS_IS_SUBMODULE) |
| 79 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| 80 | +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 81 | +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 82 | +endif() |
| 83 | + |
| 84 | +### DRAMSys directories ### |
| 85 | +set(DRAMSYS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") |
| 86 | +set(DRAMSYS_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib") |
| 87 | +set(DRAMSYS_TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests") |
| 88 | +set(DRAMSYS_RESOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/configs") |
| 89 | +set(DRAMSYS_EXTENSIONS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extensions") |
| 90 | + |
| 91 | +### Build options ### |
| 92 | +option(DRAMSYS_BUILD_TESTS "Build DRAMSys unit tests" OFF) |
| 93 | +option(DRAMSYS_VERBOSE_CMAKE_OUTPUT "Show detailed CMake output" OFF) |
| 94 | +option(DRAMSYS_BUILD_CLI "Build DRAMSys Command Line Tool" ON) |
| 95 | +option(DRAMSYS_WITH_DRAMPOWER "Build with DRAMPower support enabled." OFF) |
| 96 | +option(DRAMSYS_ENABLE_EXTENSIONS "Enable proprietary DRAMSys extensions." OFF) |
| 97 | + |
| 98 | +############################################### |
| 99 | +### Library Settings ### |
| 100 | +############################################### |
| 101 | + |
| 102 | +### Detect OS threading library ### |
| 103 | +find_package(Threads) |
| 104 | + |
| 105 | +### nlohmann_json ### |
| 106 | +add_subdirectory(${DRAMSYS_LIBRARY_DIR}/nlohmann_json) |
| 107 | + |
| 108 | +### sqlite3 ### |
| 109 | +add_subdirectory(${DRAMSYS_LIBRARY_DIR}/sqlite3) |
| 110 | + |
| 111 | +### GoogleTest ### |
| 112 | +if(DRAMSYS_BUILD_TESTS) |
| 113 | + FetchContent_Declare( |
| 114 | + googletest |
| 115 | + GIT_REPOSITORY https://github.com/google/googletest |
| 116 | + GIT_TAG release-1.12.1) |
| 117 | + |
| 118 | + # For Windows: Prevent overriding the parent project's compiler/linker settings |
| 119 | + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) |
| 120 | + FetchContent_MakeAvailable(googletest) |
| 121 | + set_target_properties(gmock PROPERTIES FOLDER lib/gtest) |
| 122 | + set_target_properties(gmock_main PROPERTIES FOLDER lib/gtest) |
| 123 | + set_target_properties(gtest PROPERTIES FOLDER lib/gtest) |
| 124 | + set_target_properties(gtest_main PROPERTIES FOLDER lib/gtest) |
| 125 | +endif() |
| 126 | + |
| 127 | +### SystemC ### |
| 128 | +list(APPEND CMAKE_PREFIX_PATH $ENV{SYSTEMC_HOME} /opt/systemc/) |
| 129 | +FetchContent_Declare( |
| 130 | + systemc |
| 131 | + GIT_REPOSITORY https://github.com/accellera-official/systemc.git |
| 132 | + GIT_TAG 2.3.4 |
| 133 | + FIND_PACKAGE_ARGS NAMES SystemCLanguage) |
| 134 | + |
| 135 | +set(DISABLE_COPYRIGHT_MESSAGE True) |
| 136 | +FetchContent_MakeAvailable(systemc) |
| 137 | + |
| 138 | +### DRAMPower ### |
| 139 | +if (DRAMSYS_WITH_DRAMPOWER) |
| 140 | + FetchContent_Declare( |
| 141 | + DRAMPower |
| 142 | + GIT_REPOSITORY https://github.com/tukl-msd/DRAMPower |
| 143 | + GIT_TAG 9e64a1b) |
| 144 | + |
| 145 | + FetchContent_MakeAvailable(DRAMPower) |
| 146 | + set_target_properties(DRAMPower PROPERTIES FOLDER lib) |
| 147 | +endif () |
| 148 | + |
| 149 | +############################################### |
| 150 | +### Source Directory ### |
| 151 | +############################################### |
| 152 | + |
| 153 | +add_subdirectory(src/util) |
| 154 | +add_subdirectory(src/configuration) |
| 155 | +add_subdirectory(src/libdramsys) |
| 156 | + |
| 157 | +if(DRAMSYS_BUILD_CLI) |
| 158 | + add_subdirectory(src/simulator) |
| 159 | +endif() |
| 160 | + |
| 161 | +if(DRAMSYS_ENABLE_EXTENSIONS) |
| 162 | + dramsys_enable_extensions() |
| 163 | +endif() |
| 164 | + |
| 165 | +############################################### |
| 166 | +### Test Directory ### |
| 167 | +############################################### |
| 168 | + |
| 169 | +if(DRAMSYS_BUILD_TESTS) |
| 170 | + include(GoogleTest) |
| 171 | + include(CTest) |
| 172 | + add_subdirectory(tests) |
| 173 | +endif() |
0 commit comments