Bläddra i källkod

Revert "[build][cmake] Improve cmake config file generation (#4541)"

This reverts commit c53dd8a931.
pull/4556/head
Ray 2 veckor sedan
förälder
incheckning
abb3c8e9f7
7 ändrade filer med 110 tillägg och 43 borttagningar
  1. +2
    -8
      cmake/GlfwImport.cmake
  2. +3
    -1
      cmake/InstallConfigurations.cmake
  3. +4
    -0
      cmake/LibraryConfigurations.cmake
  4. +0
    -23
      cmake/SetupCmakeConfig.cmake
  5. +21
    -0
      cmake/raylib-config-version.cmake
  6. +79
    -1
      cmake/raylib-config.cmake
  7. +1
    -10
      src/CMakeLists.txt

+ 2
- 8
cmake/GlfwImport.cmake Visa fil

@ -12,18 +12,12 @@ endif()
# Also adding only on desktop (web also uses glfw but it is more limited and is added using an emcc linker flag)
if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MATCHES "Desktop")
MESSAGE(STATUS "Using raylib's GLFW")
set(INTERNAL_GLFW ON CACHE INTERNAL "" FORCE)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
set(GLFW_LIBRARY_TYPE "OBJECT" CACHE STRING "" FORCE)
if (NOT BUILD_SHARED_LIBS)
message(STATUS "Enabling install of GLFW static libs because raylib will be built statically")
set(GLFW_INSTALL ON CACHE BOOL "" FORCE)
endif ()
add_subdirectory(external/glfw)
@ -31,7 +25,7 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT
if (BUILD_SHARED_LIBS)
set_property(TARGET glfw PROPERTY C_VISIBILITY_PRESET hidden)
endif()
list(APPEND raylib_sources $<TARGET_OBJECTS:glfw>)
include_directories(BEFORE SYSTEM external/glfw/include)
elseif("${PLATFORM}" STREQUAL "DRM")

+ 3
- 1
cmake/InstallConfigurations.cmake Visa fil

@ -18,8 +18,10 @@ endif ()
join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
configure_file(../raylib.pc.in raylib.pc @ONLY)
configure_file(../cmake/raylib-config-version.cmake raylib-config-version.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
include(SetupCmakeConfig)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib")
install(FILES ${PROJECT_SOURCE_DIR}/../cmake/raylib-config.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib")
# populates raylib_{FOUND, INCLUDE_DIRS, LIBRARIES, LDFLAGS, DEFINITIONS}
include(PopulateConfigVariablesLocally)

+ 4
- 0
cmake/LibraryConfigurations.cmake Visa fil

@ -125,3 +125,7 @@ if (NOT GRAPHICS)
endif ()
set(LIBS_PRIVATE ${LIBS_PRIVATE} ${OPENAL_LIBRARY})
if (${PLATFORM} MATCHES "Desktop")
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
endif ()

+ 0
- 23
cmake/SetupCmakeConfig.cmake Visa fil

@ -1,23 +0,0 @@
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
# Setup install of exported targets
install(EXPORT raylib-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/raylib
)
# Macro to write config
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake"
VERSION ${raylib_VERSION}
COMPATIBILITY SameMajorVersion
)
# Setup install of version config
install(
FILES
"../cmake/raylib-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake"
DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/raylib
)

+ 21
- 0
cmake/raylib-config-version.cmake Visa fil

@ -0,0 +1,21 @@
set(PACKAGE_VERSION "@PROJECT_VERSION@")
if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
if(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
set(PACKAGE_VERSION_COMPATIBLE TRUE)
else(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
return()
endif()
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@")
math(EXPR installedBits "8 * 8")
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()

+ 79
- 1
cmake/raylib-config.cmake Visa fil

@ -1 +1,79 @@
include("${CMAKE_CURRENT_LIST_DIR}/raylib-targets.cmake")
# - Try to find raylib
# Options:
# raylib_USE_STATIC_LIBS - OFF by default
# raylib_VERBOSE - OFF by default
# Once done, this defines a raylib target that can be passed to
# target_link_libraries as well as following variables:
#
# raylib_FOUND - System has raylib installed
# raylib_INCLUDE_DIRS - The include directories for the raylib header(s)
# raylib_LIBRARIES - The libraries needed to use raylib
# raylib_LDFLAGS - The linker flags needed with raylib
# raylib_DEFINITIONS - Compiler switches required for using raylib
if (NOT TARGET 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()
set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
find_path(raylib_INCLUDE_DIR
NAMES raylib.h
HINTS ${${XPREFIX}_INCLUDE_DIRS}
)
set(RAYLIB_NAMES raylib)
if (raylib_USE_STATIC_LIBS)
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})
set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR})
set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(raylib DEFAULT_MSG
raylib_LIBRARY
raylib_INCLUDE_DIR
)
mark_as_advanced(raylib_LIBRARY raylib_INCLUDE_DIR)
if (raylib_USE_STATIC_LIBS)
add_library(raylib STATIC IMPORTED GLOBAL)
else()
add_library(raylib SHARED IMPORTED GLOBAL)
endif()
string (REPLACE ";" " " raylib_LDFLAGS "${raylib_LDFLAGS}")
set_target_properties(raylib
PROPERTIES
IMPORTED_LOCATION "${raylib_LIBRARIES}"
IMPORTED_IMPLIB "${raylib_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}"
INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}"
)
if (raylib_VERBOSE)
message(STATUS "raylib_FOUND: ${raylib_FOUND}")
message(STATUS "raylib_INCLUDE_DIRS: ${raylib_INCLUDE_DIRS}")
message(STATUS "raylib_LIBRARIES: ${raylib_LIBRARIES}")
message(STATUS "raylib_LDFLAGS: ${raylib_LDFLAGS}")
message(STATUS "raylib_DEFINITIONS: ${raylib_DEFINITIONS}")
endif()
endif()

+ 1
- 10
src/CMakeLists.txt Visa fil

@ -90,16 +90,7 @@ if (BUILD_SHARED_LIBS)
set_property(TARGET raylib PROPERTY C_VISIBILITY_PRESET hidden)
endif ()
# If building as a static lib *AND* using internal GLFW we
# need to set it up as a PRIVATE import so cmake doesn't complain
# it isn't declared on an install rule
if (INTERNAL_GLFW AND BUILD_SHARED_LIBS)
target_link_libraries(raylib PRIVATE glfw)
endif()
target_link_libraries(raylib PUBLIC "${LIBS_PRIVATE}")
target_link_libraries(raylib "${LIBS_PRIVATE}")
# Sets some compile time definitions for the pre-processor
# If CUSTOMIZE_BUILD option is on you will not use config.h by default

Laddar…
Avbryt
Spara