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

Fix include directories in WiseEnumConfig.cmake #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aharrison24
Copy link

When the project is 'installed' via CMake, the headers are copied into
the directory: ${CMAKE_INSTALL_INCLUDE_DIR}/include/wise_enum, so that
users get a 'stuttered' include path:

#include <wise_enum/wise_enum.h>

Currently (without the patch proposed here), the WiseEnumTargets.cmake
file generated by the configure_package_config_file command contains
the lines:

set_target_properties(WiseEnum::wise_enum PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include/wise_enum"
)

I believe the second of those paths is probably incorrect, as it allows
users to include wise_enum with either of:

// Correct. Allowed by ${_IMPORT_PREFIX}/include
#include <wise_enum/wise_enum.h> 

// Incorrect. Allowed by ${_IMPORT_PREFIX}/include/wise_enum
#include <wise_enum.h> 

This negates the benefits of the stuttering scheme, as wise_enum.h is
injected in to the global include path. The proposed patch removes the
${_IMPORT_PREFIX}/include/wise_enum path entry and ensures that
callers cannot use the #include <wise_enum.h> variant.

When the project is 'installed' via CMake, the headers are copied into
the directory: `${CMAKE_INSTALL_INCLUDE_DIR}/include/wise_enum`, so that
users get a 'stuttered' include path:
```
#include <wise_enum/wise_enum.h>
```

Currently (without the patch proposed here), the `WiseEnumTargets.cmake`
file generated by the `configure_package_config_file` command contains
the lines:
```
set_target_properties(WiseEnum::wise_enum PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include/wise_enum"
)
```

I believe the second of those paths is probably incorrect, as it allows
users to include wise_enum with either of:
```
// Correct. Allowed by ${_IMPORT_PREFIX}/include
#include <wise_enum/wise_enum.h> 

// Incorrect. Allowed by ${_IMPORT_PREFIX}/include/wise_enum
#include <wise_enum.h> 
```

This negates the benefits of the stuttering scheme, as `wise_enum.h` is
injected in to the global include path. The proposed patch removes the
`${_IMPORT_PREFIX}/include/wise_enum` path entry and ensures that
callers cannot use the `#include <wise_enum.h>` variant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant