Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use framework using Cmake?

For Macos, I'd like to link to some framework. In windows, I would like to link to some library.

For example, OpenGL Framework, how to express this requirement using cmake?

like image 647
Adam Lee Avatar asked Dec 21 '14 01:12

Adam Lee


2 Answers

You could try the following code:

target_link_libraries(<target name>
    "-framework AVFoundation"
    "-framework CoreGraphics"
    "-framework CoreMotion"
    "-framework Foundation"
    "-framework MediaPlayer"
    "-framework OpenGLES"
    "-framework QuartzCore"
    "-framework UIKit"
    )
like image 85
Wensheng Yang Avatar answered Sep 29 '22 20:09

Wensheng Yang


To tell CMake that you want to link to OpenGL, add the following to your CMakeLists.txt:

find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
target_link_libraries(<your program name> ${OPENGL_LIBRARIES})

find_package will look for OpenGL and tell the rest of the script where OpenGL is by setting some OPENGL* variables. include_directories tells your compiler where to find OpenGL headers. target_link_libraries instructs CMake to link in OpenGL.

The following code will do different actions based on the operating system:

if(WIN32)
    #Windows specific code
elseif(APPLE)
    #OSX specific code
endif()
like image 29
Quip Yowert Avatar answered Sep 29 '22 19:09

Quip Yowert