Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 1 | # |
| 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 Toker | 7198f52 | 2014-06-01 18:01:33 | [diff] [blame] | 11 | |
Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 | [diff] [blame] | 12 | # CMAKE libomp |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 13 | cmake_minimum_required(VERSION 2.8 FATAL_ERROR) |
Alp Toker | 7198f52 | 2014-06-01 18:01:33 | [diff] [blame] | 14 | |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 15 | # Add cmake directory to search for custom cmake functions |
| 16 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 17 | |
Andrey Churbanov | 648467e | 2015-05-05 20:02:52 | [diff] [blame] | 18 | # Standalone build or part of LLVM? |
Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 | [diff] [blame] | 19 | set(LIBOMP_STANDALONE_BUILD FALSE) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 20 | if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}" OR |
Andrey Churbanov | 648467e | 2015-05-05 20:02:52 | [diff] [blame] | 21 | "${CMAKE_SOURCE_DIR}/runtime" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 22 | project(libomp C CXX) |
| 23 | set(LIBOMP_STANDALONE_BUILD TRUE) |
Andrey Churbanov | 648467e | 2015-05-05 20:02:52 | [diff] [blame] | 24 | endif() |
| 25 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 26 | # These include files are in the cmake/ subdirectory |
| 27 | include(LibompUtils) |
| 28 | include(LibompGetArchitecture) |
| 29 | include(LibompHandleFlags) |
| 30 | include(LibompDefinitions) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 31 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 32 | # Determine the target architecture |
| 33 | if(${LIBOMP_STANDALONE_BUILD}) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 34 | # If adding a new architecture, take a look at cmake/LibompGetArchitecture.cmake |
| 35 | libomp_get_architecture(LIBOMP_DETECTED_ARCH) |
| 36 | set(LIBOMP_ARCH ${LIBOMP_DETECTED_ARCH} CACHE STRING |
| 37 | "The architecture to build for (x86_64/i386/arm/ppc64/ppc64le/aarch64/mic).") |
| 38 | # Allow user to choose a suffix for the installation directory. |
| 39 | set(LIBOMP_LIBDIR_SUFFIX "" CACHE STRING |
| 40 | "suffix of lib installation directory e.g., 64 => lib64") |
| 41 | # Should assertions be enabled? They are on by default. |
| 42 | set(LIBOMP_ENABLE_ASSERTIONS TRUE CACHE BOOL |
| 43 | "enable assertions?") |
Chandler Carruth | 5145156 | 2015-07-18 03:14:02 | [diff] [blame] | 44 | set(LIBOMP_ENABLE_WERROR FALSE CACHE BOOL |
| 45 | "Enable -Werror flags to turn warnings into errors for supporting compilers.") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 46 | # CMAKE_BUILD_TYPE was not defined, set default to Release |
| 47 | if(NOT CMAKE_BUILD_TYPE) |
| 48 | set(CMAKE_BUILD_TYPE Release) |
| 49 | endif() |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 50 | else() # Part of LLVM build |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 51 | # Determine the native architecture from LLVM. |
| 52 | string(TOLOWER "${LLVM_TARGET_ARCH}" LIBOMP_NATIVE_ARCH) |
| 53 | if( LIBOMP_NATIVE_ARCH STREQUAL "host" ) |
| 54 | string(REGEX MATCH "^[^-]*" LIBOMP_NATIVE_ARCH ${LLVM_HOST_TRIPLE}) |
| 55 | endif () |
| 56 | if(LIBOMP_NATIVE_ARCH MATCHES "i[2-6]86") |
| 57 | set(LIBOMP_ARCH i386) |
| 58 | elseif(LIBOMP_NATIVE_ARCH STREQUAL "x86") |
| 59 | set(LIBOMP_ARCH i386) |
| 60 | elseif(LIBOMP_NATIVE_ARCH STREQUAL "amd64") |
| 61 | set(LIBOMP_ARCH x86_64) |
| 62 | elseif(LIBOMP_NATIVE_ARCH STREQUAL "x86_64") |
| 63 | set(LIBOMP_ARCH x86_64) |
| 64 | elseif(LIBOMP_NATIVE_ARCH MATCHES "powerpc") |
| 65 | set(LIBOMP_ARCH ppc64) |
| 66 | elseif(LIBOMP_NATIVE_ARCH MATCHES "aarch64") |
| 67 | set(LIBOMP_ARCH aarch64) |
| 68 | elseif(LIBOMP_NATIVE_ARCH MATCHES "arm64") |
| 69 | set(LIBOMP_ARCH aarch64) |
| 70 | elseif(LIBOMP_NATIVE_ARCH MATCHES "arm") |
| 71 | set(LIBOMP_ARCH arm) |
| 72 | else() |
| 73 | # last ditch effort |
| 74 | libomp_get_architecture(LIBOMP_ARCH) |
| 75 | endif () |
| 76 | set(LIBOMP_LIBDIR_SUFFIX ${LLVM_LIBDIR_SUFFIX}) |
| 77 | set(LIBOMP_ENABLE_ASSERTIONS ${LLVM_ENABLE_ASSERTIONS}) |
Chandler Carruth | 5145156 | 2015-07-18 03:14:02 | [diff] [blame] | 78 | set(LIBOMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR}) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 79 | endif() |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 80 | libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc64 ppc64le aarch64 mic) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 81 | |
Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 | [diff] [blame] | 82 | set(LIBOMP_LIB_TYPE normal CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 83 | "Performance,Profiling,Stubs library (normal/profile/stubs)") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 84 | libomp_check_variable(LIBOMP_LIB_TYPE normal profile stubs) |
| 85 | set(LIBOMP_VERSION 5 CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 86 | "Produce libguide (version 4) or libomp (version 5)") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 87 | set(LIBOMP_OMP_VERSION 41 CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 88 | "The OpenMP version (41/40/30)") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 89 | libomp_check_variable(LIBOMP_OMP_VERSION 41 40 30) |
| 90 | set(LIBOMP_MIC_ARCH knc CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 91 | "Intel(R) Many Integrated Core Architecture (Intel(R) MIC Architecture) (knf/knc). Ignored if not Intel(R) MIC Architecture build.") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 92 | if("${LIBOMP_ARCH}" STREQUAL "mic") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 93 | libomp_check_variable(LIBOMP_MIC_ARCH knf knc) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 94 | endif() |
| 95 | set(LIBOMP_FORTRAN_MODULES FALSE CACHE BOOL |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 96 | "Create Fortran module files? (requires fortran compiler)") |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 97 | |
Jonathan Peyton | 92907c2 | 2015-05-29 16:13:56 | [diff] [blame] | 98 | # - Support for universal fat binary builds on Mac |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 99 | # - Having this extra variable allows people to build this library as a universal library |
Jonathan Peyton | 92907c2 | 2015-05-29 16:13:56 | [diff] [blame] | 100 | # without forcing a universal build of the llvm/clang compiler. |
| 101 | set(LIBOMP_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 102 | "For Mac builds, semicolon separated list of architectures to build for universal fat binary.") |
Jonathan Peyton | 92907c2 | 2015-05-29 16:13:56 | [diff] [blame] | 103 | set(CMAKE_OSX_ARCHITECTURES ${LIBOMP_OSX_ARCHITECTURES}) |
| 104 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 105 | # User specified flags. These are appended to the configured flags. |
Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 | [diff] [blame] | 106 | set(LIBOMP_CFLAGS "" CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 107 | "Appended user specified C compiler flags.") |
Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 | [diff] [blame] | 108 | set(LIBOMP_CXXFLAGS "" CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 109 | "Appended user specified C++ compiler flags.") |
Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 | [diff] [blame] | 110 | set(LIBOMP_CPPFLAGS "" CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 111 | "Appended user specified C preprocessor flags.") |
Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 | [diff] [blame] | 112 | set(LIBOMP_ASMFLAGS "" CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 113 | "Appended user specified assembler flags.") |
Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 | [diff] [blame] | 114 | set(LIBOMP_LDFLAGS "" CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 115 | "Appended user specified linker flags.") |
Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 | [diff] [blame] | 116 | set(LIBOMP_LIBFLAGS "" CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 117 | "Appended user specified linked libs flags. (e.g., -lm)") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 118 | set(LIBOMP_FFLAGS "" CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 119 | "Appended user specified Fortran compiler flags. These are only used if LIBOMP_FORTRAN_MODULES==TRUE.") |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 120 | |
Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 | [diff] [blame] | 121 | # Should the libomp library and generated headers be copied into the original source exports/ directory |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 122 | # Turning this to FALSE aids parallel builds to not interfere with each other. |
| 123 | # Currently, the testsuite module expects the just built OpenMP library to be located inside the exports/ |
| 124 | # directory. TODO: have testsuite run under llvm-lit directly. We can then get rid of copying to exports/ |
| 125 | set(LIBOMP_COPY_EXPORTS TRUE CACHE STRING |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 126 | "Should exports be copied into source exports/ directory?") |
Andrey Churbanov | 708fa8e | 2015-05-14 12:54:08 | [diff] [blame] | 127 | |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 128 | # Get the build number from kmp_version.c |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 129 | libomp_get_build_number("${CMAKE_CURRENT_SOURCE_DIR}" LIBOMP_BUILD_NUMBER) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 130 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 131 | # Currently don't record any timestamps |
| 132 | set(LIBOMP_DATE "No_Timestamp") |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 133 | |
| 134 | # Architecture |
| 135 | set(IA32 FALSE) |
| 136 | set(INTEL64 FALSE) |
| 137 | set(ARM FALSE) |
Andrey Churbanov | cbda868 | 2015-01-13 14:43:35 | [diff] [blame] | 138 | set(AARCH64 FALSE) |
Andrey Churbanov | d1c5504 | 2015-01-19 18:29:35 | [diff] [blame] | 139 | set(PPC64BE FALSE) |
| 140 | set(PPC64LE FALSE) |
Jim Cownie | 3051f97 | 2014-08-07 10:12:54 | [diff] [blame] | 141 | set(PPC64 FALSE) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 142 | set(MIC FALSE) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 143 | if("${LIBOMP_ARCH}" STREQUAL "i386" OR "${LIBOMP_ARCH}" STREQUAL "32") # IA-32 architecture |
| 144 | set(IA32 TRUE) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 145 | elseif("${LIBOMP_ARCH}" STREQUAL "x86_64" OR "${LIBOMP_ARCH}" STREQUAL "32e") # Intel(R) 64 architecture |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 146 | set(INTEL64 TRUE) |
Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 | [diff] [blame] | 147 | elseif("${LIBOMP_ARCH}" STREQUAL "arm") # ARM architecture |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 148 | set(ARM TRUE) |
Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 | [diff] [blame] | 149 | elseif("${LIBOMP_ARCH}" STREQUAL "ppc64") # PPC64BE architecture |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 150 | set(PPC64BE TRUE) |
| 151 | set(PPC64 TRUE) |
Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 | [diff] [blame] | 152 | elseif("${LIBOMP_ARCH}" STREQUAL "ppc64le") # PPC64LE architecture |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 153 | set(PPC64LE TRUE) |
| 154 | set(PPC64 TRUE) |
Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 | [diff] [blame] | 155 | elseif("${LIBOMP_ARCH}" STREQUAL "aarch64") # AARCH64 architecture |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 156 | set(AARCH64 TRUE) |
Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 | [diff] [blame] | 157 | elseif("${LIBOMP_ARCH}" STREQUAL "mic") # Intel(R) Many Integrated Core Architecture |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 158 | set(MIC TRUE) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 159 | endif() |
| 160 | |
| 161 | # Set some flags based on build_type |
Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 | [diff] [blame] | 162 | set(RELEASE_BUILD FALSE) |
| 163 | set(DEBUG_BUILD FALSE) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 164 | set(RELWITHDEBINFO_BUILD FALSE) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 165 | set(MINSIZEREL_BUILD FALSE) |
| 166 | string(TOLOWER "${CMAKE_BUILD_TYPE}" libomp_build_type_lowercase) |
| 167 | if("${libomp_build_type_lowercase}" STREQUAL "release") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 168 | set(RELEASE_BUILD TRUE) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 169 | elseif("${libomp_build_type_lowercase}" STREQUAL "debug") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 170 | set(DEBUG_BUILD TRUE) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 171 | elseif("${libomp_build_type_lowercase}" STREQUAL "relwithdebinfo") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 172 | set(RELWITHDEBINFO_BUILD TRUE) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 173 | elseif("${libomp_build_type_lowercase}" STREQUAL "minsizerel") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 174 | set(MINSIZEREL_BUILD TRUE) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 175 | endif() |
| 176 | |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 177 | # Include itt notify interface? Right now, always. |
Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 | [diff] [blame] | 178 | set(LIBOMP_USE_ITT_NOTIFY TRUE) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 179 | |
| 180 | # normal, profile, stubs library. |
| 181 | set(NORMAL_LIBRARY FALSE) |
| 182 | set(STUBS_LIBRARY FALSE) |
| 183 | set(PROFILE_LIBRARY FALSE) |
Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 | [diff] [blame] | 184 | if("${LIBOMP_LIB_TYPE}" STREQUAL "normal") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 185 | set(NORMAL_LIBRARY TRUE) |
Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 | [diff] [blame] | 186 | elseif("${LIBOMP_LIB_TYPE}" STREQUAL "profile") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 187 | set(PROFILE_LIBRARY TRUE) |
Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 | [diff] [blame] | 188 | elseif("${LIBOMP_LIB_TYPE}" STREQUAL "stubs") |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 189 | set(STUBS_LIBRARY TRUE) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 190 | endif() |
| 191 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 192 | # Setting directory names |
| 193 | set(LIBOMP_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 194 | set(LIBOMP_SRC_DIR ${LIBOMP_BASE_DIR}/src) |
| 195 | set(LIBOMP_TOOLS_DIR ${LIBOMP_BASE_DIR}/tools) |
| 196 | set(LIBOMP_INC_DIR ${LIBOMP_SRC_DIR}/include/${LIBOMP_OMP_VERSION}) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 197 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 198 | # Enabling Fortran if it is needed |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 199 | if(${LIBOMP_FORTRAN_MODULES}) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 200 | enable_language(Fortran) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 201 | endif() |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 202 | # Enable MASM Compiler if it is needed (Windows only) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 203 | if(WIN32) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 204 | enable_language(ASM_MASM) |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 205 | endif() |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 206 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 207 | # Getting legal type/arch |
| 208 | libomp_get_legal_type(LIBOMP_LEGAL_TYPE) |
| 209 | libomp_get_legal_arch(LIBOMP_LEGAL_ARCH) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 210 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 211 | # Compiler flag checks, library checks, threading check, etc. |
| 212 | include(config-ix) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 213 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 214 | # Is there a quad precision data type available? |
| 215 | # TODO: Make this a real feature check |
| 216 | set(LIBOMP_USE_QUAD_PRECISION "${LIBOMP_HAVE_QUAD_PRECISION}" CACHE BOOL |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 217 | "Should 128-bit precision entry points be built?") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 218 | if(LIBOMP_USE_QUAD_PRECISION AND (NOT LIBOMP_HAVE_QUAD_PRECISION)) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 219 | libomp_error_say("128-bit quad precision functionality requested but not available") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 220 | endif() |
| 221 | |
| 222 | # libgomp drop-in compatibility requires versioned symbols |
| 223 | set(LIBOMP_USE_VERSION_SYMBOLS "${LIBOMP_HAVE_VERSION_SYMBOLS}" CACHE BOOL |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 224 | "Should version symbols be used? These provide binary compatibility with libgomp.") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 225 | if(LIBOMP_USE_VERSION_SYMBOLS AND (NOT LIBOMP_HAVE_VERSION_SYMBOLS)) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 226 | libomp_error_say("Version symbols functionality requested but not available") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 227 | endif() |
| 228 | |
| 229 | # On multinode systems, larger alignment is desired to avoid false sharing |
| 230 | set(LIBOMP_USE_INTERNODE_ALIGNMENT FALSE CACHE BOOL |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 231 | "Should larger alignment (4096 bytes) be used for some locks and data structures?") |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 | [diff] [blame] | 232 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 233 | # Build code that allows the OpenMP library to conveniently interface with debuggers |
| 234 | set(LIBOMP_USE_DEBUGGER FALSE CACHE BOOL |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 235 | "Enable debugger interface code?") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 236 | |
| 237 | # Should we link to C++ library? |
| 238 | set(LIBOMP_USE_STDCPPLIB FALSE CACHE BOOL |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 239 | "Should we link to C++ library?") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 240 | |
| 241 | # TSX (x86) based locks have __asm code which can be troublesome for some compilers. |
| 242 | # TODO: Make this a real feature check |
| 243 | set(LIBOMP_USE_ADAPTIVE_LOCKS "${LIBOMP_HAVE_ADAPTIVE_LOCKS}" CACHE BOOL |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 244 | "Should TSX-based lock be compiled (adaptive lock in kmp_lock.cpp). These are x86 specific.") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 245 | if(LIBOMP_USE_ADAPTIVE_LOCKS AND (NOT LIBOMP_HAVE_ADAPTIVE_LOCKS)) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 246 | libomp_error_say("Adaptive locks (TSX) functionality requested but not available") |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 | [diff] [blame] | 247 | endif() |
| 248 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 249 | # - stats-gathering enables OpenMP stats where things like the number of |
| 250 | # parallel regions, clock ticks spent in particular openmp regions are recorded. |
| 251 | # TODO: Make this a real feature check |
| 252 | set(LIBOMP_STATS FALSE CACHE BOOL |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 253 | "Stats-Gathering functionality?") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 254 | if(LIBOMP_STATS AND (NOT LIBOMP_HAVE_STATS)) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 255 | libomp_error_say("Stats-gathering functionality requested but not available") |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 256 | endif() |
Jonathan Peyton | 45be450 | 2015-08-11 21:36:41 | [diff] [blame^] | 257 | # The stats functionality requires the std c++ library |
| 258 | if(LIBOMP_STATS) |
| 259 | set(LIBOMP_USE_STDCPPLIB TRUE) |
| 260 | endif() |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 261 | |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 262 | # OMPT-support |
| 263 | # TODO: Make this a real feature check |
| 264 | set(LIBOMP_OMPT_SUPPORT FALSE CACHE BOOL |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 265 | "OMPT-support?") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 266 | set(LIBOMP_OMPT_BLAME TRUE CACHE BOOL |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 267 | "OMPT-blame?") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 268 | set(LIBOMP_OMPT_TRACE TRUE CACHE BOOL |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 269 | "OMPT-trace?") |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 270 | if(LIBOMP_OMPT_SUPPORT AND (NOT LIBOMP_HAVE_OMPT_SUPPORT)) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 271 | libomp_error_say("OpenMP Tools Interface requested but not available") |
Jonathan Peyton | b689ded | 2015-06-17 15:43:34 | [diff] [blame] | 272 | endif() |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 273 | |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 274 | # Setting final library name |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 275 | set(LIBOMP_DEFAULT_LIB_NAME libomp) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 276 | if(${PROFILE_LIBRARY}) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 277 | set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}prof) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 278 | endif() |
| 279 | if(${STUBS_LIBRARY}) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 280 | set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}stubs) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 281 | endif() |
Jonathan Peyton | 2e01335 | 2015-07-15 16:05:30 | [diff] [blame] | 282 | set(LIBOMP_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME} CACHE STRING "Base OMP library name") |
| 283 | set(LIBOMP_LIB_FILE ${LIBOMP_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 284 | |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 285 | # Print configuration after all variables are set. |
Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 | [diff] [blame] | 286 | if(${LIBOMP_STANDALONE_BUILD}) |
Jonathan Peyton | 5b4acbd | 2015-07-15 16:57:19 | [diff] [blame] | 287 | libomp_say("Operating System -- ${CMAKE_SYSTEM_NAME}") |
| 288 | libomp_say("Target Architecture -- ${LIBOMP_ARCH}") |
| 289 | if(${MIC}) |
| 290 | libomp_say("Intel(R) MIC Architecture -- ${LIBOMP_MIC_ARCH}") |
| 291 | endif() |
| 292 | libomp_say("Build Type -- ${CMAKE_BUILD_TYPE}") |
| 293 | libomp_say("OpenMP Version -- ${LIBOMP_OMP_VERSION}") |
| 294 | libomp_say("Lib Type -- ${LIBOMP_LIB_TYPE}") |
| 295 | libomp_say("Fortran Modules -- ${LIBOMP_FORTRAN_MODULES}") |
| 296 | # will say development if all zeros |
| 297 | if(${LIBOMP_BUILD_NUMBER} STREQUAL 00000000) |
| 298 | set(LIBOMP_BUILD Development) |
| 299 | else() |
| 300 | set(LIBOMP_BUILD ${LIBOMP_BUILD_NUMBER}) |
| 301 | endif() |
| 302 | libomp_say("Build -- ${LIBOMP_BUILD}") |
| 303 | libomp_say("Use Stats-gathering -- ${LIBOMP_STATS}") |
| 304 | libomp_say("Use Debugger-support -- ${LIBOMP_USE_DEBUGGER}") |
| 305 | libomp_say("Use OMPT-support -- ${LIBOMP_OMPT_SUPPORT}") |
| 306 | if(${LIBOMP_OMPT_SUPPORT}) |
| 307 | libomp_say("Use OMPT-blame -- ${LIBOMP_OMPT_BLAME}") |
| 308 | libomp_say("Use OMPT-trace -- ${LIBOMP_OMPT_TRACE}") |
| 309 | endif() |
| 310 | libomp_say("Use Adaptive locks -- ${LIBOMP_USE_ADAPTIVE_LOCKS}") |
| 311 | libomp_say("Use quad precision -- ${LIBOMP_USE_QUAD_PRECISION}") |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 312 | endif() |
Andrey Churbanov | 648467e | 2015-05-05 20:02:52 | [diff] [blame] | 313 | |
Jonathan Peyton | 5215890 | 2015-06-11 17:23:57 | [diff] [blame] | 314 | add_subdirectory(src) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 | [diff] [blame] | 315 | |