summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-03-23 22:46:28 +0800
committerruki <[email protected]>2021-03-23 22:46:28 +0800
commit53ec61959556a7efc83a1f1a0c9e17f0dd4466a1 (patch)
tree69bbaec876f4b35a00c55ec3a55781945a027b19
parent052609b2744cd9bcb124984642056ef2eaf2a22c (diff)
update cmake importfiles
-rw-r--r--xmake/modules/target/action/install/cmake_importfiles.lua8
-rw-r--r--xmake/scripts/cmake_importfiles/xxxTargets-debug.cmake10
-rw-r--r--xmake/scripts/cmake_importfiles/xxxTargets-release.cmake10
-rw-r--r--xmake/scripts/cmake_importfiles/xxxTargets.cmake8
4 files changed, 20 insertions, 16 deletions
diff --git a/xmake/modules/target/action/install/cmake_importfiles.lua b/xmake/modules/target/action/install/cmake_importfiles.lua
index c325caece..0279fe2f9 100644
--- a/xmake/modules/target/action/install/cmake_importfiles.lua
+++ b/xmake/modules/target/action/install/cmake_importfiles.lua
@@ -18,10 +18,13 @@
-- @file cmake_importfiles.lua
--
+-- imports
+import("core.project.project")
+
-- get the builtin variables
function _get_builtinvars(target, installdir)
return {TARGETNAME = target:name(),
- TARGETBASENAME = target:basename(),
+ PROJECTNAME = project.name() or target:name(),
TARGETFILE = path.absolute(target:targetfile()),
TARGETKIND = target:is_shared() and "SHARED" or "STATIC",
PACKAGE_VERSION = target:get("version") or "1.0.0",
@@ -32,8 +35,9 @@ end
function _install_cmake_importfile(target, installdir, filename, opt)
-- get import file path
+ local projectname = project.name() or target:name()
local importfile_src = path.join(os.programdir(), "scripts", "cmake_importfiles", filename)
- local importfile_dst = path.join(installdir, opt and opt.libdir or "lib", "cmake", target:name(), (filename:gsub("xxx", target:name())))
+ local importfile_dst = path.join(installdir, opt and opt.libdir or "lib", "cmake", projectname, (filename:gsub("xxx", projectname)))
-- trace
vprint("generating %s ..", importfile_dst)
diff --git a/xmake/scripts/cmake_importfiles/xxxTargets-debug.cmake b/xmake/scripts/cmake_importfiles/xxxTargets-debug.cmake
index 7e4aa5327..f2c64cb0c 100644
--- a/xmake/scripts/cmake_importfiles/xxxTargets-debug.cmake
+++ b/xmake/scripts/cmake_importfiles/xxxTargets-debug.cmake
@@ -5,15 +5,15 @@
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
-# Import target "@TARGETNAME@::@TARGETBASENAME@" for configuration "Debug"
-set_property(TARGET @TARGETNAME@::@TARGETBASENAME@ APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
-set_target_properties(@TARGETNAME@::@TARGETBASENAME@ PROPERTIES
+# Import target "@PROJECTNAME@::@TARGETNAME@" for configuration "Debug"
+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_LOCATION_DEBUG "@TARGETFILE@"
)
-list(APPEND _IMPORT_CHECK_TARGETS @TARGETNAME@::@TARGETBASENAME@ )
-list(APPEND _IMPORT_CHECK_FILES_FOR_@TARGETNAME@::@TARGETBASENAME@ "@TARGETFILE@" )
+list(APPEND _IMPORT_CHECK_TARGETS @PROJECTNAME@::@TARGETNAME@ )
+list(APPEND _IMPORT_CHECK_FILES_FOR_@PROJECTNAME@::@TARGETNAME@ "@TARGETFILE@" )
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/xmake/scripts/cmake_importfiles/xxxTargets-release.cmake b/xmake/scripts/cmake_importfiles/xxxTargets-release.cmake
index fbd5f021e..153362afa 100644
--- a/xmake/scripts/cmake_importfiles/xxxTargets-release.cmake
+++ b/xmake/scripts/cmake_importfiles/xxxTargets-release.cmake
@@ -5,15 +5,15 @@
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
-# Import target "@TARGETNAME@::@TARGETBASENAME@" for configuration "Release"
-set_property(TARGET @TARGETNAME@::@TARGETBASENAME@ APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
-set_target_properties(@TARGETNAME@::@TARGETBASENAME@ PROPERTIES
+# Import target "@PROJECTNAME@::@TARGETNAME@" for configuration "Release"
+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_LOCATION_RELEASE "@TARGETFILE@"
)
-list(APPEND _IMPORT_CHECK_TARGETS @TARGETNAME@::@TARGETBASENAME@ )
-list(APPEND _IMPORT_CHECK_FILES_FOR_@TARGETNAME@::@TARGETBASENAME@ "@TARGETFILE@" )
+list(APPEND _IMPORT_CHECK_TARGETS @PROJECTNAME@::@TARGETNAME@ )
+list(APPEND _IMPORT_CHECK_FILES_FOR_@PROJECTNAME@::@TARGETNAME@ "@TARGETFILE@" )
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/xmake/scripts/cmake_importfiles/xxxTargets.cmake b/xmake/scripts/cmake_importfiles/xxxTargets.cmake
index cbfada0b4..7a0333e24 100644
--- a/xmake/scripts/cmake_importfiles/xxxTargets.cmake
+++ b/xmake/scripts/cmake_importfiles/xxxTargets.cmake
@@ -16,7 +16,7 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
-foreach(_expectedTarget @TARGETNAME@::@TARGETBASENAME@)
+foreach(_expectedTarget @PROJECTNAME@::@TARGETNAME@)
list(APPEND _expectedTargets ${_expectedTarget})
if(NOT TARGET ${_expectedTarget})
list(APPEND _targetsNotDefined ${_expectedTarget})
@@ -44,10 +44,10 @@ unset(_expectedTargets)
# The installation prefix configured by this project.
set(_IMPORT_PREFIX "@IMPORT_PREFIX@")
-# Create imported target @TARGETNAME@::@TARGETBASENAME@
-add_library(@TARGETNAME@::@TARGETBASENAME@ @TARGETKIND@ IMPORTED)
+# Create imported target @PROJECTNAME@::@TARGETNAME@
+add_library(@PROJECTNAME@::@TARGETNAME@ @TARGETKIND@ IMPORTED)
-set_target_properties(@TARGETNAME@::@TARGETBASENAME@ PROPERTIES
+set_target_properties(@PROJECTNAME@::@TARGETNAME@ PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
)