Skip to content

Commit

Permalink
Commit missing CMakeLists for SDL_gpu.
Browse files Browse the repository at this point in the history
  • Loading branch information
lipk committed Jun 28, 2014
1 parent d60b9c6 commit 3238000
Show file tree
Hide file tree
Showing 2 changed files with 226 additions and 0 deletions.
124 changes: 124 additions & 0 deletions src/SDL_gpu/CMakeLists.txt
@@ -0,0 +1,124 @@
set(SDL_gpu_INSTALL_BY_DEFAULT OFF)

option(SDL_gpu_INSTALL "Install SDL_gpu libs, includes, and CMake scripts" ${SDL_gpu_INSTALL_BY_DEFAULT})
option(SDL_gpu_BUILD_DEBUG "Build with debugging symbols" ON)
option(SDL_gpu_BUILD_SHARED "Build SDL_gpu shared libraries" OFF)
option(SDL_gpu_BUILD_STATIC "Build SDL_gpu static libraries" ON)
option(SDL_gpu_USE_SDL1 "Use SDL 1.2 headers and library instead of SDL 2" ON)
option(SDL_gpu_DISABLE_OPENGL "Disable OpenGL renderers. Overrides specific OpenGL renderer flags." OFF)
option(SDL_gpu_DISABLE_GLES "Disable OpenGLES renderers. Overrides specific GLES renderer flags." ON)
option(SDL_gpu_DISABLE_OPENGL_1_BASE "Disable OpenGL 1 BASE renderer" OFF)
option(SDL_gpu_DISABLE_OPENGL_1 "Disable OpenGL 1.X renderer" OFF)
option(SDL_gpu_DISABLE_OPENGL_2 "Disable OpenGL 2.X renderer" OFF)
option(SDL_gpu_DISABLE_OPENGL_3 "Disable OpenGL 3.X renderer" OFF)
option(SDL_gpu_DISABLE_OPENGL_4 "Disable OpenGL 4.X renderer" OFF)
option(SDL_gpu_DISABLE_GLES_1 "Disable OpenGLES 1.X renderer" OFF)
option(SDL_gpu_DISABLE_GLES_2 "Disable OpenGLES 2.X renderer" OFF)
option(SDL_gpu_DISABLE_GLES_3 "Disable OpenGLES 3.X renderer" OFF)

set(SDL_gpu_VERSION 0.8.1)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "./CMake_scripts")

if ( SDL_gpu_BUILD_DEBUG )
SET(CMAKE_BUILD_TYPE Debug)
else ( SDL_gpu_BUILD_DEBUG )
SET(CMAKE_BUILD_TYPE Release)
endif ( SDL_gpu_BUILD_DEBUG )

# Find the package for SDL or SDL2
if ( SDL_gpu_USE_SDL1 )
find_package(SDL REQUIRED)

if ( NOT SDL_FOUND )
message ( FATAL_ERROR "SDL not found!" )
endif ( NOT SDL_FOUND )

include_directories(${SDL_INCLUDE_DIR})
link_libraries(${SDL_LIBRARY})
else ( SDL_gpu_USE_SDL1 )
find_package(SDL2 REQUIRED)

if ( NOT SDL2_FOUND )
message ( FATAL_ERROR "SDL2 not found!" )
endif ( NOT SDL2_FOUND )

if ( NOT SDL2MAIN_LIBRARY )
message ( WARNING "SDL2MAIN_LIBRARY is NOTFOUND" )
SET( SDL2MAIN_LIBRARY "" )
endif ( NOT SDL2MAIN_LIBRARY )

include_directories(${SDL2_INCLUDE_DIR})
link_libraries(${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY})
endif( SDL_gpu_USE_SDL1 )

# Find the package for OpenGL
if (SDL_gpu_DISABLE_OPENGL)
add_definitions("-DSDL_GPU_DISABLE_OPENGL")
else (SDL_gpu_DISABLE_OPENGL)

find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
link_libraries (${OPENGL_LIBRARIES})

if (SDL_gpu_DISABLE_OPENGL_1_BASE)
add_definitions("-DSDL_GPU_DISABLE_OPENGL_1_BASE")
endif (SDL_gpu_DISABLE_OPENGL_1_BASE)
if (SDL_gpu_DISABLE_OPENGL_1)
add_definitions("-DSDL_GPU_DISABLE_OPENGL_1")
endif (SDL_gpu_DISABLE_OPENGL_1)
if (SDL_gpu_DISABLE_OPENGL_2)
add_definitions("-DSDL_GPU_DISABLE_OPENGL_2")
endif (SDL_gpu_DISABLE_OPENGL_2)
if (SDL_gpu_DISABLE_OPENGL_3)
add_definitions("-DSDL_GPU_DISABLE_OPENGL_3")
endif (SDL_gpu_DISABLE_OPENGL_3)
if (SDL_gpu_DISABLE_OPENGL_4)
add_definitions("-DSDL_GPU_DISABLE_OPENGL_4")
endif (SDL_gpu_DISABLE_OPENGL_4)

endif (SDL_gpu_DISABLE_OPENGL)

# Find the package for OpenGLES
if (SDL_gpu_DISABLE_GLES)
add_definitions("-DSDL_GPU_DISABLE_GLES")
else (SDL_gpu_DISABLE_GLES)

find_package(OpenGLES REQUIRED)
include_directories(${OPENGLES_INCLUDE_DIR})
link_libraries (${OPENGLES_LIBRARIES})

if (SDL_gpu_DISABLE_GLES_1)
add_definitions("-DSDL_GPU_DISABLE_GLES_1")
endif (SDL_gpu_DISABLE_GLES_1)
if (SDL_gpu_DISABLE_GLES_2)
add_definitions("-DSDL_GPU_DISABLE_GLES_2")
endif (SDL_gpu_DISABLE_GLES_2)
if (SDL_gpu_DISABLE_GLES_3)
add_definitions("-DSDL_GPU_DISABLE_GLES_3")
endif (SDL_gpu_DISABLE_GLES_3)

endif (SDL_gpu_DISABLE_GLES)

if(NOT WIN32)
find_library(M_LIB m)
link_libraries(${M_LIB})
endif (NOT WIN32)

# Make local includes look in the right places
include_directories(SDL_gpu)
include_directories(SDL_gpu/GL_common)
include_directories(SDL_gpu/OpenGL_1_BASE)
include_directories(SDL_gpu/OpenGL_1)
include_directories(SDL_gpu/OpenGL_2)
include_directories(SDL_gpu/OpenGL_3)
include_directories(SDL_gpu/GLES_1)
include_directories(SDL_gpu/GLES_2)
include_directories(SDL_gpu/externals/glew)
include_directories(SDL_gpu/externals/stb_image)


add_definitions("-Wall -std=c99 -pedantic -DSTBI_FAILURE_USERMSG")

# Build the SDL_gpu library.
add_subdirectory(SDL_gpu)
102 changes: 102 additions & 0 deletions src/SDL_gpu/SDL_gpu/CMakeLists.txt
@@ -0,0 +1,102 @@
set(SDL_gpu_SRCS
SDL_gpu.c
SDL_gpuShapes.c
SDL_gpu_Renderer.c
GL_common/SDL_gpu_GL_matrix.c
OpenGL_1_BASE/SDL_gpu_OpenGL_1_BASE.c
OpenGL_1/SDL_gpu_OpenGL_1.c
OpenGL_2/SDL_gpu_OpenGL_2.c
OpenGL_3/SDL_gpu_OpenGL_3.c
GLES_1/SDL_gpu_GLES_1.c
GLES_2/SDL_gpu_GLES_2.c
externals/stb_image/stb_image.c
externals/stb_image/stb_image_write.c
)

set(SDL_gpu_HDRS
SDL_gpu.h
GL_common/SDL_gpu_GL_matrix.h
GL_common/SDL_gpu_GL_common.inl
GL_common/SDL_gpuShapes_GL_common.inl
OpenGL_1_BASE/SDL_gpu_OpenGL_1_BASE.h
OpenGL_1/SDL_gpu_OpenGL_1.h
OpenGL_2/SDL_gpu_OpenGL_2.h
OpenGL_3/SDL_gpu_OpenGL_3.h
GLES_1/SDL_gpu_GLES_1.h
GLES_2/SDL_gpu_GLES_2.h
externals/stb_image/stb_image.h
externals/stb_image/stb_image_write.h
)


if (NOT SDL_gpu_DISABLE_OPENGL )
SET(SDL_gpu_SRCS ${SDL_gpu_SRCS} externals/glew/glew.c)
SET(SDL_gpu_HDRS ${SDL_gpu_HDRS} externals/glew/glew.h externals/glew/glxew.h externals/glew/wglew.h)
endif (NOT SDL_gpu_DISABLE_OPENGL )

set(SDL_gpu_install_HDRS
SDL_gpu.h
GL_common/SDL_gpu_GL_matrix.h
OpenGL_1_BASE/SDL_gpu_OpenGL_1_BASE.h
OpenGL_1/SDL_gpu_OpenGL_1.h
OpenGL_2/SDL_gpu_OpenGL_2.h
OpenGL_3/SDL_gpu_OpenGL_3.h
GLES_1/SDL_gpu_GLES_1.h
GLES_2/SDL_gpu_GLES_2.h
)

# Set the appropriate library name so SDL_gpu and SDL2_gpu can co-exist.
if ( SDL_gpu_USE_SDL1)
set (SDL_gpu_OUTPUT_NAME "SDL_gpu")
else ( SDL_gpu_USE_SDL1)
set (SDL_gpu_OUTPUT_NAME "SDL2_gpu")
endif ( SDL_gpu_USE_SDL1)

# Build the shared library (.so or .dll)
if(SDL_gpu_BUILD_SHARED)
add_library(SDL_gpu_shared SHARED
${SDL_gpu_HDRS}
${SDL_gpu_SRCS}
)
set_target_properties(SDL_gpu_shared PROPERTIES
OUTPUT_NAME ${SDL_gpu_OUTPUT_NAME}
CLEAN_DIRECT_OUTPUT 1
VERSION ${SDL_gpu_VERSION}
)
set_target_properties(SDL_gpu_shared PROPERTIES LINKER_LANGUAGE C)
endif()

# Build the static library (.a)
if(SDL_gpu_BUILD_STATIC)
add_library(SDL_gpu STATIC
${SDL_gpu_HDRS}
${SDL_gpu_SRCS}
)
set_target_properties(SDL_gpu PROPERTIES
OUTPUT_NAME ${SDL_gpu_OUTPUT_NAME}
CLEAN_DIRECT_OUTPUT 1
VERSION ${SDL_gpu_VERSION}
)
set_target_properties(SDL_gpu PROPERTIES LINKER_LANGUAGE C)
endif()

# These are used to create visual studio folders.
source_group(Common FILES ${SDL_gpu_SRCS} ${SDL_gpu_HDRS})

# Install the library
if(SDL_gpu_INSTALL)
# install headers
install(FILES ${SDL_gpu_install_HDRS} DESTINATION include/SDL)

# install libraries
if(SDL_gpu_BUILD_SHARED)
install(TARGETS SDL_gpu_shared EXPORT SDL_gpu-targets DESTINATION lib)
endif()
if(SDL_gpu_BUILD_STATIC)
install(TARGETS SDL_gpu EXPORT SDL_gpu-targets DESTINATION lib)
endif()

# install build system hooks for third-party apps
#install(EXPORT SDL_gpu-targets DESTINATION ./SDL_gpu)
#install(FILES SDL_gpuConfig.cmake DESTINATION ./SDL_gpu)
endif(SDL_gpu_INSTALL)

0 comments on commit 3238000

Please sign in to comment.