blob: d17d95e3f2994a433f37f0817cf77a7c8060ad42 [file] [log] [blame]
Jim Cownie3b81ce62014-08-05 09:32:281#
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#
Alp Toker7198f522014-06-01 18:01:3311
Jonas Hahnfeld3e921d32017-11-29 19:31:4312if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
13 message(FATAL_ERROR "Direct configuration not supported, please use parent directory!")
14endif()
Alp Toker7198f522014-06-01 18:01:3315
Jim Cownie3b81ce62014-08-05 09:32:2816# Add cmake directory to search for custom cmake functions
17set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
18
Jonathan Peytonc0225ca2015-08-28 18:42:1019# Set libomp version
20set(LIBOMP_VERSION_MAJOR 5)
21set(LIBOMP_VERSION_MINOR 0)
22
Jonathan Peyton2e013352015-07-15 16:05:3023# These include files are in the cmake/ subdirectory
24include(LibompUtils)
25include(LibompGetArchitecture)
26include(LibompHandleFlags)
27include(LibompDefinitions)
Jim Cownie3b81ce62014-08-05 09:32:2828
Jonathan Peyton2e013352015-07-15 16:05:3029# Determine the target architecture
Jonas Hahnfeld3e921d32017-11-29 19:31:4330if(${OPENMP_STANDALONE_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:1931 # If adding a new architecture, take a look at cmake/LibompGetArchitecture.cmake
32 libomp_get_architecture(LIBOMP_DETECTED_ARCH)
33 set(LIBOMP_ARCH ${LIBOMP_DETECTED_ARCH} CACHE STRING
Sylvestre Ledrucd9d3742016-12-08 09:22:2434 "The architecture to build for (x86_64/i386/arm/ppc64/ppc64le/aarch64/mic/mips/mips64).")
Jonathan Peyton5b4acbd2015-07-15 16:57:1935 # Should assertions be enabled? They are on by default.
36 set(LIBOMP_ENABLE_ASSERTIONS TRUE CACHE BOOL
37 "enable assertions?")
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)
62 else()
63 # last ditch effort
64 libomp_get_architecture(LIBOMP_ARCH)
65 endif ()
Jonathan Peyton5b4acbd2015-07-15 16:57:1966 set(LIBOMP_ENABLE_ASSERTIONS ${LLVM_ENABLE_ASSERTIONS})
Jim Cownie3b81ce62014-08-05 09:32:2867endif()
Sylvestre Ledrucd9d3742016-12-08 09:22:2468libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc64 ppc64le aarch64 mic mips mips64)
Jim Cownie3b81ce62014-08-05 09:32:2869
Jonathan Peytonfbb15142015-05-26 17:27:0170set(LIBOMP_LIB_TYPE normal CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:1971 "Performance,Profiling,Stubs library (normal/profile/stubs)")
Jonathan Peyton2e013352015-07-15 16:05:3072libomp_check_variable(LIBOMP_LIB_TYPE normal profile stubs)
Jonathan Peytone844a542017-03-06 22:07:4073set(LIBOMP_OMP_VERSION 50 CACHE STRING
74 "The OpenMP version (50/45/40/30)")
75libomp_check_variable(LIBOMP_OMP_VERSION 50 45 40 30)
Jonathan Peytonc0225ca2015-08-28 18:42:1076# Set the OpenMP Year and Month assiociated with version
Jonathan Peytone844a542017-03-06 22:07:4077if(${LIBOMP_OMP_VERSION} GREATER 50 OR ${LIBOMP_OMP_VERSION} EQUAL 50)
78 set(LIBOMP_OMP_YEAR_MONTH 201611)
79elseif(${LIBOMP_OMP_VERSION} GREATER 45 OR ${LIBOMP_OMP_VERSION} EQUAL 45)
Jonathan Peyton74f3ffc2016-09-30 15:50:1480 set(LIBOMP_OMP_YEAR_MONTH 201511)
81elseif(${LIBOMP_OMP_VERSION} GREATER 40 OR ${LIBOMP_OMP_VERSION} EQUAL 40)
Jonathan Peytonc0225ca2015-08-28 18:42:1082 set(LIBOMP_OMP_YEAR_MONTH 201307)
83elseif(${LIBOMP_OMP_VERSION} GREATER 30 OR ${LIBOMP_OMP_VERSION} EQUAL 30)
84 set(LIBOMP_OMP_YEAR_MONTH 201107)
85else()
86 set(LIBOMP_OMP_YEAR_MONTH 200505)
87endif()
Jonathan Peyton2e013352015-07-15 16:05:3088set(LIBOMP_MIC_ARCH knc CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:1989 "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:3090if("${LIBOMP_ARCH}" STREQUAL "mic")
Jonathan Peyton5b4acbd2015-07-15 16:57:1991 libomp_check_variable(LIBOMP_MIC_ARCH knf knc)
Jonathan Peyton2e013352015-07-15 16:05:3092endif()
93set(LIBOMP_FORTRAN_MODULES FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:1994 "Create Fortran module files? (requires fortran compiler)")
Jim Cownie3b81ce62014-08-05 09:32:2895
Jonathan Peyton92907c22015-05-29 16:13:5696# - Support for universal fat binary builds on Mac
Jonathan Peyton2e013352015-07-15 16:05:3097# - Having this extra variable allows people to build this library as a universal library
Jonathan Peyton92907c22015-05-29 16:13:5698# without forcing a universal build of the llvm/clang compiler.
99set(LIBOMP_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19100 "For Mac builds, semicolon separated list of architectures to build for universal fat binary.")
Jonathan Peyton92907c22015-05-29 16:13:56101set(CMAKE_OSX_ARCHITECTURES ${LIBOMP_OSX_ARCHITECTURES})
102
Jonathan Peyton89d9b332016-02-09 22:15:30103# Should @rpath be used for dynamic libraries on Mac?
104# The if(NOT DEFINED) is there to guard a cached value of the variable if one
105# exists so there is no interference with what the user wants. Also, no cache entry
106# is created so there are no inadvertant effects on other parts of LLVM.
107if(NOT DEFINED CMAKE_MACOSX_RPATH)
108 set(CMAKE_MACOSX_RPATH TRUE)
109endif()
110
Jonathan Peyton2e013352015-07-15 16:05:30111# User specified flags. These are appended to the configured flags.
Jonathan Peytonfbb15142015-05-26 17:27:01112set(LIBOMP_CFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19113 "Appended user specified C compiler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01114set(LIBOMP_CXXFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19115 "Appended user specified C++ compiler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01116set(LIBOMP_CPPFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19117 "Appended user specified C preprocessor flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01118set(LIBOMP_ASMFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19119 "Appended user specified assembler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01120set(LIBOMP_LDFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19121 "Appended user specified linker flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01122set(LIBOMP_LIBFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19123 "Appended user specified linked libs flags. (e.g., -lm)")
Jonathan Peyton2e013352015-07-15 16:05:30124set(LIBOMP_FFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19125 "Appended user specified Fortran compiler flags. These are only used if LIBOMP_FORTRAN_MODULES==TRUE.")
Jim Cownie3b81ce62014-08-05 09:32:28126
Jonathan Peyton227e1ae2015-06-01 03:05:13127# Should the libomp library and generated headers be copied into the original source exports/ directory
Jonathan Peyton2e013352015-07-15 16:05:30128# Turning this to FALSE aids parallel builds to not interfere with each other.
129# Currently, the testsuite module expects the just built OpenMP library to be located inside the exports/
130# directory. TODO: have testsuite run under llvm-lit directly. We can then get rid of copying to exports/
131set(LIBOMP_COPY_EXPORTS TRUE CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19132 "Should exports be copied into source exports/ directory?")
Andrey Churbanov708fa8e2015-05-14 12:54:08133
Jonathan Peyton01dcf362015-11-30 20:02:59134# HWLOC-support
135set(LIBOMP_USE_HWLOC FALSE CACHE BOOL
136 "Use Hwloc (http://www.open-mpi.org/projects/hwloc/) library for affinity?")
137set(LIBOMP_HWLOC_INSTALL_DIR /usr/local CACHE PATH
138 "Install path for hwloc library")
139
Jonathan Peyton7cc577a2016-12-14 22:39:11140# Get the build number from kmp_version.cpp
Jonathan Peytonc0225ca2015-08-28 18:42:10141libomp_get_build_number("${CMAKE_CURRENT_SOURCE_DIR}" LIBOMP_VERSION_BUILD)
142math(EXPR LIBOMP_VERSION_BUILD_YEAR "${LIBOMP_VERSION_BUILD}/10000")
143math(EXPR LIBOMP_VERSION_BUILD_MONTH_DAY "${LIBOMP_VERSION_BUILD}%10000")
Jim Cownie3b81ce62014-08-05 09:32:28144
Jonathan Peyton2e013352015-07-15 16:05:30145# Currently don't record any timestamps
Jonathan Peytonc0225ca2015-08-28 18:42:10146set(LIBOMP_BUILD_DATE "No_Timestamp")
Jim Cownie3b81ce62014-08-05 09:32:28147
148# Architecture
149set(IA32 FALSE)
150set(INTEL64 FALSE)
151set(ARM FALSE)
Andrey Churbanovcbda8682015-01-13 14:43:35152set(AARCH64 FALSE)
Andrey Churbanovd1c55042015-01-19 18:29:35153set(PPC64BE FALSE)
154set(PPC64LE FALSE)
Jim Cownie3051f972014-08-07 10:12:54155set(PPC64 FALSE)
Jonathan Peyton2e013352015-07-15 16:05:30156set(MIC FALSE)
Sylvestre Ledrucd9d3742016-12-08 09:22:24157set(MIPS64 FALSE)
158set(MIPS FALSE)
Jonathan Peyton5b4acbd2015-07-15 16:57:19159if("${LIBOMP_ARCH}" STREQUAL "i386" OR "${LIBOMP_ARCH}" STREQUAL "32") # IA-32 architecture
160 set(IA32 TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30161elseif("${LIBOMP_ARCH}" STREQUAL "x86_64" OR "${LIBOMP_ARCH}" STREQUAL "32e") # Intel(R) 64 architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19162 set(INTEL64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24163elseif("${LIBOMP_ARCH}" STREQUAL "arm") # ARM architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19164 set(ARM TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24165elseif("${LIBOMP_ARCH}" STREQUAL "ppc64") # PPC64BE architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19166 set(PPC64BE TRUE)
167 set(PPC64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24168elseif("${LIBOMP_ARCH}" STREQUAL "ppc64le") # PPC64LE architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19169 set(PPC64LE TRUE)
170 set(PPC64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24171elseif("${LIBOMP_ARCH}" STREQUAL "aarch64") # AARCH64 architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19172 set(AARCH64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24173elseif("${LIBOMP_ARCH}" STREQUAL "mic") # Intel(R) Many Integrated Core Architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19174 set(MIC TRUE)
Sylvestre Ledrucd9d3742016-12-08 09:22:24175elseif("${LIBOMP_ARCH}" STREQUAL "mips") # MIPS architecture
176 set(MIPS TRUE)
177elseif("${LIBOMP_ARCH}" STREQUAL "mips64") # MIPS64 architecture
178 set(MIPS64 TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28179endif()
180
181# Set some flags based on build_type
Jonathan Peytonfbb15142015-05-26 17:27:01182set(RELEASE_BUILD FALSE)
183set(DEBUG_BUILD FALSE)
Jim Cownie3b81ce62014-08-05 09:32:28184set(RELWITHDEBINFO_BUILD FALSE)
Jonathan Peyton2e013352015-07-15 16:05:30185set(MINSIZEREL_BUILD FALSE)
186string(TOLOWER "${CMAKE_BUILD_TYPE}" libomp_build_type_lowercase)
187if("${libomp_build_type_lowercase}" STREQUAL "release")
Jonathan Peyton5b4acbd2015-07-15 16:57:19188 set(RELEASE_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30189elseif("${libomp_build_type_lowercase}" STREQUAL "debug")
Jonathan Peyton5b4acbd2015-07-15 16:57:19190 set(DEBUG_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30191elseif("${libomp_build_type_lowercase}" STREQUAL "relwithdebinfo")
Jonathan Peyton5b4acbd2015-07-15 16:57:19192 set(RELWITHDEBINFO_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30193elseif("${libomp_build_type_lowercase}" STREQUAL "minsizerel")
Jonathan Peyton5b4acbd2015-07-15 16:57:19194 set(MINSIZEREL_BUILD TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28195endif()
196
Jonathan Peyton7abf9d52016-05-26 18:19:10197# Include itt notify interface?
198set(LIBOMP_USE_ITT_NOTIFY TRUE CACHE BOOL
199 "Enable ITT notify?")
Jim Cownie3b81ce62014-08-05 09:32:28200
201# normal, profile, stubs library.
202set(NORMAL_LIBRARY FALSE)
203set(STUBS_LIBRARY FALSE)
204set(PROFILE_LIBRARY FALSE)
Jonathan Peyton7979a072015-05-20 22:33:24205if("${LIBOMP_LIB_TYPE}" STREQUAL "normal")
Jonathan Peyton5b4acbd2015-07-15 16:57:19206 set(NORMAL_LIBRARY TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24207elseif("${LIBOMP_LIB_TYPE}" STREQUAL "profile")
Jonathan Peyton5b4acbd2015-07-15 16:57:19208 set(PROFILE_LIBRARY TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24209elseif("${LIBOMP_LIB_TYPE}" STREQUAL "stubs")
Jonathan Peyton5b4acbd2015-07-15 16:57:19210 set(STUBS_LIBRARY TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28211endif()
212
Jonathan Peyton2e013352015-07-15 16:05:30213# Setting directory names
214set(LIBOMP_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
215set(LIBOMP_SRC_DIR ${LIBOMP_BASE_DIR}/src)
216set(LIBOMP_TOOLS_DIR ${LIBOMP_BASE_DIR}/tools)
217set(LIBOMP_INC_DIR ${LIBOMP_SRC_DIR}/include/${LIBOMP_OMP_VERSION})
Jonathan Peyton614c7ef2015-09-21 20:41:31218set(LIBOMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
Jim Cownie3b81ce62014-08-05 09:32:28219
Jonathan Peyton2e013352015-07-15 16:05:30220# Enabling Fortran if it is needed
Jonathan Peyton2e013352015-07-15 16:05:30221if(${LIBOMP_FORTRAN_MODULES})
Jonathan Peyton5b4acbd2015-07-15 16:57:19222 enable_language(Fortran)
Jonathan Peyton2e013352015-07-15 16:05:30223endif()
Jonathan Peyton5b4acbd2015-07-15 16:57:19224# Enable MASM Compiler if it is needed (Windows only)
Jonathan Peyton2e013352015-07-15 16:05:30225if(WIN32)
Jonathan Peyton5b4acbd2015-07-15 16:57:19226 enable_language(ASM_MASM)
Jonathan Peyton2e013352015-07-15 16:05:30227endif()
Jim Cownie3b81ce62014-08-05 09:32:28228
Jonathan Peyton2e013352015-07-15 16:05:30229# Getting legal type/arch
230libomp_get_legal_type(LIBOMP_LEGAL_TYPE)
231libomp_get_legal_arch(LIBOMP_LEGAL_ARCH)
Jim Cownie3b81ce62014-08-05 09:32:28232
Jonathan Peyton2e013352015-07-15 16:05:30233# Compiler flag checks, library checks, threading check, etc.
234include(config-ix)
Jim Cownie3b81ce62014-08-05 09:32:28235
Jonathan Peyton2e013352015-07-15 16:05:30236# Is there a quad precision data type available?
237# TODO: Make this a real feature check
238set(LIBOMP_USE_QUAD_PRECISION "${LIBOMP_HAVE_QUAD_PRECISION}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19239 "Should 128-bit precision entry points be built?")
Jonathan Peyton2e013352015-07-15 16:05:30240if(LIBOMP_USE_QUAD_PRECISION AND (NOT LIBOMP_HAVE_QUAD_PRECISION))
Jonathan Peyton5b4acbd2015-07-15 16:57:19241 libomp_error_say("128-bit quad precision functionality requested but not available")
Jonathan Peyton2e013352015-07-15 16:05:30242endif()
243
244# libgomp drop-in compatibility requires versioned symbols
245set(LIBOMP_USE_VERSION_SYMBOLS "${LIBOMP_HAVE_VERSION_SYMBOLS}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19246 "Should version symbols be used? These provide binary compatibility with libgomp.")
Jonathan Peyton2e013352015-07-15 16:05:30247if(LIBOMP_USE_VERSION_SYMBOLS AND (NOT LIBOMP_HAVE_VERSION_SYMBOLS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19248 libomp_error_say("Version symbols functionality requested but not available")
Jonathan Peyton2e013352015-07-15 16:05:30249endif()
250
251# On multinode systems, larger alignment is desired to avoid false sharing
252set(LIBOMP_USE_INTERNODE_ALIGNMENT FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19253 "Should larger alignment (4096 bytes) be used for some locks and data structures?")
Jim Cownie4cc4bb42014-10-07 16:25:50254
Jonathan Peyton2e013352015-07-15 16:05:30255# Build code that allows the OpenMP library to conveniently interface with debuggers
256set(LIBOMP_USE_DEBUGGER FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19257 "Enable debugger interface code?")
Jonathan Peyton2e013352015-07-15 16:05:30258
259# Should we link to C++ library?
260set(LIBOMP_USE_STDCPPLIB FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19261 "Should we link to C++ library?")
Jonathan Peyton2e013352015-07-15 16:05:30262
Jonathan Peyton644f4e32017-07-28 19:05:17263# Intel(R) Transactional Synchronization Extensions (Intel(R) TSX) based locks have
264# __asm code which can be troublesome for some compilers. This feature is also x86 specific.
Jonathan Peyton2e013352015-07-15 16:05:30265# TODO: Make this a real feature check
266set(LIBOMP_USE_ADAPTIVE_LOCKS "${LIBOMP_HAVE_ADAPTIVE_LOCKS}" CACHE BOOL
Jonathan Peyton644f4e32017-07-28 19:05:17267 "Should Intel(R) TSX lock be compiled (adaptive lock in kmp_lock.cpp). These are x86 specific.")
Jonathan Peyton2e013352015-07-15 16:05:30268if(LIBOMP_USE_ADAPTIVE_LOCKS AND (NOT LIBOMP_HAVE_ADAPTIVE_LOCKS))
Jonathan Peyton644f4e32017-07-28 19:05:17269 libomp_error_say("Adaptive locks (Intel(R) TSX) functionality is only supported on x86 Architecture")
Jim Cownie4cc4bb42014-10-07 16:25:50270endif()
271
Jonathan Peyton2e013352015-07-15 16:05:30272# - stats-gathering enables OpenMP stats where things like the number of
273# parallel regions, clock ticks spent in particular openmp regions are recorded.
Jonathan Peyton2e013352015-07-15 16:05:30274set(LIBOMP_STATS FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19275 "Stats-Gathering functionality?")
Jonathan Peyton2e013352015-07-15 16:05:30276if(LIBOMP_STATS AND (NOT LIBOMP_HAVE_STATS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19277 libomp_error_say("Stats-gathering functionality requested but not available")
Jim Cownie3b81ce62014-08-05 09:32:28278endif()
Jonathan Peyton45be4502015-08-11 21:36:41279# The stats functionality requires the std c++ library
280if(LIBOMP_STATS)
281 set(LIBOMP_USE_STDCPPLIB TRUE)
282endif()
Jim Cownie3b81ce62014-08-05 09:32:28283
Jonathan Peytonfd74f902016-02-04 19:29:35284# Shared library can be switched to a static library
285set(LIBOMP_ENABLE_SHARED TRUE CACHE BOOL
286 "Shared library instead of static library?")
287
288if(WIN32 AND NOT LIBOMP_ENABLE_SHARED)
289 libomp_error_say("Static libraries requested but not available on Windows")
290endif()
291
Andrey Churbanov31d39bf2017-03-31 16:20:07292if(LIBOMP_USE_ITT_NOTIFY AND NOT LIBOMP_ENABLE_SHARED)
293 message(STATUS "ITT Notify not supported for static libraries - forcing ITT Notify off")
294 set(LIBOMP_USE_ITT_NOTIFY FALSE)
295endif()
296
Jonathan Peyton038855a2017-08-02 20:10:00297if(LIBOMP_USE_VERSION_SYMBOLS AND (NOT LIBOMP_ENABLE_SHARED) )
298 message(STATUS "Version symbols not supported for static libraries - forcing Version symbols functionality off")
299 set (LIBOMP_USE_VERSION_SYMBOLS FALSE)
300endif()
301
Joachim Protzee5e4afd2018-01-02 21:09:00302# OMPT-support defaults to ON for OpenMP 5.0+ and if the requirements in
303# cmake/config-ix.cmake are fulfilled.
304set(OMPT_DEFAULT FALSE)
305if ((${LIBOMP_OMP_VERSION} GREATER 49) AND (LIBOMP_HAVE_OMPT_SUPPORT))
306 set(OMPT_DEFAULT TRUE)
307endif()
308set(LIBOMP_OMPT_SUPPORT ${OMPT_DEFAULT} CACHE BOOL
309 "OMPT-support?")
310
Jonathan Peyton95246e72015-11-05 16:54:55311set(LIBOMP_OMPT_DEBUG FALSE CACHE BOOL
312 "Trace OMPT initialization?")
Joachim Protze82e94a52017-11-01 10:08:30313set(LIBOMP_OMPT_OPTIONAL TRUE CACHE BOOL
314 "OMPT-optional?")
Jonathan Peyton2e013352015-07-15 16:05:30315if(LIBOMP_OMPT_SUPPORT AND (NOT LIBOMP_HAVE_OMPT_SUPPORT))
Jonathan Peyton7b16ae22017-10-20 20:14:46316 libomp_error_say("OpenMP Tools Interface requested but not available in this implementation")
317endif()
318if(LIBOMP_OMPT_SUPPORT AND (${LIBOMP_OMP_VERSION} LESS 50))
Jonas Hahnfeldf0a1c652017-11-03 18:28:19319 libomp_error_say("OpenMP Tools Interface only available with OpenMP 5.0, LIBOMP_OMP_VERSION is ${LIBOMP_OMP_VERSION}")
Jonathan Peytonb689ded2015-06-17 15:43:34320endif()
Jim Cownie3b81ce62014-08-05 09:32:28321
Jonas Hahnfeld50fed042016-11-07 15:58:36322# TSAN-support
323set(LIBOMP_TSAN_SUPPORT FALSE CACHE BOOL
324 "TSAN-support?")
325if(LIBOMP_TSAN_SUPPORT AND (NOT LIBOMP_HAVE_TSAN_SUPPORT))
326 libomp_error_say("TSAN functionality requested but not available")
327endif()
328
Jonathan Peyton01dcf362015-11-30 20:02:59329# Error check hwloc support after config-ix has run
330if(LIBOMP_USE_HWLOC AND (NOT LIBOMP_HAVE_HWLOC))
331 libomp_error_say("Hwloc requested but not available")
332endif()
333
Jim Cownie3b81ce62014-08-05 09:32:28334# Setting final library name
Jonathan Peyton2e013352015-07-15 16:05:30335set(LIBOMP_DEFAULT_LIB_NAME libomp)
Jim Cownie3b81ce62014-08-05 09:32:28336if(${PROFILE_LIBRARY})
Jonathan Peyton5b4acbd2015-07-15 16:57:19337 set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}prof)
Jim Cownie3b81ce62014-08-05 09:32:28338endif()
339if(${STUBS_LIBRARY})
Jonathan Peyton5b4acbd2015-07-15 16:57:19340 set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}stubs)
Jim Cownie3b81ce62014-08-05 09:32:28341endif()
Jonathan Peyton2e013352015-07-15 16:05:30342set(LIBOMP_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME} CACHE STRING "Base OMP library name")
Jonathan Peytonfd74f902016-02-04 19:29:35343
344if(${LIBOMP_ENABLE_SHARED})
345 set(LIBOMP_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
Jonathan Peyton975dabc2016-05-17 20:51:24346 set(LIBOMP_LIBRARY_KIND SHARED)
347 set(LIBOMP_INSTALL_KIND LIBRARY)
Jonathan Peytonfd74f902016-02-04 19:29:35348else()
349 set(LIBOMP_LIBRARY_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
Jonathan Peyton975dabc2016-05-17 20:51:24350 set(LIBOMP_LIBRARY_KIND STATIC)
351 set(LIBOMP_INSTALL_KIND ARCHIVE)
Jonathan Peytonfd74f902016-02-04 19:29:35352endif()
353
354set(LIBOMP_LIB_FILE ${LIBOMP_LIB_NAME}${LIBOMP_LIBRARY_SUFFIX})
Jim Cownie3b81ce62014-08-05 09:32:28355
Michal Gorny23132eb2016-09-14 17:46:27356# Optional backwards compatibility aliases.
357set(LIBOMP_INSTALL_ALIASES TRUE CACHE BOOL
358 "Install libgomp and libiomp5 library aliases for backwards compatibility")
359
Jim Cownie3b81ce62014-08-05 09:32:28360# Print configuration after all variables are set.
Jonas Hahnfeld3e921d32017-11-29 19:31:43361if(${OPENMP_STANDALONE_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:19362 libomp_say("Operating System -- ${CMAKE_SYSTEM_NAME}")
363 libomp_say("Target Architecture -- ${LIBOMP_ARCH}")
364 if(${MIC})
365 libomp_say("Intel(R) MIC Architecture -- ${LIBOMP_MIC_ARCH}")
366 endif()
367 libomp_say("Build Type -- ${CMAKE_BUILD_TYPE}")
368 libomp_say("OpenMP Version -- ${LIBOMP_OMP_VERSION}")
Jonathan Peytonfd74f902016-02-04 19:29:35369 libomp_say("Library Kind -- ${LIBOMP_LIBRARY_KIND}")
370 libomp_say("Library Type -- ${LIBOMP_LIB_TYPE}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19371 libomp_say("Fortran Modules -- ${LIBOMP_FORTRAN_MODULES}")
372 # will say development if all zeros
Jonathan Peytonc0225ca2015-08-28 18:42:10373 if(${LIBOMP_VERSION_BUILD} STREQUAL 00000000)
Jonathan Peyton5b4acbd2015-07-15 16:57:19374 set(LIBOMP_BUILD Development)
375 else()
Jonathan Peytonc0225ca2015-08-28 18:42:10376 set(LIBOMP_BUILD ${LIBOMP_VERSION_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:19377 endif()
378 libomp_say("Build -- ${LIBOMP_BUILD}")
379 libomp_say("Use Stats-gathering -- ${LIBOMP_STATS}")
380 libomp_say("Use Debugger-support -- ${LIBOMP_USE_DEBUGGER}")
Jonathan Peyton7abf9d52016-05-26 18:19:10381 libomp_say("Use ITT notify -- ${LIBOMP_USE_ITT_NOTIFY}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19382 libomp_say("Use OMPT-support -- ${LIBOMP_OMPT_SUPPORT}")
383 if(${LIBOMP_OMPT_SUPPORT})
Joachim Protze82e94a52017-11-01 10:08:30384 libomp_say("Use OMPT-optional -- ${LIBOMP_OMPT_OPTIONAL}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19385 endif()
386 libomp_say("Use Adaptive locks -- ${LIBOMP_USE_ADAPTIVE_LOCKS}")
387 libomp_say("Use quad precision -- ${LIBOMP_USE_QUAD_PRECISION}")
Jonas Hahnfeld50fed042016-11-07 15:58:36388 libomp_say("Use TSAN-support -- ${LIBOMP_TSAN_SUPPORT}")
Jonathan Peyton01dcf362015-11-30 20:02:59389 libomp_say("Use Hwloc library -- ${LIBOMP_USE_HWLOC}")
Jim Cownie3b81ce62014-08-05 09:32:28390endif()
Andrey Churbanov648467e2015-05-05 20:02:52391
Jonathan Peyton52158902015-06-11 17:23:57392add_subdirectory(src)
Jonathan Peyton614c7ef2015-09-21 20:41:31393add_subdirectory(test)