blob: 43299ddbad8452352c05fc997f82654c558a853c [file] [log] [blame]
Jim Cownie3b81ce62014-08-05 09:32:281#
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
Jim Cownie3b81ce62014-08-05 09:32:287#//
8#//===----------------------------------------------------------------------===//
9#
Alp Toker7198f522014-06-01 18:01:3310
Jonas Hahnfeld3e921d32017-11-29 19:31:4311if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
12 message(FATAL_ERROR "Direct configuration not supported, please use parent directory!")
13endif()
Alp Toker7198f522014-06-01 18:01:3314
Jim Cownie3b81ce62014-08-05 09:32:2815# Add cmake directory to search for custom cmake functions
16set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
17
Jonathan Peytonc0225ca2015-08-28 18:42:1018# Set libomp version
19set(LIBOMP_VERSION_MAJOR 5)
20set(LIBOMP_VERSION_MINOR 0)
21
Jonathan Peyton2e013352015-07-15 16:05:3022# These include files are in the cmake/ subdirectory
23include(LibompUtils)
24include(LibompGetArchitecture)
25include(LibompHandleFlags)
26include(LibompDefinitions)
Jim Cownie3b81ce62014-08-05 09:32:2827
Jonathan Peyton2e013352015-07-15 16:05:3028# Determine the target architecture
Jonas Hahnfeld3e921d32017-11-29 19:31:4329if(${OPENMP_STANDALONE_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:1930 # If adding a new architecture, take a look at cmake/LibompGetArchitecture.cmake
31 libomp_get_architecture(LIBOMP_DETECTED_ARCH)
32 set(LIBOMP_ARCH ${LIBOMP_DETECTED_ARCH} CACHE STRING
SignKirigami67729872022-09-19 22:49:1533 "The architecture to build for (x86_64/i386/arm/ppc64/ppc64le/aarch64/mic/mips/mips64/riscv64/loongarch64).")
Jonathan Peyton5b4acbd2015-07-15 16:57:1934 # Should assertions be enabled? They are on by default.
35 set(LIBOMP_ENABLE_ASSERTIONS TRUE CACHE BOOL
36 "enable assertions?")
Jonathan Peyton48b67dc2021-11-01 19:23:5437 string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
Jonathan Peyton2e013352015-07-15 16:05:3038else() # Part of LLVM build
Jonathan Peyton5b4acbd2015-07-15 16:57:1939 # Determine the native architecture from LLVM.
40 string(TOLOWER "${LLVM_TARGET_ARCH}" LIBOMP_NATIVE_ARCH)
41 if( LIBOMP_NATIVE_ARCH STREQUAL "host" )
42 string(REGEX MATCH "^[^-]*" LIBOMP_NATIVE_ARCH ${LLVM_HOST_TRIPLE})
43 endif ()
44 if(LIBOMP_NATIVE_ARCH MATCHES "i[2-6]86")
45 set(LIBOMP_ARCH i386)
46 elseif(LIBOMP_NATIVE_ARCH STREQUAL "x86")
47 set(LIBOMP_ARCH i386)
48 elseif(LIBOMP_NATIVE_ARCH STREQUAL "amd64")
49 set(LIBOMP_ARCH x86_64)
50 elseif(LIBOMP_NATIVE_ARCH STREQUAL "x86_64")
51 set(LIBOMP_ARCH x86_64)
George Rokos118de302016-09-09 18:04:2352 elseif(LIBOMP_NATIVE_ARCH MATCHES "powerpc64le")
53 set(LIBOMP_ARCH ppc64le)
Jonathan Peyton5b4acbd2015-07-15 16:57:1954 elseif(LIBOMP_NATIVE_ARCH MATCHES "powerpc")
55 set(LIBOMP_ARCH ppc64)
56 elseif(LIBOMP_NATIVE_ARCH MATCHES "aarch64")
57 set(LIBOMP_ARCH aarch64)
58 elseif(LIBOMP_NATIVE_ARCH MATCHES "arm64")
59 set(LIBOMP_ARCH aarch64)
60 elseif(LIBOMP_NATIVE_ARCH MATCHES "arm")
61 set(LIBOMP_ARCH arm)
Jonas Hahnfeld2488ae92019-07-25 14:36:2062 elseif(LIBOMP_NATIVE_ARCH MATCHES "riscv64")
63 set(LIBOMP_ARCH riscv64)
SignKirigami67729872022-09-19 22:49:1564 elseif(LIBOMP_NATIVE_ARCH MATCHES "loongarch64")
65 set(LIBOMP_ARCH loongarch64)
Jonathan Peyton5b4acbd2015-07-15 16:57:1966 else()
67 # last ditch effort
68 libomp_get_architecture(LIBOMP_ARCH)
69 endif ()
Jonathan Peyton5b4acbd2015-07-15 16:57:1970 set(LIBOMP_ENABLE_ASSERTIONS ${LLVM_ENABLE_ASSERTIONS})
Jim Cownie3b81ce62014-08-05 09:32:2871endif()
Shilei Tian676c7cb2021-01-09 16:58:3772
Shilei Tianc571b162021-01-28 12:24:1973# Time profiling support
74set(LIBOMP_PROFILING_SUPPORT ${OPENMP_ENABLE_LIBOMP_PROFILING})
75
Shilei Tian676c7cb2021-01-09 16:58:3776# FUJITSU A64FX is a special processor because its cache line size is 256.
77# We need to pass this information into kmp_config.h.
78if(LIBOMP_ARCH STREQUAL "aarch64")
79 libomp_is_aarch64_a64fx(LIBOMP_DETECT_AARCH64_A64FX)
80 if (LIBOMP_DETECT_AARCH64_A64FX)
81 set(LIBOMP_ARCH "aarch64_a64fx")
82 set(LIBOMP_ARCH_AARCH64_A64FX TRUE)
83 endif()
84endif()
85
SignKirigami67729872022-09-19 22:49:1586libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc64 ppc64le aarch64 aarch64_a64fx mic mips mips64 riscv64 loongarch64)
Jim Cownie3b81ce62014-08-05 09:32:2887
Jonathan Peytonfbb15142015-05-26 17:27:0188set(LIBOMP_LIB_TYPE normal CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:1989 "Performance,Profiling,Stubs library (normal/profile/stubs)")
Jonathan Peyton2e013352015-07-15 16:05:3090libomp_check_variable(LIBOMP_LIB_TYPE normal profile stubs)
Kelvin Lied5fe642020-01-04 03:03:4291# Set the OpenMP Year and Month associated with version
Jonathan Peytone4b4f992019-07-12 21:45:3692set(LIBOMP_OMP_YEAR_MONTH 201611)
Jonathan Peyton2e013352015-07-15 16:05:3093set(LIBOMP_MIC_ARCH knc CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:1994 "Intel(R) Many Integrated Core Architecture (Intel(R) MIC Architecture) (knf/knc). Ignored if not Intel(R) MIC Architecture build.")
Jonathan Peyton2e013352015-07-15 16:05:3095if("${LIBOMP_ARCH}" STREQUAL "mic")
Jonathan Peyton5b4acbd2015-07-15 16:57:1996 libomp_check_variable(LIBOMP_MIC_ARCH knf knc)
Jonathan Peyton2e013352015-07-15 16:05:3097endif()
98set(LIBOMP_FORTRAN_MODULES FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:1999 "Create Fortran module files? (requires fortran compiler)")
Jim Cownie3b81ce62014-08-05 09:32:28100
Jonathan Peyton92907c22015-05-29 16:13:56101# - Support for universal fat binary builds on Mac
Jonathan Peyton2e013352015-07-15 16:05:30102# - Having this extra variable allows people to build this library as a universal library
Jonathan Peyton92907c22015-05-29 16:13:56103# without forcing a universal build of the llvm/clang compiler.
104set(LIBOMP_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19105 "For Mac builds, semicolon separated list of architectures to build for universal fat binary.")
Jonathan Peyton92907c22015-05-29 16:13:56106set(CMAKE_OSX_ARCHITECTURES ${LIBOMP_OSX_ARCHITECTURES})
107
Jonathan Peyton89d9b332016-02-09 22:15:30108# Should @rpath be used for dynamic libraries on Mac?
109# The if(NOT DEFINED) is there to guard a cached value of the variable if one
110# exists so there is no interference with what the user wants. Also, no cache entry
111# is created so there are no inadvertant effects on other parts of LLVM.
112if(NOT DEFINED CMAKE_MACOSX_RPATH)
113 set(CMAKE_MACOSX_RPATH TRUE)
114endif()
115
Jonathan Peyton2e013352015-07-15 16:05:30116# User specified flags. These are appended to the configured flags.
Jonathan Peytonfbb15142015-05-26 17:27:01117set(LIBOMP_CXXFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19118 "Appended user specified C++ compiler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01119set(LIBOMP_CPPFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19120 "Appended user specified C preprocessor flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01121set(LIBOMP_ASMFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19122 "Appended user specified assembler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01123set(LIBOMP_LDFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19124 "Appended user specified linker flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01125set(LIBOMP_LIBFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19126 "Appended user specified linked libs flags. (e.g., -lm)")
Jonathan Peyton2e013352015-07-15 16:05:30127set(LIBOMP_FFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19128 "Appended user specified Fortran compiler flags. These are only used if LIBOMP_FORTRAN_MODULES==TRUE.")
Jim Cownie3b81ce62014-08-05 09:32:28129
Jonathan Peyton227e1ae2015-06-01 03:05:13130# Should the libomp library and generated headers be copied into the original source exports/ directory
Jonathan Peyton2e013352015-07-15 16:05:30131# Turning this to FALSE aids parallel builds to not interfere with each other.
132# Currently, the testsuite module expects the just built OpenMP library to be located inside the exports/
133# directory. TODO: have testsuite run under llvm-lit directly. We can then get rid of copying to exports/
David Trubybb099c82020-07-20 11:11:26134set(LIBOMP_COPY_EXPORTS FALSE CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19135 "Should exports be copied into source exports/ directory?")
Andrey Churbanov708fa8e2015-05-14 12:54:08136
Jonathan Peyton01dcf362015-11-30 20:02:59137# HWLOC-support
138set(LIBOMP_USE_HWLOC FALSE CACHE BOOL
139 "Use Hwloc (http://www.open-mpi.org/projects/hwloc/) library for affinity?")
140set(LIBOMP_HWLOC_INSTALL_DIR /usr/local CACHE PATH
141 "Install path for hwloc library")
142
Jonathan Peyton7cc577a2016-12-14 22:39:11143# Get the build number from kmp_version.cpp
Jonathan Peytonc0225ca2015-08-28 18:42:10144libomp_get_build_number("${CMAKE_CURRENT_SOURCE_DIR}" LIBOMP_VERSION_BUILD)
145math(EXPR LIBOMP_VERSION_BUILD_YEAR "${LIBOMP_VERSION_BUILD}/10000")
146math(EXPR LIBOMP_VERSION_BUILD_MONTH_DAY "${LIBOMP_VERSION_BUILD}%10000")
Jim Cownie3b81ce62014-08-05 09:32:28147
Jonathan Peyton2e013352015-07-15 16:05:30148# Currently don't record any timestamps
Jonathan Peytonc0225ca2015-08-28 18:42:10149set(LIBOMP_BUILD_DATE "No_Timestamp")
Jim Cownie3b81ce62014-08-05 09:32:28150
151# Architecture
152set(IA32 FALSE)
153set(INTEL64 FALSE)
154set(ARM FALSE)
Andrey Churbanovcbda8682015-01-13 14:43:35155set(AARCH64 FALSE)
Shilei Tian676c7cb2021-01-09 16:58:37156set(AARCH64_A64FX FALSE)
Andrey Churbanovd1c55042015-01-19 18:29:35157set(PPC64BE FALSE)
158set(PPC64LE FALSE)
Jim Cownie3051f972014-08-07 10:12:54159set(PPC64 FALSE)
Jonathan Peyton2e013352015-07-15 16:05:30160set(MIC FALSE)
Sylvestre Ledrucd9d3742016-12-08 09:22:24161set(MIPS64 FALSE)
162set(MIPS FALSE)
Jonas Hahnfeld2488ae92019-07-25 14:36:20163set(RISCV64 FALSE)
SignKirigami67729872022-09-19 22:49:15164set(LOONGARCH64 FALSE)
Jonathan Peyton5b4acbd2015-07-15 16:57:19165if("${LIBOMP_ARCH}" STREQUAL "i386" OR "${LIBOMP_ARCH}" STREQUAL "32") # IA-32 architecture
166 set(IA32 TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30167elseif("${LIBOMP_ARCH}" STREQUAL "x86_64" OR "${LIBOMP_ARCH}" STREQUAL "32e") # Intel(R) 64 architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19168 set(INTEL64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24169elseif("${LIBOMP_ARCH}" STREQUAL "arm") # ARM architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19170 set(ARM TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24171elseif("${LIBOMP_ARCH}" STREQUAL "ppc64") # PPC64BE architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19172 set(PPC64BE TRUE)
173 set(PPC64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24174elseif("${LIBOMP_ARCH}" STREQUAL "ppc64le") # PPC64LE architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19175 set(PPC64LE TRUE)
176 set(PPC64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24177elseif("${LIBOMP_ARCH}" STREQUAL "aarch64") # AARCH64 architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19178 set(AARCH64 TRUE)
Shilei Tian676c7cb2021-01-09 16:58:37179elseif("${LIBOMP_ARCH}" STREQUAL "aarch64_a64fx") # AARCH64_A64FX architecture
180 set(AARCH64_A64FX TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24181elseif("${LIBOMP_ARCH}" STREQUAL "mic") # Intel(R) Many Integrated Core Architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19182 set(MIC TRUE)
Sylvestre Ledrucd9d3742016-12-08 09:22:24183elseif("${LIBOMP_ARCH}" STREQUAL "mips") # MIPS architecture
184 set(MIPS TRUE)
185elseif("${LIBOMP_ARCH}" STREQUAL "mips64") # MIPS64 architecture
186 set(MIPS64 TRUE)
SignKirigami67729872022-09-19 22:49:15187elseif("${LIBOMP_ARCH}" STREQUAL "riscv64") # RISCV64 architecture
Jonas Hahnfeld2488ae92019-07-25 14:36:20188 set(RISCV64 TRUE)
SignKirigami67729872022-09-19 22:49:15189elseif("${LIBOMP_ARCH}" STREQUAL "loongarch64") # LoongArch64 architecture
190 set(LOONGARCH64 TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28191endif()
192
193# Set some flags based on build_type
Jonathan Peytonfbb15142015-05-26 17:27:01194set(RELEASE_BUILD FALSE)
195set(DEBUG_BUILD FALSE)
Jim Cownie3b81ce62014-08-05 09:32:28196set(RELWITHDEBINFO_BUILD FALSE)
Jonathan Peyton2e013352015-07-15 16:05:30197set(MINSIZEREL_BUILD FALSE)
Jonathan Peyton48b67dc2021-11-01 19:23:54198if("${uppercase_CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
Jonathan Peyton5b4acbd2015-07-15 16:57:19199 set(RELEASE_BUILD TRUE)
Jonathan Peyton48b67dc2021-11-01 19:23:54200elseif("${uppercase_CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
Jonathan Peyton5b4acbd2015-07-15 16:57:19201 set(DEBUG_BUILD TRUE)
Jonathan Peyton48b67dc2021-11-01 19:23:54202elseif("${uppercase_CMAKE_BUILD_TYPE}" STREQUAL "RELWITHDEBINFO")
Jonathan Peyton5b4acbd2015-07-15 16:57:19203 set(RELWITHDEBINFO_BUILD TRUE)
Jonathan Peyton48b67dc2021-11-01 19:23:54204elseif("${uppercase_CMAKE_BUILD_TYPE}" STREQUAL "MINSIZEREL")
Jonathan Peyton5b4acbd2015-07-15 16:57:19205 set(MINSIZEREL_BUILD TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28206endif()
207
Jonathan Peyton7abf9d52016-05-26 18:19:10208# Include itt notify interface?
209set(LIBOMP_USE_ITT_NOTIFY TRUE CACHE BOOL
210 "Enable ITT notify?")
Jim Cownie3b81ce62014-08-05 09:32:28211
212# normal, profile, stubs library.
213set(NORMAL_LIBRARY FALSE)
214set(STUBS_LIBRARY FALSE)
215set(PROFILE_LIBRARY FALSE)
Jonathan Peyton7979a072015-05-20 22:33:24216if("${LIBOMP_LIB_TYPE}" STREQUAL "normal")
Jonathan Peyton5b4acbd2015-07-15 16:57:19217 set(NORMAL_LIBRARY TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24218elseif("${LIBOMP_LIB_TYPE}" STREQUAL "profile")
Jonathan Peyton5b4acbd2015-07-15 16:57:19219 set(PROFILE_LIBRARY TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24220elseif("${LIBOMP_LIB_TYPE}" STREQUAL "stubs")
Jonathan Peyton5b4acbd2015-07-15 16:57:19221 set(STUBS_LIBRARY TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28222endif()
223
Jonathan Peyton2e013352015-07-15 16:05:30224# Setting directory names
225set(LIBOMP_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
226set(LIBOMP_SRC_DIR ${LIBOMP_BASE_DIR}/src)
227set(LIBOMP_TOOLS_DIR ${LIBOMP_BASE_DIR}/tools)
Jonathan Peytone4b4f992019-07-12 21:45:36228set(LIBOMP_INC_DIR ${LIBOMP_SRC_DIR}/include)
Jonathan Peyton614c7ef2015-09-21 20:41:31229set(LIBOMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
Jim Cownie3b81ce62014-08-05 09:32:28230
Jonathan Peyton2e013352015-07-15 16:05:30231# Enabling Fortran if it is needed
Jonathan Peyton2e013352015-07-15 16:05:30232if(${LIBOMP_FORTRAN_MODULES})
Jonathan Peyton5b4acbd2015-07-15 16:57:19233 enable_language(Fortran)
Jonathan Peyton2e013352015-07-15 16:05:30234endif()
Jonathan Peyton5b4acbd2015-07-15 16:57:19235# Enable MASM Compiler if it is needed (Windows only)
Jonathan Peyton2e013352015-07-15 16:05:30236if(WIN32)
Jonathan Peyton5b4acbd2015-07-15 16:57:19237 enable_language(ASM_MASM)
Jonathan Peyton2e013352015-07-15 16:05:30238endif()
Jim Cownie3b81ce62014-08-05 09:32:28239
Jonathan Peyton2e013352015-07-15 16:05:30240# Getting legal type/arch
241libomp_get_legal_type(LIBOMP_LEGAL_TYPE)
242libomp_get_legal_arch(LIBOMP_LEGAL_ARCH)
Jim Cownie3b81ce62014-08-05 09:32:28243
Jonathan Peyton2e013352015-07-15 16:05:30244# Compiler flag checks, library checks, threading check, etc.
245include(config-ix)
Jim Cownie3b81ce62014-08-05 09:32:28246
Jonathan Peyton2e013352015-07-15 16:05:30247# Is there a quad precision data type available?
248# TODO: Make this a real feature check
249set(LIBOMP_USE_QUAD_PRECISION "${LIBOMP_HAVE_QUAD_PRECISION}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19250 "Should 128-bit precision entry points be built?")
Jonathan Peyton2e013352015-07-15 16:05:30251if(LIBOMP_USE_QUAD_PRECISION AND (NOT LIBOMP_HAVE_QUAD_PRECISION))
Jonathan Peyton5b4acbd2015-07-15 16:57:19252 libomp_error_say("128-bit quad precision functionality requested but not available")
Jonathan Peyton2e013352015-07-15 16:05:30253endif()
254
255# libgomp drop-in compatibility requires versioned symbols
256set(LIBOMP_USE_VERSION_SYMBOLS "${LIBOMP_HAVE_VERSION_SYMBOLS}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19257 "Should version symbols be used? These provide binary compatibility with libgomp.")
Jonathan Peyton2e013352015-07-15 16:05:30258if(LIBOMP_USE_VERSION_SYMBOLS AND (NOT LIBOMP_HAVE_VERSION_SYMBOLS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19259 libomp_error_say("Version symbols functionality requested but not available")
Jonathan Peyton2e013352015-07-15 16:05:30260endif()
261
262# On multinode systems, larger alignment is desired to avoid false sharing
263set(LIBOMP_USE_INTERNODE_ALIGNMENT FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19264 "Should larger alignment (4096 bytes) be used for some locks and data structures?")
Jim Cownie4cc4bb42014-10-07 16:25:50265
Jonathan Peyton2e013352015-07-15 16:05:30266# Build code that allows the OpenMP library to conveniently interface with debuggers
267set(LIBOMP_USE_DEBUGGER FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19268 "Enable debugger interface code?")
Jonathan Peyton2e013352015-07-15 16:05:30269
270# Should we link to C++ library?
271set(LIBOMP_USE_STDCPPLIB FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19272 "Should we link to C++ library?")
Jonathan Peyton2e013352015-07-15 16:05:30273
Jonathan Peyton644f4e32017-07-28 19:05:17274# Intel(R) Transactional Synchronization Extensions (Intel(R) TSX) based locks have
275# __asm code which can be troublesome for some compilers. This feature is also x86 specific.
Jonathan Peyton2e013352015-07-15 16:05:30276# TODO: Make this a real feature check
277set(LIBOMP_USE_ADAPTIVE_LOCKS "${LIBOMP_HAVE_ADAPTIVE_LOCKS}" CACHE BOOL
Jonathan Peyton644f4e32017-07-28 19:05:17278 "Should Intel(R) TSX lock be compiled (adaptive lock in kmp_lock.cpp). These are x86 specific.")
Jonathan Peyton2e013352015-07-15 16:05:30279if(LIBOMP_USE_ADAPTIVE_LOCKS AND (NOT LIBOMP_HAVE_ADAPTIVE_LOCKS))
Jonathan Peyton644f4e32017-07-28 19:05:17280 libomp_error_say("Adaptive locks (Intel(R) TSX) functionality is only supported on x86 Architecture")
Jim Cownie4cc4bb42014-10-07 16:25:50281endif()
282
Jonathan Peyton2e013352015-07-15 16:05:30283# - stats-gathering enables OpenMP stats where things like the number of
284# parallel regions, clock ticks spent in particular openmp regions are recorded.
Jonathan Peyton2e013352015-07-15 16:05:30285set(LIBOMP_STATS FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19286 "Stats-Gathering functionality?")
Jonathan Peyton2e013352015-07-15 16:05:30287if(LIBOMP_STATS AND (NOT LIBOMP_HAVE_STATS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19288 libomp_error_say("Stats-gathering functionality requested but not available")
Jim Cownie3b81ce62014-08-05 09:32:28289endif()
Jonathan Peyton45be4502015-08-11 21:36:41290# The stats functionality requires the std c++ library
291if(LIBOMP_STATS)
292 set(LIBOMP_USE_STDCPPLIB TRUE)
293endif()
Jim Cownie3b81ce62014-08-05 09:32:28294
Jonathan Peytonfd74f902016-02-04 19:29:35295# Shared library can be switched to a static library
296set(LIBOMP_ENABLE_SHARED TRUE CACHE BOOL
297 "Shared library instead of static library?")
298
299if(WIN32 AND NOT LIBOMP_ENABLE_SHARED)
300 libomp_error_say("Static libraries requested but not available on Windows")
301endif()
302
Andrey Churbanov31d39bf2017-03-31 16:20:07303if(LIBOMP_USE_ITT_NOTIFY AND NOT LIBOMP_ENABLE_SHARED)
304 message(STATUS "ITT Notify not supported for static libraries - forcing ITT Notify off")
305 set(LIBOMP_USE_ITT_NOTIFY FALSE)
306endif()
307
Jonathan Peyton038855a2017-08-02 20:10:00308if(LIBOMP_USE_VERSION_SYMBOLS AND (NOT LIBOMP_ENABLE_SHARED) )
309 message(STATUS "Version symbols not supported for static libraries - forcing Version symbols functionality off")
310 set (LIBOMP_USE_VERSION_SYMBOLS FALSE)
311endif()
312
Joachim Protzee5e4afd2018-01-02 21:09:00313# OMPT-support defaults to ON for OpenMP 5.0+ and if the requirements in
314# cmake/config-ix.cmake are fulfilled.
315set(OMPT_DEFAULT FALSE)
Jonathan Peytone4b4f992019-07-12 21:45:36316if ((LIBOMP_HAVE_OMPT_SUPPORT) AND (NOT WIN32))
Joachim Protzee5e4afd2018-01-02 21:09:00317 set(OMPT_DEFAULT TRUE)
318endif()
319set(LIBOMP_OMPT_SUPPORT ${OMPT_DEFAULT} CACHE BOOL
320 "OMPT-support?")
321
Jonathan Peyton95246e72015-11-05 16:54:55322set(LIBOMP_OMPT_DEBUG FALSE CACHE BOOL
323 "Trace OMPT initialization?")
Joachim Protze82e94a52017-11-01 10:08:30324set(LIBOMP_OMPT_OPTIONAL TRUE CACHE BOOL
325 "OMPT-optional?")
Jonathan Peyton2e013352015-07-15 16:05:30326if(LIBOMP_OMPT_SUPPORT AND (NOT LIBOMP_HAVE_OMPT_SUPPORT))
Jonathan Peyton7b16ae22017-10-20 20:14:46327 libomp_error_say("OpenMP Tools Interface requested but not available in this implementation")
328endif()
Jim Cownie3b81ce62014-08-05 09:32:28329
Vignesh Balasubramanianf61602b02021-06-08 11:03:39330# OMPD-support
331# Enable if OMPT SUPPORT is ON
332set(OMPD_DEFAULT FALSE)
333if (LIBOMP_HAVE_OMPT_SUPPORT AND ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))
334 set(OMPD_DEFAULT TRUE)
335endif()
336
337set(LIBOMP_OMPD_SUPPORT ${OMPD_DEFAULT} CACHE BOOL
338 "OMPD-support?")
339
340if(LIBOMP_OMPD_SUPPORT AND ((NOT LIBOMP_OMPT_SUPPORT) OR (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")))
Vignesh Balasubramanian23eced92021-07-27 10:47:07341 libomp_warning_say("OpenMP Debug Interface(OMPD) requested but not available in this implementation")
342 set(LIBOMP_OMPD_SUPPORT FALSE)
Vignesh Balasubramanianf61602b02021-06-08 11:03:39343endif()
344
Jonathan Peyton01dcf362015-11-30 20:02:59345# Error check hwloc support after config-ix has run
346if(LIBOMP_USE_HWLOC AND (NOT LIBOMP_HAVE_HWLOC))
347 libomp_error_say("Hwloc requested but not available")
348endif()
349
Jonathan Peytonf6399362018-07-09 17:51:13350# Hierarchical scheduling support
351set(LIBOMP_USE_HIER_SCHED FALSE CACHE BOOL
352 "Hierarchical scheduling support?")
353
Jim Cownie3b81ce62014-08-05 09:32:28354# Setting final library name
Jonathan Peyton2e013352015-07-15 16:05:30355set(LIBOMP_DEFAULT_LIB_NAME libomp)
Jim Cownie3b81ce62014-08-05 09:32:28356if(${PROFILE_LIBRARY})
Jonathan Peyton5b4acbd2015-07-15 16:57:19357 set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}prof)
Jim Cownie3b81ce62014-08-05 09:32:28358endif()
359if(${STUBS_LIBRARY})
Jonathan Peyton5b4acbd2015-07-15 16:57:19360 set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}stubs)
Jim Cownie3b81ce62014-08-05 09:32:28361endif()
Jonathan Peyton2e013352015-07-15 16:05:30362set(LIBOMP_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME} CACHE STRING "Base OMP library name")
Bran Hagger9f15cac2021-11-11 19:08:25363if (OPENMP_MSVC_NAME_SCHEME)
364 # MSVC_TOOLS_VERSION corresponds to the version of the VC++ toolset.
365 set(MSVC_TOOLS_VERSION 140)
366 set(LIBOMP_LIB_NAME ${LIBOMP_LIB_NAME}${MSVC_TOOLS_VERSION}.${LIBOMP_ARCH})
367endif()
Jonathan Peytonfd74f902016-02-04 19:29:35368
369if(${LIBOMP_ENABLE_SHARED})
370 set(LIBOMP_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
Jonathan Peyton975dabc2016-05-17 20:51:24371 set(LIBOMP_LIBRARY_KIND SHARED)
372 set(LIBOMP_INSTALL_KIND LIBRARY)
Jonathan Peytonfd74f902016-02-04 19:29:35373else()
374 set(LIBOMP_LIBRARY_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
Jonathan Peyton975dabc2016-05-17 20:51:24375 set(LIBOMP_LIBRARY_KIND STATIC)
376 set(LIBOMP_INSTALL_KIND ARCHIVE)
Jonathan Peytonfd74f902016-02-04 19:29:35377endif()
378
379set(LIBOMP_LIB_FILE ${LIBOMP_LIB_NAME}${LIBOMP_LIBRARY_SUFFIX})
Jim Cownie3b81ce62014-08-05 09:32:28380
Michal Gorny23132eb2016-09-14 17:46:27381# Optional backwards compatibility aliases.
382set(LIBOMP_INSTALL_ALIASES TRUE CACHE BOOL
383 "Install libgomp and libiomp5 library aliases for backwards compatibility")
384
Jim Cownie3b81ce62014-08-05 09:32:28385# Print configuration after all variables are set.
Jonas Hahnfeld3e921d32017-11-29 19:31:43386if(${OPENMP_STANDALONE_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:19387 libomp_say("Operating System -- ${CMAKE_SYSTEM_NAME}")
388 libomp_say("Target Architecture -- ${LIBOMP_ARCH}")
389 if(${MIC})
390 libomp_say("Intel(R) MIC Architecture -- ${LIBOMP_MIC_ARCH}")
391 endif()
392 libomp_say("Build Type -- ${CMAKE_BUILD_TYPE}")
Jonathan Peytonfd74f902016-02-04 19:29:35393 libomp_say("Library Kind -- ${LIBOMP_LIBRARY_KIND}")
394 libomp_say("Library Type -- ${LIBOMP_LIB_TYPE}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19395 libomp_say("Fortran Modules -- ${LIBOMP_FORTRAN_MODULES}")
396 # will say development if all zeros
Jonathan Peytonc0225ca2015-08-28 18:42:10397 if(${LIBOMP_VERSION_BUILD} STREQUAL 00000000)
Jonathan Peyton5b4acbd2015-07-15 16:57:19398 set(LIBOMP_BUILD Development)
399 else()
Jonathan Peytonc0225ca2015-08-28 18:42:10400 set(LIBOMP_BUILD ${LIBOMP_VERSION_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:19401 endif()
402 libomp_say("Build -- ${LIBOMP_BUILD}")
403 libomp_say("Use Stats-gathering -- ${LIBOMP_STATS}")
404 libomp_say("Use Debugger-support -- ${LIBOMP_USE_DEBUGGER}")
Jonathan Peyton7abf9d52016-05-26 18:19:10405 libomp_say("Use ITT notify -- ${LIBOMP_USE_ITT_NOTIFY}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19406 libomp_say("Use OMPT-support -- ${LIBOMP_OMPT_SUPPORT}")
407 if(${LIBOMP_OMPT_SUPPORT})
Joachim Protze82e94a52017-11-01 10:08:30408 libomp_say("Use OMPT-optional -- ${LIBOMP_OMPT_OPTIONAL}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19409 endif()
Vignesh Balasubramanianf61602b02021-06-08 11:03:39410 libomp_say("Use OMPD-support -- ${LIBOMP_OMPD_SUPPORT}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19411 libomp_say("Use Adaptive locks -- ${LIBOMP_USE_ADAPTIVE_LOCKS}")
412 libomp_say("Use quad precision -- ${LIBOMP_USE_QUAD_PRECISION}")
Jonathan Peyton01dcf362015-11-30 20:02:59413 libomp_say("Use Hwloc library -- ${LIBOMP_USE_HWLOC}")
Jim Cownie3b81ce62014-08-05 09:32:28414endif()
Andrey Churbanov648467e2015-05-05 20:02:52415
Jonathan Peyton52158902015-06-11 17:23:57416add_subdirectory(src)
Jonathan Peyton614c7ef2015-09-21 20:41:31417add_subdirectory(test)
[email protected]2b8115b2019-11-18 00:23:31418
419# make these variables available for tools:
420set(LIBOMP_LIBRARY_DIR ${LIBOMP_LIBRARY_DIR} PARENT_SCOPE)
421set(LIBOMP_INCLUDE_DIR ${LIBOMP_INCLUDE_DIR} PARENT_SCOPE)
Dhruva Chakrabarti5b67bce2022-11-15 20:27:04422set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${LIBOMP_OMP_TOOLS_INCLUDE_DIR} PARENT_SCOPE)
Vignesh Balasubramanianf61602b02021-06-08 11:03:39423# make these variables available for tools/libompd:
424set(LIBOMP_SRC_DIR ${LIBOMP_SRC_DIR} PARENT_SCOPE)
Usman Nadeem248342b2021-09-21 19:45:15425set(LIBOMP_OMPD_SUPPORT ${LIBOMP_OMPD_SUPPORT} PARENT_SCOPE)