Skip to content

Commit 6f27c42

Browse files
committed
Use pkg-config instead of cmake to link zstd library correctly on macOS
1 parent ccd411a commit 6f27c42

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ project(libCacheSim)
33
set(DESCRIPTION "a high performance cache simulation library")
44
set(PROJECT_WEB "http://cachesim.com")
55

6+
find_package(PkgConfig REQUIRED)
7+
68
set(${PROJECT_NAME}_VERSION_MAJOR 0)
79
set(${PROJECT_NAME}_VERSION_MINOR 1)
810
set(${PROJECT_NAME}_VERSION_PATCH 0)
@@ -39,7 +41,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
3941
add_definitions(-DOS_DARWIN)
4042
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "/opt/homebrew/include/")
4143
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/opt/homebrew/")
42-
4344
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
4445
add_definitions(-DOS_LINUX)
4546
else()
@@ -142,7 +143,7 @@ set(LIBS ${LIBS} ${ARGP_LIBRARY})
142143

143144
if(OPT_SUPPORT_ZSTD_TRACE)
144145
add_compile_definitions(SUPPORT_ZSTD_TRACE=1)
145-
find_package(ZSTD)
146+
pkg_check_modules(ZSTD REQUIRED libzstd)
146147

147148
# https://stackoverflow.com/questions/61377055/cannot-find-gflags-gflags-h-while-building-library-osx/61379123#61379123
148149
include_directories(${ZSTD_INCLUDE_DIR})
@@ -151,6 +152,7 @@ if(OPT_SUPPORT_ZSTD_TRACE)
151152
message(FATAL_ERROR "zstd not found")
152153
endif()
153154

155+
link_directories(${ZSTD_LIBRARY_DIRS})
154156
link_libraries(${ZSTD_LIBRARIES})
155157
message(STATUS "ZSTD_INCLUDE_DIR ${ZSTD_INCLUDE_DIR}, ZSTD_LIBRARIES ${ZSTD_LIBRARIES}")
156158
else()

0 commit comments

Comments
 (0)