Skip to content

Commit 114f71d

Browse files
committed
Install SDL2/SDL3 cmake config only when installing the ports
The cmake config files are logically part of the ports so install them then the port is installed This doesn't fix #19780 completely, since trying to build an SDL2 or SDL3 cmake project will still require some kind of install step, but it makes it less confusing.
1 parent 75b0b54 commit 114f71d

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

tools/ports/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ def install_header_dir(src_dir, target=None):
162162
logger.debug(f'installing headers: {dest}')
163163
shutil.copytree(src_dir, dest, dirs_exist_ok=True, copy_function=maybe_copy)
164164

165+
@staticmethod
166+
def install_file(filename, target):
167+
sysroot = cache.get_sysroot_dir()
168+
target_dir = os.path.join(sysroot, os.path.dirname(target))
169+
os.makedirs(target_dir, exist_ok=True)
170+
maybe_copy(filename, os.path.join(sysroot, target))
171+
165172
@staticmethod
166173
def install_headers(src_dir, pattern='*.h', target=None):
167174
logger.debug('install_headers')

tools/ports/sdl2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def create(final):
3636
source_include_path = os.path.join(src_dir, 'include')
3737
ports.install_headers(source_include_path, target='SDL2')
3838

39+
rootdir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
40+
ports.install_file(os.path.join(rootdir, 'system/lib/cmake/SDL2/sdl2-config.cmake'), 'lib/cmake/SDL2/sdl2-config.cmake')
41+
3942
# build
4043
srcs = '''SDL.c SDL_assert.c SDL_dataqueue.c SDL_error.c SDL_guid.c SDL_hints.c SDL_list.c SDL_log.c
4144
SDL_utils.c atomic/SDL_atomic.c atomic/SDL_spinlock.c audio/SDL_audio.c audio/SDL_audiocvt.c

tools/ports/sdl3.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def create(final):
4444
source_include_path = os.path.join(root_dir, 'include', 'SDL3')
4545
ports.install_headers(source_include_path, target='SDL3')
4646

47+
rootdir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
48+
ports.install_file(os.path.join(rootdir, 'system/lib/cmake/SDL3/sdl3-config.cmake'), 'lib/cmake/SDL3/sdl3-config.cmake')
49+
4750
glob_patterns = [
4851
# Generic sources (from SDL3's CMakeLists.txt)
4952
'*.c',

tools/system_libs.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,10 +2493,6 @@ def install_system_headers(stamp):
24932493
bin_dest = cache.get_sysroot_dir('bin')
24942494
copytree_exist_ok(bin_src, bin_dest)
24952495

2496-
cmake_src = utils.path_from_root('system/lib/cmake')
2497-
cmake_dest = cache.get_sysroot_dir('lib/cmake')
2498-
copytree_exist_ok(cmake_src, cmake_dest)
2499-
25002496
# Create a version header based on the emscripten-version.txt
25012497
version_file = cache.get_include_dir('emscripten/version.h')
25022498
utils.write_file(version_file, textwrap.dedent(f'''\

0 commit comments

Comments
 (0)