blob: 461e47d449157789a3055f003a5f9fa57797a4e5 [file] [log] [blame]
Jonathan Peyton2e013352015-07-15 16:05:301#
2#//===----------------------------------------------------------------------===//
3#//
Chandler Carruth57b08b02019-01-19 10:56:404#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5#// See https://llvm.org/LICENSE.txt for license information.
6#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Jonathan Peyton2e013352015-07-15 16:05:307#//
8#//===----------------------------------------------------------------------===//
9#
10
11# LibompExports.cmake
12# Copy library and header files into the exports/ subdirectory after library build
13
14# Create the suffix for the export directory
15# - Only add to suffix when not a default value
Jonathan Peytone4b4f992019-07-12 21:45:3616# - Example suffix: .deb.s1
17# final export directory: exports/lin_32e.deb.s1/lib
18# - These suffixes imply the build is a Debug, Stats-Gathering version of the library
Jonathan Peyton2e013352015-07-15 16:05:3019set(libomp_suffix)
20libomp_append(libomp_suffix .deb DEBUG_BUILD)
21libomp_append(libomp_suffix .dia RELWITHDEBINFO_BUILD)
22libomp_append(libomp_suffix .min MINSIZEREL_BUILD)
Jonathan Peyton2e013352015-07-15 16:05:3023libomp_append(libomp_suffix .s1 LIBOMP_STATS)
24libomp_append(libomp_suffix .ompt LIBOMP_OMPT_SUPPORT)
25if(${LIBOMP_OMPT_SUPPORT})
Jonas Hahnfeldd30cb272017-11-10 15:17:5726 libomp_append(libomp_suffix .optional LIBOMP_OMPT_OPTIONAL)
Jonathan Peyton2e013352015-07-15 16:05:3027endif()
28string(REPLACE ";" "" libomp_suffix "${libomp_suffix}")
29
30# Set exports locations
Jonathan Peyton88dae3d2024-06-20 17:54:4931if(WIN32)
32 set(LIBOMP_SHORT_OS win)
33elseif(APPLE)
34 set(LIBOMP_SHORT_OS mac)
35else()
36 set(LIBOMP_SHORT_OS lin)
37endif()
Jonathan Peyton2e013352015-07-15 16:05:3038if(${MIC})
Jonathan Peyton88dae3d2024-06-20 17:54:4939 set(libomp_platform "${LIBOMP_SHORT_OS}_${LIBOMP_MIC_ARCH}") # e.g., lin_knf, lin_knc
Jonathan Peyton2e013352015-07-15 16:05:3040else()
Jonathan Peyton5b4acbd2015-07-15 16:57:1941 if(${IA32})
Jonathan Peyton88dae3d2024-06-20 17:54:4942 set(libomp_platform "${LIBOMP_SHORT_OS}_32")
Jonathan Peyton5b4acbd2015-07-15 16:57:1943 elseif(${INTEL64})
Jonathan Peyton88dae3d2024-06-20 17:54:4944 set(libomp_platform "${LIBOMP_SHORT_OS}_32e")
Jonathan Peyton5b4acbd2015-07-15 16:57:1945 else()
Jonathan Peyton88dae3d2024-06-20 17:54:4946 set(libomp_platform "${LIBOMP_SHORT_OS}_${LIBOMP_ARCH}") # e.g., lin_arm, lin_ppc64
Jonathan Peyton5b4acbd2015-07-15 16:57:1947 endif()
Jonathan Peyton2e013352015-07-15 16:05:3048endif()
49set(LIBOMP_EXPORTS_DIR "${LIBOMP_BASE_DIR}/exports")
50set(LIBOMP_EXPORTS_PLATFORM_DIR "${LIBOMP_EXPORTS_DIR}/${libomp_platform}${libomp_suffix}")
51set(LIBOMP_EXPORTS_CMN_DIR "${LIBOMP_EXPORTS_DIR}/common${libomp_suffix}/include")
52set(LIBOMP_EXPORTS_INC_DIR "${LIBOMP_EXPORTS_PLATFORM_DIR}/include")
53set(LIBOMP_EXPORTS_MOD_DIR "${LIBOMP_EXPORTS_PLATFORM_DIR}/include_compat")
54set(LIBOMP_EXPORTS_LIB_DIR "${LIBOMP_EXPORTS_DIR}/${libomp_platform}${libomp_suffix}/lib")
55
56# Put headers in exports/ directory post build
57add_custom_command(TARGET omp POST_BUILD
Jonathan Peyton5b4acbd2015-07-15 16:57:1958 COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_CMN_DIR}
59 COMMAND ${CMAKE_COMMAND} -E copy omp.h ${LIBOMP_EXPORTS_CMN_DIR}
Johannes Doerfertdaef6d32023-07-27 00:25:3960 COMMAND ${CMAKE_COMMAND} -E copy ompx.h ${LIBOMP_EXPORTS_CMN_DIR}
Jonathan Peyton2e013352015-07-15 16:05:3061)
62if(${LIBOMP_OMPT_SUPPORT})
Jonathan Peyton5b4acbd2015-07-15 16:57:1963 add_custom_command(TARGET omp POST_BUILD
Joachim Protze2b46d302019-01-15 15:36:5364 COMMAND ${CMAKE_COMMAND} -E copy omp-tools.h ${LIBOMP_EXPORTS_CMN_DIR}
Jonathan Peyton5b4acbd2015-07-15 16:57:1965 )
Jonathan Peyton2e013352015-07-15 16:05:3066endif()
67if(${LIBOMP_FORTRAN_MODULES})
Jonathan Peyton5b4acbd2015-07-15 16:57:1968 add_custom_command(TARGET libomp-mod POST_BUILD
69 COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_MOD_DIR}
Jonathan Peyton5b4acbd2015-07-15 16:57:1970 COMMAND ${CMAKE_COMMAND} -E copy omp_lib.mod ${LIBOMP_EXPORTS_MOD_DIR}
71 COMMAND ${CMAKE_COMMAND} -E copy omp_lib_kinds.mod ${LIBOMP_EXPORTS_MOD_DIR}
72 )
Paul Osmialowski7a9c29e2016-09-30 22:05:4573 add_custom_command(TARGET omp POST_BUILD
74 COMMAND ${CMAKE_COMMAND} -E copy omp_lib.h ${LIBOMP_EXPORTS_CMN_DIR}
75 )
Jonathan Peyton2e013352015-07-15 16:05:3076endif()
77
78# Copy OpenMP library into exports/ directory post build
79if(WIN32)
Jonathan Peyton5b4acbd2015-07-15 16:57:1980 get_target_property(LIBOMP_OUTPUT_DIRECTORY omp RUNTIME_OUTPUT_DIRECTORY)
Jonathan Peyton2e013352015-07-15 16:05:3081else()
Jonathan Peyton5b4acbd2015-07-15 16:57:1982 get_target_property(LIBOMP_OUTPUT_DIRECTORY omp LIBRARY_OUTPUT_DIRECTORY)
Jonathan Peyton2e013352015-07-15 16:05:3083endif()
84if(NOT LIBOMP_OUTPUT_DIRECTORY)
Jonathan Peyton5b4acbd2015-07-15 16:57:1985 set(LIBOMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
Jonathan Peyton2e013352015-07-15 16:05:3086endif()
87add_custom_command(TARGET omp POST_BUILD
Jonathan Peyton5b4acbd2015-07-15 16:57:1988 COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_LIB_DIR}
David Trubybb099c82020-07-20 11:11:2689 COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:omp> ${LIBOMP_EXPORTS_LIB_DIR}
Jonathan Peyton2e013352015-07-15 16:05:3090)
91
92# Copy Windows import library into exports/ directory post build
93if(WIN32)
AndreyChurbanov4a04bc82020-08-04 15:48:2594 get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY ${LIBOMP_IMP_LIB_TARGET} ARCHIVE_OUTPUT_DIRECTORY)
Jonathan Peyton5b4acbd2015-07-15 16:57:1995 if(NOT LIBOMPIMP_OUTPUT_DIRECTORY)
96 set(LIBOMPIMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
97 endif()
AndreyChurbanov4a04bc82020-08-04 15:48:2598 add_custom_command(TARGET ${LIBOMP_IMP_LIB_TARGET} POST_BUILD
Jonathan Peyton5b4acbd2015-07-15 16:57:1999 COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBOMP_EXPORTS_LIB_DIR}
100 COMMAND ${CMAKE_COMMAND} -E copy ${LIBOMPIMP_OUTPUT_DIRECTORY}/${LIBOMP_IMP_LIB_FILE} ${LIBOMP_EXPORTS_LIB_DIR}
101 )
Jonathan Peyton2e013352015-07-15 16:05:30102endif()