XL.cmake 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # This module is shared by multiple languages; use include blocker.
  4. if(__COMPILER_XL)
  5. return()
  6. endif()
  7. set(__COMPILER_XL 1)
  8. include(Compiler/CMakeCommonCompilerMacros)
  9. # Find the CreateExportList program that comes with this toolchain.
  10. find_program(CMAKE_XL_CreateExportList
  11. NAMES CreateExportList
  12. DOC "IBM XL CreateExportList tool"
  13. )
  14. macro(__compiler_xl lang)
  15. # Feature flags.
  16. set(CMAKE_${lang}_VERBOSE_FLAG "-V")
  17. set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-qpic")
  18. set(CMAKE_${lang}_RESPONSE_FILE_FLAG "-qoptfile=")
  19. set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-qoptfile=")
  20. string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g")
  21. string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O")
  22. string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O")
  23. string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -g")
  24. set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
  25. set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
  26. # CMAKE_XL_CreateExportList is part of the AIX XL compilers but not the linux ones.
  27. # If we found the tool, we'll use it to create exports, otherwise stick with the regular
  28. # create shared library compile line.
  29. if (CMAKE_XL_CreateExportList)
  30. # The compiler front-end passes all object files, archive files, and shared
  31. # library files named on the command line to CreateExportList to create a
  32. # list of all symbols to be exported from the shared library. This causes
  33. # all archive members to be copied into the shared library whether they are
  34. # needed or not. Instead we run the tool ourselves to pass only the object
  35. # files so that we export only the symbols actually provided by the sources.
  36. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
  37. "${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>"
  38. "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
  39. )
  40. endif()
  41. endmacro()