aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/Modules
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2022-11-16 07:59:55 +0100
committerPierre Ossman <ossman@cendio.se>2023-01-10 19:41:13 +0100
commit0043c557fcfece5cc45f41293b06548474362b20 (patch)
tree8097b4ae21a61e0af8d8ae8377f4b0c48431dcf7 /cmake/Modules
parent11ebff62d7ba49c72132dd5b731af70e3ddab75f (diff)
downloadtigervnc-0043c557fcfece5cc45f41293b06548474362b20.tar.gz
tigervnc-0043c557fcfece5cc45f41293b06548474362b20.zip
Create .la files at the end of the cmake run
We might not have all the necessary information, e.g. all targets might not exist yet, until we're done going through all CMakeLists.
Diffstat (limited to 'cmake/Modules')
-rw-r--r--cmake/Modules/CMakeMacroLibtoolFile.cmake43
1 files changed, 32 insertions, 11 deletions
diff --git a/cmake/Modules/CMakeMacroLibtoolFile.cmake b/cmake/Modules/CMakeMacroLibtoolFile.cmake
index 7395a3f1..12ba9909 100644
--- a/cmake/Modules/CMakeMacroLibtoolFile.cmake
+++ b/cmake/Modules/CMakeMacroLibtoolFile.cmake
@@ -1,4 +1,20 @@
-macro(libtool_create_control_file _target)
+# FIXME: Since we cannot require CMake 3.17, we cannot used deferred
+# functions, and hence we have to do something similar manually
+
+set_property(GLOBAL PROPERTY LIBTOOL_TARGETS "")
+
+function(libtool_create_control_file target)
+ set_property(GLOBAL APPEND PROPERTY LIBTOOL_TARGETS ${target})
+endfunction()
+
+function(libtool_generate_control_files)
+ get_property(LIBTOOL_TARGETS GLOBAL PROPERTY LIBTOOL_TARGETS)
+ foreach(target ${LIBTOOL_TARGETS})
+ libtool_generate_control_file(${target})
+ endforeach()
+endfunction()
+
+function(libtool_generate_control_file _target)
get_target_property(_target_type ${_target} TYPE)
message("-- Creating static libtool control file for target ${_target}")
@@ -141,9 +157,11 @@ macro(libtool_create_control_file _target)
endif()
endforeach()
+ get_target_property(_binary_dir ${_target} BINARY_DIR)
+
# Write the libtool control file for the static library
set(_lname ${CMAKE_STATIC_LIBRARY_PREFIX}${_target})
- set(_laname ${CMAKE_CURRENT_BINARY_DIR}/${_lname}.la)
+ set(_laname ${_binary_dir}/${_lname}.la)
file(WRITE ${_laname} "# ${_lname}.la - a libtool library file\n# Generated by ltmain.sh (GNU libtool) 2.2.6b\n")
file(APPEND ${_laname} "dlname=''\n\n")
@@ -162,15 +180,18 @@ macro(libtool_create_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(TARGET ${_target} POST_BUILD COMMAND
- "${CMAKE_COMMAND}" -E touch "${_laname}")
-
+ add_custom_command(OUTPUT "${_laname}" DEPENDS ${_target}
+ COMMENT "Updating timestamp on ${_lname}.la"
+ COMMAND "${CMAKE_COMMAND}" -E touch "${_laname}")
# Add custom command to symlink the static library so that autotools finds
# the library in .libs. These are executed after the specified target build.
- add_custom_command(TARGET ${_target} POST_BUILD COMMAND
- "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/.libs")
- add_custom_command(TARGET ${_target} POST_BUILD COMMAND
- "${CMAKE_COMMAND}" -E create_symlink ../${_lname}${CMAKE_STATIC_LIBRARY_SUFFIX} "${CMAKE_CURRENT_BINARY_DIR}/.libs/${_lname}${CMAKE_STATIC_LIBRARY_SUFFIX}")
-
-endmacro()
+ set(_libname ${_binary_dir}/.libs/${_lname}${CMAKE_STATIC_LIBRARY_SUFFIX})
+ add_custom_command(OUTPUT "${_libname}" DEPENDS ${_target}
+ COMMENT "Creating symlink .libs/${_lname}${CMAKE_STATIC_LIBRARY_SUFFIX}"
+ COMMAND "${CMAKE_COMMAND}" -E make_directory "${_binary_dir}/.libs"
+ COMMAND "${CMAKE_COMMAND}" -E create_symlink ../${_lname}${CMAKE_STATIC_LIBRARY_SUFFIX} "${_libname}")
+
+ add_custom_target(${_target}.la ALL
+ DEPENDS "${_laname}" "${_libname}")
+endfunction()