Last active
October 2, 2018 13:21
-
-
Save JPenuchot/92f381d972a1a6331b33e25789abf320 to your computer and use it in GitHub Desktop.
CMakeLists.tkt for Christian Jacquemin's OpenGL course at https://perso.limsi.fr/jacquemi/OGL/, tested on Arch Linux (Previous versions were tested on Solus and MacOS, you might want to try them if this one doesn't work on your system)
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
cmake_minimum_required(VERSION 2.8.9) | |
project(prog) | |
find_package(PkgConfig REQUIRED) | |
# Adding compiler optimizations | |
set(CMAKE_CXX_STANDARD 17) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -march=native") | |
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0") | |
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG") | |
# Prefer vendor OpenGL over legacy version | |
set(OpenGL_GL_PREFERENCE GLVND) | |
find_package(OpenCV REQUIRED) | |
find_package(GLEW REQUIRED) | |
find_package(OpenGL REQUIRED) | |
pkg_search_module(GLFW REQUIRED glfw3) | |
# Adding includes | |
include_directories( | |
"include/" | |
${OPENGL_INCLUDE_DIR} | |
${GLFW_INCLUDE_DIRS} | |
${GLEW_INCLUDE_DIRS} | |
) | |
# Linking libraries | |
link_libraries( | |
${OpenCV_LIBRARIES} | |
${OPENGL_LIBRARIES} | |
${GLFW_LIBRARIES} | |
${GLEW_LIBRARIES} | |
) | |
# Adding sources | |
file(GLOB_RECURSE SOURCES "src/*.cpp") | |
add_executable(${PROJECT_NAME} ${SOURCES}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated on 29/03/2017
Requirements
Both can be installed using Brew on MacOS or any decent package manager on *nix distros.
OpenGL compatibility - Required for MacOS users
Add these lines after the glfwInit() if statement at the beginning of the main() to enable OpenGL Core profile to enable support for recent OpenGL versions :
Source : http://www.opengl-tutorial.org/
After this you might want to change
#version 130
in your shaders to#version 410
to enable a newer version of GLSL.This was tested on a MacBook Air and a Dell XPS 13 (6560U, Iris Graphics 540) running Solus Project (Linux) and should work on any other device.
Usage
First put the CMakeLists.txt in the main folder where the src folder is
cmake . make
This will output the program as 'prog'.