diff --git a/cmake/Modules/FindOpenGL.cmake b/cmake/Modules/FindOpenGL.cmake index 3220a11fddbce..8d1bc6e1aced5 100644 --- a/cmake/Modules/FindOpenGL.cmake +++ b/cmake/Modules/FindOpenGL.cmake @@ -30,3 +30,15 @@ mark_as_advanced( OPENGL_glu_LIBRARY OPENGL_gl_LIBRARY ) + +add_library(OpenGL::GL INTERFACE IMPORTED) +set_target_properties(OpenGL::GL PROPERTIES + IMPORTED_LIBNAME "${OPENGL_gl_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}" +) + +add_library(OpenGL::GLU INTERFACE IMPORTED) +set_target_properties(OpenGL::GLU PROPERTIES + IMPORTED_LIBNAME "${OPENGL_glu_LIBRARY}" + INTERFACE_LINK_LIBRARIES OpenGL::GL +) diff --git a/test/cmake/find_modules/CMakeLists.txt b/test/cmake/find_modules/CMakeLists.txt index 0167aa9aa04f2..911bf33ed53bd 100644 --- a/test/cmake/find_modules/CMakeLists.txt +++ b/test/cmake/find_modules/CMakeLists.txt @@ -6,15 +6,21 @@ add_executable(test_prog test.c) find_package(OpenGL REQUIRED) include_directories(${OPENGL_INCLUDE_DIR}) target_link_libraries(test_prog ${OPENGL_LIBRARIES}) -message(" test: OPENGL_LIBRARIES: ${OPENGL_LIBRARIES}") +message(STATUS " test: OPENGL_LIBRARIES: ${OPENGL_LIBRARIES}") find_package(OpenAL REQUIRED) include_directories(${OPENAL_INCLUDE_DIR}) target_link_libraries(test_prog ${OPENAL_LIBRARY}) -message(" test: OPENGL_LIBRARIES: ${OPENAL_LIBRARIES}") +message(STATUS " test: OPENAL_LIBRARIES: ${OPENAL_LIBRARIES}") find_package(SDL2 REQUIRED) include_directories(${SDL2_INCLUDE_DIRS}) target_link_libraries(test_prog SDL2::SDL2) -message(" test: SDL2_LIBRARIES: ${SDL2_LIBRARIES}") -message(" test: SDL2_INCLUDE_DIRS: ${SDL2_INCLUDE_DIRS}") +message(STATUS " test: SDL2_LIBRARIES: ${SDL2_LIBRARIES}") +message(STATUS " test: SDL2_INCLUDE_DIRS: ${SDL2_INCLUDE_DIRS}") + +get_target_property(TEST_OPENGL_GL_LIBNAME OpenGL::GL IMPORTED_LIBNAME) +message(STATUS " test: OpenGL::GL IMPORTED_LIBNAME: ${TEST_OPENGL_GL_LIBNAME}") + +get_target_property(TEST_OPENGL_GL_INCLUDES OpenGL::GL INTERFACE_INCLUDE_DIRECTORIES) +message(STATUS " test: OpenGL::GL INTERFACE_INCLUDE_DIRECTORIES: ${TEST_OPENGL_GL_INCLUDES}") diff --git a/test/cmake/find_modules/test.c b/test/cmake/find_modules/test.c index ba2c5d6a9f03b..fdff340c58116 100644 --- a/test/cmake/find_modules/test.c +++ b/test/cmake/find_modules/test.c @@ -1,4 +1,4 @@ -// Invlude emscripten/version.h to ensure that the in-tree +// Include emscripten/version.h to ensure that the in-tree // include directory has not been added to the include path. #include #include diff --git a/test/test_other.py b/test/test_other.py index 4aaa0b964e5fd..1dcd2e8cd090e 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -1091,7 +1091,9 @@ def test_cmake_install(self): @requires_network def test_cmake_find_modules(self): - self.run_process([EMCMAKE, 'cmake', test_file('cmake/find_modules')]) + output = self.run_process([EMCMAKE, 'cmake', test_file('cmake/find_modules')], stdout=PIPE).stdout + self.assertContained(' test: OpenGL::GL IMPORTED_LIBNAME: GL', output) + self.assertContained(' test: OpenGL::GL INTERFACE_INCLUDE_DIRECTORIES: /.+/cache/sysroot/include', output, regex=True) self.run_process(['cmake', '--build', '.']) output = self.run_js('test_prog.js') self.assertContained('AL_VERSION: 1.1', output)