Skip to content

[CMake] Include GNUInstallDirs #709

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

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

jmschonfeld
Copy link
Contributor

The GNUInstallDirs module sets CMAKE_INSTALL_BINDIR which is used on Windows as the destination for installed .dll files. This addresses issues that I saw when building a Windows toolchain where the .dll files were not installed into the toolchain previously, but with this change are correctly installed into the bin directory.

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@itingliu itingliu left a comment

Choose a reason for hiding this comment

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

For my information, cmake's documentation says this defines MAKE_INSTALL_<dir> where dir can be one of many options, BINDIR being one of those. Does the includer automatically choose BINDIR on Windows or was there another config you had to set to get that to be set?

@jmschonfeld
Copy link
Contributor Author

In our case, we use it inside of SwiftFoundationSwiftSupport.cmake which has a _swift_foundation_install_target function that installs a swift target (it installs the binary and copies over swift module files). When it installs the target, it installs via

install(TARGETS ${module}
  ARCHIVE DESTINATION lib/${swift}/${swift_os}
  LIBRARY DESTINATION lib/${swift}/${swift_os}
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

and in this case without this include, CMAKE_INSTALL_BINDIR would be empty. On linux this didn't matter since libraries get installed into the library destination path. However on Windows, .dll files get installed into the runtime destination path while .lib files get installed into the library destination path, so with this runtime destination left empty the installed toolchain was missing the .dll files

@jmschonfeld jmschonfeld merged commit cd6d25b into swiftlang:main Jul 1, 2024
2 checks passed
@jmschonfeld jmschonfeld deleted the cmake/import-gnu branch July 1, 2024 15:45
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.

2 participants