I want to include SDL2 and GLEW to my Cmake project
The scr files are in C:\libs\src and I createt all the libaries in CMAKE with PATH CMAKE_Install_PRÄFIX like in this documentation:
- Download and install CMake ( https://cmake.org/ ) and Visual Studio Community Edition ( https://visualstudio.microsoft.com/de/ )
- Create a directory libs or libraries (whatever suits you) where you install all your libraries. It is reasonable to have this on a low level as in the future you might want to add further libraries and use this folder also for other projects. The following explanations assume that you use C:/libs. If you want to use another directory, just adapt the directory the way you need it.
- Add C:/libs and C:/libs/bin to the Environment Variable Path ( https://www.computerhope.com/issues/ch000549.htm ).
- Create a subdirectory libs/src, copy all the libraries from cgAdvancedFramework/deps/ to this folder and extract them.
- SDL2:
- Open cmake-gui
- Source code: C:/libs/src/SDL2-2.0.12
- Binaries: C:/libs/src/SDL2-2.0.12/build
- Add entry
- Name: CMAKE_INSTALL_PREFIX
- Type: PATH
- Value: C:\libs
- Ok
- Configure
- Accept creating build directory
- Use default native compiler --> Finish
- Generate
- Open Project (this should start Visual Studio)
- Visual Studio
- Solution Configuration: Debug
- right-click ALL_BUILD --> Build (if errors appear, here you might have done something wrong before)
- right-click INSTALL --> Build (if errors appear, ...)
- do the same for Solution Configuration: RelWithDebInfo (optional but recommended)
- Open cmake-gui
My Project is locatet C:\Users\Documents...\dvs\volren
and the build dir is locatet C:\Users\Documents...\dvs\build and
C:\libs\include\GL
C:\libs\include\SDL2 ...
main.cpp:
#include <iostream>
#pragma once
#define NOMINMAX
#include <SDL2.h> //dont find
#include <GL/glew.h> //dont find
#include <vtk3DS.h> // find
CMakelist.txt:
cmake_minimum_required(VERSION 2.8)
PROJECT(volren)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
add_executable(volren MACOSX_BUNDLE main.cpp Camera.hpp Math.hpp Image.hpp)
target_link_libraries(volren ${VTK_LIBRARIES} ${GLEW_LIBRARIES} ${VTK_LIBRARIES})
Error: Can not open source file GL/glew.h
Where is my mistake ?