CMake: Targets with variables not recognized correctly
Created by: donbcd
In my CMakeLists.txt I have several of these (lets say test1 to test9):
set(TARGET_NAME test1)
set(SOURCES test1.cpp)
add_executable(${TARGET_NAME}
${SOURCES})
set_property(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD 14)
target_link_libraries(${TARGET_NAME}
SomeLibrary)
add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME})
No matter in which .cpp file I am, Compile+Run always runs test9, which is the last one in the list. If I remove the variables, everything works fine!
Edit: If I move this into a function and pass the target_name and sources via two parameters, everything works fine too, so the problem seems to be the set(...)