首先,我查看了这篇文章,但找不到解决问题的方法。我正在尝试使用两个头文件在文件夹中设置一个库并与我的主程序链接,在我的文件夹容器中它包括:
linkedStack.h
linkedQueue.h
我的容器文件夹中的 CMakeLists.txt 是
add_library(container linkedQueue.h linkedStack.h)
install (TARGETS container DESTINATION bin)
install (FILES linkedQueue.h linkedStack.h DESTINATION include)
而我在源目录中的 CMakeLists.txt 是:
cmake_minimum_required(VERSION 2.6)
project(wordLadder)
# set version number
set (MAJOR 1)
set (MINOR 0)
# configure header file to be placed in binary
configure_file(
"${PROJECT_SOURCE_DIR}/ladderConfig.h.in"
"${PROJECT_BINARY_DIR}/ladderConfig.h"
)
# add binary tree to search path for include files
# so we can find config
include_directories("${PROJECT_BINARY_DIR}")
#add container library
include_directories ("${PROJECT_SOURCE_DIR}/container")
add_subdirectory(container)
#add executable
add_executable(wordLadder ladderMain.cpp)
target_link_libraries (wordLadder container)
install (TARGETS wordLadder DESTINATION bin)
install (FILES "${PROJECT_BINARY_DIR}/ladderConfig.h"
DESTINATION include)
和我得到的错误:
CMake Error: Cannot determine link language for target "container".
CMake Error: CMake can not determine linker language for target:container
-- Generating done
-- Build files have been written to: /home/gmercer/Linux_dev/wordLadder/build
我不确定我在这里做错了什么,但我认为这与我的库 CMake 文件有关。