2 #//===----------------------------------------------------------------------===//
4 #// 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
8 #//===----------------------------------------------------------------------===//
13 # The generated headers will be placed in clang's resource directory if present.
14 if(OPENMP_STANDALONE_BUILD OR NOT LLVM_RUNTIMES_BUILD)
15 set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
17 set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})
20 # Configure omp.h, kmp_config.h and omp-tools.h if necessary
21 configure_file(${LIBOMP_INC_DIR}/omp.h.var ${LIBOMP_HEADERS_INTDIR}/omp.h @ONLY)
22 configure_file(${LIBOMP_INC_DIR}/ompx.h.var ${LIBOMP_HEADERS_INTDIR}/ompx.h @ONLY)
23 configure_file(kmp_config.h.cmake kmp_config.h @ONLY)
24 if(${LIBOMP_OMPT_SUPPORT})
25 configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var ${LIBOMP_HEADERS_INTDIR}/omp-tools.h @ONLY)
28 # Generate message catalog files: kmp_i18n_id.inc and kmp_i18n_default.inc
30 OUTPUT kmp_i18n_id.inc
31 COMMAND ${Python3_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/message-converter.py
32 --enum=kmp_i18n_id.inc ${LIBOMP_SRC_DIR}/i18n/en_US.txt
33 DEPENDS ${LIBOMP_SRC_DIR}/i18n/en_US.txt ${LIBOMP_TOOLS_DIR}/message-converter.py
36 OUTPUT kmp_i18n_default.inc
37 COMMAND ${Python3_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/message-converter.py
38 --default=kmp_i18n_default.inc ${LIBOMP_SRC_DIR}/i18n/en_US.txt
39 DEPENDS ${LIBOMP_SRC_DIR}/i18n/en_US.txt ${LIBOMP_TOOLS_DIR}/message-converter.py
42 # Set the -D definitions for all sources
43 # UNICODE and _UNICODE are set in LLVM's CMake system. They affect the
44 # ittnotify code and should only be set when compiling ittnotify_static.cpp
45 # on Windows (done below).
46 # TODO: Fix the UNICODE usage in ittnotify code for Windows.
47 remove_definitions(-DUNICODE -D_UNICODE)
48 libomp_get_definitions_flags(LIBOMP_CONFIGURED_DEFINITIONS_FLAGS)
49 add_definitions(${LIBOMP_CONFIGURED_DEFINITIONS_FLAGS})
51 # Set the -I includes for all sources
53 ${CMAKE_CURRENT_BINARY_DIR}
55 ${LIBOMP_SRC_DIR}/i18n
57 ${LIBOMP_SRC_DIR}/thirdparty/ittnotify
60 # Building with time profiling support requires LLVM directory includes.
61 if(LIBOMP_PROFILING_SUPPORT)
63 ${LLVM_MAIN_INCLUDE_DIR}
68 # Getting correct source files to build library
71 set(LIBOMP_GNUASMFILES)
73 set(LIBOMP_CXXFILES kmp_stub.cpp)
102 # Windows specific files
103 libomp_append(LIBOMP_CXXFILES z_Windows_NT_util.cpp)
104 libomp_append(LIBOMP_CXXFILES z_Windows_NT-586_util.cpp)
105 if(${LIBOMP_ARCH} STREQUAL "i386" OR ${LIBOMP_ARCH} STREQUAL "x86_64")
106 libomp_append(LIBOMP_ASMFILES z_Windows_NT-586_asm.asm) # Windows assembly file
107 elseif((${LIBOMP_ARCH} STREQUAL "aarch64" OR ${LIBOMP_ARCH} STREQUAL "arm") AND (NOT MSVC OR CMAKE_C_COMPILER_ID STREQUAL "Clang"))
108 # z_Linux_asm.S works for AArch64 and ARM Windows too.
109 libomp_append(LIBOMP_GNUASMFILES z_Linux_asm.S)
111 # AArch64 with MSVC gets implementations of the functions from
112 # ifdeffed sections in z_Windows_NT-586_util.cpp.
115 # Unix specific files
116 libomp_append(LIBOMP_CXXFILES z_Linux_util.cpp)
117 libomp_append(LIBOMP_CXXFILES kmp_gsupport.cpp)
118 if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
119 libomp_append(LIBOMP_GNUASMFILES z_AIX_asm.S) # AIX assembly file
121 libomp_append(LIBOMP_GNUASMFILES z_Linux_asm.S) # Unix assembly file
124 libomp_append(LIBOMP_CXXFILES thirdparty/ittnotify/ittnotify_static.cpp LIBOMP_USE_ITT_NOTIFY)
125 libomp_append(LIBOMP_CXXFILES kmp_debugger.cpp LIBOMP_USE_DEBUGGER)
126 libomp_append(LIBOMP_CXXFILES kmp_stats.cpp LIBOMP_STATS)
127 libomp_append(LIBOMP_CXXFILES kmp_stats_timing.cpp LIBOMP_STATS)
128 libomp_append(LIBOMP_CXXFILES kmp_taskdeps.cpp)
129 libomp_append(LIBOMP_CXXFILES kmp_cancel.cpp)
131 # Files common to stubs and normal library
132 libomp_append(LIBOMP_CXXFILES kmp_ftn_cdecl.cpp)
133 libomp_append(LIBOMP_CXXFILES kmp_ftn_extra.cpp)
134 libomp_append(LIBOMP_CXXFILES kmp_version.cpp)
135 libomp_append(LIBOMP_CXXFILES ompt-general.cpp IF_TRUE LIBOMP_OMPT_SUPPORT)
136 libomp_append(LIBOMP_CXXFILES ompd-specific.cpp IF_TRUE LIBOMP_OMPD_SUPPORT)
138 set(LIBOMP_SOURCE_FILES ${LIBOMP_CXXFILES} ${LIBOMP_ASMFILES} ${LIBOMP_GNUASMFILES})
139 # For Windows, there is a resource file (.rc -> .res) that is also compiled
140 libomp_append(LIBOMP_SOURCE_FILES libomp.rc WIN32)
142 # Get compiler and assembler flags
143 libomp_get_cxxflags(LIBOMP_CONFIGURED_CXXFLAGS)
144 libomp_get_asmflags(LIBOMP_CONFIGURED_ASMFLAGS)
145 # Set the compiler flags for each type of source
146 set_source_files_properties(${LIBOMP_CXXFILES} PROPERTIES COMPILE_FLAGS "${LIBOMP_CONFIGURED_CXXFLAGS}")
147 set_source_files_properties(${LIBOMP_ASMFILES} ${LIBOMP_GNUASMFILES} PROPERTIES COMPILE_FLAGS "${LIBOMP_CONFIGURED_ASMFLAGS}")
149 # Remove any cmake-automatic linking of the standard C++ library.
150 # We neither need (nor want) the standard C++ library dependency even though we compile c++ files.
151 if(NOT ${LIBOMP_USE_STDCPPLIB})
152 set(LIBOMP_LINKER_LANGUAGE C)
153 set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES)
155 set(LIBOMP_LINKER_LANGUAGE CXX)
159 set(LIBOMP_DL_LIBS ${CMAKE_DL_LIBS})
162 # Disable libstdc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build, to
163 # avoid an unwanted dependency on libstdc++.so.
165 add_definitions(-U_GLIBCXX_ASSERTIONS)
168 # Add the OpenMP library
169 libomp_get_ldflags(LIBOMP_CONFIGURED_LDFLAGS)
171 libomp_get_libflags(LIBOMP_CONFIGURED_LIBFLAGS)
172 # Build libomp library. Add LLVMSupport dependency if building in-tree with libomptarget profiling enabled.
173 if(OPENMP_STANDALONE_BUILD OR (NOT OPENMP_ENABLE_LIBOMP_PROFILING))
174 add_library(omp ${LIBOMP_LIBRARY_KIND} ${LIBOMP_SOURCE_FILES})
175 set_property(TARGET omp PROPERTY FOLDER "OpenMP/Libraries")
176 # Linking command will include libraries in LIBOMP_CONFIGURED_LIBFLAGS
177 target_link_libraries(omp ${LIBOMP_CONFIGURED_LIBFLAGS} ${LIBOMP_DL_LIBS})
179 add_llvm_library(omp ${LIBOMP_LIBRARY_KIND} ${LIBOMP_SOURCE_FILES} PARTIAL_SOURCES_INTENDED
180 LINK_LIBS ${LIBOMP_CONFIGURED_LIBFLAGS} ${LIBOMP_DL_LIBS}
181 LINK_COMPONENTS Support
184 # libomp must be a C++ library such that it can link libLLVMSupport
185 set(LIBOMP_LINKER_LANGUAGE CXX)
187 if(${LIBOMP_USE_HWLOC})
188 target_include_directories(omp
190 "$<BUILD_INTERFACE:${LIBOMP_HWLOC_INCLUDE_DIR}>"
191 "$<INSTALL_INTERFACE:${LIBOMP_HWLOC_INCLUDE_DIR}>"
195 if(OPENMP_MSVC_NAME_SCHEME)
196 if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
197 set(LIBOMP_PDB_NAME ${LIBOMP_DEFAULT_LIB_NAME}${MSVC_TOOLS_VERSION}d.${LIBOMP_ARCH})
198 set(LIBOMP_LIB_FILE ${LIBOMP_PDB_NAME}${LIBOMP_LIBRARY_SUFFIX})
200 # ${LIBOMP_LIB_NAME} is ${LIBOMP_DEFAULT_LIB_NAME}${MSVC_TOOLS_VERSION}.${LIBOMP_ARCH}
201 set(LIBOMP_PDB_NAME ${LIBOMP_LIB_NAME})
205 # LIBOMP_LIB_FILE should be LIBOMP_LIB_FILE_DBG = ${LIBOMP_LIB_NAME_DBG}${LIBOMP_LIBRARY_SUFFIX}
206 # = ${LIBOMP_DEFAULT_LIB_NAME}${MSVC_TOOLS_VERSION}d.${LIBOMP_ARCH}${LIBOMP_LIBRARY_SUFFIX}
207 # COMPILE_PDB_NAME/PDB_NAME should be LIBOMP_LIB_NAME_DBG = ${LIBOMP_DEFAULT_LIB_NAME}${MSVC_TOOLS_VERSION}d.${LIBOMP_ARCH}
208 set_target_properties(omp PROPERTIES
209 PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_LIB_FILE}"
210 PDB_NAME "${LIBOMP_PDB_NAME}"
211 COMPILE_PDB_NAME "${LIBOMP_PDB_NAME}"
212 LINK_FLAGS "${LIBOMP_CONFIGURED_LDFLAGS}"
213 LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE}
216 set_target_properties(omp PROPERTIES
217 PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_LIB_FILE}"
218 LINK_FLAGS "${LIBOMP_CONFIGURED_LDFLAGS}"
219 LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE}
223 # Get the library's location within the build tree for the unit tester
225 get_target_property(LIBOMP_LIBRARY_DIR omp LIBRARY_OUTPUT_DIRECTORY)
227 get_target_property(LIBOMP_LIBRARY_DIR omp RUNTIME_OUTPUT_DIRECTORY)
229 if(NOT LIBOMP_LIBRARY_DIR)
230 set(LIBOMP_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
231 set(LIBOMP_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
233 set(LIBOMP_LIBRARY_DIR ${LIBOMP_LIBRARY_DIR} PARENT_SCOPE)
235 set(LIBOMP_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR})
236 set(LIBOMP_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
238 # Add symbolic links to libomp
240 add_custom_command(TARGET omp POST_BUILD
241 COMMAND ${CMAKE_COMMAND} -E create_symlink ${LIBOMP_LIB_FILE}
242 libgomp${LIBOMP_LIBRARY_SUFFIX}
243 COMMAND ${CMAKE_COMMAND} -E create_symlink ${LIBOMP_LIB_FILE}
244 libiomp5${LIBOMP_LIBRARY_SUFFIX}
245 WORKING_DIRECTORY ${LIBOMP_LIBRARY_DIR}
249 # Definitions for testing, for reuse when testing libomptarget-nvptx.
250 set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${LIBOMP_INCLUDE_DIR}" CACHE STRING
251 "Path to folder containing omp.h")
252 set(LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER "${LIBOMP_LIBRARY_DIR}" CACHE STRING
253 "Path to folder containing libomp.so, and libLLVMSupport.so with profiling enabled")
255 # Create *.inc before compiling any sources
256 # objects depend on : .inc files
257 add_custom_target(libomp-needed-headers DEPENDS kmp_i18n_id.inc kmp_i18n_default.inc)
258 set_target_properties(libomp-needed-headers PROPERTIES FOLDER "OpenMP/Sourcegenning")
259 add_dependencies(omp libomp-needed-headers)
261 # Windows specific build rules
263 configure_file(libomp.rc.var libomp.rc @ONLY)
264 # z_Windows_NT-586_asm.asm requires definitions to be sent via command line
265 # It only needs the architecture macro and OMPT_SUPPORT=0|1
266 libomp_append(LIBOMP_MASM_DEFINITIONS "-D_M_IA32" IF_TRUE IA32)
267 libomp_append(LIBOMP_MASM_DEFINITIONS "-D_M_AMD64" IF_TRUE INTEL64)
268 libomp_append(LIBOMP_MASM_DEFINITIONS "-DOMPT_SUPPORT" IF_TRUE_1_0 LIBOMP_OMPT_SUPPORT)
269 libomp_append(LIBOMP_MASM_DEFINITIONS "-DOMPD_SUPPORT" IF_TRUE_1_0 LIBOMP_OMPD_SUPPORT)
270 libomp_list_to_string("${LIBOMP_MASM_DEFINITIONS}" LIBOMP_MASM_DEFINITIONS)
271 set_property(SOURCE z_Windows_NT-586_asm.asm APPEND_STRING PROPERTY COMPILE_FLAGS " ${LIBOMP_MASM_DEFINITIONS}")
272 set_source_files_properties(thirdparty/ittnotify/ittnotify_static.cpp PROPERTIES COMPILE_DEFINITIONS "UNICODE")
274 # Create Windows import library
275 # On debug LIBOMP_IMP_LIB_FILE should be LIBOMP_IMP_LIB_FILE_DBG = ${LIBOMP_DEFAULT_LIB_NAME_DBG}${CMAKE_STATIC_LIBRARY_SUFFIX}
276 # ${LIBOMP_DEFAULT_LIB_NAME}d${CMAKE_STATIC_LIBRARY_SUFFIX}
277 # and the ARCHIVE_OUTPUT_NAME of ompdbg should be ${LIBOMP_DEFAULT_LIB_NAME_DBG}${LIBOMP_LIBRARY_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
279 if(OPENMP_MSVC_NAME_SCHEME)
280 if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
281 set(LIBOMP_IMP_LIB_FILE ${LIBOMP_DEFAULT_LIB_NAME}d${CMAKE_STATIC_LIBRARY_SUFFIX})
282 set(LIBOMP_GENERATED_IMP_LIB_FILENAME ${LIBOMP_DEFAULT_LIB_NAME}d${LIBOMP_LIBRARY_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
284 set(LIBOMP_IMP_LIB_FILE ${LIBOMP_DEFAULT_LIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX})
285 set(LIBOMP_GENERATED_IMP_LIB_FILENAME ${LIBOMP_DEFAULT_LIB_NAME}${LIBOMP_LIBRARY_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
288 set(LIBOMP_IMP_LIB_FILE ${LIBOMP_LIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX})
289 set(LIBOMP_GENERATED_IMP_LIB_FILENAME ${LIBOMP_LIB_FILE}${CMAKE_STATIC_LIBRARY_SUFFIX})
291 set_target_properties(omp PROPERTIES
292 VERSION ${LIBOMP_VERSION_MAJOR}.${LIBOMP_VERSION_MINOR} # uses /version flag
293 IMPORT_PREFIX "" IMPORT_SUFFIX "" # control generated import library name when building omp
294 ARCHIVE_OUTPUT_NAME ${LIBOMP_GENERATED_IMP_LIB_FILENAME}
297 set(LIBOMP_IMP_LIB_TARGET omp)
298 set(LIBOMP_GENERATED_DEF_FILE ${LIBOMP_LIB_NAME}.def)
299 add_custom_target(libomp-needed-def-file DEPENDS ${LIBOMP_GENERATED_DEF_FILE})
300 set_target_properties(libomp-needed-def-file PROPERTIES FOLDER "OpenMP/Sourcegenning")
301 add_dependencies(omp libomp-needed-def-file)
303 # Create the main def file with ordinals to use for building the runtime dll to maintain backwards compatible exports order
304 libomp_get_gdflags(LIBOMP_GDFLAGS)
305 libomp_string_to_list("${LIBOMP_GDFLAGS}" LIBOMP_GDFLAGS)
308 OUTPUT ${LIBOMP_GENERATED_DEF_FILE}
309 COMMAND ${Python3_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/generate-def.py ${LIBOMP_GDFLAGS} --name ${LIBOMP_LIB_FILE}
310 -o ${LIBOMP_GENERATED_DEF_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/dllexports
311 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dllexports ${LIBOMP_TOOLS_DIR}/generate-def.py
315 # For toolchains that generated the import library importing by ordinal, re-generate it to import by name
316 set(LIBOMP_IMP_LIB_TARGET ompimp)
317 # Create the auxiliary def file without ordinals to use for building the import library to import by name
318 set(LIBOMPIMP_GENERATED_DEF_FILE ${LIBOMP_LIB_NAME}.imp.def)
319 add_custom_target(libompimp-needed-def-file DEPENDS ${LIBOMPIMP_GENERATED_DEF_FILE})
320 set_target_properties(libompimp-needed-def-file PROPERTIES FOLDER "OpenMP/Resources")
322 OUTPUT ${LIBOMPIMP_GENERATED_DEF_FILE}
323 COMMAND ${Python3_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/generate-def.py ${LIBOMP_GDFLAGS}
324 --name ${LIBOMP_LIB_FILE} --no-ordinals
325 -o ${LIBOMPIMP_GENERATED_DEF_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/dllexports
326 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dllexports ${LIBOMP_TOOLS_DIR}/generate-def.py
328 # while this merely generates an import library off a def file, CMAKE still requires it to have a "source" so feed it a dummy one,
329 # making it a .txt which CMAKE will filter out from the librarian (a .cpp will make lib.exe punt trying to resolve the .def symbols)
330 add_library(${LIBOMP_IMP_LIB_TARGET} STATIC kmp_dummy.txt)
331 set_target_properties(${LIBOMP_IMP_LIB_TARGET} PROPERTIES FOLDER "OpenMP/Libraries")
332 set_target_properties(${LIBOMP_IMP_LIB_TARGET} PROPERTIES
333 PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}" LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE}
334 STATIC_LIBRARY_OPTIONS "${CMAKE_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_BINARY_DIR}/${LIBOMPIMP_GENERATED_DEF_FILE}")
335 add_dependencies(${LIBOMP_IMP_LIB_TARGET} libompimp-needed-def-file)
336 add_dependencies(omp ${LIBOMP_IMP_LIB_TARGET})
340 # Building the Fortran module files
341 # One compilation step creates both omp_lib.mod and omp_lib_kinds.mod
342 configure_file(${LIBOMP_INC_DIR}/omp_lib.h.var omp_lib.h @ONLY)
343 configure_file(${LIBOMP_INC_DIR}/omp_lib.F90.var omp_lib.F90 @ONLY)
345 set(BUILD_FORTRAN_MODULES False)
346 if (NOT ${LIBOMP_FORTRAN_MODULES_COMPILER} STREQUAL "")
347 # If libomp is built as an LLVM runtime and the flang compiler is available,
348 # compile the Fortran module files.
349 message(STATUS "configuring openmp to build Fortran module files using ${LIBOMP_FORTRAN_MODULES_COMPILER}")
350 set(LIBOMP_FORTRAN_SOURCE_FILE omp_lib.F90)
351 add_custom_target(libomp-mod ALL DEPENDS omp_lib.mod omp_lib_kinds.mod)
353 OUTPUT omp_lib.mod omp_lib_kinds.mod
354 COMMAND ${LIBOMP_FORTRAN_MODULES_COMPILER} -cpp -fsyntax-only ${LIBOMP_FORTRAN_SOURCE_FILE}
355 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_FORTRAN_SOURCE_FILE}
356 ${CMAKE_CURRENT_BINARY_DIR}/omp_lib.h
358 set(BUILD_FORTRAN_MODULES True)
359 elseif(${LIBOMP_FORTRAN_MODULES})
360 # The following requests explicit building of the Fortran module files
361 # Workaround for gfortran to build modules with the
362 # omp_sched_monotonic integer parameter
363 if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
364 set(ADDITIONAL_Fortran_FLAGS "-fno-range-check")
366 add_custom_target(libomp-mod ALL DEPENDS omp_lib.mod omp_lib_kinds.mod)
367 set_target_properties(libomp-mod PROPERTIES FOLDER "OpenMP/Misc")
368 libomp_get_fflags(LIBOMP_CONFIGURED_FFLAGS)
369 if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
370 set(LIBOMP_FORTRAN_SOURCE_FILE omp_lib.F90)
372 message(FATAL_ERROR "Fortran module build requires Fortran 90 compiler")
375 OUTPUT omp_lib.mod omp_lib_kinds.mod
376 COMMAND ${CMAKE_Fortran_COMPILER} -c ${ADDITIONAL_Fortran_FLAGS}
377 ${LIBOMP_CONFIGURED_FFLAGS} ${LIBOMP_FORTRAN_SOURCE_FILE}
378 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_FORTRAN_SOURCE_FILE}
379 ${CMAKE_CURRENT_BINARY_DIR}/omp_lib.h
381 set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES omp_lib${CMAKE_C_OUTPUT_EXTENSION})
382 set(BUILD_FORTRAN_MODULES True)
385 # Move files to exports/ directory if requested
386 if(${LIBOMP_COPY_EXPORTS})
387 include(LibompExports)
390 # Micro test rules for after library has been built (cmake/LibompMicroTests.cmake)
391 include(LibompMicroTests)
392 add_custom_target(libomp-micro-tests)
393 set_target_properties(libomp-micro-tests PROPERTIES FOLDER "OpenMP/Tests")
394 if(NOT ${MIC} AND NOT CMAKE_CROSSCOMPILING)
395 add_dependencies(libomp-micro-tests libomp-test-touch)
397 if(NOT WIN32 AND NOT APPLE)
398 add_dependencies(libomp-micro-tests libomp-test-relo)
400 if(NOT WIN32 AND NOT APPLE)
401 add_dependencies(libomp-micro-tests libomp-test-execstack)
403 add_dependencies(libomp-micro-tests libomp-test-deps)
405 # `omp` needs to be exported if in-tree build.
406 set(export_to_llvmexports)
407 if (NOT OPENMP_STANDALONE_BUILD)
408 get_target_export_arg(omp LLVM export_to_llvmexports)
409 set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS omp)
413 # We want to install libomp in ${DESTDIR}/${CMAKE_INSTALL_FULL_LIBDIR}
414 # We want to install headers in ${DESTDIR}/${CMAKE_INSTALL_FULL_INCLUDEDIR}
416 install(TARGETS omp ${export_to_llvmexports} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
417 install(TARGETS ${LIBOMP_IMP_LIB_TARGET} ARCHIVE DESTINATION "${OPENMP_INSTALL_LIBDIR}")
418 # Create aliases (regular copies) of the library for backwards compatibility
419 set(LIBOMP_ALIASES "libiomp5md")
420 foreach(alias IN LISTS LIBOMP_ALIASES)
421 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_LIB_FILE}\"
422 \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"${CMAKE_INSTALL_FULL_BINDIR}\")")
423 extend_path(outdir "${CMAKE_INSTALL_PREFIX}" "${OPENMP_INSTALL_LIBDIR}")
424 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_IMP_LIB_FILE}\"
425 \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"${outdir}\")")
429 install(TARGETS omp ${export_to_llvmexports} ${LIBOMP_INSTALL_KIND} DESTINATION "${OPENMP_INSTALL_LIBDIR}")
431 if(${LIBOMP_INSTALL_ALIASES})
432 # Create aliases (symlinks) of the library for backwards compatibility
433 set(LIBOMP_ALIASES "libgomp;libiomp5")
434 foreach(alias IN LISTS LIBOMP_ALIASES)
435 extend_path(outdir "${CMAKE_INSTALL_PREFIX}" "${OPENMP_INSTALL_LIBDIR}")
436 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink \"${LIBOMP_LIB_FILE}\"
437 \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY
438 \"\$ENV{DESTDIR}${outdir}\")")
444 ${LIBOMP_HEADERS_INTDIR}/omp.h
445 ${LIBOMP_HEADERS_INTDIR}/ompx.h
446 DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}
448 if(${LIBOMP_OMPT_SUPPORT})
449 install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH})
450 # install under legacy name ompt.h
451 install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
452 set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
454 if(${BUILD_FORTRAN_MODULES})
455 set (destination ${LIBOMP_HEADERS_INSTALL_PATH})
456 if (NOT ${LIBOMP_MODULES_INSTALL_PATH} STREQUAL "")
457 set (destination ${LIBOMP_MODULES_INSTALL_PATH})
460 ${CMAKE_CURRENT_BINARY_DIR}/omp_lib.h
461 ${CMAKE_CURRENT_BINARY_DIR}/omp_lib.mod
462 ${CMAKE_CURRENT_BINARY_DIR}/omp_lib_kinds.mod
463 DESTINATION ${destination}