[cmake-developers] Cmake-server question
Ben Boeckel
ben.boeckel at kitware.com
Thu Feb 15 09:18:17 EST 2018
On Wed, Feb 14, 2018 at 19:19:39 +0100, Paweł Rutka wrote:
> I would like to ask about some important feature:
> Is there any possibility to provide form Cmake Server side location of
> command that generate the target? The Use Case is as follow:
> In IDE you want to, after Class creation, automatically add CPP file into
> proper add_executable or extend some variable passed to add_executable or
> any other case that lead to target creation.
Note that this is a very hard problem. Take the following examples:
=======
add_executable(myexe a.c b.c)
=======
=======
set(sources a.c b.c)
add_executable(myexe ${sources})
=======
=======
set(sources a.c b.c)
add_subdirectory(foo) # does a `set(sources PARENT_SCOPE)`
add_executable(myexe ${sources})
=======
=======
set(sources a.c b.c)
if (some_option)
list(APPEND sources c.c)
endif ()
add_executable(myexe ${sources})
=======
=======
set(sources a.c b.c)
add_executable(myexe ${sources})
set_property(TARGET myexe APPEND SOURCES d.c)
=======
What would the IDE be expected to do for each of these cases?
Personally, I think it would be best to just get where the target is
declared. This should have a backtrace available so that this pattern is
supported:
=======
function (wrap_add_library)
add_library(${ARGN})
# Project-specific bits.
endfunction ()
# Somewhere else...
wrap_add_library(mylib STATIC ...)
=======
Once the main location is found, I think just having the "your cursor is
on FOO, I'll highlight other instances of FOO" feature should be enough
to get one to the right place.
--Ben
More information about the cmake-developers
mailing list