我正试图在Windows 7 x64上运行一个包含Visual Studio 2010和Cygwin的cmake hello world程序,但两个程序都无法运行.我的目录 struct 如下:
HelloWorld
-- 克马克主义者.txt
-- src/
-- -- 克马克主义者.txt
-- -- main.cpp
-- build/
我在cd build
后面加了cmake ..
,得到了一个错误
CMake Error: CMake can not determine linker language for target:helloworld
CMake Error: Cannot determine link language for target "helloworld".
但是,如果我将文件系统和src/克马克主义者.txt
中的main.cpp扩展名都更改为main.c,则一切都按预期工作.这是从Visual Studio命令提示符(Visual Studio解决方案生成器)和Cygwin终端(Unix Makefiles生成器)运行的情况.
你知道为什么这个代码不起作用吗?
克马克主义者.txt
PROJECT(HelloWorld C)
cmake_minimum_required(VERSION 2.8)
# include the cmake modules directory
set(CMAKE_MODULE_PATH ${HelloWorld_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
add_subdirectory(src)
src/克马克主义者.txt
# Include the directory itself as a path to include directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Create a variable called helloworld_SOURCES containing all .cpp files:
set(HelloWorld_SOURCES main.cpp)
# Create an executable file called helloworld from sources:
add_executable(hello ${HelloWorld_SOURCES })
src/main.cpp
int main()
{
return 0;
}