XL.cmake 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #=============================================================================
  2. # Copyright 2002-2011 Kitware, Inc.
  3. #
  4. # Distributed under the OSI-approved BSD License (the "License");
  5. # see accompanying file Copyright.txt for details.
  6. #
  7. # This software is distributed WITHOUT ANY WARRANTY; without even the
  8. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the License for more information.
  10. #=============================================================================
  11. # (To distribute this file outside of CMake, substitute the full
  12. # License text for the above reference.)
  13. # This module is shared by multiple languages; use include blocker.
  14. if(__COMPILER_XL)
  15. return()
  16. endif()
  17. set(__COMPILER_XL 1)
  18. # Find the CreateExportList program that comes with this toolchain.
  19. find_program(CMAKE_XL_CreateExportList
  20. NAMES CreateExportList
  21. DOC "IBM XL CreateExportList tool"
  22. )
  23. macro(__compiler_xl lang)
  24. # Feature flags.
  25. set(CMAKE_${lang}_VERBOSE_FLAG "-V")
  26. set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-qpic")
  27. set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g")
  28. set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O")
  29. set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-O")
  30. set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-g")
  31. set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
  32. set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
  33. # CMAKE_XL_CreateExportList is part of the AIX XL compilers but not the linux ones.
  34. # If we found the tool, we'll use it to create exports, otherwise stick with the regular
  35. # create shared library compile line.
  36. if (CMAKE_XL_CreateExportList)
  37. # The compiler front-end passes all object files, archive files, and shared
  38. # library files named on the command line to CreateExportList to create a
  39. # list of all symbols to be exported from the shared library. This causes
  40. # all archive members to be copied into the shared library whether they are
  41. # needed or not. Instead we run the tool ourselves to pass only the object
  42. # files so that we export only the symbols actually provided by the sources.
  43. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
  44. "${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>"
  45. "<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>"
  46. )
  47. endif()
  48. endmacro()