Can someone give me a simple step-by-step on how to set up and compile a simple "Hello World!" program on CLion using OpenGl/SDL/Freeglut . I see a lot of tutorials on Visual Studio, but CLion uses CMake so it's a lot different.
1 Answer
\$\begingroup\$ \$\endgroup\$
1 Use a CMakeLists.txt file. It would look something like this.
cmake_minimum_required(VERSION 3.3) project(projectname) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread -fpermissive") find_package (PkgConfig REQUIRED) find_package (OpenGL REQUIRED) find_package (GLUT REQUIRED) include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIRS}) file(GLOB SOURCE_FILES *.cpp *.h ) add_executable(main.cpp ${SOURCE_FILES}) target_link_libraries (main.cpp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} GL m dl Xinerama Xrandr Xi Xcursor X11 Xxf86vm pthread) I copied this from a test project that I have. It works on Linux and Windows both. It is stripped down to only what is necessary.
This is where I learned https://cmake.org/cmake-tutorial/
- \$\begingroup\$ Are
OPENGL_INCLUDE_DIRandGLUT_INCLUDE_DIRSautomatically set, or are they placeholders for the actual include directories? \$\endgroup\$anon– anon2018-03-08 05:45:09 +00:00Commented Mar 8, 2018 at 5:45