this is my project structure before compile
~/proj/CMakeLists.txt
~/proj/src/CMakeLists.txt
~/proj/src/main.cpp
~/proj/build/
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})
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"
}
]