Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL2 static compilation #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ install_manifest.txt
node_modules
.vscode
.idea
_deps
#mac
.DS_Store
SDL2TriangleGLEW/SDL2TriangleGLEW
.vscode

SDL2Triangle3DGLMGlew/SDL2Triangle3DGLMGLEW
45 changes: 38 additions & 7 deletions SDL2Triangle3DGLMGlew/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
#-------------------------------------------------------------------------------------------
# I'm going to use vcpk in most cases for our install of 3rd party libs
# this is going to check the environment variable for CMAKE_TOOLCHAIN_FILE and this must point to where
Expand All @@ -14,18 +14,49 @@ project(SDL2Triangle3DGLMGLEWBuild)
# This is the name of the Exe change this and it will change everywhere
set(TargetName SDL2Triangle3DGLMGLEW)
# find Qt libs
find_package(SDL2 CONFIG REQUIRED)
find_package(glm CONFIG REQUIRED)

include(FetchContent)
# sdl2
FetchContent_Declare(
sdl2
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG release-2.28.4
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(sdl2)

# glm
FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 0.9.9.8
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(glm)

# glew
FetchContent_Declare(
glew
GIT_REPOSITORY https://github.com/Perlmint/glew-cmake.git
GIT_TAG glew-cmake-2.2.0
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(glew)


find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
# use C++ 17

# use C++ 17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
# Set the name of the executable we want to build
add_executable(${TargetName})
include_directories(include)
include_directories(include ${glm_SOURCE_DIR})
add_compile_definitions(GLM_ENABLE_EXPERIMENTAL)

# Add NGL include path
Expand All @@ -50,6 +81,6 @@ endif()


# add exe and link libs that must be after the other defines
target_link_libraries(${TargetName} PRIVATE SDL2::SDL2-static OpenGL::GL)
target_link_libraries(${TargetName} PRIVATE SDL2::SDL2-static OpenGL::GL)

target_link_libraries(${TargetName} PRIVATE ${PROJECT_LINK_LIBS} GLEW::GLEW glm::glm)
target_link_libraries(${TargetName} PRIVATE ${PROJECT_LINK_LIBS} GLEW::GLEW glm)
14 changes: 12 additions & 2 deletions SDL2TriangleGLEW/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.11)
#-------------------------------------------------------------------------------------------
# I'm going to use vcpk in most cases for our install of 3rd party libs
# this is going to check the environment variable for CMAKE_TOOLCHAIN_FILE and this must point to where
Expand All @@ -14,7 +14,17 @@ project(SDL2TriangleGLEWBuild)
# This is the name of the Exe change this and it will change everywhere
set(TargetName SDL2TriangleGLEW)
# find Qt libs
find_package(SDL2 CONFIG REQUIRED)

include(FetchContent)
FetchContent_Declare(
SDL2
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG release-2.28.4
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(SDL2)

find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
# use C++ 17
Expand Down
3 changes: 3 additions & 0 deletions SDLPython/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PySDL2
numpy
pyopengl
3 changes: 3 additions & 0 deletions SDLPython/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
pip3 install -r requirements.txt
python3 SDLTriangle.py