-
Notifications
You must be signed in to change notification settings - Fork 12
Sankel feedback on BCM #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,11 @@ bcm_find_package | |
|
||
This works the same as cmake's ``find_package`` except in addition, it will keep track of the each call to ``bcm_find_package`` in the project. Functions like ``bcm_package`` and ``bcm_boost_package`` will include these dependencies automatically in cmake's package config that gets generated. | ||
|
||
.. I don't understand why 'bcm_find_package' needs to do anything other than | ||
what the standard find_package does. Can't the targets exported by | ||
'find_package' carry all the "package config" information needed for '.pg' | ||
file generation? | ||
|
||
----------- | ||
bcm_package | ||
----------- | ||
|
@@ -18,10 +23,17 @@ bcm_package | |
|
||
This setups a non-boost package in cmake. This is similar to ``bcm_boost_package`` but with extra flexibility as it does not have boost specific conventions. This function creates a library target that will be installed and exported. In addition, the target will be setup to auto-link for the tests. | ||
|
||
.. "setup to auto-link for the tests". This is a bit unclear. Maybe say | ||
"Subsequent uses of 'bcm_test' will automatically include this target as a | ||
dependency" or something along these lines. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I think that sounds better. Although "subsequent uses" is not needed. If you write: bcm_test(...)
bcm_package(...) It will still use the package. This is because |
||
|
||
.. option:: <package-name> | ||
|
||
The name of the package. This is both the name of the library target and the cmake package config that can be used with ``find_package(<package-name>)``. | ||
|
||
.. This is inconsistent with 'bcm_boost_package' below. Why does Boost have to | ||
be special? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
.. option:: VERSION <version> | ||
|
||
Sets the version of the package. | ||
|
@@ -30,6 +42,10 @@ Sets the version of the package. | |
|
||
This will parse the version from a header file. It will parse the macros defined in the header as ``<prefix>_<package-name>_VERSION_MAJOR``, ``<prefix>_<package-name>_VERSION_MINOR``, and ``<prefix>_<package-name>_VERSION_PATCH``. The ``prefix`` by default is the package name in all caps, but can be set using the ``VERSION_PREFIX`` option. | ||
|
||
.. I'm a bit unsure about the above and following option. I think many codebases | ||
use their own "version header" format and hardcoding this one is a but | ||
unflexible. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but if a project uses a different version header format, then they can parse the header themselves and set the header: # Parse custom version header
parse_header_version_header(MYVERSION)
bcm_setup_version(VERSION ${MYVERSION}) This format is what is used by some boost projects and kde projects as well(they provided similar functionality in their cmake modules: ecm_setup_version). |
||
|
||
.. option:: VERSION_PREFIX <prefix> | ||
|
||
This sets the prefix that macros used to define the version will use. | ||
|
@@ -74,3 +90,5 @@ The source files to build the library. | |
|
||
This specifies internal boost dependencies, that is, dependencies on other boost libraries. The libraries should not be prefixed with ``boost_`` nor ``boost::``. | ||
|
||
.. Why not use 'boost::' here? This special casing will be unobvious for casual | ||
readers of code which uses this library. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is good point. I didn't because it always needs boost dependencies, so it might be a good idea to always require it to make it explicit that its a boost dependency: bcm_boost_package(boost_core
VERSION 1.61.0
DEPENDS
boost::assert
boost::config
) I don't know if it always helps clarity as the package is declared with |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,9 @@ CXX_EXCEPTIONS | |
|
||
This property can be used to enable or disable C++ exceptions. This can be applied at global, directory or target scope. At global scope this defaults to On. | ||
|
||
.. Why these particular C++ options? If we go down this route, won't someone | ||
always be dissappointed because their particular option won't be here? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is used by many tests in boosts, and there may need to be more added to support other options as well. |
||
|
||
-------- | ||
CXX_RTTI | ||
-------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,14 @@ Motivation | |
|
||
This provides cmake modules that can be re-used by boost and other dependencies. It provides modules to reduce the boilerplate for installing, versioning, setting up package config, and creating tests. | ||
|
||
.. It isn't immediately clear what this is going to provide for the user. | ||
Perhaps something like this: BCM provides CMake functions for building and | ||
releasing software packages. It is a simplification of CMake's builtin | ||
functions and additionally incorporates pkg-config support. | ||
|
||
.. This section should be expanded as well. Perhaps with a side-by-side | ||
comparison of the CMake way of doing things in comparison to the BCM way. | ||
|
||
===== | ||
Usage | ||
===== | ||
|
@@ -44,6 +52,10 @@ The BCM modules provide some high-level cmake functions to take care of all the | |
|
||
bcm_auto_pkgconfig() | ||
|
||
.. The above snippet is mysterious for folks not accustomed to this library. | ||
Where are the '.cpp' files being added? Where are the include files? What | ||
do these functions do? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I need to explain this better. This relies on boost's directory structure to find the includes. Of course, Boost.Core does not have any source files, so that is why it is not mentioned here. |
||
|
||
This sets up the Boost.Config cmake with the version ``1.61.0``. More importantly the user can now install the library, like this:: | ||
|
||
mkdir build | ||
|
@@ -63,6 +75,8 @@ Or if the user isn't using cmake, then ``pkg-config`` can be used instead:: | |
|
||
g++ `pkg-config boost_config --cflags --libs` foo.cpp | ||
|
||
.. Very nice! | ||
|
||
------------ | ||
Dependencies | ||
------------ | ||
|
@@ -76,6 +90,12 @@ For dependencies on other boost libraries, they can be listed with the ``DEPENDS | |
config | ||
) | ||
|
||
.. This is interesting. I like the reduction in boilerplate, but I question the | ||
choice to go in such a different direction from the standard CMake way of | ||
doing things. It strikes me as a possibly leaky abstraction where folks will | ||
have a mix of code which uses both the CMake way and the BCM way; maintainers | ||
will have to be familiar with both. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The bcm_find_package(boost_assert)
bcm_find_package(boost_config)
bcm_boost_package(boost_core
VERSION 1.61.0
)
target_link_libraries(boost_core boost::assert boost::config) We will just need to hijack Of course, I like the terse version more. I don't think its a problem mixing bcm functions with cmake functions. Its designed to do that. Also, I think it helps authors who are not familiar with cmake. Finally, there is no tool to ensure the correctness of the above snippet. An author may do: bcm_find_package(boost_assert)
bcm_find_package(boost_config)
bcm_boost_package(boost_core
VERSION 1.61.0
)
target_link_libraries(boost_core boost::config) Which is a mistake, but there is no way to detect this mistake. Of course, for external dependencies, it needs to be done like above: bcm_find_package(ZLib)
bcm_boost_package(boost_core
VERSION 1.61.0
DEPENDS
assert
config
)
target_link_libraries(boost_core Zlib::ZLib) However, boost has very little external dependencies. |
||
|
||
This will call ``find_package`` for the dependency and link it in the library. This structured this way to be able to support superbuilds(ie building all libraries together) in the future. | ||
|
||
----- | ||
|
@@ -86,6 +106,11 @@ The BCM modules provide functions for creating tests that integrate into cmake's | |
|
||
bcm_test(NAME config_test_c SOURCES config_test_c.c) | ||
|
||
.. 'that' should be 'which' in the first sentence in the above paragraph I'm | ||
pretty sure. | ||
|
||
This will compile the ``SOURCES`` and run them. Also, there is no need to link in the ``boost_config``, as ``bcm_test`` will automatically link it in for us. Also, tests can be specified as compile-only or as expected to fail:: | ||
|
||
bcm_test(NAME test_thread_fail1 SOURCES threads/test_thread_fail1.cpp COMPILE_ONLY WILL_FAIL) | ||
|
||
.. Nice! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to track the dependency, it works exactly as
find_package
does except it stores this in a variable, so when 'foo-config.cmake' is generated, it will generate a callfind_dependency
for eachbcm_find_package
that is called. This only happens withbcm_boost_package
orbcm_package
. When usingbcm_auto_export
the user will still need to explicitly define each dependency.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the
PACKAGE_FOUND
property could be used for this, however, this is a global property, so it will break superproject builds, I believe. Let me test this.It could possible be named differently as well, since its only to be used for non-build dependencies.