[Solved] CMake Error Cannot specify link libraries for target “variational“ which is not built by this projec

For errors:

CMake Error at D:\VSA_paper\VSA\CMakeLists.txt:48 (target_link_libraries):
1> [CMake] Cannot specify link libraries for target “variational” which is not built by this project.

 

All the information found said target_link_libraries is not placed behind add_executable, but not mine
the following is the code segment where the error is located

add_executable(${PROJECT_NAME}_bin ${SRCFILES}  ${HEAD_FILES} ${RCC_FILES} ${WRAP_FILES}  "gauss.h" "developable_degree.h")
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Core Qt5::Gui)
target_link_libraries(${PROJECT_NAME}_bin igl::core igl::opengl_glfw)
target_link_libraries(${PROJECT_NAME}_bin OpenMesh)

From the error “Cannot specify link libraries for target “variational” which is not built by this project.” You can see that the project name “variant” is wrong and should be “variant_bin”.

The solution is to add the missing “_bin” after ${project_name} in the above code segment. The modified result is as follows:

add_executable(${PROJECT_NAME}_bin ${SRCFILES}  ${HEAD_FILES} ${RCC_FILES} ${WRAP_FILES}  "gauss.h" "developable_degree.h")
#add Qt5
target_link_libraries(${PROJECT_NAME}_bin Qt5::Widgets Qt5::Core Qt5::Gui)
target_link_libraries(${PROJECT_NAME}_bin igl::core igl::opengl_glfw)
target_link_libraries(${PROJECT_NAME}_bin OpenMesh)

Read More: