-
Notifications
You must be signed in to change notification settings - Fork 733
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
Install GSL.natvis #1112
Install GSL.natvis #1112
Conversation
@@ -19,8 +17,7 @@ target_compile_features(GSL INTERFACE "cxx_std_14") | |||
# Setup include directory | |||
add_subdirectory(include) | |||
|
|||
# Add natvis file | |||
gsl_add_native_visualizer_support() | |||
target_sources(GSL INTERFACE $<BUILD_INTERFACE:${GSL_SOURCE_DIR}/GSL.natvis>) |
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 does nothing on all platforms except for when generating a visual studio project.
In which case you get the .natvis experience that doesn't affect the PDB.
@@ -46,4 +43,6 @@ if (GSL_INSTALL) | |||
write_basic_package_version_file(${gls_config_version} COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT) | |||
|
|||
install(FILES ${gls_config_version} DESTINATION ${cmake_files_install_dir}) | |||
|
|||
install(FILES GSL.natvis DESTINATION ${cmake_files_install_dir}) |
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.
Installing the file at least gives find_package users a chance to decide what they want to do. Versus nothing which is what they currently get.
endif() | ||
|
||
# add natvis file to the library so it will automatically be loaded into Visual Studio | ||
if(GSL_VS_ADD_NATIVE_VISUALIZERS) |
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 if statement isn't really needed. Just complicates the code IMO. I don't see a reason to keep it.
@jpr42 Thanks a lot for looking into this! Unfortunate that natvis support is so limited, but the cleanup you've done to work around it looks good. |
Turns out supporting GSL.natvis perfectly is quite difficult.
There is no universal way to consume .natvis files that would satisfy everyone.
I thought the solution was to use the /NATVIS linker option. But it turns out that actually embeds information into the PDB. So I'm not sure how to properly support the Ninja generator...
That's not even accounting for the fact target_link_options doesn't play nicely with /NATVIS when installing.
When you just add the file via target_sources the visual studio solution will just pick it up and recognize it without adding it to the PDB file. Which won't affect the binary and is what most devs want.
This all comes down to the fact that /NATVIS files have native integration with visual studio that makes it difficult to use with non-visual studio solutions. /NATVIS almost works but embeds itself into the PDB which not everyone wants, and not everyone generates PDBs either.
Docs for natvis files and /NATVIS
So my current solution is to just simplify the existing CMake code, and install the natvis so the user can decide.
closes #1084