I am trying to start opengl develop with cMake on Qt, the base informations are as below:
glad: version4.6; glfw: version3.3.4, QT: version5.12.
the file tree as below:
my cmake are as below:
cmake_minimum_required(VERSION 3.5)
project(opengl1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(GLFW_3P ${PROJECT_ROOT_DIR}/3rdpart/glfw)
set(GLAD_3P ${PROJECT_ROOT_DIR}/3rdpart/glad)
set(GLAD_FILE ${GLAD_3P}/src/glad.c)
add_executable(opengl1
main.cpp
${GLAD_FILE}) #**acttually, this file add failed**
target_include_directories(opengl1
PUBLIC ${GLFW_3P}/include
PUBLIC ${GLAD_3P}/include
)
find_library(GLFW_LIB glfw3 HINTS {GLFW_3P}/lib)
target_link_libraries(opengl1 ${GLFW_LIB})
but when compile, all the functions located in glad.c are “undefined reference to”, the file glad.c not invove compile:
cmd.exe /C "cd . && C:\Qt\Tools\mingw810_64\bin\g++.exe -g src/CMakeFiles/opengl1.dir/main.cpp.obj -o src\opengl1.exe -Wl,--out-implib,src\libopengl1.dll.a -Wl,--major-image-version,0,--minor-image-version,0 C:/openGl/glfw/lib/libglfw3.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
Q: how can I include a external c file successfully? (thank you so much if get you response)