1# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2# file Copyright.txt or https://cmake.org/licensing for details.
3
4
5# This module is shared by multiple languages; use include blocker.
6if(__AIX_COMPILER_XL)
7  return()
8endif()
9set(__AIX_COMPILER_XL 1)
10
11macro(__aix_compiler_xl lang)
12  set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:")
13  set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":")
14  string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,-bnoipath")
15  set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") # CMP0065 old behavior
16  set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS " ")
17  set(CMAKE_SHARED_MODULE_${lang}_FLAGS  " ")
18
19  set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath")
20
21  set(_OBJECTS " <OBJECTS>")
22  if(DEFINED CMAKE_XL_CreateExportList AND CMAKE_XL_CreateExportList STREQUAL "")
23    # Prior to CMake 3.16, CMAKE_XL_CreateExportList held the path to the XL CreateExportList tool.
24    # Users could set it to an empty value to skip automatic exports in favor of manual -bE: flags.
25    # Preserve that behavior for compatibility (even though it was undocumented).
26    set(_OBJECTS "")
27  endif()
28
29  # Construct the export list ourselves to pass only the object files so
30  # that we export only the symbols actually provided by the sources.
31  set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
32    "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/exports.exp <AIX_EXPORTS>${_OBJECTS}"
33    "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/exports.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
34    )
35
36  set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS
37    "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -l . <AIX_EXPORTS> <OBJECTS>"
38    "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<TARGET_IMPLIB> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
39
40  unset(_OBJECTS)
41endmacro()
42