Skip to content

Commit 99c6e41

Browse files
authored
Install SDL2/SDL3 cmake config only when installing the ports (#24306)
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 ffac9a6 commit 99c6e41

File tree

7 files changed

+17
-4
lines changed

7 files changed

+17
-4
lines changed

test/test_other.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,8 @@ def test_cmake_install(self):
10551055
@requires_network
10561056
@crossplatform
10571057
def test_cmake_find_modules(self):
1058+
# This test expects SDL2 and SDL3 to be installed
1059+
self.run_process([EMBUILDER, 'build', 'sdl2', 'sdl3'])
10581060
output = self.run_process([EMCMAKE, 'cmake', test_file('cmake/find_modules')], stdout=PIPE).stdout
10591061
self.assertContained(' test: OpenGL::GL IMPORTED_LIBNAME: GL', output)
10601062
self.assertContained(' test: OpenGL::GL INTERFACE_INCLUDE_DIRECTORIES: .+/cache/sysroot/include', output, regex=True)

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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def create(final):
3636
source_include_path = os.path.join(src_dir, 'include')
3737
ports.install_headers(source_include_path, target='SDL2')
3838

39+
# copy sdl2-config.cmake
40+
cmake_file = os.path.join(os.path.dirname(__file__), 'sdl2/sdl2-config.cmake')
41+
ports.install_file(cmake_file, 'lib/cmake/SDL2/sdl2-config.cmake')
42+
3943
# build
4044
srcs = '''SDL.c SDL_assert.c SDL_dataqueue.c SDL_error.c SDL_guid.c SDL_hints.c SDL_list.c SDL_log.c
4145
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def create(final):
4646
source_include_path = os.path.join(root_dir, 'include', 'SDL3')
4747
ports.install_headers(source_include_path, target='SDL3')
4848

49+
# copy sdl3-config.cmake
50+
cmake_file = os.path.join(os.path.dirname(__file__), 'sdl3/sdl3-config.cmake')
51+
ports.install_file(cmake_file, 'lib/cmake/SDL3/sdl3-config.cmake')
52+
4953
glob_patterns = [
5054
# Generic sources (from SDL3's CMakeLists.txt)
5155
'*.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)