mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-22 19:45:40 +00:00
cmake: allow #include "SDL2/SDL.h.h" when using SDL2 as subproject
This commit is contained in:
parent
48e71ae87b
commit
72606d97e6
|
@ -2988,7 +2988,7 @@ string(TOLOWER "${CMAKE_BUILD_TYPE}" lower_build_type)
|
|||
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/include-config-${lower_build_type}")
|
||||
# 3. generate SDL_config in an build_type-dependent folder (which should be first in the include search path)
|
||||
file(GENERATE
|
||||
OUTPUT "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL_config.h"
|
||||
OUTPUT "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2/SDL_config.h"
|
||||
INPUT "${SDL2_BINARY_DIR}/SDL_config.h.intermediate")
|
||||
|
||||
# Prepare the flags and remove duplicates
|
||||
|
@ -3039,9 +3039,9 @@ else()
|
|||
endif()
|
||||
|
||||
configure_file("${SDL2_SOURCE_DIR}/include/SDL_revision.h.cmake"
|
||||
"${SDL2_BINARY_DIR}/include/SDL_revision.h")
|
||||
"${SDL2_BINARY_DIR}/include/SDL2/SDL_revision.h")
|
||||
|
||||
# Copy all non-generated headers to "${SDL2_BINARY_DIR}/include"
|
||||
# Copy all non-generated headers to "${SDL2_BINARY_DIR}/include/SDL2"
|
||||
# This is done to avoid the inclusion of a pre-generated SDL_config.h
|
||||
file(GLOB SDL2_INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h)
|
||||
set(SDL2_COPIED_INCLUDE_FILES)
|
||||
|
@ -3050,7 +3050,7 @@ foreach(_hdr IN LISTS SDL2_INCLUDE_FILES)
|
|||
list(REMOVE_ITEM SDL2_INCLUDE_FILES "${_hdr}")
|
||||
else()
|
||||
get_filename_component(_name "${_hdr}" NAME)
|
||||
set(_bin_hdr "${SDL2_BINARY_DIR}/include/${_name}")
|
||||
set(_bin_hdr "${SDL2_BINARY_DIR}/include/SDL2/${_name}")
|
||||
list(APPEND SDL2_COPIED_INCLUDE_FILES "${_bin_hdr}")
|
||||
add_custom_command(OUTPUT "${_bin_hdr}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_hdr}" "${_bin_hdr}"
|
||||
|
@ -3284,7 +3284,11 @@ if(NOT WINDOWS_STORE AND NOT SDL2_DISABLE_SDL2MAIN)
|
|||
add_dependencies(SDL2main sdl_headers_copy)
|
||||
# alias target for in-tree builds
|
||||
add_library(SDL2::SDL2main ALIAS SDL2main)
|
||||
target_include_directories(SDL2main BEFORE PRIVATE "${SDL2_BINARY_DIR}/include" PRIVATE "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>")
|
||||
target_include_directories(SDL2main BEFORE
|
||||
PRIVATE "${SDL2_BINARY_DIR}/include"
|
||||
PRIVATE "${SDL2_BINARY_DIR}/include/SDL2"
|
||||
PRIVATE "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2"
|
||||
)
|
||||
target_include_directories(SDL2main PUBLIC "$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>" $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>)
|
||||
if (WIN32)
|
||||
target_link_libraries(SDL2main PRIVATE shell32)
|
||||
|
@ -3375,7 +3379,8 @@ if(SDL_SHARED)
|
|||
target_link_libraries(SDL2 PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${EXTRA_LDFLAGS_BUILD} ${CMAKE_DEPENDS})
|
||||
target_include_directories(SDL2 PUBLIC
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>>"
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include/SDL2>"
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>"
|
||||
)
|
||||
|
@ -3410,7 +3415,8 @@ if(SDL_STATIC)
|
|||
target_link_libraries(SDL2-static PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${CMAKE_DEPENDS})
|
||||
target_include_directories(SDL2-static PUBLIC
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>>"
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include/SDL2>"
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>"
|
||||
)
|
||||
|
@ -3441,7 +3447,8 @@ if(SDL_TEST)
|
|||
EXPORT_NAME SDL2test)
|
||||
target_include_directories(SDL2_test PUBLIC
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>>"
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include/SDL2>"
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>")
|
||||
target_link_libraries(SDL2_test PRIVATE ${EXTRA_TEST_LIBS})
|
||||
|
@ -3559,8 +3566,8 @@ if(NOT SDL2_DISABLE_INSTALL)
|
|||
install(
|
||||
FILES
|
||||
${SDL2_INCLUDE_FILES}
|
||||
"${SDL2_BINARY_DIR}/include/SDL_revision.h"
|
||||
"${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL_config.h"
|
||||
"${SDL2_BINARY_DIR}/include/SDL2/SDL_revision.h"
|
||||
"${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2/SDL_config.h"
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SDL2)
|
||||
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)
|
||||
|
|
Loading…
Reference in a new issue