executable target name is reserved

I have following CMakeLists.txt file:

CMAKE_MINIMUM_REQUIRED(VERSION 3.1)

PROJECT(MyProject)

FILE(GLOB_RECURSE sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
FILE(GLOB_RECURSE headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h)

ADD_EXECUTABLE(AnyNameHere, ${sources})

When I use "Configure" in CMake I get this error:

CMake Error at CMakeLists.txt:8 (ADD_EXECUTABLE): The target name "AnyNameHere," is reserved or not valid for certain CMake features, such as generator expressions, and may result in undefined behavior.

I changed the name, but I get same error no matter what name I choose. I checked the documentation and all the characters I used for the name seem to be valid and I assume the actual error is somewhere else.

Can you please guide me to fix this?

EDIT:

I further simplified the script to have only:

CMAKE_MINIMUM_REQUIRED(VERSION 3.1)

PROJECT(MyProject)

ADD_EXECUTABLE(AnyNameHere, HelloWorld.cpp)

with the same error. I'm using CMake GUI, version 3.1


Remove the comma. CMake command parameters are separated by whitespace, not commas.

链接地址: http://www.djcxy.com/p/31880.html

上一篇: cmake的

下一篇: 可执行目标名称被保留