Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 1 | # |
| 2 | #//===----------------------------------------------------------------------===// |
| 3 | #// |
| 4 | #// The LLVM Compiler Infrastructure |
| 5 | #// |
| 6 | #// This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | #// Source Licenses. See LICENSE.txt for details. |
| 8 | #// |
| 9 | #//===----------------------------------------------------------------------===// |
| 10 | # |
| 11 | |
| 12 | # LibompExports.cmake |
| 13 | # Copy library and header files into the exports/ subdirectory after library build |
| 14 | |
| 15 | # Create the suffix for the export directory |
| 16 | # - Only add to suffix when not a default value |
| 17 | # - Example suffix: .deb.30.s1 |
| 18 | # final export directory: exports/lin_32e.deb.30.s1/lib |
| 19 | # - These suffixes imply the build is a Debug, OpenMP 3.0, Stats-Gathering version of the library |
| 20 | set(libomp_suffix) |
| 21 | libomp_append(libomp_suffix .deb DEBUG_BUILD) |
| 22 | libomp_append(libomp_suffix .dia RELWITHDEBINFO_BUILD) |
| 23 | libomp_append(libomp_suffix .min MINSIZEREL_BUILD) |
Jonathan Peyton | df6818b | 2016-06-14 17:57:47 +0000 | [diff] [blame] | 24 | if(NOT "${LIBOMP_OMP_VERSION}" STREQUAL "45") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 25 | libomp_append(libomp_suffix .${LIBOMP_OMP_VERSION}) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 26 | endif() |
| 27 | libomp_append(libomp_suffix .s1 LIBOMP_STATS) |
| 28 | libomp_append(libomp_suffix .ompt LIBOMP_OMPT_SUPPORT) |
| 29 | if(${LIBOMP_OMPT_SUPPORT}) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 30 | libomp_append(libomp_suffix .no-ompt-blame IF_FALSE LIBOMP_OMPT_BLAME) |
| 31 | libomp_append(libomp_suffix .no-ompt-trace IF_FALSE LIBOMP_OMPT_TRACE) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 32 | endif() |
| 33 | string(REPLACE ";" "" libomp_suffix "${libomp_suffix}") |
| 34 | |
| 35 | # Set exports locations |
| 36 | if(${MIC}) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 37 | set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_${LIBOMP_MIC_ARCH}") # e.g., lin_knf, lin_knc |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 38 | else() |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 39 | if(${IA32}) |
| 40 | set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_32") |
| 41 | elseif(${INTEL64}) |
| 42 | set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_32e") |
| 43 | else() |
| 44 | set(libomp_platform "${LIBOMP_PERL_SCRIPT_OS}_${LIBOMP_ARCH}") # e.g., lin_arm, lin_ppc64 |
| 45 | endif() |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 46 | endif() |
| 47 | set(LIBOMP_EXPORTS_DIR "${LIBOMP_BASE_DIR}/exports") |
| 48 | set(LIBOMP_EXPORTS_PLATFORM_DIR "${LIBOMP_EXPORTS_DIR}/${libomp_platform}${libomp_suffix}") |
| 49 | set(LIBOMP_EXPORTS_CMN_DIR "${LIBOMP_EXPORTS_DIR}/common${libomp_suffix}/include") |
| 50 | set(LIBOMP_EXPORTS_INC_DIR "${LIBOMP_EXPORTS_PLATFORM_DIR}/include") |
| 51 | set(LIBOMP_EXPORTS_MOD_DIR "${LIBOMP_EXPORTS_PLATFORM_DIR}/include_compat") |
| 52 | set(LIBOMP_EXPORTS_LIB_DIR "${LIBOMP_EXPORTS_DIR}/${libomp_platform}${libomp_suffix}/lib") |
| 53 | |
| 54 | # Put headers in exports/ directory post build |
| 55 | add_custom_command(TARGET omp POST_BUILD |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 56 | COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_CMN_DIR} |
| 57 | COMMAND ${CMAKE_COMMAND} -E copy omp.h ${LIBOMP_EXPORTS_CMN_DIR} |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 58 | ) |
| 59 | if(${LIBOMP_OMPT_SUPPORT}) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 60 | add_custom_command(TARGET omp POST_BUILD |
| 61 | COMMAND ${CMAKE_COMMAND} -E copy ompt.h ${LIBOMP_EXPORTS_CMN_DIR} |
| 62 | ) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 63 | endif() |
| 64 | if(${LIBOMP_FORTRAN_MODULES}) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 65 | add_custom_command(TARGET libomp-mod POST_BUILD |
| 66 | COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_MOD_DIR} |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 67 | COMMAND ${CMAKE_COMMAND} -E copy omp_lib.mod ${LIBOMP_EXPORTS_MOD_DIR} |
| 68 | COMMAND ${CMAKE_COMMAND} -E copy omp_lib_kinds.mod ${LIBOMP_EXPORTS_MOD_DIR} |
| 69 | ) |
Paul Osmialowski | 7a9c29e | 2016-09-30 22:05:45 +0000 | [diff] [blame^] | 70 | add_custom_command(TARGET omp POST_BUILD |
| 71 | COMMAND ${CMAKE_COMMAND} -E copy omp_lib.h ${LIBOMP_EXPORTS_CMN_DIR} |
| 72 | ) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 73 | endif() |
| 74 | |
| 75 | # Copy OpenMP library into exports/ directory post build |
| 76 | if(WIN32) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 77 | get_target_property(LIBOMP_OUTPUT_DIRECTORY omp RUNTIME_OUTPUT_DIRECTORY) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 78 | else() |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 79 | get_target_property(LIBOMP_OUTPUT_DIRECTORY omp LIBRARY_OUTPUT_DIRECTORY) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 80 | endif() |
| 81 | if(NOT LIBOMP_OUTPUT_DIRECTORY) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 82 | set(LIBOMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 83 | endif() |
| 84 | add_custom_command(TARGET omp POST_BUILD |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 85 | COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_LIB_DIR} |
| 86 | COMMAND ${CMAKE_COMMAND} -E copy ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE} ${LIBOMP_EXPORTS_LIB_DIR} |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 87 | ) |
| 88 | |
| 89 | # Copy Windows import library into exports/ directory post build |
| 90 | if(WIN32) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 +0000 | [diff] [blame] | 91 | get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY ompimp ARCHIVE_OUTPUT_DIRECTORY) |
| 92 | if(NOT LIBOMPIMP_OUTPUT_DIRECTORY) |
| 93 | set(LIBOMPIMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 94 | endif() |
| 95 | add_custom_command(TARGET ompimp POST_BUILD |
| 96 | COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_LIB_DIR} |
| 97 | COMMAND ${CMAKE_COMMAND} -E copy ${LIBOMPIMP_OUTPUT_DIRECTORY}/${LIBOMP_IMP_LIB_FILE} ${LIBOMP_EXPORTS_LIB_DIR} |
| 98 | ) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 +0000 | [diff] [blame] | 99 | endif() |
| 100 | |