Aleix Pol wrote:
> Hi,
> I would like to propose this as a final version of this patch.
> http://proli.net/meu/kdevelop/0001-cmake-Add-option-to-generate-target-metadata-for-IDE.patch
>
> I have a working proof of concept in KDevelop already I'm quite happy
> with.
>
> Any thoughts?
Just some quick ones:
1) Getting the right sources:
Consider this:
cmake_minimum_required(VERSION 2.8)
project(cmaketest)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/other.cpp"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/bar.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/other.cpp"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/bar.cpp"
)
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/somefile.cpp"
CONTENT "
static const char all_srcs[] = \"$<TARGET_PROPERTY:foo,SOURCES>\";\n"
)
add_executable(foo
main.cpp
"${CMAKE_CURRENT_BINARY_DIR}/other.cpp"
somefile.txt
foo.h
)
After running cmake:
$ cat somefile.cpp
static const char all_srcs[] =
"main.cpp;/home/stephen/dev/src/playground/cmake/build/other.cpp;somefile.txt;foo.h;/home/stephen/dev/src/playground/cmake/bar.cpp";
You would get the same result with your patch: "bar.cpp" is a 'SOURCE', but
it is not an 'object source'. It is not compiled into the target.
CMake knows that, and provides cmGeneratorTarget::GetObjectSources to get
'the list of sources compiled into objects by this buildsystem'. You should
list that in your JSON instead.
You might also make use of GetHeaderSources and GetExtraSources at least to
cover foo.h and somefile.txt too, and probably GetExternalObjects too.
2) The final patch will need to have unit tests and documentation.
3) Did you find any of the feedback from the Creator or CLion guys relevant?
I'd have to review the rest of the thread again to see if there's anything
else which should be addressed already by this iteration of the patch.
4) I won't be able to do a complete review before January.
Thanks!
Steve.
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers