My c project

this is my project structure before compile

~/proj/CMakeLists.txt
~/proj/src/CMakeLists.txt
~/proj/src/main.cpp
~/proj/build/

input

proj/CMakeList.txt

cmake_minimum_required(VERSION 3.10) project(test) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include_directories(/usr/local/include) add_subdirectory(src)

proj/src/CMakeList.txt

find_package(OpenGL REQUIRED) find_package(GLUT REQUIRED) add_executable(test main.cpp) set(GL_LIBRARIES OpenGL::GL GLUT::GLUT) target_link_libraries(test ${GL_LIBRARIES})

Output

build/compile_command.json

[
{
  "directory": "/home/hanslu95/proj/src",
  "command": "/usr/bin/c++  -isystem /usr/local/include  -o CMakeFiles/test.dir/main.cpp.o -c /home/hanslu95/proj/src/main.cpp",
  "file": "/home/hanslu95/proj/src/main.cpp",
  "output": "src/CMakeFiles/test.dir/main.cpp.o"
}
]

compile_command.json

[
{
  "directory": "/home/hanslu95/proj/src",
  "command": "/usr/bin/c++  -isystem /usr/local/include  -o CMakeFiles/test.dir/main.cpp.o -c /home/hanslu95/proj/src/main.cpp",
[
{
  "directory": "/home/hanslu95/proj/build/src",
  "command": "/usr/bin/c++  -isystem /usr/local/include  -o CMakeFiles/test.dir/main.cpp.o -c /home/hanslu95/proj/src/main.cpp",
  "file": "/home/hanslu95/proj/src/main.cpp",
  "output": "src/CMakeFiles/test.dir/main.cpp.o"
}
]

Final Result

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →