|
1 | | -cmake_minimum_required (VERSION 3.2) |
2 | | -project (cacheSimulatorMultiSize) |
3 | | -set(CMAKE_CXX_STANDARD 17) |
4 | | -set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 1 | +cmake_minimum_required (VERSION 3.10) |
| 2 | +project (cacheSimulatorConcurrent) |
5 | 3 |
|
| 4 | +set(CMAKE_CXX_STANDARD 17) |
| 5 | +set(CMAKE_CXX_STANDARD_REQUIRED On) |
| 6 | +set(CMAKE_CXX_EXTENSIONS Off) |
6 | 7 |
|
7 | | -find_library(libCacheSim libCacheSim) |
8 | | -find_path(libCacheSimInclude libCacheSim) |
9 | | -include_directories(${libCacheSimInclude}) |
10 | | -message(STATUS "libCacheSim found? ${libCacheSim}, ${libCacheSimInclude}") |
| 8 | +# Find required packages |
| 9 | +find_package(PkgConfig REQUIRED) |
| 10 | +pkg_check_modules(GLIB REQUIRED glib-2.0) |
11 | 11 |
|
| 12 | +# Find ZSTD library |
| 13 | +find_library(ZSTD_LIBRARY |
| 14 | + NAMES zstd libzstd |
| 15 | + PATHS /usr/local/lib /usr/lib /opt/homebrew/lib |
| 16 | + DOC "ZSTD library" |
| 17 | +) |
12 | 18 |
|
13 | | -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") |
14 | | -find_package(GLib "2.40" REQUIRED) |
15 | | -include_directories(${GLib_INCLUDE_DIRS}) |
16 | | -message(STATUS "glib found? ${GLib_FOUND}, lib = ${GLib_LIBRARY}, header = ${GLib_INCLUDE_DIRS}") |
| 19 | +find_path(ZSTD_INCLUDE_DIR |
| 20 | + NAMES zstd.h |
| 21 | + PATHS /usr/local/include /usr/include /opt/homebrew/include |
| 22 | + DOC "ZSTD include directory" |
| 23 | +) |
17 | 24 |
|
18 | | -find_package(ZSTD) |
19 | | -# https://stackoverflow.com/questions/61377055/cannot-find-gflags-gflags-h-while-building-library-osx/61379123#61379123 |
20 | 25 | include_directories(${ZSTD_INCLUDE_DIR}) |
21 | | -if ("${ZSTD_LIBRARIES}" STREQUAL "") |
22 | | - message(FATAL_ERROR "zstd not found") |
| 26 | +message(STATUS "ZSTD library: ${ZSTD_LIBRARY}") |
| 27 | +message(STATUS "ZSTD include: ${ZSTD_INCLUDE_DIR}") |
| 28 | + |
| 29 | +# Find libCacheSim |
| 30 | +find_library(LIBCACHESIM_LIBRARY |
| 31 | + NAMES CacheSim libCacheSim |
| 32 | + PATHS /usr/local/lib /usr/lib |
| 33 | + DOC "libCacheSim unified library" |
| 34 | +) |
| 35 | + |
| 36 | +find_path(LIBCACHESIM_INCLUDE_DIR |
| 37 | + NAMES libCacheSim.h |
| 38 | + PATHS /usr/local/include /usr/include |
| 39 | + DOC "libCacheSim include directory" |
| 40 | +) |
| 41 | + |
| 42 | +message(STATUS "libCacheSim library: ${LIBCACHESIM_LIBRARY}") |
| 43 | +message(STATUS "libCacheSim include: ${LIBCACHESIM_INCLUDE_DIR}") |
| 44 | + |
| 45 | +if(NOT LIBCACHESIM_LIBRARY OR NOT LIBCACHESIM_INCLUDE_DIR) |
| 46 | + message(FATAL_ERROR "libCacheSim not found! Please install libCacheSim first.") |
23 | 47 | endif() |
24 | 48 |
|
25 | | -add_executable(cacheSimulatorMultiSize main.cpp) |
26 | | -target_link_libraries(cacheSimulatorMultiSize libCacheSim m ${GLib_LIBRARY} ${ZSTD_LIBRARIES}) |
| 49 | +add_executable(cacheSimulatorConcurrent main.cpp) |
| 50 | + |
| 51 | +target_include_directories(cacheSimulatorConcurrent PRIVATE |
| 52 | + ${ZSTD_INCLUDE_DIR} |
| 53 | + ${LIBCACHESIM_INCLUDE_DIR} |
| 54 | +) |
| 55 | + |
| 56 | +# Add GLib compile and link flags |
| 57 | +target_compile_options(cacheSimulatorConcurrent PRIVATE ${GLIB_CFLAGS_OTHER}) |
| 58 | +target_include_directories(cacheSimulatorConcurrent PRIVATE ${GLIB_INCLUDE_DIRS}) |
| 59 | +target_link_directories(cacheSimulatorConcurrent PRIVATE ${GLIB_LIBRARY_DIRS}) |
| 60 | + |
27 | 61 |
|
| 62 | +target_link_libraries(cacheSimulatorConcurrent |
| 63 | + ${LIBCACHESIM_LIBRARY} |
| 64 | + m |
| 65 | + ${GLIB_LIBRARIES} |
| 66 | + ${ZSTD_LIBRARY} |
| 67 | +) |
0 commit comments