Make project compile on macOS as well as Linux
This commit is contained in:
parent
00a21b7c4a
commit
32bf572d00
|
@ -6,6 +6,8 @@ set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)
|
||||||
|
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
find_package(GLUT REQUIRED)
|
||||||
find_package(OpenCV HINTS /usr/local/opt/opencv /usr/local/Cellar/opencv REQUIRED)
|
find_package(OpenCV HINTS /usr/local/opt/opencv /usr/local/Cellar/opencv REQUIRED)
|
||||||
|
|
||||||
set( NAME_SRC
|
set( NAME_SRC
|
||||||
|
@ -15,4 +17,11 @@ set( NAME_SRC
|
||||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
|
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
|
||||||
add_executable( opengl_opencv_example ${NAME_SRC} ${NAME_HEADERS} )
|
add_executable( opengl_opencv_example ${NAME_SRC} ${NAME_HEADERS} )
|
||||||
|
|
||||||
target_link_libraries(opengl_opencv_example GL GLU glut ${OpenCV_LIBS} )
|
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
# Equivalent to pass flags -framework OpenGL
|
||||||
|
target_link_libraries(opengl_opencv_example OpenGL::GL GLUT::GLUT ${OpenCV_LIBS})
|
||||||
|
else()
|
||||||
|
target_link_libraries(opengl_opencv_example GL GLU glut ${OpenCV_LIBS} )
|
||||||
|
endif()
|
10
main.cpp
10
main.cpp
|
@ -6,8 +6,14 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#ifdef __APPLE__
|
||||||
#include <GL/glut.h>
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/gl3.h>
|
||||||
|
#include <GLUT/glut.h>
|
||||||
|
#else
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
Loading…
Reference in New Issue