I want to link GLFW. I already installed: sudo apt-get install cmake make g++ libx11-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxrandr-dev libxext-dev Then I create catalog with 2 sub catalogs build(cmake out source build) and libs(for external libraries). from build catalog I run cmake with command "cmake .."
CMakeLists.txt in main catalog
cmake_minimum_required(VERSION 2.6)
project(MyProject) # project name
#version number
set(MyProject_Version_Major 1) #numer wersji glowny
set(MyProject_Version_Minor 0) #numer wydania
find_package(OpenGL REQUIRED)#when not found skip script
# add external subdirectory with another cmake file
add_subdirectory (libs)
include_directories(
libs/glfw-3.0.4/include/GLFW/
)
set(allLibs
${OPENGL_LIBRARY}
${GLFW_LIBRARIES}
)
add_executable(Manipulator main.cpp)
target_link_libraries(Manipulator ${allLibs})
CMakeLists.txt in libs catalog
GLFW
add_subdirectory (glfw-3.0.4)
include_directories(
glfw-3.0.4/include/GLFW/
)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(OPENGL_LIBRARY
${OPENGL_LIBRARY}
${GLFW_LIBRARIES}
)
From official documentation I got information:
add_subdirectory(path/to/glfw) - done, main catalog CMakeList.txt
To be able to include the GLFW header from your code, you need to tell the compiler where to find it.
include_directories(path/to/glfw/include) done, main catalog CMakeList.txt
Once GLFW has been added to the project, the GLFW_LIBRARIES cache variable contains all link-time dependencies of GLFW as it is currently configured. To link against GLFW, link against them and the glfw target.
target_link_libraries(myapp glfw ${GLFW_LIBRARIES}) done, main catalog CMakeList.txt
Note that GLFW_LIBRARIES does not include GLU, as GLFW does not use it. If your application needs GLU, you can add it to the list of dependencies with the OPENGL_glu_LIBRARY cache variable, which is implicitly created when the GLFW CMake files look for OpenGL.
target_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY} done, main catalog CMakeList.txt ${GLFW_LIBRARIES})
Still don't working, got following error:
error: GLFW/glfw3.h: No such file or directory #include
I'm using QTCreator 3.0.1, Ubuntu 14.02 Ubuntu 14.04 lts.
In QTCreator I specified the main CMakeLists.txt directory, build directory (different then source) Build directory - path to build directory main catalog/build Working directory - path to main CMakeLists.txt directory Run configoration: Manipulator
And still don't working. I found working examples on internet but I don't understand them( i.e. they create some directives no idea why).
GLFW/prefix :include_directories(libs/glfw-3.0.4/include/GLFW/). Try to useinclude_directories(libs/glfw-3.0.4/include). - jet47