XL.cmake 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. # The compiler front-end passes all object files, archive files, and shared
  33. # library files named on the command line to CreateExportList to create a
  34. # list of all symbols to be exported from the shared library. This causes
  35. # all archive members to be copied into the shared library whether they are
  36. # needed or not. Instead we run the tool ourselves to pass only the object
  37. # files so that we export only the symbols actually provided by the sources.
  38. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
  39. "${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>"
  40. "<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 <CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
  41. )
  42. endmacro()