Skip to content

Commit

Permalink
Avoid .la files getting removed on "make clean"
Browse files Browse the repository at this point in the history
These are generated during the cmake stage, but cmake thinks they are
generated during the build stage because of our rule to update the
timestamp on them. As a result, it thinks they should be removed when
doing "make clean".

There doesn't seems to be an easy way to tell cmake to leave these
alone. So instead, point cmake to a different marker file when updating
the timestamps. We don't care if that gets removed as it has no valuable
contents.
  • Loading branch information
CendioOssman committed Oct 29, 2024
1 parent 9e15952 commit 9f51fcf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmake/Modules/CMakeMacroLibtoolFile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ function(libtool_generate_control_file _target)
file(APPEND ${_laname} "libdir='/usr/lib'\n\n")

# Make sure the timestamp is updated to trigger other make invocations
add_custom_command(OUTPUT "${_laname}" DEPENDS ${_target}
set(_lamarker ${_binary_dir}/.${_lname}.la.fresh)
add_custom_command(OUTPUT "${_lamarker}" DEPENDS ${_target}
COMMENT "Updating timestamp on ${_lname}.la"
COMMAND "${CMAKE_COMMAND}" -E touch "${_lamarker}"
COMMAND "${CMAKE_COMMAND}" -E touch "${_laname}")

# Add custom command to symlink the static library so that autotools finds
Expand All @@ -193,5 +195,5 @@ function(libtool_generate_control_file _target)
COMMAND "${CMAKE_COMMAND}" -E create_symlink ../${_lname}${CMAKE_STATIC_LIBRARY_SUFFIX} "${_libname}")

add_custom_target(${_target}.la ALL
DEPENDS "${_laname}" "${_libname}")
DEPENDS "${_lamarker}" "${_libname}")
endfunction()

0 comments on commit 9f51fcf

Please sign in to comment.