Skip to content
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

Allow config #defines to be written out to custom config/defines.hpp … #2398

Merged
merged 2 commits into from Nov 19, 2016

Conversation

biddisco
Copy link
Contributor

@biddisco biddisco commented Nov 17, 2016

The existing cmake macro can be used to generate #defines for the global
hpx/config/defines.hpp file by using

  hpx_add_config_define(HPX_HAVE_LOGGING)
  hpx_add_config_define(HPX_HAVE_MAX_CPU_COUNT ${HPX_WITH_MAX_CPU_COUNT})
  ...

and then written to hpx/config/defines.hpp using a new macro and
specifying the default namespace

write_config_defines_file(
  TEMPLATE "${PROJECT_SOURCE_DIR}/cmake/templates/config_defines.hpp.in"
  NAMESPACE default
  FILENAME "${CMAKE_BINARY_DIR}/hpx/config/defines.hpp")

This keeps the existing behaviour unchanged.
However a new NAMESPACE feature is supported to allow the user to add

  hpx_add_config_define_namespace(
    DEFINE    HPX_PARCELPORT_VERBS_DEVICE
    VALUE     "\"${HPX_PARCELPORT_VERBS_DEVICE}\""
    NAMESPACE parcelport_verbs)

  hpx_add_config_define_namespace(
    DEFINE    HPX_PARCELPORT_VERBS_INTERFACE
    VALUE     "\"${HPX_PARCELPORT_VERBS_INTERFACE}\""
    NAMESPACE parcelport_verbs)

and then to generate a defines.hpp file as follows

  write_config_defines_file(
    TEMPLATE ""
    NAMESPACE "parcelport_verbs"
    FILENAME "${CMAKE_BINARY_DIR}/hpx/config/parcelport_verbs_defines.hpp")

when no template is specified, the function will generate a copyright
block, and include guard #ifndef...#endif section with the #defines between.
In the above example, the following would be generated from the variables

  #define HPX_PARCELPORT_VERBS_DEVICE "mlx5_0"
  #define HPX_PARCELPORT_VERBS_INTERFACE "ib0"

This feature allows a module (e.g. parcelport) to generate #defines without
writing to the global defines.hpp file and triggering full rebuilds on every change.

…files

The existing cmake macro can be used to generate #defines for the global
hpx/config/defines.hpp file by using

  hpx_add_config_define(HPX_HAVE_LOGGING)
  hpx_add_config_define(HPX_HAVE_MAX_CPU_COUNT ${HPX_WITH_MAX_CPU_COUNT})
  ...

and then written to hpx/config/defines.hpp using a new macro and
specifying the default namespace

write_config_defines_file(
  TEMPLATE "${PROJECT_SOURCE_DIR}/cmake/templates/config_defines.hpp.in"
  NAMESPACE default
  FILENAME "${CMAKE_BINARY_DIR}/hpx/config/defines.hpp")

This keeps the existing behaviour unchanged.
However a new NAMESPACE feature is supported to allow the user to add

  hpx_add_config_define_namespace(
    DEFINE    HPX_PARCELPORT_VERBS_DEVICE
    VALUE     "\"${HPX_PARCELPORT_VERBS_DEVICE}\""
    NAMESPACE parcelport_verbs)

  hpx_add_config_define_namespace(
    DEFINE    HPX_PARCELPORT_VERBS_INTERFACE
    VALUE     "\"${HPX_PARCELPORT_VERBS_INTERFACE}\""
    NAMESPACE parcelport_verbs)

and then to generate a defines.hpp file as follows

  write_config_defines_file(
    TEMPLATE ""
    NAMESPACE "parcelport_verbs"
    FILENAME "${CMAKE_BINARY_DIR}/hpx/config/parcelport_verbs_defines.hpp")

when no template is specified, the function will generate a copyright
block, and include guard #ifndef...#endif section with the #defines between.
In the above example, the following would be generated from the variables

  #define HPX_PARCELPORT_VERBS_DEVICE "mlx5_0"
  #define HPX_PARCELPORT_VERBS_INTERFACE "ib0"

This feature allows a module (e.g. parcelport) to generate #defines without
writing to the global defines.hpp file and triggering full rebuilds on every change.
Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice idea!

@hkaiser
Copy link
Member

hkaiser commented Nov 17, 2016

This fixes #2397

@biddisco biddisco merged commit 61e0269 into master Nov 19, 2016
@biddisco biddisco deleted the fixing_2397 branch November 19, 2016 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants