-
Notifications
You must be signed in to change notification settings - Fork 454
Only add the uninstall target if the C driver is the top level project #1352
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
Changes from all commits
73e9f24
de2558e
976ab56
f06de4f
c42d9be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,12 @@ if (WIN32) | |
") | ||
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}" DESTINATION "${UNINSTALL_PROG_DIR}" PERMISSIONS ${UNINSTALL_PERMISSIONS}) | ||
|
||
add_custom_target (uninstall | ||
COMMAND call "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}" | ||
) | ||
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") | ||
# Define the `uninstall` target if the C driver is the top-level project. | ||
add_custom_target (uninstall | ||
COMMAND call "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}" | ||
) | ||
endif () | ||
else () | ||
install (CODE " | ||
string(REPLACE \";\" \"\\n\" MONGOC_INSTALL_MANIFEST_CONTENT | ||
|
@@ -50,7 +53,10 @@ else () | |
") | ||
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}" DESTINATION "${UNINSTALL_PROG_DIR}" PERMISSIONS ${UNINSTALL_PERMISSIONS}) | ||
|
||
add_custom_target (uninstall | ||
COMMAND sh "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}" | ||
) | ||
Comment on lines
-53
to
-55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest a different design: if(NOT TARGET uninstall)
add_custom_target(uninstall)
endif()
add_custom_target(mongo-c-driver-uninstall COMMAND [do the uninstall])
add_dependencies(uninstall mongo-c-driver-uninstall) This way, we "add" to an existing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be preferable to defer the responsibility of including C Driver files in the uninstall command to the CXX Driver (top-level project) rather than unconditionally hooking into it from the C Driver side? The CXX Driver may want to uninstall the C Driver as part of its uninstall command, but another top-level project (i.e. 3rd party that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's tricky, since the C driver unconditionally(?) adds its install rules, which the parent may not want, which would imply that it should also unconditionally(?) add its uninstall rules as well. It is possible to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A quick local test suggests that
combined with CMake documentation for
This is also consistent with this comment by a CMake maintainer, although their remarks are not as confident as I would have hoped:
The documentation stating "undefined behavior" seems to have been changed from CMake 3.17 to CMake 3.18 (current wording):
Summary: there seems to be a lot more "should" qualifiers to this than one would expect or hope, but it should behave as expected ( |
||
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") | ||
kkloberdanz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Define the `uninstall` target if the C driver is the top-level project. | ||
add_custom_target (uninstall | ||
COMMAND sh "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}" | ||
) | ||
endif () | ||
endif () |
Uh oh!
There was an error while loading. Please reload this page.