浏览代码

CMake: fix dependency build with -Draylib_USE_STATIC_LIBS=ON

Fixes #899, which made apparent three issues with how static libraries
are handled in raylib-config.cmake:

- XPREFIX is set before pkg_check_modules, which causes a duplicate
  STATIC in variables, e.g. PC_RAYLIB_STATIC_STATIC_.*
- raylib_static is searched for, but no library exists with that name
- raylib_LDFLAGS isn't populated properly

This commit fixes these.
pull/927/head
Ahmad Fatoum 5 年前
父节点
当前提交
47137b1489
找不到此签名对应的密钥 GPG 密钥 ID: C3EAC3DE9321D59B
共有 1 个文件被更改,包括 13 次插入12 次删除
  1. +13
    -12
      cmake/raylib-config.cmake

+ 13
- 12
cmake/raylib-config.cmake 查看文件

@ -12,12 +12,14 @@
# raylib_DEFINITIONS - Compiler switches required for using raylib
set(XPREFIX PC_RAYLIB)
find_package(PkgConfig QUIET)
pkg_check_modules(${XPREFIX} QUIET raylib)
if (raylib_USE_STATIC_LIBS)
set(XPREFIX ${XPREFIX}_STATIC)
endif()
find_package(PkgConfig QUIET)
pkg_check_modules(${XPREFIX} QUIET raylib)
set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
find_path(raylib_INCLUDE_DIR
@ -25,17 +27,16 @@ find_path(raylib_INCLUDE_DIR
HINTS ${${XPREFIX}_INCLUDE_DIRS}
)
set(RAYLIB_NAMES raylib)
if (raylib_USE_STATIC_LIBS)
find_library(raylib_LIBRARY
NAMES raylib_static
HINTS ${${XPREFIX}_LIBRARY_DIRS}
)
else ()
find_library(raylib_LIBRARY
NAMES raylib
HINTS ${${XPREFIX}_LIBRARY_DIRS}
)
endif ()
set(RAYLIB_NAMES libraylib.a raylib.lib ${RAYLIB_NAMES})
endif()
find_library(raylib_LIBRARY
NAMES ${RAYLIB_NAMES}
HINTS ${${XPREFIX}_LIBRARY_DIRS}
)
set(raylib_LIBRARIES ${raylib_LIBRARY})
set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})

正在加载...
取消
保存