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(LIBGLES_CM_SRC_FILES 26 Buffer.cpp 27 Buffer.h 28 Context.cpp 29 Context.h 30 Device.cpp 31 Device.hpp 32 Framebuffer.cpp 33 Framebuffer.h 34 IndexDataManager.cpp 35 IndexDataManager.h 36 libGLES_CM.cpp 37 libGLES_CM.hpp 38 main.cpp 39 main.h 40 mathutil.h 41 Renderbuffer.cpp 42 Renderbuffer.h 43 resource.h 44 ResourceManager.cpp 45 ResourceManager.h 46 Texture.cpp 47 Texture.h 48 utilities.cpp 49 utilities.h 50 VertexDataManager.cpp 51 VertexDataManager.h 52) 53 54if(WIN32) 55 list(APPEND LIBGLES_CM_SRC_FILES 56 libGLES_CM.rc 57 ) 58endif() 59 60add_library(libGLES_CM SHARED 61 ${LIBGLES_CM_SRC_FILES} 62) 63 64set_target_properties(libGLES_CM PROPERTIES 65 POSITION_INDEPENDENT_CODE 1 66 FOLDER "OpenGL" 67 PREFIX "" 68 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" 69 LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" 70) 71 72target_include_directories(libGLES_CM 73 PRIVATE 74 ".." 75 "../.." 76) 77 78target_compile_definitions(libGLES_CM 79 PRIVATE 80 "GL_GLEXT_PROTOTYPES" 81 "EGLAPI=" 82 "GL_API=" 83 "GL_APICALL=" 84 "GLAPI=" 85) 86 87target_compile_options(libGLES_CM 88 PRIVATE 89 ${ROOT_PROJECT_COMPILE_OPTIONS} 90) 91 92target_link_options(libGLES_CM 93 PUBLIC 94 ${SWIFTSHADER_LINK_FLAGS} 95) 96 97target_link_libraries(libGLES_CM 98 PRIVATE 99 libGLESCommon 100 gl_swiftshader_core 101 ${ROOT_PROJECT_LINK_LIBRARIES} 102) 103 104if (ANDROID) 105 set_target_properties(libGLES_CM PROPERTIES SUFFIX "_swiftshader.so") 106endif () 107 108set_shared_library_export_map(libGLES_CM ${CMAKE_CURRENT_SOURCE_DIR}) 109 110if(CMAKE_SIZEOF_VOID_P EQUAL 8) 111 set(LIB_PREFIX "lib64") 112else() 113 set(LIB_PREFIX "lib") 114endif() 115 116add_custom_command( 117 TARGET libGLES_CM 118 POST_BUILD 119 COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:libGLES_CM>/translator 120 COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:libGLES_CM> $<TARGET_FILE_DIR:libGLES_CM>/translator/${LIB_PREFIX}GLES_CM_translator${CMAKE_SHARED_LIBRARY_SUFFIX} 121) 122