microsoft / GSL

Guidelines Support Library
Other
6.13k stars 737 forks source link

CMake cleanup #1060

Closed jpr42 closed 1 year ago

jpr42 commented 1 year ago
jpr42 commented 1 year ago

I tested that find_package still works as expected by using the tests directory which invokes find_package(Microsoft.GSL REQUIRED) if it consumed as a top level project.

  • This makes reading the logic easier, and avoids the enable language issue with GNUInstallDirs by having it included after the project call

By issue I just mean how the logic was a bit awkward. Since the guidelineSupportLibrary.cmake relied on GNUInstallDirs but couldn't directly include itself being included before a language is enabled.

include(gsl_functions)

project(GSL
    VERSION 4.0.0
    LANGUAGES CXX // Language is enabled here <- Now you can use GNUInstallDirs
)

Now GNUInstallDirs is included by gsl_install.cmake which handles all the installation.

dmitrykobets-msft commented 1 year ago

Awesome, thanks a lot @jpr42 for this cleanup.