2
我有這樣的CMakeLists.txt文件鏈接語言:無法確定項目
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_POLICY(SET CMP0002 OLD)
PROJECT(gl_nbody C CXX)
ADD_EXECUTABLE(gl_nbody src/main.cpp)
set_target_properties(gl_nbody PROPERTIES LINKER_LANGUAGE CXX)
INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(gl_nbody ${SDL2_LIBRARIES})
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})
target_link_libraries(gl_nbody ${OPENGL_LIBRARIES})
add_subdirectory("src")
add_subdirectory("include")
我不完全知道我做錯了。我曾看過this的帖子。但是,發佈的解決方案並未解決我的問題。從C進行輸出是:
-- Configuring done
CMake Error: CMake can not determine linker language for target:gl_nbody
CMake Error: Cannot determine link language for target "gl_nbody".
-- Generating done
-- Build files have been written to: /home/jared/projects/gl_nbody
編輯:我發現,這個問題是由於的CMakeLists.txt文件我包括目錄。那就是:
file(GLOB gl_nbody_HEADER
"*.h"
)
#add_executable(gl_nbody ${gl_nbody_HEADER})
有什麼奇怪的是,我在我的SRC類似的文件目錄的唯一區別是,它增加了.cpp文件,而不是.h文件。但是,當我嘗試將頭文件添加到我的項目時,出現鏈接錯誤。