• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15set(ROOT_PROJECT_COMPILE_OPTIONS
16    ${SWIFTSHADER_COMPILE_OPTIONS}
17    ${WARNINGS_AS_ERRORS}
18)
19
20set(ROOT_PROJECT_LINK_LIBRARIES
21    ${OS_LIBS}
22    ${SWIFTSHADER_LIBS}
23)
24
25set(LIBEGL_SRC_FILES
26    Config.cpp
27    Config.h
28    Context.hpp
29    Display.cpp
30    Display.h
31    libEGL.cpp
32    libEGL.hpp
33    main.cpp
34    main.h
35    OSXUtils.hpp
36    resource.h
37    Surface.cpp
38    Surface.hpp
39    Sync.hpp
40    Texture.hpp
41)
42
43if(WIN32)
44    list(APPEND LIBEGL_SRC_FILES
45        libEGL.rc
46    )
47elseif(APPLE)
48    list(APPEND LIBEGL_SRC_FILES
49        OSXUtils.mm
50        OSXUtils.hpp
51    )
52endif()
53
54add_library(libEGL SHARED
55    ${LIBEGL_SRC_FILES}
56)
57
58set_target_properties(libEGL PROPERTIES
59    POSITION_INDEPENDENT_CODE 1
60    FOLDER "OpenGL"
61    PREFIX ""
62    RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
63    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
64)
65
66target_include_directories(libEGL
67    PRIVATE
68        ".."
69        "../.."
70)
71
72target_compile_definitions(libEGL
73    PRIVATE
74        "EGL_EGLEXT_PROTOTYPES"
75        "EGLAPI="
76        "NO_SANITIZE_FUNCTION="
77        $<$<CONFIG:Debug>:"DEBUGGER_WAIT_DIALOG">
78)
79
80target_compile_options(libEGL
81    PRIVATE
82        ${ROOT_PROJECT_COMPILE_OPTIONS}
83)
84
85target_link_options(libEGL
86    PUBLIC
87        ${SWIFTSHADER_LINK_FLAGS}
88)
89
90target_link_libraries(libEGL
91    PRIVATE
92        libGLESCommon
93        gl_swiftshader_core
94        ${ROOT_PROJECT_LINK_LIBRARIES}
95)
96
97if(LINUX)
98    if(X11)
99        set_property(TARGET libEGL APPEND PROPERTY COMPILE_DEFINITIONS "USE_X11=1")
100    endif()
101endif()
102
103if (ANDROID)
104    set_target_properties(libEGL PROPERTIES SUFFIX "_swiftshader.so")
105endif ()
106
107set_shared_library_export_map(libEGL ${CMAKE_CURRENT_SOURCE_DIR})
108
109if(CMAKE_SIZEOF_VOID_P EQUAL 8)
110    set(LIB_PREFIX "lib64")
111else()
112    set(LIB_PREFIX "lib")
113endif()
114
115add_custom_command(
116    TARGET libEGL
117    POST_BUILD
118    COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:libEGL>/translator
119    COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:libEGL> $<TARGET_FILE_DIR:libEGL>/translator/${LIB_PREFIX}EGL_translator${CMAKE_SHARED_LIBRARY_SUFFIX}
120    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/
121    COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:libEGL> ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/
122
123    # Copy to ${CMAKE_BINARY_DIR}/bin so the library sits next to the PVR samples.
124    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin
125    COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:libEGL> ${CMAKE_BINARY_DIR}/bin/$<TARGET_FILE_NAME:libEGL>
126)
127