|
1 | | -cmake_minimum_required (VERSION 3.2) |
| 1 | +cmake_minimum_required (VERSION 3.30) |
| 2 | + |
| 3 | +# Enable Hot Reload for MSVC compilers if supported. |
| 4 | +if (POLICY CMP0141) |
| 5 | + cmake_policy(SET CMP0141 NEW) |
| 6 | + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>") |
| 7 | +endif() |
2 | 8 |
|
3 | 9 | project (wrangle-gl) |
4 | 10 |
|
5 | | -# test-egl |
| 11 | +enable_testing () |
| 12 | + |
| 13 | +set(CMAKE_CXX_STANDARD 17) |
6 | 14 |
|
7 | 15 | include_directories ("include") |
8 | 16 |
|
9 | | -add_executable ("test-egl" |
10 | | - "include/wrangle.h" |
| 17 | +if(WIN32) |
| 18 | + include(FetchContent) |
| 19 | + FetchContent_Declare( |
| 20 | + mali_gles_emulator |
| 21 | + URL https://developer.arm.com/-/media/Files/downloads/open-gl-es-emulator/3.0.4/Mali_OpenGL_ES_Emulator-v3.0.4-2-g8d905-Windows-64bit.zip?revision=89a52b4d-c891-4abc-be58-50db8c20bff9?product=OpenGL%20ES%20Emulator,64-bit,,Windows,3.0.4 |
| 22 | + ) |
| 23 | + FetchContent_MakeAvailable(mali_gles_emulator) |
| 24 | + message(STATUS "Fetched mali_gles_emulator to ${mali_gles_emulator_SOURCE_DIR}") |
| 25 | + find_file(OPENGL_EGL_LIBRARY |
| 26 | + NAMES libEGL.lib |
| 27 | + PATHS ${mali_gles_emulator_SOURCE_DIR} |
| 28 | + REQUIRED |
| 29 | + ) |
| 30 | + find_file(OPENGL_GLESv2_LIBRARY |
| 31 | + NAMES libGLESv2.lib |
| 32 | + PATHS ${mali_gles_emulator_SOURCE_DIR} |
| 33 | + REQUIRED |
| 34 | + ) |
| 35 | + set(OPENGL_egl_LIBRARY ${OPENGL_EGL_LIBRARY}) |
| 36 | + set(OPENGL_opengl_LIBRARY ${OPENGL_GLESv2_LIBRARY}) |
| 37 | + # Runtime dependencies |
| 38 | + configure_file ("${mali_gles_emulator_SOURCE_DIR}/libEGL.dll" "${CMAKE_CURRENT_BINARY_DIR}/libEGL.dll" COPYONLY) |
| 39 | + configure_file ("${mali_gles_emulator_SOURCE_DIR}/libGLESv2.dll" "${CMAKE_CURRENT_BINARY_DIR}/libGLESv2.dll" COPYONLY) |
| 40 | + configure_file ("${mali_gles_emulator_SOURCE_DIR}/libMaliEmulator.dll" "${CMAKE_CURRENT_BINARY_DIR}/libMaliEmulator.dll" COPYONLY) |
| 41 | + configure_file ("${mali_gles_emulator_SOURCE_DIR}/log4cplus.dll" "${CMAKE_CURRENT_BINARY_DIR}/log4cplus.dll" COPYONLY) |
| 42 | +else() |
| 43 | + find_package(OpenGL REQUIRED COMPONENTS EGL) |
| 44 | +endif() |
| 45 | + |
| 46 | +# egl_glcore |
| 47 | + |
| 48 | +add_executable (egl_glcore |
| 49 | + WIN32 |
| 50 | + "include/wrangle-gl.h" |
11 | 51 | "include/wrangle-egl.h" |
| 52 | + "src/wrangle-gl.cpp" |
12 | 53 | "src/wrangle-egl.cpp" |
13 | 54 | "tests/test-egl.cpp") |
14 | 55 |
|
15 | | -target_compile_options ("test-egl" |
16 | | - PUBLIC "-DGLEW_USE_EGL") |
| 56 | +target_compile_options (egl_glcore |
| 57 | + PUBLIC "-DGLEW_USE_EGL" |
| 58 | + PUBLIC "-DGLEW_USE_OPENGL") |
17 | 59 |
|
18 | | -if(WIN32) |
19 | | - # https://developer.arm.com/-/media/Files/downloads/open-gl-es-emulator/3.0.4/Mali_OpenGL_ES_Emulator-v3.0.4-2-g8d905-Windows-64bit.zip?revision=89a52b4d-c891-4abc-be58-50db8c20bff9?product=OpenGL%20ES%20Emulator,64-bit,,Windows,3.0.4 |
20 | | - #target_link_libraries ("test-egl" |
21 | | - # "${CMAKE_CURRENT_SOURCE_DIR}/khronos/emulator/ARM/libEGL.lib" |
22 | | - # "${CMAKE_CURRENT_SOURCE_DIR}/khronos/emulator/ARM/libGLESv2.lib") |
23 | | - #configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/khronos/emulator/AMD/x86/libEGL.dll" "${CMAKE_CURRENT_BINARY_DIR}/libEGL.dll" COPYONLY) |
24 | | - #configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/khronos/emulator/AMD/x86/libGLESv2.dll" "${CMAKE_CURRENT_BINARY_DIR}/libGLESv2.dll" COPYONLY) |
25 | | -else() |
26 | | - find_package(OpenGL REQUIRED COMPONENTS EGL) |
27 | | - if(NOT OPENGL_FOUND) |
28 | | - message(SEND_ERROR "Error: No OpenGL found.") |
29 | | - endif() |
30 | | - target_link_libraries ("test-egl" |
| 60 | +target_link_libraries (egl_glcore |
| 61 | + "${OPENGL_egl_LIBRARY}") |
| 62 | + |
| 63 | +add_test(NAME run_egl_glcore COMMAND $<TARGET_FILE:egl_glcore>) |
| 64 | + |
| 65 | +# egl_gles |
| 66 | + |
| 67 | +add_executable (egl_gles |
| 68 | + WIN32 |
| 69 | + "include/wrangle-egl.h" |
| 70 | + "include/wrangle-gles.h" |
| 71 | + "src/wrangle-egl.cpp" |
| 72 | + "src/wrangle-gles.cpp" |
| 73 | + "tests/test-egl.cpp") |
| 74 | + |
| 75 | +target_compile_options (egl_gles |
| 76 | + PUBLIC "-DGLEW_USE_EGL" |
| 77 | + PUBLIC "-DGLEW_USE_OPENGL_ES") |
| 78 | + |
| 79 | +target_link_libraries (egl_gles |
31 | 80 | "${OPENGL_egl_LIBRARY}" |
32 | | - "${OPENGL_opengl_LIBRARY}" |
33 | | - dl) |
| 81 | + "${OPENGL_opengl_LIBRARY}") |
| 82 | + |
| 83 | +if(LINUX) |
| 84 | +target_link_libraries (egl_gles dl) |
34 | 85 | endif() |
35 | 86 |
|
| 87 | +add_test(NAME run_egl_gles COMMAND $<TARGET_FILE:egl_gles>) |
| 88 | + |
| 89 | +# wgl_glcore (Windows only) |
| 90 | + |
36 | 91 | if(WIN32) |
37 | | -set_target_properties("test-egl" PROPERTIES |
38 | | - LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS" |
39 | | - LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS" |
40 | | - LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS" |
41 | | - LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") |
| 92 | + |
| 93 | +add_executable (wgl_glcore |
| 94 | + WIN32 |
| 95 | + "include/wrangle-gl.h" |
| 96 | + "include/wrangle-wgl.h" |
| 97 | + "src/wrangle-gl.cpp" |
| 98 | + "src/wrangle-wgl.cpp" |
| 99 | + "tests/test-wgl.cpp" |
| 100 | +) |
| 101 | + |
| 102 | +target_compile_options (wgl_glcore |
| 103 | + PUBLIC "-DGLEW_USE_WGL" |
| 104 | + PUBLIC "-DGLEW_USE_OPENGL") |
| 105 | + |
| 106 | +add_test(NAME run_wgl_glcore COMMAND $<TARGET_FILE:wgl_glcore>) |
| 107 | + |
42 | 108 | endif() |
43 | 109 |
|
44 | | -# test-wgl (Windows only) |
| 110 | +# wgl_gles (Windows only) |
45 | 111 |
|
46 | 112 | if(WIN32) |
47 | | -add_executable ("test-wgl" |
48 | | - "include/wrangle.h" |
| 113 | + |
| 114 | +add_executable (wgl_gles |
| 115 | + WIN32 |
49 | 116 | "include/wrangle-wgl.h" |
50 | | - "include/wrangle-gl.h" |
51 | 117 | "include/wrangle-gles.h" |
52 | 118 | "src/wrangle-wgl.cpp" |
53 | | - "src/wrangle-gl.cpp" |
54 | 119 | "src/wrangle-gles.cpp" |
55 | | - "tests/test-wgl.cpp") |
| 120 | + "tests/test-wgl.cpp" |
| 121 | +) |
56 | 122 |
|
57 | | -target_compile_options ("test-wgl" |
| 123 | +target_compile_options (wgl_gles |
58 | 124 | PUBLIC "-DGLEW_USE_WGL" |
59 | 125 | PUBLIC "-DGLEW_USE_OPENGL_ES") |
60 | 126 |
|
61 | | -set_target_properties("test-wgl" PROPERTIES |
62 | | - LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS" |
63 | | - LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS" |
64 | | - LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS" |
65 | | - LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") |
| 127 | +add_test(NAME run_wgl_gles COMMAND $<TARGET_FILE:wgl_gles>) |
| 128 | + |
66 | 129 | endif() |
0 commit comments