blob: a4c7690bd285549431b8aaf368d78a09d34fb875 [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)
Jonathan Peyton2e013352015-07-15 16:05:3020if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}" OR
Andrey Churbanov648467e2015-05-05 20:02:5221 "${CMAKE_SOURCE_DIR}/runtime" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
Jonathan Peyton5b4acbd2015-07-15 16:57:1922 project(libomp C CXX)
23 set(LIBOMP_STANDALONE_BUILD TRUE)
Andrey Churbanov648467e2015-05-05 20:02:5224endif()
25
Jonathan Peytonc0225ca2015-08-28 18:42:1026# Set libomp version
27set(LIBOMP_VERSION_MAJOR 5)
28set(LIBOMP_VERSION_MINOR 0)
29
Jonathan Peyton2e013352015-07-15 16:05:3030# These include files are in the cmake/ subdirectory
31include(LibompUtils)
32include(LibompGetArchitecture)
33include(LibompHandleFlags)
34include(LibompDefinitions)
Jim Cownie3b81ce62014-08-05 09:32:2835
Jonathan Peyton2e013352015-07-15 16:05:3036# Determine the target architecture
37if(${LIBOMP_STANDALONE_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:1938 # If adding a new architecture, take a look at cmake/LibompGetArchitecture.cmake
39 libomp_get_architecture(LIBOMP_DETECTED_ARCH)
40 set(LIBOMP_ARCH ${LIBOMP_DETECTED_ARCH} CACHE STRING
41 "The architecture to build for (x86_64/i386/arm/ppc64/ppc64le/aarch64/mic).")
42 # Allow user to choose a suffix for the installation directory.
43 set(LIBOMP_LIBDIR_SUFFIX "" CACHE STRING
44 "suffix of lib installation directory e.g., 64 => lib64")
45 # Should assertions be enabled? They are on by default.
46 set(LIBOMP_ENABLE_ASSERTIONS TRUE CACHE BOOL
47 "enable assertions?")
Chandler Carruth51451562015-07-18 03:14:0248 set(LIBOMP_ENABLE_WERROR FALSE CACHE BOOL
49 "Enable -Werror flags to turn warnings into errors for supporting compilers.")
Jonathan Peyton5b4acbd2015-07-15 16:57:1950 # CMAKE_BUILD_TYPE was not defined, set default to Release
51 if(NOT CMAKE_BUILD_TYPE)
52 set(CMAKE_BUILD_TYPE Release)
53 endif()
Jonathan Peyton2e013352015-07-15 16:05:3054else() # Part of LLVM build
Jonathan Peyton5b4acbd2015-07-15 16:57:1955 # Determine the native architecture from LLVM.
56 string(TOLOWER "${LLVM_TARGET_ARCH}" LIBOMP_NATIVE_ARCH)
57 if( LIBOMP_NATIVE_ARCH STREQUAL "host" )
58 string(REGEX MATCH "^[^-]*" LIBOMP_NATIVE_ARCH ${LLVM_HOST_TRIPLE})
59 endif ()
60 if(LIBOMP_NATIVE_ARCH MATCHES "i[2-6]86")
61 set(LIBOMP_ARCH i386)
62 elseif(LIBOMP_NATIVE_ARCH STREQUAL "x86")
63 set(LIBOMP_ARCH i386)
64 elseif(LIBOMP_NATIVE_ARCH STREQUAL "amd64")
65 set(LIBOMP_ARCH x86_64)
66 elseif(LIBOMP_NATIVE_ARCH STREQUAL "x86_64")
67 set(LIBOMP_ARCH x86_64)
68 elseif(LIBOMP_NATIVE_ARCH MATCHES "powerpc")
69 set(LIBOMP_ARCH ppc64)
70 elseif(LIBOMP_NATIVE_ARCH MATCHES "aarch64")
71 set(LIBOMP_ARCH aarch64)
72 elseif(LIBOMP_NATIVE_ARCH MATCHES "arm64")
73 set(LIBOMP_ARCH aarch64)
74 elseif(LIBOMP_NATIVE_ARCH MATCHES "arm")
75 set(LIBOMP_ARCH arm)
76 else()
77 # last ditch effort
78 libomp_get_architecture(LIBOMP_ARCH)
79 endif ()
80 set(LIBOMP_LIBDIR_SUFFIX ${LLVM_LIBDIR_SUFFIX})
81 set(LIBOMP_ENABLE_ASSERTIONS ${LLVM_ENABLE_ASSERTIONS})
Chandler Carruth51451562015-07-18 03:14:0282 set(LIBOMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR})
Jim Cownie3b81ce62014-08-05 09:32:2883endif()
Jonathan Peyton2e013352015-07-15 16:05:3084libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc64 ppc64le aarch64 mic)
Jim Cownie3b81ce62014-08-05 09:32:2885
Jonathan Peytonfbb15142015-05-26 17:27:0186set(LIBOMP_LIB_TYPE normal CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:1987 "Performance,Profiling,Stubs library (normal/profile/stubs)")
Jonathan Peyton2e013352015-07-15 16:05:3088libomp_check_variable(LIBOMP_LIB_TYPE normal profile stubs)
Jonathan Peyton2e013352015-07-15 16:05:3089set(LIBOMP_OMP_VERSION 41 CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:1990 "The OpenMP version (41/40/30)")
Jonathan Peyton2e013352015-07-15 16:05:3091libomp_check_variable(LIBOMP_OMP_VERSION 41 40 30)
Jonathan Peytonc0225ca2015-08-28 18:42:1092# Set the OpenMP Year and Month assiociated with version
93if(${LIBOMP_OMP_VERSION} GREATER 40 OR ${LIBOMP_OMP_VERSION} EQUAL 40)
94 set(LIBOMP_OMP_YEAR_MONTH 201307)
95elseif(${LIBOMP_OMP_VERSION} GREATER 30 OR ${LIBOMP_OMP_VERSION} EQUAL 30)
96 set(LIBOMP_OMP_YEAR_MONTH 201107)
97else()
98 set(LIBOMP_OMP_YEAR_MONTH 200505)
99endif()
Jonathan Peyton2e013352015-07-15 16:05:30100set(LIBOMP_MIC_ARCH knc CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19101 "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:30102if("${LIBOMP_ARCH}" STREQUAL "mic")
Jonathan Peyton5b4acbd2015-07-15 16:57:19103 libomp_check_variable(LIBOMP_MIC_ARCH knf knc)
Jonathan Peyton2e013352015-07-15 16:05:30104endif()
105set(LIBOMP_FORTRAN_MODULES FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19106 "Create Fortran module files? (requires fortran compiler)")
Jim Cownie3b81ce62014-08-05 09:32:28107
Jonathan Peyton92907c22015-05-29 16:13:56108# - Support for universal fat binary builds on Mac
Jonathan Peyton2e013352015-07-15 16:05:30109# - Having this extra variable allows people to build this library as a universal library
Jonathan Peyton92907c22015-05-29 16:13:56110# without forcing a universal build of the llvm/clang compiler.
111set(LIBOMP_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19112 "For Mac builds, semicolon separated list of architectures to build for universal fat binary.")
Jonathan Peyton92907c22015-05-29 16:13:56113set(CMAKE_OSX_ARCHITECTURES ${LIBOMP_OSX_ARCHITECTURES})
114
Jonathan Peyton89d9b332016-02-09 22:15:30115# Should @rpath be used for dynamic libraries on Mac?
116# The if(NOT DEFINED) is there to guard a cached value of the variable if one
117# exists so there is no interference with what the user wants. Also, no cache entry
118# is created so there are no inadvertant effects on other parts of LLVM.
119if(NOT DEFINED CMAKE_MACOSX_RPATH)
120 set(CMAKE_MACOSX_RPATH TRUE)
121endif()
122
Jonathan Peyton2e013352015-07-15 16:05:30123# User specified flags. These are appended to the configured flags.
Jonathan Peytonfbb15142015-05-26 17:27:01124set(LIBOMP_CFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19125 "Appended user specified C compiler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01126set(LIBOMP_CXXFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19127 "Appended user specified C++ compiler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01128set(LIBOMP_CPPFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19129 "Appended user specified C preprocessor flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01130set(LIBOMP_ASMFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19131 "Appended user specified assembler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01132set(LIBOMP_LDFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19133 "Appended user specified linker flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01134set(LIBOMP_LIBFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19135 "Appended user specified linked libs flags. (e.g., -lm)")
Jonathan Peyton2e013352015-07-15 16:05:30136set(LIBOMP_FFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19137 "Appended user specified Fortran compiler flags. These are only used if LIBOMP_FORTRAN_MODULES==TRUE.")
Jim Cownie3b81ce62014-08-05 09:32:28138
Jonathan Peyton227e1ae2015-06-01 03:05:13139# Should the libomp library and generated headers be copied into the original source exports/ directory
Jonathan Peyton2e013352015-07-15 16:05:30140# Turning this to FALSE aids parallel builds to not interfere with each other.
141# Currently, the testsuite module expects the just built OpenMP library to be located inside the exports/
142# directory. TODO: have testsuite run under llvm-lit directly. We can then get rid of copying to exports/
143set(LIBOMP_COPY_EXPORTS TRUE CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19144 "Should exports be copied into source exports/ directory?")
Andrey Churbanov708fa8e2015-05-14 12:54:08145
Jonathan Peyton01dcf362015-11-30 20:02:59146# HWLOC-support
147set(LIBOMP_USE_HWLOC FALSE CACHE BOOL
148 "Use Hwloc (http://www.open-mpi.org/projects/hwloc/) library for affinity?")
149set(LIBOMP_HWLOC_INSTALL_DIR /usr/local CACHE PATH
150 "Install path for hwloc library")
151
Jim Cownie3b81ce62014-08-05 09:32:28152# Get the build number from kmp_version.c
Jonathan Peytonc0225ca2015-08-28 18:42:10153libomp_get_build_number("${CMAKE_CURRENT_SOURCE_DIR}" LIBOMP_VERSION_BUILD)
154math(EXPR LIBOMP_VERSION_BUILD_YEAR "${LIBOMP_VERSION_BUILD}/10000")
155math(EXPR LIBOMP_VERSION_BUILD_MONTH_DAY "${LIBOMP_VERSION_BUILD}%10000")
Jim Cownie3b81ce62014-08-05 09:32:28156
Jonathan Peyton2e013352015-07-15 16:05:30157# Currently don't record any timestamps
Jonathan Peytonc0225ca2015-08-28 18:42:10158set(LIBOMP_BUILD_DATE "No_Timestamp")
Jim Cownie3b81ce62014-08-05 09:32:28159
160# Architecture
161set(IA32 FALSE)
162set(INTEL64 FALSE)
163set(ARM FALSE)
Andrey Churbanovcbda8682015-01-13 14:43:35164set(AARCH64 FALSE)
Andrey Churbanovd1c55042015-01-19 18:29:35165set(PPC64BE FALSE)
166set(PPC64LE FALSE)
Jim Cownie3051f972014-08-07 10:12:54167set(PPC64 FALSE)
Jonathan Peyton2e013352015-07-15 16:05:30168set(MIC FALSE)
Jonathan Peyton5b4acbd2015-07-15 16:57:19169if("${LIBOMP_ARCH}" STREQUAL "i386" OR "${LIBOMP_ARCH}" STREQUAL "32") # IA-32 architecture
170 set(IA32 TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30171elseif("${LIBOMP_ARCH}" STREQUAL "x86_64" OR "${LIBOMP_ARCH}" STREQUAL "32e") # Intel(R) 64 architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19172 set(INTEL64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24173elseif("${LIBOMP_ARCH}" STREQUAL "arm") # ARM architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19174 set(ARM TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24175elseif("${LIBOMP_ARCH}" STREQUAL "ppc64") # PPC64BE architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19176 set(PPC64BE TRUE)
177 set(PPC64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24178elseif("${LIBOMP_ARCH}" STREQUAL "ppc64le") # PPC64LE architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19179 set(PPC64LE TRUE)
180 set(PPC64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24181elseif("${LIBOMP_ARCH}" STREQUAL "aarch64") # AARCH64 architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19182 set(AARCH64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24183elseif("${LIBOMP_ARCH}" STREQUAL "mic") # Intel(R) Many Integrated Core Architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19184 set(MIC TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28185endif()
186
187# Set some flags based on build_type
Jonathan Peytonfbb15142015-05-26 17:27:01188set(RELEASE_BUILD FALSE)
189set(DEBUG_BUILD FALSE)
Jim Cownie3b81ce62014-08-05 09:32:28190set(RELWITHDEBINFO_BUILD FALSE)
Jonathan Peyton2e013352015-07-15 16:05:30191set(MINSIZEREL_BUILD FALSE)
192string(TOLOWER "${CMAKE_BUILD_TYPE}" libomp_build_type_lowercase)
193if("${libomp_build_type_lowercase}" STREQUAL "release")
Jonathan Peyton5b4acbd2015-07-15 16:57:19194 set(RELEASE_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30195elseif("${libomp_build_type_lowercase}" STREQUAL "debug")
Jonathan Peyton5b4acbd2015-07-15 16:57:19196 set(DEBUG_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30197elseif("${libomp_build_type_lowercase}" STREQUAL "relwithdebinfo")
Jonathan Peyton5b4acbd2015-07-15 16:57:19198 set(RELWITHDEBINFO_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30199elseif("${libomp_build_type_lowercase}" STREQUAL "minsizerel")
Jonathan Peyton5b4acbd2015-07-15 16:57:19200 set(MINSIZEREL_BUILD TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28201endif()
202
Jim Cownie3b81ce62014-08-05 09:32:28203# Include itt notify interface? Right now, always.
Jonathan Peyton7979a072015-05-20 22:33:24204set(LIBOMP_USE_ITT_NOTIFY TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28205
206# normal, profile, stubs library.
207set(NORMAL_LIBRARY FALSE)
208set(STUBS_LIBRARY FALSE)
209set(PROFILE_LIBRARY FALSE)
Jonathan Peyton7979a072015-05-20 22:33:24210if("${LIBOMP_LIB_TYPE}" STREQUAL "normal")
Jonathan Peyton5b4acbd2015-07-15 16:57:19211 set(NORMAL_LIBRARY TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24212elseif("${LIBOMP_LIB_TYPE}" STREQUAL "profile")
Jonathan Peyton5b4acbd2015-07-15 16:57:19213 set(PROFILE_LIBRARY TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24214elseif("${LIBOMP_LIB_TYPE}" STREQUAL "stubs")
Jonathan Peyton5b4acbd2015-07-15 16:57:19215 set(STUBS_LIBRARY TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28216endif()
217
Jonathan Peyton2e013352015-07-15 16:05:30218# Setting directory names
219set(LIBOMP_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
220set(LIBOMP_SRC_DIR ${LIBOMP_BASE_DIR}/src)
221set(LIBOMP_TOOLS_DIR ${LIBOMP_BASE_DIR}/tools)
222set(LIBOMP_INC_DIR ${LIBOMP_SRC_DIR}/include/${LIBOMP_OMP_VERSION})
Jonathan Peyton614c7ef2015-09-21 20:41:31223set(LIBOMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
Jim Cownie3b81ce62014-08-05 09:32:28224
Jonathan Peyton2e013352015-07-15 16:05:30225# Enabling Fortran if it is needed
Jonathan Peyton2e013352015-07-15 16:05:30226if(${LIBOMP_FORTRAN_MODULES})
Jonathan Peyton5b4acbd2015-07-15 16:57:19227 enable_language(Fortran)
Jonathan Peyton2e013352015-07-15 16:05:30228endif()
Jonathan Peyton5b4acbd2015-07-15 16:57:19229# Enable MASM Compiler if it is needed (Windows only)
Jonathan Peyton2e013352015-07-15 16:05:30230if(WIN32)
Jonathan Peyton5b4acbd2015-07-15 16:57:19231 enable_language(ASM_MASM)
Jonathan Peyton2e013352015-07-15 16:05:30232endif()
Jim Cownie3b81ce62014-08-05 09:32:28233
Jonathan Peyton2e013352015-07-15 16:05:30234# Getting legal type/arch
235libomp_get_legal_type(LIBOMP_LEGAL_TYPE)
236libomp_get_legal_arch(LIBOMP_LEGAL_ARCH)
Jim Cownie3b81ce62014-08-05 09:32:28237
Jonathan Peyton2e013352015-07-15 16:05:30238# Compiler flag checks, library checks, threading check, etc.
239include(config-ix)
Jim Cownie3b81ce62014-08-05 09:32:28240
Jonathan Peyton2e013352015-07-15 16:05:30241# Is there a quad precision data type available?
242# TODO: Make this a real feature check
243set(LIBOMP_USE_QUAD_PRECISION "${LIBOMP_HAVE_QUAD_PRECISION}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19244 "Should 128-bit precision entry points be built?")
Jonathan Peyton2e013352015-07-15 16:05:30245if(LIBOMP_USE_QUAD_PRECISION AND (NOT LIBOMP_HAVE_QUAD_PRECISION))
Jonathan Peyton5b4acbd2015-07-15 16:57:19246 libomp_error_say("128-bit quad precision functionality requested but not available")
Jonathan Peyton2e013352015-07-15 16:05:30247endif()
248
249# libgomp drop-in compatibility requires versioned symbols
250set(LIBOMP_USE_VERSION_SYMBOLS "${LIBOMP_HAVE_VERSION_SYMBOLS}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19251 "Should version symbols be used? These provide binary compatibility with libgomp.")
Jonathan Peyton2e013352015-07-15 16:05:30252if(LIBOMP_USE_VERSION_SYMBOLS AND (NOT LIBOMP_HAVE_VERSION_SYMBOLS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19253 libomp_error_say("Version symbols functionality requested but not available")
Jonathan Peyton2e013352015-07-15 16:05:30254endif()
255
256# On multinode systems, larger alignment is desired to avoid false sharing
257set(LIBOMP_USE_INTERNODE_ALIGNMENT FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19258 "Should larger alignment (4096 bytes) be used for some locks and data structures?")
Jim Cownie4cc4bb42014-10-07 16:25:50259
Jonathan Peyton2e013352015-07-15 16:05:30260# Build code that allows the OpenMP library to conveniently interface with debuggers
261set(LIBOMP_USE_DEBUGGER FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19262 "Enable debugger interface code?")
Jonathan Peyton2e013352015-07-15 16:05:30263
264# Should we link to C++ library?
265set(LIBOMP_USE_STDCPPLIB FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19266 "Should we link to C++ library?")
Jonathan Peyton2e013352015-07-15 16:05:30267
268# TSX (x86) based locks have __asm code which can be troublesome for some compilers.
269# TODO: Make this a real feature check
270set(LIBOMP_USE_ADAPTIVE_LOCKS "${LIBOMP_HAVE_ADAPTIVE_LOCKS}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19271 "Should TSX-based lock be compiled (adaptive lock in kmp_lock.cpp). These are x86 specific.")
Jonathan Peyton2e013352015-07-15 16:05:30272if(LIBOMP_USE_ADAPTIVE_LOCKS AND (NOT LIBOMP_HAVE_ADAPTIVE_LOCKS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19273 libomp_error_say("Adaptive locks (TSX) functionality requested but not available")
Jim Cownie4cc4bb42014-10-07 16:25:50274endif()
275
Jonathan Peyton2e013352015-07-15 16:05:30276# - stats-gathering enables OpenMP stats where things like the number of
277# parallel regions, clock ticks spent in particular openmp regions are recorded.
Jonathan Peyton2e013352015-07-15 16:05:30278set(LIBOMP_STATS FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19279 "Stats-Gathering functionality?")
Jonathan Peyton2e013352015-07-15 16:05:30280if(LIBOMP_STATS AND (NOT LIBOMP_HAVE_STATS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19281 libomp_error_say("Stats-gathering functionality requested but not available")
Jim Cownie3b81ce62014-08-05 09:32:28282endif()
Jonathan Peyton45be4502015-08-11 21:36:41283# The stats functionality requires the std c++ library
284if(LIBOMP_STATS)
285 set(LIBOMP_USE_STDCPPLIB TRUE)
286endif()
Jim Cownie3b81ce62014-08-05 09:32:28287
Jonathan Peytonfd74f902016-02-04 19:29:35288# Shared library can be switched to a static library
289set(LIBOMP_ENABLE_SHARED TRUE CACHE BOOL
290 "Shared library instead of static library?")
291
292if(WIN32 AND NOT LIBOMP_ENABLE_SHARED)
293 libomp_error_say("Static libraries requested but not available on Windows")
294endif()
295
Jonathan Peyton2e013352015-07-15 16:05:30296# OMPT-support
Jonathan Peyton95246e72015-11-05 16:54:55297set(LIBOMP_OMPT_DEBUG FALSE CACHE BOOL
298 "Trace OMPT initialization?")
Jonathan Peyton2e013352015-07-15 16:05:30299set(LIBOMP_OMPT_SUPPORT FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19300 "OMPT-support?")
Jonathan Peyton2e013352015-07-15 16:05:30301set(LIBOMP_OMPT_BLAME TRUE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19302 "OMPT-blame?")
Jonathan Peyton2e013352015-07-15 16:05:30303set(LIBOMP_OMPT_TRACE TRUE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19304 "OMPT-trace?")
Jonathan Peyton2e013352015-07-15 16:05:30305if(LIBOMP_OMPT_SUPPORT AND (NOT LIBOMP_HAVE_OMPT_SUPPORT))
Jonathan Peyton5b4acbd2015-07-15 16:57:19306 libomp_error_say("OpenMP Tools Interface requested but not available")
Jonathan Peytonb689ded2015-06-17 15:43:34307endif()
Jim Cownie3b81ce62014-08-05 09:32:28308
Jonathan Peyton01dcf362015-11-30 20:02:59309# Error check hwloc support after config-ix has run
310if(LIBOMP_USE_HWLOC AND (NOT LIBOMP_HAVE_HWLOC))
311 libomp_error_say("Hwloc requested but not available")
312endif()
313
Jim Cownie3b81ce62014-08-05 09:32:28314# Setting final library name
Jonathan Peyton2e013352015-07-15 16:05:30315set(LIBOMP_DEFAULT_LIB_NAME libomp)
Jim Cownie3b81ce62014-08-05 09:32:28316if(${PROFILE_LIBRARY})
Jonathan Peyton5b4acbd2015-07-15 16:57:19317 set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}prof)
Jim Cownie3b81ce62014-08-05 09:32:28318endif()
319if(${STUBS_LIBRARY})
Jonathan Peyton5b4acbd2015-07-15 16:57:19320 set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}stubs)
Jim Cownie3b81ce62014-08-05 09:32:28321endif()
Jonathan Peyton2e013352015-07-15 16:05:30322set(LIBOMP_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME} CACHE STRING "Base OMP library name")
Jonathan Peytonfd74f902016-02-04 19:29:35323
324if(${LIBOMP_ENABLE_SHARED})
325 set(LIBOMP_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
Jonathan Peyton975dabc2016-05-17 20:51:24326 set(LIBOMP_LIBRARY_KIND SHARED)
327 set(LIBOMP_INSTALL_KIND LIBRARY)
Jonathan Peytonfd74f902016-02-04 19:29:35328else()
329 set(LIBOMP_LIBRARY_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
Jonathan Peyton975dabc2016-05-17 20:51:24330 set(LIBOMP_LIBRARY_KIND STATIC)
331 set(LIBOMP_INSTALL_KIND ARCHIVE)
Jonathan Peytonfd74f902016-02-04 19:29:35332endif()
333
334set(LIBOMP_LIB_FILE ${LIBOMP_LIB_NAME}${LIBOMP_LIBRARY_SUFFIX})
Jim Cownie3b81ce62014-08-05 09:32:28335
Jim Cownie3b81ce62014-08-05 09:32:28336# Print configuration after all variables are set.
Jonathan Peyton7979a072015-05-20 22:33:24337if(${LIBOMP_STANDALONE_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:19338 libomp_say("Operating System -- ${CMAKE_SYSTEM_NAME}")
339 libomp_say("Target Architecture -- ${LIBOMP_ARCH}")
340 if(${MIC})
341 libomp_say("Intel(R) MIC Architecture -- ${LIBOMP_MIC_ARCH}")
342 endif()
343 libomp_say("Build Type -- ${CMAKE_BUILD_TYPE}")
344 libomp_say("OpenMP Version -- ${LIBOMP_OMP_VERSION}")
Jonathan Peytonfd74f902016-02-04 19:29:35345 libomp_say("Library Kind -- ${LIBOMP_LIBRARY_KIND}")
346 libomp_say("Library Type -- ${LIBOMP_LIB_TYPE}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19347 libomp_say("Fortran Modules -- ${LIBOMP_FORTRAN_MODULES}")
348 # will say development if all zeros
Jonathan Peytonc0225ca2015-08-28 18:42:10349 if(${LIBOMP_VERSION_BUILD} STREQUAL 00000000)
Jonathan Peyton5b4acbd2015-07-15 16:57:19350 set(LIBOMP_BUILD Development)
351 else()
Jonathan Peytonc0225ca2015-08-28 18:42:10352 set(LIBOMP_BUILD ${LIBOMP_VERSION_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:19353 endif()
354 libomp_say("Build -- ${LIBOMP_BUILD}")
355 libomp_say("Use Stats-gathering -- ${LIBOMP_STATS}")
356 libomp_say("Use Debugger-support -- ${LIBOMP_USE_DEBUGGER}")
357 libomp_say("Use OMPT-support -- ${LIBOMP_OMPT_SUPPORT}")
358 if(${LIBOMP_OMPT_SUPPORT})
359 libomp_say("Use OMPT-blame -- ${LIBOMP_OMPT_BLAME}")
360 libomp_say("Use OMPT-trace -- ${LIBOMP_OMPT_TRACE}")
361 endif()
362 libomp_say("Use Adaptive locks -- ${LIBOMP_USE_ADAPTIVE_LOCKS}")
363 libomp_say("Use quad precision -- ${LIBOMP_USE_QUAD_PRECISION}")
Jonathan Peyton01dcf362015-11-30 20:02:59364 libomp_say("Use Hwloc library -- ${LIBOMP_USE_HWLOC}")
Jim Cownie3b81ce62014-08-05 09:32:28365endif()
Andrey Churbanov648467e2015-05-05 20:02:52366
Jonathan Peyton52158902015-06-11 17:23:57367add_subdirectory(src)
Jonathan Peyton614c7ef2015-09-21 20:41:31368add_subdirectory(test)
Jim Cownie3b81ce62014-08-05 09:32:28369