add: cmake config include guard (#2592)
This commit is contained in:
parent
00c7509454
commit
6f3a633f2e
@ -11,67 +11,69 @@
|
|||||||
# raylib_LDFLAGS - The linker flags needed with raylib
|
# raylib_LDFLAGS - The linker flags needed with raylib
|
||||||
# raylib_DEFINITIONS - Compiler switches required for using raylib
|
# raylib_DEFINITIONS - Compiler switches required for using raylib
|
||||||
|
|
||||||
set(XPREFIX PC_RAYLIB)
|
if (NOT TARGET raylib)
|
||||||
|
set(XPREFIX PC_RAYLIB)
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
pkg_check_modules(${XPREFIX} QUIET raylib)
|
pkg_check_modules(${XPREFIX} QUIET raylib)
|
||||||
|
|
||||||
if (raylib_USE_STATIC_LIBS)
|
if (raylib_USE_STATIC_LIBS)
|
||||||
set(XPREFIX ${XPREFIX}_STATIC)
|
set(XPREFIX ${XPREFIX}_STATIC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
|
set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
|
||||||
|
|
||||||
find_path(raylib_INCLUDE_DIR
|
find_path(raylib_INCLUDE_DIR
|
||||||
NAMES raylib.h
|
NAMES raylib.h
|
||||||
HINTS ${${XPREFIX}_INCLUDE_DIRS}
|
HINTS ${${XPREFIX}_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
set(RAYLIB_NAMES raylib)
|
set(RAYLIB_NAMES raylib)
|
||||||
|
|
||||||
if (raylib_USE_STATIC_LIBS)
|
if (raylib_USE_STATIC_LIBS)
|
||||||
set(RAYLIB_NAMES libraylib.a raylib.lib ${RAYLIB_NAMES})
|
set(RAYLIB_NAMES libraylib.a raylib.lib ${RAYLIB_NAMES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_library(raylib_LIBRARY
|
find_library(raylib_LIBRARY
|
||||||
NAMES ${RAYLIB_NAMES}
|
NAMES ${RAYLIB_NAMES}
|
||||||
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
set(raylib_LIBRARIES ${raylib_LIBRARY})
|
set(raylib_LIBRARIES ${raylib_LIBRARY})
|
||||||
set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
|
set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
|
||||||
set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
|
set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
|
||||||
set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR})
|
set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR})
|
||||||
set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS})
|
set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS})
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(raylib DEFAULT_MSG
|
find_package_handle_standard_args(raylib DEFAULT_MSG
|
||||||
raylib_LIBRARY
|
raylib_LIBRARY
|
||||||
raylib_INCLUDE_DIR
|
raylib_INCLUDE_DIR
|
||||||
)
|
)
|
||||||
|
|
||||||
mark_as_advanced(raylib_LIBRARY raylib_INCLUDE_DIR)
|
mark_as_advanced(raylib_LIBRARY raylib_INCLUDE_DIR)
|
||||||
|
|
||||||
if (raylib_USE_STATIC_LIBS)
|
if (raylib_USE_STATIC_LIBS)
|
||||||
add_library(raylib STATIC IMPORTED GLOBAL)
|
add_library(raylib STATIC IMPORTED GLOBAL)
|
||||||
else()
|
else()
|
||||||
add_library(raylib SHARED IMPORTED GLOBAL)
|
add_library(raylib SHARED IMPORTED GLOBAL)
|
||||||
endif()
|
endif()
|
||||||
string (REPLACE ";" " " raylib_LDFLAGS "${raylib_LDFLAGS}")
|
string (REPLACE ";" " " raylib_LDFLAGS "${raylib_LDFLAGS}")
|
||||||
|
|
||||||
set_target_properties(raylib
|
set_target_properties(raylib
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
IMPORTED_LOCATION "${raylib_LIBRARIES}"
|
IMPORTED_LOCATION "${raylib_LIBRARIES}"
|
||||||
IMPORTED_IMPLIB "${raylib_LIBRARIES}"
|
IMPORTED_IMPLIB "${raylib_LIBRARIES}"
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}"
|
INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}"
|
||||||
INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}"
|
INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}"
|
||||||
INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}"
|
INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (raylib_VERBOSE)
|
if (raylib_VERBOSE)
|
||||||
message(STATUS "raylib_FOUND: ${raylib_FOUND}")
|
message(STATUS "raylib_FOUND: ${raylib_FOUND}")
|
||||||
message(STATUS "raylib_INCLUDE_DIRS: ${raylib_INCLUDE_DIRS}")
|
message(STATUS "raylib_INCLUDE_DIRS: ${raylib_INCLUDE_DIRS}")
|
||||||
message(STATUS "raylib_LIBRARIES: ${raylib_LIBRARIES}")
|
message(STATUS "raylib_LIBRARIES: ${raylib_LIBRARIES}")
|
||||||
message(STATUS "raylib_LDFLAGS: ${raylib_LDFLAGS}")
|
message(STATUS "raylib_LDFLAGS: ${raylib_LDFLAGS}")
|
||||||
message(STATUS "raylib_DEFINITIONS: ${raylib_DEFINITIONS}")
|
message(STATUS "raylib_DEFINITIONS: ${raylib_DEFINITIONS}")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user