Created
August 15, 2023 09:47
-
-
Save arkenidar/d3904aead673b76e4ac07de946bd1b9d to your computer and use it in GitHub Desktop.
CMake for OpenGL projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### https://github.com/arkenidar/sdl2-gl | |
# cmake -S . -B build && cmake --build build && build/app | |
# cmake -S . -B build -G "Ninja" && cmake --build build && build/app | |
# cmake -S . -B build -G "CodeBlocks - Ninja" && cmake --build build && build/app | |
# cmake -S . -B build -G "Visual Studio 17 2022" && cmake --build build && build/app | |
cmake_minimum_required(VERSION 3.18) | |
project( app VERSION 0.1 ) | |
file(GLOB SOURCE_FILES "*.c*" ) | |
add_executable(app ${SOURCE_FILES}) | |
find_package( OpenGL REQUIRED ) | |
find_package( SDL2 REQUIRED ) | |
target_link_libraries(${PROJECT_NAME} OpenGL::GL OpenGL::GLU ${SDL2_LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## https://github.com/arkenidar/tinyobjloader-c | |
# cmake -S . -B build && cmake --build build && build/app | |
# cmake -S . -B build -G "Ninja" && cmake --build build && build/app | |
# cmake -S . -B build -G "CodeBlocks - Ninja" && cmake --build build && build/app | |
# cmake -S . -B build -G "Visual Studio 17 2022" && cmake --build build && build/app | |
cmake_minimum_required(VERSION 3.18) | |
project( app VERSION 0.1 ) | |
file(GLOB SOURCE_FILES "*.c*" ) | |
add_executable(app ${SOURCE_FILES}) | |
find_package( OpenGL REQUIRED ) | |
find_package( glfw3 REQUIRED ) | |
set(ADDITIONAL_LIBRARIES "") | |
if(UNIX) | |
set(ADDITIONAL_LIBRARIES m dl) | |
endif() | |
target_link_libraries(${PROJECT_NAME} OpenGL::GL OpenGL::GLU glfw ${ADDITIONAL_LIBRARIES} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## https://github.com/arkenidar/tinyobjloader | |
# cmake -S . -B build && cmake --build build && build/app | |
# cmake -S . -B build -G "Ninja" && cmake --build build && build/app | |
# cmake -S . -B build -G "CodeBlocks - Ninja" && cmake --build build && build/app | |
# cmake -S . -B build -G "Visual Studio 17 2022" && cmake --build build && build/app | |
cmake_minimum_required(VERSION 3.18) | |
project( app VERSION 0.1 ) | |
file(GLOB SOURCE_FILES "*.c*" ) | |
add_executable(app ${SOURCE_FILES}) | |
find_package( OpenGL REQUIRED ) | |
find_package( glfw3 REQUIRED ) | |
set(ADDITIONAL_LIBRARIES "") | |
if(WIN32) | |
set(ADDITIONAL_LIBRARIES winmm) | |
endif() | |
set(GLEW_LIBRARY "") | |
if(UNIX) | |
set(GLEW_LIBRARY GLEW) | |
else() | |
find_package( glew REQUIRED ) | |
set(GLEW_LIBRARY GLEW::glew) | |
endif() | |
target_link_libraries(${PROJECT_NAME} OpenGL::GL OpenGL::GLU glfw ${ADDITIONAL_LIBRARIES} ${GLEW_LIBRARY} ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment