1
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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/

\$\endgroup\$
  • \$\begingroup\$ Are OPENGL_INCLUDE_DIR and GLUT_INCLUDE_DIRS automatically set, or are they placeholders for the actual include directories? \$\endgroup\$ – Fund Monica's Lawsuit Mar 8 '18 at 5:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.