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 CMake 3.31 warnings #59703

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ if(NOT "${CMAKE_VERSION}" VERSION_LESS "3.27")
# include(Dart) still used, as is the "Experimental" target
cmake_policy(SET CMP0145 OLD)
endif()
if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.31")
cmake_policy(SET CMP0177 NEW)
endif()

# don't relink it only the shared object changes
set(CMAKE_LINK_DEPENDS_NO_SHARED ON)
Expand Down
4 changes: 2 additions & 2 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ foreach(pyfile ${PY_FILES})
COMMAND ${CMAKE_COMMAND} -E make_directory "${QGIS_PYTHON_OUTPUT_DIRECTORY}"
COMMAND ${CMAKE_COMMAND} -E copy ${pyfile} "${QGIS_PYTHON_OUTPUT_DIRECTORY}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${pyfile}
# DEPENDS ${pyfile}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the story here? Does newer cmake auto-determine this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, that has never been valid and is ignored: cf https://cmake.org/cmake/help/latest/command/add_custom_command.html#build-events
We'd need using some other CMake syntax to handle dependencies

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like it was there up till 3.31: https://cmake.org/cmake/help/v3.31/command/add_custom_command.html#depends

You aren't looking at the variant of add_custom_command() we use in the lines I modified. There are 2: the one whose first keyword is OUTPUT and which accepts a DEPENDS, and the one we use here which starts with TARGET and doesn't accept DEPENDS. I've been confused by that many times
If you look way back like 3.16 the TARGET variant has never accepted DEPENDS: https://cmake.org/cmake/help/v3.16/command/add_custom_command.html#build-events . I assume it was silently ignored, and in 3.31 likely due to people complaining their DEPENDS was ignored, they start warning.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, thanks for the explanation! If this was never working then let's just remove those lines instead of commenting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I had an hesitation if we'd want to keep them as a memory that we may want to do something more involved to track dependencies. But I'm fine removing them too

)
PY_COMPILE(pyutils "${QGIS_PYTHON_OUTPUT_DIRECTORY}/${pyfile}")
endforeach(pyfile)
Expand Down Expand Up @@ -448,7 +448,7 @@ foreach(module ${PY_MODULES})
COMMAND ${CMAKE_COMMAND} -E make_directory "${QGIS_PYTHON_OUTPUT_DIRECTORY}/${subdir}"
COMMAND ${CMAKE_COMMAND} -E copy ${pyfile} "${QGIS_PYTHON_OUTPUT_DIRECTORY}/${subdir}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${PY_FILES}
# DEPENDS ${PY_FILES}
)
endforeach(pyfile)
PY_COMPILE(py${module} "${QGIS_PYTHON_OUTPUT_DIRECTORY}/${module_name}")
Expand Down
4 changes: 2 additions & 2 deletions python/console/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ add_custom_command(TARGET pyconsole
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${UI_FILES} ${PYTHON_OUTPUT_DIRECTORY}/console
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${UI_FILES}
# DEPENDS ${UI_FILES}
)
foreach(pyfile ${PY_CONSOLE_FILES})
add_custom_command(TARGET pyconsole
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${pyfile} ${PYTHON_OUTPUT_DIRECTORY}/console
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${pyfile}
# DEPENDS ${pyfile}
)
endforeach(pyfile)
PY_COMPILE(pyconsole "${PYTHON_OUTPUT_DIRECTORY}/console")
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ macro (PLUGIN_INSTALL plugin subdir )
add_dependencies(zzz-${plugin}-stageinstall zzz-${plugin}-depend)

add_custom_command(TARGET zzz-${plugin}-stageinstall
COMMAND ${CMAKE_COMMAND} -P ${_cmake}
POST_BUILD COMMAND ${CMAKE_COMMAND} -P ${_cmake}
)

add_custom_target(clean-staged-${plugin}
Expand Down
2 changes: 1 addition & 1 deletion python/processing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ foreach(pyfile ${PY_FILES})
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${pyfile} "${QGIS_PYTHON_OUTPUT_DIRECTORY}/processing"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${pyfile}
# DEPENDS ${pyfile}
)
PY_COMPILE(pyutils "${QGIS_PYTHON_OUTPUT_DIRECTORY}/processing/${pyfile}")
endforeach(pyfile)
4 changes: 2 additions & 2 deletions python/pyplugin_installer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ add_custom_command(TARGET pyplugin-installer
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${UI_FILES} ${PYTHON_OUTPUT_DIRECTORY}/pyplugin_installer
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${UI_FILES}
# DEPENDS ${UI_FILES}
)

foreach(pyfile ${PY_PLUGININSTALLER_FILES})
add_custom_command(TARGET pyplugin-installer
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${pyfile} ${PYTHON_OUTPUT_DIRECTORY}/pyplugin_installer
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${pyfile}
# DEPENDS ${pyfile}
)
endforeach(pyfile)
PY_COMPILE(pyplugin-installer "${PYTHON_OUTPUT_DIRECTORY}/pyplugin_installer")
Expand Down
2 changes: 1 addition & 1 deletion python/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ foreach(pyfile ${PY_FILES})
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${pyfile} "${QGIS_PYTHON_OUTPUT_DIRECTORY}/testing"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${pyfile}
# DEPENDS ${pyfile}
)
PY_COMPILE(pyutils "${QGIS_PYTHON_OUTPUT_DIRECTORY}/testing/${pyfile}")
endforeach(pyfile)
Expand Down
Loading