blob: 77599f5f05806eb7530ff1ae536dff5792866365 [file] [log] [blame]
Jim Cownie3b81ce62014-08-05 09:32:28 +00001#
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:33 +000011
Jonathan Peyton227e1ae2015-06-01 03:05:13 +000012# CMAKE libomp
Jim Cownie3b81ce62014-08-05 09:32:28 +000013cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
Alp Toker7198f522014-06-01 18:01:33 +000014
Jim Cownie3b81ce62014-08-05 09:32:28 +000015# 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:52 +000018# Standalone build or part of LLVM?
Jonathan Peyton7979a072015-05-20 22:33:24 +000019set(LIBOMP_STANDALONE_BUILD FALSE)
Jonathan Peyton2e013352015-07-15 16:05:30 +000020if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}" OR
Andrey Churbanov648467e2015-05-05 20:02:52 +000021 "${CMAKE_SOURCE_DIR}/runtime" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +000022 project(libomp C CXX)
23 set(LIBOMP_STANDALONE_BUILD TRUE)
Andrey Churbanov648467e2015-05-05 20:02:52 +000024endif()
25
Jonathan Peytonc0225ca2015-08-28 18:42:10 +000026# Set libomp version
27set(LIBOMP_VERSION_MAJOR 5)
28set(LIBOMP_VERSION_MINOR 0)
29
Jonathan Peyton2e013352015-07-15 16:05:30 +000030# These include files are in the cmake/ subdirectory
31include(LibompUtils)
32include(LibompGetArchitecture)
33include(LibompHandleFlags)
34include(LibompDefinitions)
Jim Cownie3b81ce62014-08-05 09:32:28 +000035
Jonathan Peyton2e013352015-07-15 16:05:30 +000036# Determine the target architecture
37if(${LIBOMP_STANDALONE_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +000038 # 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:02 +000048 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:19 +000050 # 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:30 +000054else() # Part of LLVM build
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +000055 # 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:02 +000082 set(LIBOMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR})
Jim Cownie3b81ce62014-08-05 09:32:28 +000083endif()
Jonathan Peyton2e013352015-07-15 16:05:30 +000084libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc64 ppc64le aarch64 mic)
Jim Cownie3b81ce62014-08-05 09:32:28 +000085
Jonathan Peytonfbb15142015-05-26 17:27:01 +000086set(LIBOMP_LIB_TYPE normal CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +000087 "Performance,Profiling,Stubs library (normal/profile/stubs)")
Jonathan Peyton2e013352015-07-15 16:05:30 +000088libomp_check_variable(LIBOMP_LIB_TYPE normal profile stubs)
Jonathan Peytondf6818b2016-06-14 17:57:47 +000089set(LIBOMP_OMP_VERSION 45 CACHE STRING
90 "The OpenMP version (45/40/30)")
91if(LIBOMP_OMP_VERSION EQUAL 41)
92 libomp_warning_say("LIBOMP_OMP_VERSION=41 is deprecated and will be removed in a later version. Please use 45.")
93 set(LIBOMP_OMP_VERSION 45)
94endif()
95libomp_check_variable(LIBOMP_OMP_VERSION 45 40 30)
Jonathan Peytonc0225ca2015-08-28 18:42:10 +000096# Set the OpenMP Year and Month assiociated with version
97if(${LIBOMP_OMP_VERSION} GREATER 40 OR ${LIBOMP_OMP_VERSION} EQUAL 40)
98 set(LIBOMP_OMP_YEAR_MONTH 201307)
99elseif(${LIBOMP_OMP_VERSION} GREATER 30 OR ${LIBOMP_OMP_VERSION} EQUAL 30)
100 set(LIBOMP_OMP_YEAR_MONTH 201107)
101else()
102 set(LIBOMP_OMP_YEAR_MONTH 200505)
103endif()
Jonathan Peyton2e013352015-07-15 16:05:30 +0000104set(LIBOMP_MIC_ARCH knc CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000105 "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:30 +0000106if("${LIBOMP_ARCH}" STREQUAL "mic")
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000107 libomp_check_variable(LIBOMP_MIC_ARCH knf knc)
Jonathan Peyton2e013352015-07-15 16:05:30 +0000108endif()
109set(LIBOMP_FORTRAN_MODULES FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000110 "Create Fortran module files? (requires fortran compiler)")
Jim Cownie3b81ce62014-08-05 09:32:28 +0000111
Jonathan Peyton92907c22015-05-29 16:13:56 +0000112# - Support for universal fat binary builds on Mac
Jonathan Peyton2e013352015-07-15 16:05:30 +0000113# - Having this extra variable allows people to build this library as a universal library
Jonathan Peyton92907c22015-05-29 16:13:56 +0000114# without forcing a universal build of the llvm/clang compiler.
115set(LIBOMP_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000116 "For Mac builds, semicolon separated list of architectures to build for universal fat binary.")
Jonathan Peyton92907c22015-05-29 16:13:56 +0000117set(CMAKE_OSX_ARCHITECTURES ${LIBOMP_OSX_ARCHITECTURES})
118
Jonathan Peyton89d9b332016-02-09 22:15:30 +0000119# Should @rpath be used for dynamic libraries on Mac?
120# The if(NOT DEFINED) is there to guard a cached value of the variable if one
121# exists so there is no interference with what the user wants. Also, no cache entry
122# is created so there are no inadvertant effects on other parts of LLVM.
123if(NOT DEFINED CMAKE_MACOSX_RPATH)
124 set(CMAKE_MACOSX_RPATH TRUE)
125endif()
126
Jonathan Peyton2e013352015-07-15 16:05:30 +0000127# User specified flags. These are appended to the configured flags.
Jonathan Peytonfbb15142015-05-26 17:27:01 +0000128set(LIBOMP_CFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000129 "Appended user specified C compiler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01 +0000130set(LIBOMP_CXXFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000131 "Appended user specified C++ compiler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01 +0000132set(LIBOMP_CPPFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000133 "Appended user specified C preprocessor flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01 +0000134set(LIBOMP_ASMFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000135 "Appended user specified assembler flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01 +0000136set(LIBOMP_LDFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000137 "Appended user specified linker flags.")
Jonathan Peytonfbb15142015-05-26 17:27:01 +0000138set(LIBOMP_LIBFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000139 "Appended user specified linked libs flags. (e.g., -lm)")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000140set(LIBOMP_FFLAGS "" CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000141 "Appended user specified Fortran compiler flags. These are only used if LIBOMP_FORTRAN_MODULES==TRUE.")
Jim Cownie3b81ce62014-08-05 09:32:28 +0000142
Jonathan Peyton227e1ae2015-06-01 03:05:13 +0000143# Should the libomp library and generated headers be copied into the original source exports/ directory
Jonathan Peyton2e013352015-07-15 16:05:30 +0000144# Turning this to FALSE aids parallel builds to not interfere with each other.
145# Currently, the testsuite module expects the just built OpenMP library to be located inside the exports/
146# directory. TODO: have testsuite run under llvm-lit directly. We can then get rid of copying to exports/
147set(LIBOMP_COPY_EXPORTS TRUE CACHE STRING
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000148 "Should exports be copied into source exports/ directory?")
Andrey Churbanov708fa8e2015-05-14 12:54:08 +0000149
Jonathan Peyton01dcf362015-11-30 20:02:59 +0000150# HWLOC-support
151set(LIBOMP_USE_HWLOC FALSE CACHE BOOL
152 "Use Hwloc (http://www.open-mpi.org/projects/hwloc/) library for affinity?")
153set(LIBOMP_HWLOC_INSTALL_DIR /usr/local CACHE PATH
154 "Install path for hwloc library")
155
Jim Cownie3b81ce62014-08-05 09:32:28 +0000156# Get the build number from kmp_version.c
Jonathan Peytonc0225ca2015-08-28 18:42:10 +0000157libomp_get_build_number("${CMAKE_CURRENT_SOURCE_DIR}" LIBOMP_VERSION_BUILD)
158math(EXPR LIBOMP_VERSION_BUILD_YEAR "${LIBOMP_VERSION_BUILD}/10000")
159math(EXPR LIBOMP_VERSION_BUILD_MONTH_DAY "${LIBOMP_VERSION_BUILD}%10000")
Jim Cownie3b81ce62014-08-05 09:32:28 +0000160
Jonathan Peyton2e013352015-07-15 16:05:30 +0000161# Currently don't record any timestamps
Jonathan Peytonc0225ca2015-08-28 18:42:10 +0000162set(LIBOMP_BUILD_DATE "No_Timestamp")
Jim Cownie3b81ce62014-08-05 09:32:28 +0000163
164# Architecture
165set(IA32 FALSE)
166set(INTEL64 FALSE)
167set(ARM FALSE)
Andrey Churbanovcbda8682015-01-13 14:43:35 +0000168set(AARCH64 FALSE)
Andrey Churbanovd1c55042015-01-19 18:29:35 +0000169set(PPC64BE FALSE)
170set(PPC64LE FALSE)
Jim Cownie3051f972014-08-07 10:12:54 +0000171set(PPC64 FALSE)
Jonathan Peyton2e013352015-07-15 16:05:30 +0000172set(MIC FALSE)
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000173if("${LIBOMP_ARCH}" STREQUAL "i386" OR "${LIBOMP_ARCH}" STREQUAL "32") # IA-32 architecture
174 set(IA32 TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30 +0000175elseif("${LIBOMP_ARCH}" STREQUAL "x86_64" OR "${LIBOMP_ARCH}" STREQUAL "32e") # Intel(R) 64 architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000176 set(INTEL64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24 +0000177elseif("${LIBOMP_ARCH}" STREQUAL "arm") # ARM architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000178 set(ARM TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24 +0000179elseif("${LIBOMP_ARCH}" STREQUAL "ppc64") # PPC64BE architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000180 set(PPC64BE TRUE)
181 set(PPC64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24 +0000182elseif("${LIBOMP_ARCH}" STREQUAL "ppc64le") # PPC64LE architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000183 set(PPC64LE TRUE)
184 set(PPC64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24 +0000185elseif("${LIBOMP_ARCH}" STREQUAL "aarch64") # AARCH64 architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000186 set(AARCH64 TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24 +0000187elseif("${LIBOMP_ARCH}" STREQUAL "mic") # Intel(R) Many Integrated Core Architecture
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000188 set(MIC TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28 +0000189endif()
190
191# Set some flags based on build_type
Jonathan Peytonfbb15142015-05-26 17:27:01 +0000192set(RELEASE_BUILD FALSE)
193set(DEBUG_BUILD FALSE)
Jim Cownie3b81ce62014-08-05 09:32:28 +0000194set(RELWITHDEBINFO_BUILD FALSE)
Jonathan Peyton2e013352015-07-15 16:05:30 +0000195set(MINSIZEREL_BUILD FALSE)
196string(TOLOWER "${CMAKE_BUILD_TYPE}" libomp_build_type_lowercase)
197if("${libomp_build_type_lowercase}" STREQUAL "release")
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000198 set(RELEASE_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30 +0000199elseif("${libomp_build_type_lowercase}" STREQUAL "debug")
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000200 set(DEBUG_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30 +0000201elseif("${libomp_build_type_lowercase}" STREQUAL "relwithdebinfo")
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000202 set(RELWITHDEBINFO_BUILD TRUE)
Jonathan Peyton2e013352015-07-15 16:05:30 +0000203elseif("${libomp_build_type_lowercase}" STREQUAL "minsizerel")
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000204 set(MINSIZEREL_BUILD TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28 +0000205endif()
206
Jonathan Peyton7abf9d52016-05-26 18:19:10 +0000207# Include itt notify interface?
208set(LIBOMP_USE_ITT_NOTIFY TRUE CACHE BOOL
209 "Enable ITT notify?")
Jim Cownie3b81ce62014-08-05 09:32:28 +0000210
211# normal, profile, stubs library.
212set(NORMAL_LIBRARY FALSE)
213set(STUBS_LIBRARY FALSE)
214set(PROFILE_LIBRARY FALSE)
Jonathan Peyton7979a072015-05-20 22:33:24 +0000215if("${LIBOMP_LIB_TYPE}" STREQUAL "normal")
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000216 set(NORMAL_LIBRARY TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24 +0000217elseif("${LIBOMP_LIB_TYPE}" STREQUAL "profile")
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000218 set(PROFILE_LIBRARY TRUE)
Jonathan Peyton7979a072015-05-20 22:33:24 +0000219elseif("${LIBOMP_LIB_TYPE}" STREQUAL "stubs")
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000220 set(STUBS_LIBRARY TRUE)
Jim Cownie3b81ce62014-08-05 09:32:28 +0000221endif()
222
Jonathan Peyton2e013352015-07-15 16:05:30 +0000223# Setting directory names
224set(LIBOMP_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
225set(LIBOMP_SRC_DIR ${LIBOMP_BASE_DIR}/src)
226set(LIBOMP_TOOLS_DIR ${LIBOMP_BASE_DIR}/tools)
227set(LIBOMP_INC_DIR ${LIBOMP_SRC_DIR}/include/${LIBOMP_OMP_VERSION})
Jonathan Peyton614c7ef2015-09-21 20:41:31 +0000228set(LIBOMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
Jim Cownie3b81ce62014-08-05 09:32:28 +0000229
Jonathan Peyton2e013352015-07-15 16:05:30 +0000230# Enabling Fortran if it is needed
Jonathan Peyton2e013352015-07-15 16:05:30 +0000231if(${LIBOMP_FORTRAN_MODULES})
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000232 enable_language(Fortran)
Jonathan Peyton2e013352015-07-15 16:05:30 +0000233endif()
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000234# Enable MASM Compiler if it is needed (Windows only)
Jonathan Peyton2e013352015-07-15 16:05:30 +0000235if(WIN32)
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000236 enable_language(ASM_MASM)
Jonathan Peyton2e013352015-07-15 16:05:30 +0000237endif()
Jim Cownie3b81ce62014-08-05 09:32:28 +0000238
Jonathan Peyton2e013352015-07-15 16:05:30 +0000239# Getting legal type/arch
240libomp_get_legal_type(LIBOMP_LEGAL_TYPE)
241libomp_get_legal_arch(LIBOMP_LEGAL_ARCH)
Jim Cownie3b81ce62014-08-05 09:32:28 +0000242
Jonathan Peyton2e013352015-07-15 16:05:30 +0000243# Compiler flag checks, library checks, threading check, etc.
244include(config-ix)
Jim Cownie3b81ce62014-08-05 09:32:28 +0000245
Jonathan Peyton2e013352015-07-15 16:05:30 +0000246# Is there a quad precision data type available?
247# TODO: Make this a real feature check
248set(LIBOMP_USE_QUAD_PRECISION "${LIBOMP_HAVE_QUAD_PRECISION}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000249 "Should 128-bit precision entry points be built?")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000250if(LIBOMP_USE_QUAD_PRECISION AND (NOT LIBOMP_HAVE_QUAD_PRECISION))
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000251 libomp_error_say("128-bit quad precision functionality requested but not available")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000252endif()
253
254# libgomp drop-in compatibility requires versioned symbols
255set(LIBOMP_USE_VERSION_SYMBOLS "${LIBOMP_HAVE_VERSION_SYMBOLS}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000256 "Should version symbols be used? These provide binary compatibility with libgomp.")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000257if(LIBOMP_USE_VERSION_SYMBOLS AND (NOT LIBOMP_HAVE_VERSION_SYMBOLS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000258 libomp_error_say("Version symbols functionality requested but not available")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000259endif()
260
261# On multinode systems, larger alignment is desired to avoid false sharing
262set(LIBOMP_USE_INTERNODE_ALIGNMENT FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000263 "Should larger alignment (4096 bytes) be used for some locks and data structures?")
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000264
Jonathan Peyton2e013352015-07-15 16:05:30 +0000265# Build code that allows the OpenMP library to conveniently interface with debuggers
266set(LIBOMP_USE_DEBUGGER FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000267 "Enable debugger interface code?")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000268
269# Should we link to C++ library?
270set(LIBOMP_USE_STDCPPLIB FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000271 "Should we link to C++ library?")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000272
273# TSX (x86) based locks have __asm code which can be troublesome for some compilers.
274# TODO: Make this a real feature check
275set(LIBOMP_USE_ADAPTIVE_LOCKS "${LIBOMP_HAVE_ADAPTIVE_LOCKS}" CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000276 "Should TSX-based lock be compiled (adaptive lock in kmp_lock.cpp). These are x86 specific.")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000277if(LIBOMP_USE_ADAPTIVE_LOCKS AND (NOT LIBOMP_HAVE_ADAPTIVE_LOCKS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000278 libomp_error_say("Adaptive locks (TSX) functionality requested but not available")
Jim Cownie4cc4bb42014-10-07 16:25:50 +0000279endif()
280
Jonathan Peyton2e013352015-07-15 16:05:30 +0000281# - stats-gathering enables OpenMP stats where things like the number of
282# parallel regions, clock ticks spent in particular openmp regions are recorded.
Jonathan Peyton2e013352015-07-15 16:05:30 +0000283set(LIBOMP_STATS FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000284 "Stats-Gathering functionality?")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000285if(LIBOMP_STATS AND (NOT LIBOMP_HAVE_STATS))
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000286 libomp_error_say("Stats-gathering functionality requested but not available")
Jim Cownie3b81ce62014-08-05 09:32:28 +0000287endif()
Jonathan Peyton45be4502015-08-11 21:36:41 +0000288# The stats functionality requires the std c++ library
289if(LIBOMP_STATS)
290 set(LIBOMP_USE_STDCPPLIB TRUE)
291endif()
Jim Cownie3b81ce62014-08-05 09:32:28 +0000292
Jonathan Peytonfd74f902016-02-04 19:29:35 +0000293# Shared library can be switched to a static library
294set(LIBOMP_ENABLE_SHARED TRUE CACHE BOOL
295 "Shared library instead of static library?")
296
297if(WIN32 AND NOT LIBOMP_ENABLE_SHARED)
298 libomp_error_say("Static libraries requested but not available on Windows")
299endif()
300
Jonathan Peyton2e013352015-07-15 16:05:30 +0000301# OMPT-support
Jonathan Peyton95246e72015-11-05 16:54:55 +0000302set(LIBOMP_OMPT_DEBUG FALSE CACHE BOOL
303 "Trace OMPT initialization?")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000304set(LIBOMP_OMPT_SUPPORT FALSE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000305 "OMPT-support?")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000306set(LIBOMP_OMPT_BLAME TRUE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000307 "OMPT-blame?")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000308set(LIBOMP_OMPT_TRACE TRUE CACHE BOOL
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000309 "OMPT-trace?")
Jonathan Peyton2e013352015-07-15 16:05:30 +0000310if(LIBOMP_OMPT_SUPPORT AND (NOT LIBOMP_HAVE_OMPT_SUPPORT))
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000311 libomp_error_say("OpenMP Tools Interface requested but not available")
Jonathan Peytonb689ded2015-06-17 15:43:34 +0000312endif()
Jim Cownie3b81ce62014-08-05 09:32:28 +0000313
Jonathan Peyton01dcf362015-11-30 20:02:59 +0000314# Error check hwloc support after config-ix has run
315if(LIBOMP_USE_HWLOC AND (NOT LIBOMP_HAVE_HWLOC))
316 libomp_error_say("Hwloc requested but not available")
317endif()
318
Jim Cownie3b81ce62014-08-05 09:32:28 +0000319# Setting final library name
Jonathan Peyton2e013352015-07-15 16:05:30 +0000320set(LIBOMP_DEFAULT_LIB_NAME libomp)
Jim Cownie3b81ce62014-08-05 09:32:28 +0000321if(${PROFILE_LIBRARY})
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000322 set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}prof)
Jim Cownie3b81ce62014-08-05 09:32:28 +0000323endif()
324if(${STUBS_LIBRARY})
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000325 set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}stubs)
Jim Cownie3b81ce62014-08-05 09:32:28 +0000326endif()
Jonathan Peyton2e013352015-07-15 16:05:30 +0000327set(LIBOMP_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME} CACHE STRING "Base OMP library name")
Jonathan Peytonfd74f902016-02-04 19:29:35 +0000328
329if(${LIBOMP_ENABLE_SHARED})
330 set(LIBOMP_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
Jonathan Peyton975dabc2016-05-17 20:51:24 +0000331 set(LIBOMP_LIBRARY_KIND SHARED)
332 set(LIBOMP_INSTALL_KIND LIBRARY)
Jonathan Peytonfd74f902016-02-04 19:29:35 +0000333else()
334 set(LIBOMP_LIBRARY_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
Jonathan Peyton975dabc2016-05-17 20:51:24 +0000335 set(LIBOMP_LIBRARY_KIND STATIC)
336 set(LIBOMP_INSTALL_KIND ARCHIVE)
Jonathan Peytonfd74f902016-02-04 19:29:35 +0000337endif()
338
339set(LIBOMP_LIB_FILE ${LIBOMP_LIB_NAME}${LIBOMP_LIBRARY_SUFFIX})
Jim Cownie3b81ce62014-08-05 09:32:28 +0000340
Jim Cownie3b81ce62014-08-05 09:32:28 +0000341# Print configuration after all variables are set.
Jonathan Peyton7979a072015-05-20 22:33:24 +0000342if(${LIBOMP_STANDALONE_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000343 libomp_say("Operating System -- ${CMAKE_SYSTEM_NAME}")
344 libomp_say("Target Architecture -- ${LIBOMP_ARCH}")
345 if(${MIC})
346 libomp_say("Intel(R) MIC Architecture -- ${LIBOMP_MIC_ARCH}")
347 endif()
348 libomp_say("Build Type -- ${CMAKE_BUILD_TYPE}")
349 libomp_say("OpenMP Version -- ${LIBOMP_OMP_VERSION}")
Jonathan Peytonfd74f902016-02-04 19:29:35 +0000350 libomp_say("Library Kind -- ${LIBOMP_LIBRARY_KIND}")
351 libomp_say("Library Type -- ${LIBOMP_LIB_TYPE}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000352 libomp_say("Fortran Modules -- ${LIBOMP_FORTRAN_MODULES}")
353 # will say development if all zeros
Jonathan Peytonc0225ca2015-08-28 18:42:10 +0000354 if(${LIBOMP_VERSION_BUILD} STREQUAL 00000000)
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000355 set(LIBOMP_BUILD Development)
356 else()
Jonathan Peytonc0225ca2015-08-28 18:42:10 +0000357 set(LIBOMP_BUILD ${LIBOMP_VERSION_BUILD})
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000358 endif()
359 libomp_say("Build -- ${LIBOMP_BUILD}")
360 libomp_say("Use Stats-gathering -- ${LIBOMP_STATS}")
361 libomp_say("Use Debugger-support -- ${LIBOMP_USE_DEBUGGER}")
Jonathan Peyton7abf9d52016-05-26 18:19:10 +0000362 libomp_say("Use ITT notify -- ${LIBOMP_USE_ITT_NOTIFY}")
Jonathan Peyton5b4acbd2015-07-15 16:57:19 +0000363 libomp_say("Use OMPT-support -- ${LIBOMP_OMPT_SUPPORT}")
364 if(${LIBOMP_OMPT_SUPPORT})
365 libomp_say("Use OMPT-blame -- ${LIBOMP_OMPT_BLAME}")
366 libomp_say("Use OMPT-trace -- ${LIBOMP_OMPT_TRACE}")
367 endif()
368 libomp_say("Use Adaptive locks -- ${LIBOMP_USE_ADAPTIVE_LOCKS}")
369 libomp_say("Use quad precision -- ${LIBOMP_USE_QUAD_PRECISION}")
Jonathan Peyton01dcf362015-11-30 20:02:59 +0000370 libomp_say("Use Hwloc library -- ${LIBOMP_USE_HWLOC}")
Jim Cownie3b81ce62014-08-05 09:32:28 +0000371endif()
Andrey Churbanov648467e2015-05-05 20:02:52 +0000372
Jonathan Peyton52158902015-06-11 17:23:57 +0000373add_subdirectory(src)
Jonathan Peyton614c7ef2015-09-21 20:41:31 +0000374add_subdirectory(test)
Jim Cownie3b81ce62014-08-05 09:32:28 +0000375