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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With