aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/Modules
diff options
context:
space:
mode:
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()