环境:
MAC os:10.12.6
CMake版本:3.8
CMake Error at CMakeLists.txt:7 (add_executable):
The target name "test" is reserved or not valid for certain CMake features, such as generator expressions, and may result in undefined behavior.
这是我的CMakeLists.txt:
cmake_minimum_required(VERSION 3.8)
project(test)
# set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(test ${SOURCE_FILES})
我该怎么办?
答案 0 :(得分:4)
CMake包含一些自动化测试功能。即有add_test
命令和相关内容,因此保留名称test
。只需将test
重命名为其他内容。
答案 1 :(得分:0)
这可能是与CMakeLists.txt中的语法有关的问题。 我在尝试Android NDK时遇到类似的错误。
就我而言,在CMakeLists.txt中声明C ++文件时出错。声明C ++文件的正确方法如下:
add_library(
Your-library-name
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
your-cpp-file1.cpp
your-cpp-file2.cpp
your-cpp-file3.cpp
)