Bug 306600

Summary: "wrong-target" for a valid add_executable()
Product: [Applications] kdevelop Reporter: Vasiliy Yeremeyev <vayerx>
Component: Build tools: CMakeAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal CC: meyerm
Priority: NOR    
Version: 4.3.1   
Target Milestone: 4.3.0   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Vasiliy Yeremeyev 2012-09-11 11:56:54 UTC
Following CMakeLists.txt produces "wrong-target" in Projects Tool View:

# ===== BEGIN =====
cmake_minimum_required(VERSION 2.8)
project(bug_demo)

function(Executable name)
    set_property(DIRECTORY APPEND PROPERTY ${name}_EXE_SOURCES ${ARGN})
    get_property(sources DIRECTORY PROPERTY ${name}_EXE_SOURCES)

    # Using of ADD_LIBRARY() instead of ADD_EXECUTABLE() adds a valid target (but without source files attached to it):
    #add_library(${name} ${sources})
    add_executable(${name} ${sources})

endfunction(Executable)

Executable(wrong_target_bug main.cpp)
# ===== END =====

main.cpp may be any hello-world sample:

#include <iostream>
int main(int argc, char **argv) { std::cout << "Hello, world!" << std::endl; return 0; }


Reproducible: Always

Steps to Reproduce:
1. Create project with specified CMakeLists.txt and main.cpp
2. Look at Project Tool View

Actual Results:  
"|wrong-target" displayed

Expected Results:  
target named "bug_demo"

Looks similiar to bug 293750, but is more general and different/simple way to reproduce.
As written in comments, using of ADD_LIBRARY() instead of ADD_EXECUTABLE() adds a valid target (but without source files attached to it)
Comment 1 Vasiliy Yeremeyev 2012-09-11 12:02:14 UTC
"wrong_target_bug" in "Executable(wrong_target_bug main.cpp)" should be replaced by "bug_demo", of course
Comment 2 Aleix Pol 2012-09-12 01:25:13 UTC
Git commit 866d099e05ec5c4d0c9c02a715fd9e351260d753 by Aleix Pol.
Committed on 12/09/2012 at 03:24.
Pushed by apol into branch '4.4'.

Improve properties fetching

In case it's a directory property and the directory is not specified,
use the cmake_current_source_dir value as the directory.

M  +33   -19   projectmanagers/cmake/parser/cmakeprojectvisitor.cpp

http://commits.kde.org/kdevelop/866d099e05ec5c4d0c9c02a715fd9e351260d753
Comment 3 Aleix Pol 2012-09-12 01:25:13 UTC
Git commit 74825d9cc9baaccf60ba366750971c0d13278fcf by Aleix Pol.
Committed on 12/09/2012 at 03:24.
Pushed by apol into branch 'master'.

Improve properties fetching

In case it's a directory property and the directory is not specified,
use the cmake_current_source_dir value as the directory.

M  +33   -19   projectmanagers/cmake/parser/cmakeprojectvisitor.cpp

http://commits.kde.org/kdevelop/74825d9cc9baaccf60ba366750971c0d13278fcf