mirror of
https://github.com/libsdl-org/SDL.git
synced 2024-11-23 10:53:27 +08:00
Allow in-tree build
This commit is contained in:
parent
6647345be0
commit
f543faf837
18
.gitignore
vendored
18
.gitignore
vendored
@ -29,15 +29,27 @@ __pycache__
|
|||||||
*.rej
|
*.rej
|
||||||
|
|
||||||
# for CMake
|
# for CMake
|
||||||
|
.cmake
|
||||||
CMakeFiles/
|
CMakeFiles/
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
cmake_uninstall.cmake
|
cmake_uninstall.cmake
|
||||||
SDL3ConfigVersion.cmake
|
install_manifest.txt
|
||||||
.ninja_*
|
*Targets.cmake
|
||||||
*.ninja
|
*Config.cmake
|
||||||
|
*ConfigVersion.cmake
|
||||||
|
CTestTestfile.cmake
|
||||||
|
Testing
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
.cache/
|
.cache/
|
||||||
|
/include-config-*
|
||||||
|
/include-revision
|
||||||
|
/Makefile
|
||||||
|
.ninja_*
|
||||||
|
*.ninja
|
||||||
|
*.pc
|
||||||
|
test/*.test
|
||||||
|
wayland-generated-protocols
|
||||||
|
|
||||||
# for CLion
|
# for CLion
|
||||||
.idea
|
.idea
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
|
||||||
message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the SDL source code and run \"cmake -S ${CMAKE_SOURCE_DIR} -B .\" from there")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# See docs/release_checklist.md
|
# See docs/release_checklist.md
|
||||||
project(SDL3 LANGUAGES C VERSION "3.1.5")
|
project(SDL3 LANGUAGES C VERSION "3.1.5")
|
||||||
|
|
||||||
@ -456,7 +452,7 @@ sdl_compile_definitions(PRIVATE "USING_GENERATED_CONFIG_H")
|
|||||||
sdl_include_directories(
|
sdl_include_directories(
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${SDL3_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/build_config"
|
"${SDL3_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/build_config"
|
||||||
"${SDL3_BINARY_DIR}/include"
|
"${SDL3_BINARY_DIR}/include-revision"
|
||||||
"${SDL3_SOURCE_DIR}/include"
|
"${SDL3_SOURCE_DIR}/include"
|
||||||
)
|
)
|
||||||
# Note: The clang toolset for Visual Studio does not support the '-idirafter' option.
|
# Note: The clang toolset for Visual Studio does not support the '-idirafter' option.
|
||||||
@ -3050,11 +3046,11 @@ endif()
|
|||||||
# config variables may contain generator expression, so we need to generate SDL_build_config.h in 2 steps:
|
# config variables may contain generator expression, so we need to generate SDL_build_config.h in 2 steps:
|
||||||
# 1. replace all `#cmakedefine`'s and `@abc@`
|
# 1. replace all `#cmakedefine`'s and `@abc@`
|
||||||
configure_file("${SDL3_SOURCE_DIR}/include/build_config/SDL_build_config.h.cmake"
|
configure_file("${SDL3_SOURCE_DIR}/include/build_config/SDL_build_config.h.cmake"
|
||||||
"${SDL3_BINARY_DIR}/SDL_build_config.h.intermediate")
|
"${SDL3_BINARY_DIR}/CMakeFiles/SDL_build_config.h.intermediate")
|
||||||
# 2. generate SDL_build_config.h in an build_type-dependent folder (which should be first in the include search path)
|
# 2. generate SDL_build_config.h in an build_type-dependent folder (which should be first in the include search path)
|
||||||
file(GENERATE
|
file(GENERATE
|
||||||
OUTPUT "${SDL3_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/build_config/SDL_build_config.h"
|
OUTPUT "${SDL3_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/build_config/SDL_build_config.h"
|
||||||
INPUT "${SDL3_BINARY_DIR}/SDL_build_config.h.intermediate"
|
INPUT "${SDL3_BINARY_DIR}/CMakeFiles/SDL_build_config.h.intermediate"
|
||||||
)
|
)
|
||||||
|
|
||||||
file(GLOB SDL3_INCLUDE_FILES "${SDL3_SOURCE_DIR}/include/SDL3/*.h")
|
file(GLOB SDL3_INCLUDE_FILES "${SDL3_SOURCE_DIR}/include/SDL3/*.h")
|
||||||
@ -3078,9 +3074,9 @@ if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/REVISION.txt")
|
|||||||
set(SDL_REVISION "SDL3-${SDL_REVISION_CENTER}")
|
set(SDL_REVISION "SDL3-${SDL_REVISION_CENTER}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${SDL3_BINARY_DIR}/include/SDL3")
|
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${SDL3_BINARY_DIR}/include-revision/SDL3")
|
||||||
configure_file(include/build_config/SDL_revision.h.cmake include/SDL3/SDL_revision.h @ONLY)
|
configure_file(include/build_config/SDL_revision.h.cmake include-revision/SDL3/SDL_revision.h @ONLY)
|
||||||
list(APPEND SDL3_INCLUDE_FILES "${SDL3_BINARY_DIR}/include/SDL3/SDL_revision.h")
|
list(APPEND SDL3_INCLUDE_FILES "${SDL3_BINARY_DIR}/include-revision/SDL3/SDL_revision.h")
|
||||||
|
|
||||||
if(SDL_FRAMEWORK)
|
if(SDL_FRAMEWORK)
|
||||||
# With Apple frameworks, headers in the PUBLIC_HEADER property also need to be added as sources
|
# With Apple frameworks, headers in the PUBLIC_HEADER property also need to be added as sources
|
||||||
@ -3277,7 +3273,7 @@ add_library(SDL3::Headers ALIAS SDL3_Headers)
|
|||||||
set_property(TARGET SDL3_Headers PROPERTY EXPORT_NAME "Headers")
|
set_property(TARGET SDL3_Headers PROPERTY EXPORT_NAME "Headers")
|
||||||
target_include_directories(SDL3_Headers
|
target_include_directories(SDL3_Headers
|
||||||
INTERFACE
|
INTERFACE
|
||||||
"$<BUILD_INTERFACE:${SDL3_BINARY_DIR}/include>"
|
"$<BUILD_INTERFACE:${SDL3_BINARY_DIR}/include-revision>"
|
||||||
"$<BUILD_INTERFACE:${SDL3_SOURCE_DIR}/include>"
|
"$<BUILD_INTERFACE:${SDL3_SOURCE_DIR}/include>"
|
||||||
)
|
)
|
||||||
if(SDL_FRAMEWORK)
|
if(SDL_FRAMEWORK)
|
||||||
|
@ -299,8 +299,8 @@ function(check_linker_supports_version_file VAR)
|
|||||||
set(LINKER_SUPPORTS_VERSION_SCRIPT FALSE)
|
set(LINKER_SUPPORTS_VERSION_SCRIPT FALSE)
|
||||||
else()
|
else()
|
||||||
cmake_push_check_state(RESET)
|
cmake_push_check_state(RESET)
|
||||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.sym" "n_0 {\n global:\n func;\n local: *;\n};\n")
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/dummy.sym" "n_0 {\n global:\n func;\n local: *;\n};\n")
|
||||||
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/dummy.sym")
|
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/dummy.sym")
|
||||||
check_c_source_compiles("int func(void) {return 0;} int main(int argc,char*argv[]){(void)argc;(void)argv;return func();}" LINKER_SUPPORTS_VERSION_SCRIPT FAIL_REGEX "(unsupported|syntax error|unrecognized option)")
|
check_c_source_compiles("int func(void) {return 0;} int main(int argc,char*argv[]){(void)argc;(void)argv;return func();}" LINKER_SUPPORTS_VERSION_SCRIPT FAIL_REGEX "(unsupported|syntax error|unrecognized option)")
|
||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user