blob: 555fd9f7decdd167d29220d75316efb78eaa6343 [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
Jonathan Peyton227e1ae2015-06-01 03:05:1312# CMAKE libomp
Jim Cownie3b81ce62014-08-05 09:32:2813cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
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
Andrey Churbanov648467e2015-05-05 20:02:5218# Standalone build or part of LLVM?
Jonathan Peyton7979a072015-05-20 22:33:2419set(LIBOMP_STANDALONE_BUILD FALSE)
Jonas Hahnfeld49152b32017-01-04 18:11:3720if(OPENMP_STANDALONE_BUILD OR
21 "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}" OR
Andrey Churbanov648467e2015-05-05 20:02:5222 "${CMAKE_SOURCE_DIR}/runtime" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
Jonathan Peyton5b4acbd2015-07-15 16:57:1923 project(libomp C CXX)
24 set(LIBOMP_STANDALONE_BUILD TRUE)
Andrey Churbanov648467e2015-05-05 20:02:5225endif()
26
Jonathan Peytonc0225ca2015-08-28 18:42:1027# Set libomp version
28set(LIBOMP_VERSION_MAJOR 5)
29set(LIBOMP_VERSION_MINOR 0)
30
Jonathan Peyton2e013352015-07-15 16:05:3031# These include files are in the cmake/ subdirectory
32include(LibompUtils)
33include(LibompGetArchitecture)
34include(LibompHandleFlags)
35include(LibompDefinitions)
Jim Cownie3b81ce62014-08-05 09:32:2836
Jonathan Peyton2e013352015-07-15 16:05:3037# Determine the target architecture
38if(${LIBOMP_STANDALONE_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:1939 # If adding a new architecture, take a look at cmake/LibompGetArchitecture.cmake
40 libomp_get_architecture(LIBOMP_DETECTED_ARCH)
41 set(LIBOMP_ARCH ${LIBOMP_DETECTED_ARCH} CACHE STRING
Sylvestre Ledrucd9d3742016-12-08 09:22:2442 "The architecture to build for (x86_64/i386/arm/ppc64/ppc64le/aarch64/mic/mips/mips64).")
Jonathan Peyton5b4acbd2015-07-15 16:57:1943 # Allow user to choose a suffix for the installation directory.
44 set(LIBOMP_LIBDIR_SUFFIX "" CACHE STRING
45 "suffix of lib installation directory e.g., 64 => lib64")
46 # Should assertions be enabled? They are on by default.
47 set(LIBOMP_ENABLE_ASSERTIONS TRUE CACHE BOOL
48 "enable assertions?")
Chandler Carruth51451562015-07-18 03:14:0249 set(LIBOMP_ENABLE_WERROR FALSE CACHE BOOL
50 "Enable -Werror flags to turn warnings into errors for supporting compilers.")
Jonathan Peyton5b4acbd2015-07-15 16:57:1951 # CMAKE_BUILD_TYPE was not defined, set default to Release
52 if(NOT CMAKE_BUILD_TYPE)
53 set(CMAKE_BUILD_TYPE Release)
54 endif()
Jonathan Peyton2e013352015-07-15 16:05:3055else() # Part of LLVM build
Jonathan Peyton5b4acbd2015-07-15 16:57:1956 # Determine the native architecture from LLVM.
57 string(TOLOWER "${LLVM_TARGET_ARCH}" LIBOMP_NATIVE_ARCH)
58 if( LIBOMP_NATIVE_ARCH STREQUAL "host" )
59 string(REGEX MATCH "^[^-]*" LIBOMP_NATIVE_ARCH ${LLVM_HOST_TRIPLE})
60 endif ()
61 if(LIBOMP_NATIVE_ARCH MATCHES "i[2-6]86")
62 set(LIBOMP_ARCH i386)
63 elseif(LIBOMP_NATIVE_ARCH STREQUAL "x86")
64 set(LIBOMP_ARCH i386)
65 elseif(LIBOMP_NATIVE_ARCH STREQUAL "amd64")
66 set(LIBOMP_ARCH x86_64)
67 elseif(LIBOMP_NATIVE_ARCH STREQUAL "x86_64")
68 set(LIBOMP_ARCH x86_64)
George Rokos118de302016-09-09 18:04:2369 elseif(LIBOMP_NATIVE_ARCH MATCHES "powerpc64le")
70 set(LIBOMP_ARCH ppc64le)
Jonathan Peyton5b4acbd2015-07-15 16:57:1971 elseif(LIBOMP_NATIVE_ARCH MATCHES "powerpc")
72 set(LIBOMP_ARCH ppc64)
73 elseif(LIBOMP_NATIVE_ARCH MATCHES "aarch64")
74 set(LIBOMP_ARCH aarch64)
75 elseif(LIBOMP_NATIVE_ARCH MATCHES "arm64")
76 set(LIBOMP_ARCH aarch64)
77 elseif(LIBOMP_NATIVE_ARCH MATCHES "arm")
78 set(LIBOMP_ARCH arm)
79 else()
80 # last ditch effort
81 libomp_get_architecture(LIBOMP_ARCH)
82 endif ()
83 set(LIBOMP_LIBDIR_SUFFIX ${LLVM_LIBDIR_SUFFIX})
84 set(LIBOMP_ENABLE_ASSERTIONS ${LLVM_ENABLE_ASSERTIONS})
Chandler Carruth51451562015-07-18 03:14:0285 set(LIBOMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR})
Jim Cownie3b81ce62014-08-05 09:32:2886endif()
Sylvestre Ledrucd9d3742016-12-08 09:22:2487libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc64 ppc64le aarch64 mic mips mips64)
Jim Cownie3b81ce62014-08-05 09:32:2888
Jonathan Peytonfbb15142015-05-26 17:27:0189set(LIBOMP_LIB_TYPE normal CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:1990 "Performance,Profiling,Stubs library (normal/profile/stubs)")
Jonathan Peyton2e013352015-07-15 16:05:3091libomp_check_variable(LIBOMP_LIB_TYPE normal profile stubs)
Jonathan Peytone844a542017-03-06 22:07:4092set(LIBOMP_OMP_VERSION 50 CACHE STRING
93 "The OpenMP version (50/45/40/30)")
94libomp_check_variable(LIBOMP_OMP_VERSION 50 45 40 30)
Jonathan Peytonc0225ca2015-08-28 18:42:1095# Set the OpenMP Year and Month assiociated with version
Jonathan Peytone844a542017-03-06 22:07:4096if(${LIBOMP_OMP_VERSION} GREATER 50 OR ${LIBOMP_OMP_VERSION} EQUAL 50)
97 set(LIBOMP_OMP_YEAR_MONTH 201611)
98elseif(${LIBOMP_OMP_VERSION} GREATER 45 OR ${LIBOMP_OMP_VERSION} EQUAL 45)
Jonathan Peyton74f3ffc2016-09-30 15:50:1499 set(LIBOMP_OMP_YEAR_MONTH 201511)
100elseif(${LIBOMP_OMP_VERSION} GREATER 40 OR ${LIBOMP_OMP_VERSION} EQUAL 40)
Jonathan Peytonc0225ca2015-08-28 18:42:10101 set(LIBOMP_OMP_YEAR_MONTH 201307)
102elseif(${LIBOMP_OMP_VERSION} GREATER 30 OR ${LIBOMP_OMP_VERSION} EQUAL 30)
103 set(LIBOMP_OMP_YEAR_MONTH 201107)
104else()
105 set(LIBOMP_OMP_YEAR_MONTH 200505)
106endif()
Jonathan Peyton2e013352015-07-15 16:05:30107set(LIBOMP_MIC_ARCH knc CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19108 "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:30109if("${LIBOMP_ARCH}" STREQUAL "mic")
Jonathan Peyton5b4acbd2015-07-15 16:57:19110 libomp_check_variable(LIBOMP_MIC_ARCH knf knc)
Jonathan Peyton2e013352015-07-15 16:05:30111endif()
112set(LIBOMP_FORTRAN_MODULES FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19113 "Create Fortran module files? (requires fortran compiler)")
Jim Cownie3b81ce62014-08-05 09:32:28114
Jonathan Peyton92907c22015-05-29 16:13:56115# - Support for universal fat binary builds on Mac
Jonathan Peyton2e013352015-07-15 16:05:30116# - Having this extra variable allows people to build this library as a universal library
Jonathan Peyton92907c22015-05-29 16:13:56117# without forcing a universal build of the llvm/clang compiler.
118set(LIBOMP_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19119 "For Mac builds, semicolon separated list of architectures to build for universal fat binary.")
Jonathan Peyton92907c22015-05-29 16:13:56120set(CMAKE_OSX_ARCHITECTURES ${LIBOMP_OSX_ARCHITECTURES})
121
Jonathan Peyton89d9b332016-02-09 22:15:30122# Should @rpath be used for dynamic libraries on Mac?
123# The if(NOT DEFINED) is there to guard a cached value of the variable if one
124# exists so there is no interference with what the user wants. Also, no cache entry
125# is created so there are no inadvertant effects on other parts of LLVM.
126if(NOT DEFINED CMAKE_MACOSX_RPATH)
127 set(CMAKE_MACOSX_RPATH TRUE)
128endif()
129
Jonathan Peyton2e013352015-07-15 16:05:30130# User specified flags. These are appended to the configured flags.
Jonathan Peytonfbb15142015-05-26 17:27:01131set(LIBOMP_CFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19132 "Appended user specified C compiler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01133set(LIBOMP_CXXFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19134 "Appended user specified C++ compiler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01135set(LIBOMP_CPPFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19136 "Appended user specified C preprocessor flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01137set(LIBOMP_ASMFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19138 "Appended user specified assembler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01139set(LIBOMP_LDFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19140 "Appended user specified linker flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01141set(LIBOMP_LIBFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19142 "Appended user specified linked libs flags. (e.g., -lm)")
Jonathan Peyton2e013352015-07-15 16:05:30143set(LIBOMP_FFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19144 "Appended user specified Fortran compiler flags. These are only used if LIBOMP_FORTRAN_MODULES==TRUE.")
Jim Cownie3b81ce62014-08-05 09:32:28145
Jonathan Peyton227e1ae2015-06-01 03:05:13146# Should the libomp library and generated headers be copied into the original source exports/ directory
Jonathan Peyton2e013352015-07-15 16:05:30147# Turning this to FALSE aids parallel builds to not interfere with each other.
148# Currently, the testsuite module expects the just built OpenMP library to be located inside the exports/
149# directory. TODO: have testsuite run under llvm-lit directly. We can then get rid of copying to exports/
150set(LIBOMP_COPY_EXPORTS TRUE CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19151 "Should exports be copied into source exports/ directory?")
Andrey Churbanov708fa8e2015-05-14 12:54:08152
Jonathan Peyton01dcf362015-11-30 20:02:59153# HWLOC-support
154set(LIBOMP_USE_HWLOC FALSE CACHE BOOL
155 "Use Hwloc (http://www.open-mpi.org/projects/hwloc/) library for affinity?")
156set(LIBOMP_HWLOC_INSTALL_DIR /usr/local CACHE PATH
157 "Install path for hwloc library")
158
Jonathan Peyton7cc577a2016-12-14 22:39:11159# Get the build number from kmp_version.cpp
Jonathan Peytonc0225ca2015-08-28 18:42:10160libomp_get_build_number("${CMAKE_CURRENT_SOURCE_DIR}" LIBOMP_VERSION_BUILD)
161math(EXPR LIBOMP_VERSION_BUILD_YEAR "${LIBOMP_VERSION_BUILD}/10000")
162math(EXPR LIBOMP_VERSION_BUILD_MONTH_DAY "${LIBOMP_VERSION_BUILD}%10000")
Jim Cownie3b81ce62014-08-05 09:32:28163
Jonathan Peyton2e013352015-07-15 16:05:30164# Currently don't record any timestamps
Jonathan Peytonc0225ca2015-08-28 18:42:10165set(LIBOMP_BUILD_DATE "No_Timestamp")
Jim Cownie3b81ce62014-08-05 09:32:28166
167# Architecture
168set(IA32 FALSE)
169set(INTEL64 FALSE)
170set(ARM FALSE)
Andrey Churbanovcbda8682015-01-13 14:43:35171set(AARCH64 FALSE)
Andrey Churbanovd1c55042015-01-19 18:29:35172set(PPC64BE FALSE)
173set(PPC64LE FALSE)
Jim Cownie3051f972014-08-07 10:12:54174set(PPC64 FALSE)
Jonathan Peyton2e013352015-07-15 16:05:30175set(MIC FALSE)
Sylvestre Ledrucd9d3742016-12-08 09:22:24176set(MIPS64 FALSE)
177set(MIPS FALSE)
Jonathan Peyton5b4acbd2015-07-15 16:57:19178if("${LIBOMP_ARCH}" STREQUAL "i386" OR "${LIBOMP_ARCH}" STREQUAL "32") # IA-32 architecture
179 set(IA32 TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30180elseif("${LIBOMP_ARCH}" STREQUAL "x86_64" OR "${LIBOMP_ARCH}" STREQUAL "32e") # Intel(R) 64 architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19181 set(INTEL64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24182elseif("${LIBOMP_ARCH}" STREQUAL "arm") # ARM architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19183 set(ARM TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24184elseif("${LIBOMP_ARCH}" STREQUAL "ppc64") # PPC64BE architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19185 set(PPC64BE TRUE)
186 set(PPC64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24187elseif("${LIBOMP_ARCH}" STREQUAL "ppc64le") # PPC64LE architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19188 set(PPC64LE TRUE)
189 set(PPC64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24190elseif("${LIBOMP_ARCH}" STREQUAL "aarch64") # AARCH64 architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19191 set(AARCH64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24192elseif("${LIBOMP_ARCH}" STREQUAL "mic") # Intel(R) Many Integrated Core Architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19193 set(MIC TRUE)
Sylvestre Ledrucd9d3742016-12-08 09:22:24194elseif("${LIBOMP_ARCH}" STREQUAL "mips") # MIPS architecture
195 set(MIPS TRUE)
196elseif("${LIBOMP_ARCH}" STREQUAL "mips64") # MIPS64 architecture
197 set(MIPS64 TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28198endif()
199
200# Set some flags based on build_type
Jonathan Peytonfbb15142015-05-26 17:27:01201set(RELEASE_BUILD FALSE)
202set(DEBUG_BUILD FALSE)
Jim Cownie3b81ce62014-08-05 09:32:28203set(RELWITHDEBINFO_BUILD FALSE)
Jonathan Peyton2e013352015-07-15 16:05:30204set(MINSIZEREL_BUILD FALSE)
205string(TOLOWER "${CMAKE_BUILD_TYPE}" libomp_build_type_lowercase)
206if("${libomp_build_type_lowercase}" STREQUAL "release")
Jonathan Peyton5b4acbd2015-07-15 16:57:19207 set(RELEASE_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30208elseif("${libomp_build_type_lowercase}" STREQUAL "debug")
Jonathan Peyton5b4acbd2015-07-15 16:57:19209 set(DEBUG_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30210elseif("${libomp_build_type_lowercase}" STREQUAL "relwithdebinfo")
Jonathan Peyton5b4acbd2015-07-15 16:57:19211 set(RELWITHDEBINFO_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30212elseif("${libomp_build_type_lowercase}" STREQUAL "minsizerel")
Jonathan Peyton5b4acbd2015-07-15 16:57:19213 set(MINSIZEREL_BUILD TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28214endif()
215
Jonathan Peyton7abf9d52016-05-26 18:19:10216# Include itt notify interface?
217set(LIBOMP_USE_ITT_NOTIFY TRUE CACHE BOOL
218 "Enable ITT notify?")
Jim Cownie3b81ce62014-08-05 09:32:28219
220# normal, profile, stubs library.
221set(NORMAL_LIBRARY FALSE)
222set(STUBS_LIBRARY FALSE)
223set(PROFILE_LIBRARY FALSE)
Jonathan Peyton7979a072015-05-20 22:33:24224if("${LIBOMP_LIB_TYPE}" STREQUAL "normal")
Jonathan Peyton5b4acbd2015-07-15 16:57:19225 set(NORMAL_LIBRARY TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24226elseif("${LIBOMP_LIB_TYPE}" STREQUAL "profile")
Jonathan Peyton5b4acbd2015-07-15 16:57:19227 set(PROFILE_LIBRARY TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24228elseif("${LIBOMP_LIB_TYPE}" STREQUAL "stubs")
Jonathan Peyton5b4acbd2015-07-15 16:57:19229 set(STUBS_LIBRARY TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28230endif()
231
Jonathan Peyton2e013352015-07-15 16:05:30232# Setting directory names
233set(LIBOMP_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
234set(LIBOMP_SRC_DIR ${LIBOMP_BASE_DIR}/src)
235set(LIBOMP_TOOLS_DIR ${LIBOMP_BASE_DIR}/tools)
236set(LIBOMP_INC_DIR ${LIBOMP_SRC_DIR}/include/${LIBOMP_OMP_VERSION})
Jonathan Peyton614c7ef2015-09-21 20:41:31237set(LIBOMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
Jim Cownie3b81ce62014-08-05 09:32:28238
Jonathan Peyton2e013352015-07-15 16:05:30239# Enabling Fortran if it is needed
Jonathan Peyton2e013352015-07-15 16:05:30240if(${LIBOMP_FORTRAN_MODULES})
Jonathan Peyton5b4acbd2015-07-15 16:57:19241 enable_language(Fortran)
Jonathan Peyton2e013352015-07-15 16:05:30242endif()
Jonathan Peyton5b4acbd2015-07-15 16:57:19243# Enable MASM Compiler if it is needed (Windows only)
Jonathan Peyton2e013352015-07-15 16:05:30244if(WIN32)
Jonathan Peyton5b4acbd2015-07-15 16:57:19245 enable_language(ASM_MASM)
Jonathan Peyton2e013352015-07-15 16:05:30246endif()
Jim Cownie3b81ce62014-08-05 09:32:28247
Jonathan Peyton2e013352015-07-15 16:05:30248# Getting legal type/arch
249libomp_get_legal_type(LIBOMP_LEGAL_TYPE)
250libomp_get_legal_arch(LIBOMP_LEGAL_ARCH)
Jim Cownie3b81ce62014-08-05 09:32:28251
Jonathan Peyton2e013352015-07-15 16:05:30252# Compiler flag checks, library checks, threading check, etc.
253include(config-ix)
Jim Cownie3b81ce62014-08-05 09:32:28254
Jonathan Peyton2e013352015-07-15 16:05:30255# Is there a quad precision data type available?
256# TODO: Make this a real feature check
257set(LIBOMP_USE_QUAD_PRECISION "${LIBOMP_HAVE_QUAD_PRECISION}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19258 "Should 128-bit precision entry points be built?")
Jonathan Peyton2e013352015-07-15 16:05:30259if(LIBOMP_USE_QUAD_PRECISION AND (NOT LIBOMP_HAVE_QUAD_PRECISION))
Jonathan Peyton5b4acbd2015-07-15 16:57:19260 libomp_error_say("128-bit quad precision functionality requested but not available")
Jonathan Peyton2e013352015-07-15 16:05:30261endif()
262
263# libgomp drop-in compatibility requires versioned symbols
264set(LIBOMP_USE_VERSION_SYMBOLS "${LIBOMP_HAVE_VERSION_SYMBOLS}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19265 "Should version symbols be used? These provide binary compatibility with libgomp.")
Jonathan Peyton2e013352015-07-15 16:05:30266if(LIBOMP_USE_VERSION_SYMBOLS AND (NOT LIBOMP_HAVE_VERSION_SYMBOLS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19267 libomp_error_say("Version symbols functionality requested but not available")
Jonathan Peyton2e013352015-07-15 16:05:30268endif()
269
270# On multinode systems, larger alignment is desired to avoid false sharing
271set(LIBOMP_USE_INTERNODE_ALIGNMENT FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19272 "Should larger alignment (4096 bytes) be used for some locks and data structures?")
Jim Cownie4cc4bb42014-10-07 16:25:50273
Jonathan Peyton2e013352015-07-15 16:05:30274# Build code that allows the OpenMP library to conveniently interface with debuggers
275set(LIBOMP_USE_DEBUGGER FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19276 "Enable debugger interface code?")
Jonathan Peyton2e013352015-07-15 16:05:30277
278# Should we link to C++ library?
279set(LIBOMP_USE_STDCPPLIB FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19280 "Should we link to C++ library?")
Jonathan Peyton2e013352015-07-15 16:05:30281
282# TSX (x86) based locks have __asm code which can be troublesome for some compilers.
283# TODO: Make this a real feature check
284set(LIBOMP_USE_ADAPTIVE_LOCKS "${LIBOMP_HAVE_ADAPTIVE_LOCKS}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19285 "Should TSX-based lock be compiled (adaptive lock in kmp_lock.cpp). These are x86 specific.")
Jonathan Peyton2e013352015-07-15 16:05:30286if(LIBOMP_USE_ADAPTIVE_LOCKS AND (NOT LIBOMP_HAVE_ADAPTIVE_LOCKS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19287 libomp_error_say("Adaptive locks (TSX) functionality requested but not available")
Jim Cownie4cc4bb42014-10-07 16:25:50288endif()
289
Jonathan Peyton2e013352015-07-15 16:05:30290# - stats-gathering enables OpenMP stats where things like the number of
291# parallel regions, clock ticks spent in particular openmp regions are recorded.
Jonathan Peyton2e013352015-07-15 16:05:30292set(LIBOMP_STATS FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19293 "Stats-Gathering functionality?")
Jonathan Peyton2e013352015-07-15 16:05:30294if(LIBOMP_STATS AND (NOT LIBOMP_HAVE_STATS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19295 libomp_error_say("Stats-gathering functionality requested but not available")
Jim Cownie3b81ce62014-08-05 09:32:28296endif()
Jonathan Peyton45be4502015-08-11 21:36:41297# The stats functionality requires the std c++ library
298if(LIBOMP_STATS)
299 set(LIBOMP_USE_STDCPPLIB TRUE)
300endif()
Jim Cownie3b81ce62014-08-05 09:32:28301
Jonathan Peytonfd74f902016-02-04 19:29:35302# Shared library can be switched to a static library
303set(LIBOMP_ENABLE_SHARED TRUE CACHE BOOL
304 "Shared library instead of static library?")
305
306if(WIN32 AND NOT LIBOMP_ENABLE_SHARED)
307 libomp_error_say("Static libraries requested but not available on Windows")
308endif()
309
Andrey Churbanov31d39bf2017-03-31 16:20:07310if(LIBOMP_USE_ITT_NOTIFY AND NOT LIBOMP_ENABLE_SHARED)
311 message(STATUS "ITT Notify not supported for static libraries - forcing ITT Notify off")
312 set(LIBOMP_USE_ITT_NOTIFY FALSE)
313endif()
314
Jonathan Peyton2e013352015-07-15 16:05:30315# OMPT-support
Jonathan Peyton95246e72015-11-05 16:54:55316set(LIBOMP_OMPT_DEBUG FALSE CACHE BOOL
317 "Trace OMPT initialization?")
Jonathan Peyton2e013352015-07-15 16:05:30318set(LIBOMP_OMPT_SUPPORT FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19319 "OMPT-support?")
Jonathan Peyton2e013352015-07-15 16:05:30320set(LIBOMP_OMPT_BLAME TRUE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19321 "OMPT-blame?")
Jonathan Peyton2e013352015-07-15 16:05:30322set(LIBOMP_OMPT_TRACE TRUE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19323 "OMPT-trace?")
Jonathan Peyton2e013352015-07-15 16:05:30324if(LIBOMP_OMPT_SUPPORT AND (NOT LIBOMP_HAVE_OMPT_SUPPORT))
Jonathan Peyton5b4acbd2015-07-15 16:57:19325 libomp_error_say("OpenMP Tools Interface requested but not available")
Jonathan Peytonb689ded2015-06-17 15:43:34326endif()
Jim Cownie3b81ce62014-08-05 09:32:28327
Jonas Hahnfeld50fed042016-11-07 15:58:36328# TSAN-support
329set(LIBOMP_TSAN_SUPPORT FALSE CACHE BOOL
330 "TSAN-support?")
331if(LIBOMP_TSAN_SUPPORT AND (NOT LIBOMP_HAVE_TSAN_SUPPORT))
332 libomp_error_say("TSAN functionality requested but not available")
333endif()
334
Jonathan Peyton01dcf362015-11-30 20:02:59335# Error check hwloc support after config-ix has run
336if(LIBOMP_USE_HWLOC AND (NOT LIBOMP_HAVE_HWLOC))
337 libomp_error_say("Hwloc requested but not available")
338endif()
339
Jim Cownie3b81ce62014-08-05 09:32:28340# Setting final library name
Jonathan Peyton2e013352015-07-15 16:05:30341set(LIBOMP_DEFAULT_LIB_NAME libomp)
Jim Cownie3b81ce62014-08-05 09:32:28342if(${PROFILE_LIBRARY})
Jonathan Peyton5b4acbd2015-07-15 16:57:19343 set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}prof)
Jim Cownie3b81ce62014-08-05 09:32:28344endif()
345if(${STUBS_LIBRARY})
Jonathan Peyton5b4acbd2015-07-15 16:57:19346 set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}stubs)
Jim Cownie3b81ce62014-08-05 09:32:28347endif()
Jonathan Peyton2e013352015-07-15 16:05:30348set(LIBOMP_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME} CACHE STRING "Base OMP library name")
Jonathan Peytonfd74f902016-02-04 19:29:35349
350if(${LIBOMP_ENABLE_SHARED})
351 set(LIBOMP_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
Jonathan Peyton975dabc2016-05-17 20:51:24352 set(LIBOMP_LIBRARY_KIND SHARED)
353 set(LIBOMP_INSTALL_KIND LIBRARY)
Jonathan Peytonfd74f902016-02-04 19:29:35354else()
355 set(LIBOMP_LIBRARY_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
Jonathan Peyton975dabc2016-05-17 20:51:24356 set(LIBOMP_LIBRARY_KIND STATIC)
357 set(LIBOMP_INSTALL_KIND ARCHIVE)
Jonathan Peytonfd74f902016-02-04 19:29:35358endif()
359
360set(LIBOMP_LIB_FILE ${LIBOMP_LIB_NAME}${LIBOMP_LIBRARY_SUFFIX})
Jim Cownie3b81ce62014-08-05 09:32:28361
Michal Gorny23132eb2016-09-14 17:46:27362# Optional backwards compatibility aliases.
363set(LIBOMP_INSTALL_ALIASES TRUE CACHE BOOL
364 "Install libgomp and libiomp5 library aliases for backwards compatibility")
365
Jim Cownie3b81ce62014-08-05 09:32:28366# Print configuration after all variables are set.
Jonathan Peyton7979a072015-05-20 22:33:24367if(${LIBOMP_STANDALONE_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:19368 libomp_say("Operating System -- ${CMAKE_SYSTEM_NAME}")
369 libomp_say("Target Architecture -- ${LIBOMP_ARCH}")
370 if(${MIC})
371 libomp_say("Intel(R) MIC Architecture -- ${LIBOMP_MIC_ARCH}")
372 endif()
373 libomp_say("Build Type -- ${CMAKE_BUILD_TYPE}")
374 libomp_say("OpenMP Version -- ${LIBOMP_OMP_VERSION}")
Jonathan Peytonfd74f902016-02-04 19:29:35375 libomp_say("Library Kind -- ${LIBOMP_LIBRARY_KIND}")
376 libomp_say("Library Type -- ${LIBOMP_LIB_TYPE}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19377 libomp_say("Fortran Modules -- ${LIBOMP_FORTRAN_MODULES}")
378 # will say development if all zeros
Jonathan Peytonc0225ca2015-08-28 18:42:10379 if(${LIBOMP_VERSION_BUILD} STREQUAL 00000000)
Jonathan Peyton5b4acbd2015-07-15 16:57:19380 set(LIBOMP_BUILD Development)
381 else()
Jonathan Peytonc0225ca2015-08-28 18:42:10382 set(LIBOMP_BUILD ${LIBOMP_VERSION_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:19383 endif()
384 libomp_say("Build -- ${LIBOMP_BUILD}")
385 libomp_say("Use Stats-gathering -- ${LIBOMP_STATS}")
386 libomp_say("Use Debugger-support -- ${LIBOMP_USE_DEBUGGER}")
Jonathan Peyton7abf9d52016-05-26 18:19:10387 libomp_say("Use ITT notify -- ${LIBOMP_USE_ITT_NOTIFY}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19388 libomp_say("Use OMPT-support -- ${LIBOMP_OMPT_SUPPORT}")
389 if(${LIBOMP_OMPT_SUPPORT})
390 libomp_say("Use OMPT-blame -- ${LIBOMP_OMPT_BLAME}")
391 libomp_say("Use OMPT-trace -- ${LIBOMP_OMPT_TRACE}")
392 endif()
393 libomp_say("Use Adaptive locks -- ${LIBOMP_USE_ADAPTIVE_LOCKS}")
394 libomp_say("Use quad precision -- ${LIBOMP_USE_QUAD_PRECISION}")
Jonas Hahnfeld50fed042016-11-07 15:58:36395 libomp_say("Use TSAN-support -- ${LIBOMP_TSAN_SUPPORT}")
Jonathan Peyton01dcf362015-11-30 20:02:59396 libomp_say("Use Hwloc library -- ${LIBOMP_USE_HWLOC}")
Jim Cownie3b81ce62014-08-05 09:32:28397endif()
Andrey Churbanov648467e2015-05-05 20:02:52398
Jonathan Peyton52158902015-06-11 17:23:57399add_subdirectory(src)
Jonathan Peyton614c7ef2015-09-21 20:41:31400add_subdirectory(test)