From 1152743f0bd369b4e1d3ff822e9d309fc7dac3e2 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Fri, 3 Jan 2020 14:27:15 +0000 Subject: [PATCH] Fix detection of system physfs (#1312) check_symbol_exists checks if compilation succeeds with the specified symbol and header, but also fails if linking is not successful. To detect the system library correctly, ask it to link against ${PHYSFS_LIBRARY} (which is set by find_package). --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36bf4a67ac..3b8959a0fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,10 @@ include_directories(SYSTEM ${VORBIS_INCLUDE_DIR}) include(CheckSymbolExists) find_package(PhysFS) -check_symbol_exists("PHYSFS_getPrefDir" "${PHYSFS_INCLUDE_DIR}/physfs.h" HAVE_PHYSFS_GETPREFDIR) +if(PHYSFS_LIBRARY) + set(CMAKE_REQUIRED_LIBRARIES ${PHYSFS_LIBRARY}) + check_symbol_exists("PHYSFS_getPrefDir" "${PHYSFS_INCLUDE_DIR}/physfs.h" HAVE_PHYSFS_GETPREFDIR) +endif() if(HAVE_PHYSFS_GETPREFDIR) set(USE_SYSTEM_PHYSFS ON CACHE BOOL "Use preinstalled physfs (must support getPrefDir)") else(HAVE_PHYSFS_GETPREFDIR)