[cmake-developers] Generating buildsystem metadata from CMake
Stephen Kelly
steveire at gmail.com
Tue Mar 31 19:03:42 EDT 2015
Tobias Hunger wrote:
> I think we can combine the include_directories, compile definitions
> and flags ourselves though when that is needed for us to run the
> compiler. I do not see the need to have the full command line that
> would be run for each and every file, which is how I read "full
> compiler command line".
Ok, great.
We've discussed some issues here about what the metadata file should
contain, and you guys have made some proposals on specific details of what
should be in the JSON. However, I think to bring this to a conclusion,
you'll need to post 'structurally complete' JSON files for what you need
(and what CMake is actually able to generate!), instead of suggestions on
specific details.
Please post some sample CMakeLists.txt files together with some
corresponding sample JSON files that you propose would be generated by
CMake. Please show all of the objects and properties that you propose should
be in the JSON file, and in what positions. It's ok to elide things, but
please make sure your proposal is clear. I think some of the suggestions
that were brought up already have changed over the course of the thread, so
I want to know what you guys now propose at this point.
I know Tobias posted an example JSON file already, but that was too big to
extract the meaning from it.
Please use your knowledge of CMake features and post some interesting ones,
because the interesting ones determine what the structure of the JSON needs
to be to some extent.
For example, here's small CMakeLists file which requires you to design
something which allows a single source file to be compiled multiple times
with different flags:
cmake_minimum_required(VERSION 2.8)
project(cmaketest)
# CMake just copy-pastes this string without parsing. What should the
# metadata contain?
set(CMAKE_CXX_FLAGS "-I /opt/something -D INTERESTING -DANOTHER_DEFINE")
add_executable(foo main.cpp)
# The user specified /opt/specified/directory in the 'normal'way
# for CMake.
# Does that deserve special handling so that the IDE can just to the place
# where the directory was specified, for example?
target_include_directories(foo PRIVATE
/opt/specified/directory
)
target_compile_definitions(foo PRIVATE
FOO_DEFINE
)
add_executable(bar main.cpp)
target_compile_definitions(bar PRIVATE
BAR_DEFINE
)
# main.cpp is compiled twice - both times with FILE_DEFINE and
# -DFILE_FLAG and -DIN_OPAQUE_STRING, one time with
# FOO_DEFINE and one time with BAR_DEFINE.
# Run with make VERBOSE=1 to see where the defines appear on the
# command line!
# What should the metadata contain?
set_source_files_properties(main.cpp PROPERTIES
COMPILE_DEFINITIONS FILE_DEFINE
COMPILE_FLAGS "-DFILE_FLAG -DIN_OPAQUE_STRING"
)
Thanks,
Steve.
More information about the cmake-developers
mailing list