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

Update cmake_importfiles #5733

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 11 additions & 1 deletion xmake/modules/target/action/install/cmake_importfiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function _get_builtinvars(target, installdir)
TARGETFILENAME = target:targetfile() and _get_libfile(target, installdir),
TARGETKIND = target:is_headeronly() and "INTERFACE" or (target:is_shared() and "SHARED" or "STATIC"),
PACKAGE_VERSION = target:get("version") or "1.0.0",
TARGET_PTRBYTES = target:is_arch("x86", "i386") and "4" or "8"}
TARGET_PTRBYTES = target:is_arch("armeabi", "armeabi-v7a", "x86", "mips", "i386", "armv7", "armv7s", "mipsel", "wasm32") and "4" or "8"}
end

-- install cmake config file
Expand Down Expand Up @@ -130,6 +130,16 @@ function _install_cmake_targetfile(target, installdir, filename, opt)
local value = builtinvars[variable]
return type(value) == "function" and value() or value
end)
local libfile = path.filename(target:targetfile())
local postfix = is_mode("debug") and "DEBUG" or "RELEASE"
if target:is_shared() and (_get_libfile(target, installdir) ~= libfile) then
-- On DLL platforms, the import library is named differently from the target file
content = content:gsub("# IMPORTED_IMPLIB_" .. postfix, "IMPORTED_IMPLIB_" .. postfix)
content = content:gsub(
"IMPORTED_LOCATION_" .. postfix .. " \"%%${_IMPORT_PREFIX}/lib/.-\"",
"IMPORTED_LOCATION_" .. postfix .. " \"%%${_IMPORT_PREFIX}/bin/" .. libfile .. "\""
)
Yc7521 marked this conversation as resolved.
Show resolved Hide resolved
end
io.writefile(importfile_dst, content)
end
end
Expand Down
1 change: 1 addition & 0 deletions xmake/scripts/cmake_importfiles/xxxTargets-debug.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
set_property(TARGET @PROJECTNAME@::@TARGETNAME@ APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(@PROJECTNAME@::@TARGETNAME@ PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "ASM_NASM;C"
# IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/@TARGETFILENAME@"
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/@TARGETFILENAME@"
)

Expand Down
1 change: 1 addition & 0 deletions xmake/scripts/cmake_importfiles/xxxTargets-release.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
set_property(TARGET @PROJECTNAME@::@TARGETNAME@ APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(@PROJECTNAME@::@TARGETNAME@ PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "ASM_NASM;C"
# IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/@TARGETFILENAME@"
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/@TARGETFILENAME@"
)

Expand Down