summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/command/install.rst2
-rw-r--r--Help/manual/cmake-buildsystem.7.rst4
-rw-r--r--Help/prop_tgt/ENABLE_EXPORTS.rst4
-rw-r--r--Help/prop_tgt/IMPORTED_IMPLIB.rst6
-rw-r--r--Help/release/dev/aix.rst10
-rw-r--r--Modules/Platform/AIX-GNU.cmake4
-rw-r--r--Modules/Platform/AIX-XL.cmake4
-rw-r--r--Modules/Platform/AIX.cmake2
-rwxr-xr-xModules/Platform/AIX/ExportImportList7
-rw-r--r--Source/cmComputeLinkInformation.cxx9
-rw-r--r--Source/cmGeneratorTarget.cxx3
-rw-r--r--Source/cmInstallCommand.cxx3
-rw-r--r--Source/cmTarget.cxx9
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-check.py9
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake2
18 files changed, 68 insertions, 16 deletions
diff --git a/Help/command/install.rst b/Help/command/install.rst
index ab6fef6..5affc5b 100644
--- a/Help/command/install.rst
+++ b/Help/command/install.rst
@@ -126,6 +126,8 @@ project. There are several kinds of target files that may be installed:
marked with the ``FRAMEWORK`` property on macOS (see ``FRAMEWORK``
below.) For DLL platforms (all Windows-based systems including
Cygwin), the DLL import library is treated as an ``ARCHIVE`` target.
+ On AIX, the linker import file created for executables with
+ :prop_tgt:`ENABLE_EXPORTS` is treated as an ``ARCHIVE`` target.
``LIBRARY``
Module libraries are always treated as ``LIBRARY`` targets. For non-
diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst
index 8cd6e68..d8142a2 100644
--- a/Help/manual/cmake-buildsystem.7.rst
+++ b/Help/manual/cmake-buildsystem.7.rst
@@ -811,6 +811,10 @@ An *archive* output artifact of a buildsystem target may be:
executable target created by the :command:`add_executable` command
when its :prop_tgt:`ENABLE_EXPORTS` target property is set.
+* On AIX: the linker import file (e.g. ``.imp``) of an executable target
+ created by the :command:`add_executable` command when its
+ :prop_tgt:`ENABLE_EXPORTS` target property is set.
+
The :prop_tgt:`ARCHIVE_OUTPUT_DIRECTORY` and :prop_tgt:`ARCHIVE_OUTPUT_NAME`
target properties may be used to control archive output artifact locations
and names in the build tree.
diff --git a/Help/prop_tgt/ENABLE_EXPORTS.rst b/Help/prop_tgt/ENABLE_EXPORTS.rst
index daef78b..0b1064a 100644
--- a/Help/prop_tgt/ENABLE_EXPORTS.rst
+++ b/Help/prop_tgt/ENABLE_EXPORTS.rst
@@ -19,6 +19,10 @@ varies by platform:
* On macOS, loadable modules link to the executable itself using the
``-bundle_loader`` flag.
+* On AIX, a linker "import file" is created along with the executable
+ to list the exported symbols for import when linking other targets.
+ Loadable modules link to the import file to get the symbols.
+
* On other platforms, loadable modules are simply linked without
referencing the executable since the dynamic loader will
automatically bind symbols when the module is loaded.
diff --git a/Help/prop_tgt/IMPORTED_IMPLIB.rst b/Help/prop_tgt/IMPORTED_IMPLIB.rst
index 77fb552..c8b6fde 100644
--- a/Help/prop_tgt/IMPORTED_IMPLIB.rst
+++ b/Help/prop_tgt/IMPORTED_IMPLIB.rst
@@ -3,5 +3,7 @@ IMPORTED_IMPLIB
Full path to the import library for an ``IMPORTED`` target.
-Set this to the location of the ``.lib`` part of a Windows DLL. Ignored
-for non-imported targets.
+Set this to the location of the ``.lib`` part of a Windows DLL, or on
+AIX set it to an import file created for executables that export symbols
+(see the :prop_tgt:`ENABLE_EXPORTS` target property).
+Ignored for non-imported targets.
diff --git a/Help/release/dev/aix.rst b/Help/release/dev/aix.rst
new file mode 100644
index 0000000..c24872e
--- /dev/null
+++ b/Help/release/dev/aix.rst
@@ -0,0 +1,10 @@
+aix
+---
+
+* On AIX, executables using the :prop_tgt:`ENABLE_EXPORTS` target property
+ now produce a linker import file with a ``.imp`` extension in addition
+ to the executable file. Plugins (created via :command:`add_library` with
+ the ``MODULE`` option) that use :command:`target_link_libraries` to link
+ to the executable for its symbols are now linked using the import file.
+ The :command:`install(TARGETS)` command now installs the import file as
+ an ``ARCHIVE`` artifact.
diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake
index cec71a1..9e981c6 100644
--- a/Modules/Platform/AIX-GNU.cmake
+++ b/Modules/Platform/AIX-GNU.cmake
@@ -34,6 +34,6 @@ macro(__aix_compiler_gnu lang)
)
set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS
- "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/objects.exp <OBJECTS>"
- "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+ "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -l . <OBJECTS>"
+ "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<TARGET_IMPLIB> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
endmacro()
diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake
index 52292bd..3424e2c 100644
--- a/Modules/Platform/AIX-XL.cmake
+++ b/Modules/Platform/AIX-XL.cmake
@@ -32,6 +32,6 @@ macro(__aix_compiler_xl lang)
)
set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS
- "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/objects.exp <OBJECTS>"
- "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+ "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -l . <OBJECTS>"
+ "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<TARGET_IMPLIB> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
endmacro()
diff --git a/Modules/Platform/AIX.cmake b/Modules/Platform/AIX.cmake
index 551a995..03cef51 100644
--- a/Modules/Platform/AIX.cmake
+++ b/Modules/Platform/AIX.cmake
@@ -1,5 +1,7 @@
set(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so
+set(CMAKE_AIX_IMPORT_FILE_PREFIX "")
+set(CMAKE_AIX_IMPORT_FILE_SUFFIX ".imp")
set(CMAKE_DL_LIBS "-lld")
# RPATH support on AIX is called libpath. By default the runtime
diff --git a/Modules/Platform/AIX/ExportImportList b/Modules/Platform/AIX/ExportImportList
index c17378c..4f67ef5 100755
--- a/Modules/Platform/AIX/ExportImportList
+++ b/Modules/Platform/AIX/ExportImportList
@@ -5,7 +5,7 @@
# This script is internal to CMake and meant only to be
# invoked by CMake-generated build systems on AIX.
-usage='usage: ExportImportList -o <out-file> [--] <objects>...'
+usage='usage: ExportImportList -o <out-file> [-l <lib>] [--] <objects>...'
die() {
echo "$@" 1>&2; exit 1
@@ -13,8 +13,10 @@ die() {
# Process command-line arguments.
out=''
+lib=''
while test "$#" != 0; do
case "$1" in
+ -l) shift; lib="$1" ;;
-o) shift; out="$1" ;;
--) shift; break ;;
-*) die "$usage" ;;
@@ -44,5 +46,8 @@ done > "$out_tmp"
# Generate the export/import file.
{
+ if test -n "$lib"; then
+ echo "#! $lib"
+ fi
sort -u "$out_tmp"
} > "$out"
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 5a03670..f696f28 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -616,6 +616,15 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
// Pass the full path to the target file.
std::string lib = tgt->GetFullPath(config, artifact, true);
+ if (tgt->Target->IsAIX() && cmHasLiteralSuffix(lib, "-NOTFOUND") &&
+ artifact == cmStateEnums::ImportLibraryArtifact) {
+ // This is an imported executable on AIX that has ENABLE_EXPORTS
+ // but not IMPORTED_IMPLIB. CMake used to produce and accept such
+ // imported executables on AIX before we taught it to use linker
+ // import files. For compatibility, simply skip linking to this
+ // executable as we did before. It works with runtime linking.
+ return;
+ }
if (!this->LinkDependsNoShared ||
tgt->GetType() != cmStateEnums::SHARED_LIBRARY) {
this->Depends.push_back(lib);
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index a2c0503..d3e8248 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -6363,7 +6363,8 @@ bool cmGeneratorTarget::HasImportLibrary(std::string const& config) const
this->IsExecutableWithExports()) &&
// Assemblies which have only managed code do not have
// import libraries.
- this->GetManagedType(config) != ManagedType::Managed);
+ this->GetManagedType(config) != ManagedType::Managed) ||
+ (this->Target->IsAIX() && this->IsExecutableWithExports());
}
bool cmGeneratorTarget::NeedImportLibraryName(std::string const& config) const
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 750ed8c..3b0659c 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -637,7 +637,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// On DLL platforms an executable may also have an import
// library. Install it to the archive destination if it
// exists.
- if (target.IsDLLPlatform() && !archiveArgs.GetDestination().empty() &&
+ if ((target.IsDLLPlatform() || target.IsAIX()) &&
+ !archiveArgs.GetDestination().empty() &&
target.IsExecutableWithExports()) {
// The import library uses the ARCHIVE properties.
archiveGenerator = CreateInstallTargetGenerator(
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 9290d27..b1a0127 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1716,7 +1716,8 @@ const char* cmTarget::GetSuffixVariableInternal(
? "CMAKE_SHARED_LIBRARY_SUFFIX"
: "CMAKE_EXECUTABLE_SUFFIX");
case cmStateEnums::ImportLibraryArtifact:
- return "CMAKE_IMPORT_LIBRARY_SUFFIX";
+ return (impl->IsAIX ? "CMAKE_AIX_IMPORT_FILE_SUFFIX"
+ : "CMAKE_IMPORT_LIBRARY_SUFFIX");
}
break;
default:
@@ -1756,7 +1757,8 @@ const char* cmTarget::GetPrefixVariableInternal(
? "CMAKE_SHARED_LIBRARY_PREFIX"
: "");
case cmStateEnums::ImportLibraryArtifact:
- return "CMAKE_IMPORT_LIBRARY_PREFIX";
+ return (impl->IsAIX ? "CMAKE_AIX_IMPORT_FILE_PREFIX"
+ : "CMAKE_IMPORT_LIBRARY_PREFIX");
}
break;
default:
@@ -1892,7 +1894,8 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
// library or an executable with exports.
bool allowImp = (this->IsDLLPlatform() &&
(this->GetType() == cmStateEnums::SHARED_LIBRARY ||
- this->IsExecutableWithExports()));
+ this->IsExecutableWithExports())) ||
+ (this->IsAIX() && this->IsExecutableWithExports());
// If a mapping was found, check its configurations.
for (std::vector<std::string>::const_iterator mci = mappedConfigs.begin();
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
index 18b9347..3b0ec6e 100644
--- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
@@ -979,6 +979,11 @@ def gen_check_targets(c, g, inSource):
"_dllExtra": False,
},
{
+ "path": "^lib/my_interface_exe\\.imp$",
+ "_aixExtra": True,
+ "_dllExtra": False,
+ },
+ {
"path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?my_interface_exe\\.(dll\\.a|lib)$",
"_dllExtra": True,
},
@@ -4895,6 +4900,10 @@ def gen_check_targets(c, g, inSource):
for e in expected:
e["artifacts"] = filter_list(lambda a: not a["_dllExtra"], e["artifacts"])
+ if "aix" not in sys.platform:
+ for e in expected:
+ e["artifacts"] = filter_list(lambda a: not a.get("_aixExtra", False), e["artifacts"])
+
return expected
def check_targets(c, g, inSource):
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake
index 34e500a..f52776e 100644
--- a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake
@@ -38,7 +38,7 @@ set_property (TARGET static2 PROPERTY IMPORT_PREFIX static2_import_prefix)
string (APPEND GENERATE_CONTENT
"\ncheck_value (\"TARGET_FILE_PREFIX executable custom\" \"$<TARGET_FILE_PREFIX:exec2>\" \"exec2_prefix\")
-check_value (\"TARGET_LINKER_FILE_PREFIX executable linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,exec2_import_prefix,exec2_prefix>\")
+check_value (\"TARGET_LINKER_FILE_PREFIX executable linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms};AIX>,exec2_import_prefix,exec2_prefix>\")
check_value (\"TARGET_FILE_PREFIX shared custom\" \"$<TARGET_FILE_PREFIX:shared2>\" \"shared2_prefix\")
check_value (\"TARGET_LINKER_FILE_PREFIX shared linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_prefix,shared2_prefix>\")
check_value (\"TARGET_FILE_PREFIX static custom\" \"$<TARGET_FILE_PREFIX:static2>\" \"static2_prefix\")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake
index 6bb1e44..bef7bbf 100644
--- a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake
@@ -38,7 +38,7 @@ set_property (TARGET static2 PROPERTY IMPORT_PREFIX static2_import_prefix)
string (APPEND GENERATE_CONTENT
"\ncheck_value (\"TARGET_FILE_PREFIX executable custom\" \"$<TARGET_FILE_PREFIX:exec2>\" \"exec2_prefix\")
-check_value (\"TARGET_LINKER_FILE_PREFIX executable linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,exec2_import_prefix,exec2_prefix>\")
+check_value (\"TARGET_LINKER_FILE_PREFIX executable linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms};AIX>,exec2_import_prefix,exec2_prefix>\")
check_value (\"TARGET_FILE_PREFIX shared custom\" \"$<TARGET_FILE_PREFIX:shared2>\" \"shared2_prefix\")
check_value (\"TARGET_LINKER_FILE_PREFIX shared linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_prefix,shared2_prefix>\")
check_value (\"TARGET_FILE_PREFIX static custom\" \"$<TARGET_FILE_PREFIX:static2>\" \"static2_prefix\")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake
index e1b7654..cefeb86 100644
--- a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake
@@ -38,7 +38,7 @@ set_property (TARGET static2 PROPERTY IMPORT_SUFFIX static2_import_suffix)
string (APPEND GENERATE_CONTENT
"\ncheck_value (\"TARGET_FILE_SUFFIX executable custom\" \"$<TARGET_FILE_SUFFIX:exec2>\" \"exec2_suffix\")
-check_value (\"TARGET_LINKER_FILE_SUFFIX executable linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,exec2_import_suffix,exec2_suffix>\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX executable linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms};AIX>,exec2_import_suffix,exec2_suffix>\")
check_value (\"TARGET_FILE_SUFFIX shared custom\" \"$<TARGET_FILE_SUFFIX:shared2>\" \"shared2_suffix\")
check_value (\"TARGET_LINKER_FILE_SUFFIX shared linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_suffix,shared2_suffix>\")
check_value (\"TARGET_FILE_SUFFIX static custom\" \"$<TARGET_FILE_SUFFIX:static2>\" \"static2_suffix\")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake
index 78afecd..39e39fd 100644
--- a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake
@@ -38,7 +38,7 @@ set_property (TARGET static2 PROPERTY IMPORT_SUFFIX static2_import_suffix)
string (APPEND GENERATE_CONTENT
"\ncheck_value (\"TARGET_FILE_SUFFIX executable custom\" \"$<TARGET_FILE_SUFFIX:exec2>\" \"exec2_suffix\")
-check_value (\"TARGET_LINKER_FILE_SUFFIX executable linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,exec2_import_suffix,exec2_suffix>\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX executable linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms};AIX>,exec2_import_suffix,exec2_suffix>\")
check_value (\"TARGET_FILE_SUFFIX shared custom\" \"$<TARGET_FILE_SUFFIX:shared2>\" \"shared2_suffix\")
check_value (\"TARGET_LINKER_FILE_SUFFIX shared linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_suffix,shared2_suffix>\")
check_value (\"TARGET_FILE_SUFFIX static custom\" \"$<TARGET_FILE_SUFFIX:static2>\" \"static2_suffix\")