소스 검색

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
No known key found for this signature in database 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})

불러오는 중...
취소
저장