[CMake] Syntax to document cmake files, functions and macros

2018-12-24 Thread Olivier Croquette

Hello,

I have quite a few .cmake files that I want to document. They define 
functions, macros, and variables, and I was wondering if there is any 
standard or tooling to help.


Is there a complete specification of the syntax used in the CMake 
distribution itself?


E.g.:

add_executable( [WIN32] [MACOSX_BUNDLE]
   [EXCLUDE_FROM_ALL]
   [source1] [source2 ...])

add_definitions(-DFOO -DBAR ...)

add_custom_target(Name [ALL] [command1 [args1...]]
  [COMMAND command2 [args2...] ...]
  [DEPENDS depend depend depend ... ]
  [BYPRODUCTS [files...]]
  [WORKING_DIRECTORY dir]
  [COMMENT comment]
  [VERBATIM] [USES_TERMINAL]
  [COMMAND_EXPAND_LISTS]
  [SOURCES src1 [src2...]])

It looks like the documentation is not completely consistent by the way, 
for instance, the first argument of add_executable is , and of 
add_custom_target is Name, although is same situation, isn't it?



For functions and macros, I can reuse this syntax, is there anything 
similar for documenting a file, or variables?


More generally, is there anything like Doxygen, Javadoc, both in terms 
of syntax and tooling to generate documents from source code?


Olivier

--

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:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] Syntax to document cmake files, functions and macros

2018-12-24 Thread Oleksii Vilchanskyi
On 12/24/18 12:01 PM, Olivier Croquette wrote:
> I have quite a few .cmake files that I want to document. They define
> functions, macros, and variables, and I was wondering if there is any
> standard or tooling to help.

Yes, see [1]. You can find concrete examples at [2].

[1]:

[2]: 



signature.asc
Description: OpenPGP digital signature
-- 

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:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] Get linker flags / include directories for a library target

2018-12-24 Thread Robert Maynard via CMake
That functionality exists in the C++ side of the code base and is run
during the 'generate' stage  ( CMakeLists are parsed during
'configure', than a 'generate' step is run ).

To get access to how import targets and generator expressions are
resolved you have two options.
1. You can try to use file(GENERATE but it doesn't support all the
generator expressions currently
2. You use cmake-server
(https://cmake.org/cmake/help/latest/manual/cmake-server.7.html) to
query a build directory for all this information.

On Fri, Dec 21, 2018 at 9:12 AM Unknown  wrote:
>
> Hello Kai,
>
> thanks for your suggestion. I tried the property,
> but I just got "foo_linker_flags-NOTFOUND" as a
> result (I am using cmake 3.13.1 btw). The
> same goes for
>
> LINK_OPTIONS, and
> INTERFACE_LINK_OPTIONS.
>
> I tried using the INTERFACE_LINK_LIBRARIES property
> instead. The resulting list contains things I can use,
> such as /usr/lib/libz.so
>
> However, I am using another cmake imported library.
> Therefore, the list contains some libbaz::libbaz
> dependency as well.
>
> In order to get the actual list of libraries, I would
> have to also resolve these names.
>
> But this has to be done somewhere during the
> generation of the Makefiles, so that functionality
> must exist somewhere in cmake.
>
>
> On Fri, 2018-12-21 at 09:33 +0100, Kai Wolf wrote:
> > You can ask a CMake build target for its properties using
> > get_target_property().
> > For instance, to retrieve the linker flags for a given target foo,
> > you’d write:
> >
> > get_target_prooperty(foo_linker_flags foo LINK_FLAGS)
> >
> > See [1] for a list of valid parameters.
> >
> > Greetings,
> >
> > Kai
> >
> > [1]
> > https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-targets
> >
> > http://kai-wolf.me
> > http://effective-cmake.com
> >
> > > Am 20.12.2018 um 23:14 schrieb Unknown :
> > >
> > > Dear community,
> > >
> > > I have been wondering on multiple occasions about how to get the
> > > linker flags (i.e. all -llib -Ldir) and include flags (-Idir)
> > > for a library (i.e. a target added to the project using
> > > add_library) within a cmake.
> > >
> > > There are many cases in which the flags are required, noticeably
> > > generating a suitable pkg-config file or creating a wrappers around
> > > C/C++ libraries.
> > >
> > > I think that it should be possible to derive the flags from
> > > some of the target properties of the library, but I don't
> > > know exactly how.
> > >
> > > Could you give me a hand?
> > >
> > > ax487
> > >
> > > --
> > >
> > > 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:
> > > https://cmake.org/mailman/listinfo/cmake
>
> --
>
> 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:
> https://cmake.org/mailman/listinfo/cmake
-- 

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:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] Get linker flags / include directories for a library target

2018-12-24 Thread Bo Zhou
All the flags/options in the CMake they could be considered as a list.

So it's much more easier to handle it as this

set(WIN_DEFINITIONS -DNOMINMAX)


Remember the list is the object, so we could construct the new list for the
specific target.

Then to the specific target, just use the 3 commands.

target_compile_options()

target_include_directories()
target_link_libraries()


We use this method to organize the cross-platform with library and
executable without any problem, and super easy to control and manage.

Thanks.


On Fri, Dec 21, 2018 at 7:19 AM Unknown  wrote:

> Dear community,
>
> I have been wondering on multiple occasions about how to get the
> linker flags (i.e. all -llib -Ldir) and include flags (-Idir)
> for a library (i.e. a target added to the project using
> add_library) within a cmake.
>
> There are many cases in which the flags are required, noticeably
> generating a suitable pkg-config file or creating a wrappers around
> C/C++ libraries.
>
> I think that it should be possible to derive the flags from
> some of the target properties of the library, but I don't
> know exactly how.
>
> Could you give me a hand?
>
> ax487
>
> --
>
> 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:
> https://cmake.org/mailman/listinfo/cmake
>
-- 

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:
https://cmake.org/mailman/listinfo/cmake