XL.cmake 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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}_FLAGS_DEBUG_INIT "-g")
  27. set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O")
  28. set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-O")
  29. set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-g")
  30. set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
  31. set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
  32. # CMAKE_XL_CreateExportList is part of the AIX XL compilers but not the linux ones.
  33. # If we found the tool, we'll use it to create exports, otherwise stick with the regular
  34. # create shared library compile line.
  35. if (CMAKE_XL_CreateExportList)
  36. # The compiler front-end passes all object files, archive files, and shared
  37. # library files named on the command line to CreateExportList to create a
  38. # list of all symbols to be exported from the shared library. This causes
  39. # all archive members to be copied into the shared library whether they are
  40. # needed or not. Instead we run the tool ourselves to pass only the object
  41. # files so that we export only the symbols actually provided by the sources.
  42. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
  43. "${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>"
  44. "<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>"
  45. )
  46. endif()
  47. endmacro()