| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [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 +0000 | [diff] [blame] | 11 | |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 12 | ################ |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 13 | # CMAKE libomp |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 14 | cmake_minimum_required(VERSION 2.8 FATAL_ERROR) |
| Alp Toker | 7198f52 | 2014-06-01 18:01:33 +0000 | [diff] [blame] | 15 | |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 16 | ######### |
| 17 | # GLOBALS |
| 18 | set(GLOBAL_DEBUG 0) |
| 19 | |
| 20 | # Add cmake directory to search for custom cmake functions |
| 21 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 22 | |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 23 | ####################################################################### |
| 24 | # Standalone build or part of LLVM? |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 25 | set(LIBOMP_STANDALONE_BUILD FALSE) |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 26 | if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}" OR |
| 27 | "${CMAKE_SOURCE_DIR}/runtime" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 28 | project(libomp C CXX) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 29 | set(LIBOMP_STANDALONE_BUILD TRUE) |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 30 | endif() |
| 31 | |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 32 | # These include files are in cmake/ subdirectory except for FindPerl which is a cmake standard module |
| 33 | include(HelperFunctions) |
| 34 | include(Definitions) # -D definitions when compiling |
| 35 | include(CommonFlags) # compiler, assembler, fortran, linker flags common for all compilers |
| 36 | include(SourceFiles) # source files to compile |
| 37 | include(PerlFlags) # Perl flags for generate-def.pl and expand-vars.pl |
| 38 | include(FindPerl) # Standard cmake module to check for Perl |
| Andrey Churbanov | 17cce42 | 2015-01-13 14:35:23 +0000 | [diff] [blame] | 39 | include(GetArchitecture) # get_architecture() |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 40 | |
| 41 | #################################################################### |
| 42 | # CONFIGURATION |
| 43 | # |
| 44 | # * Any variable/value that is CACHE-ed can be changed after the initial run of cmake |
| 45 | # through the file, CMakeCache.txt which is in the build directory. |
| 46 | # * If you change any value in CMakeCache.txt, then just run cmake .. |
| 47 | # and the changed will be picked up. One can also use -DVARIABLE=VALUE |
| 48 | # when calling cmake to changed configuration values. |
| 49 | # * CMAKE_C_COMPILER, CMAKE_CXX_COMPILER, CMAKE_ASM_MASM_COMPILER, CMAKE_ASM_COMPILER, |
| 50 | # CMAKE_Fortran_COMPILER can only by specified on the initial run of cmake. |
| 51 | # This means you cannot specify -DCMAKE_C_COMPILER= on a subsequent run of cmake |
| 52 | # in the same build directory until that build directory is emptied. |
| 53 | # If you want to change the compiler, then empty the build directory and rerun cmake. |
| 54 | |
| 55 | # Build Configuration |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 56 | set(os_possible_values lin mac win) |
| 57 | set(arch_possible_values 32e 32 arm ppc64 ppc64le aarch64 mic) |
| 58 | set(build_type_possible_values release debug relwithdebinfo) |
| Andrey Churbanov | 062e198 | 2015-05-07 17:07:06 +0000 | [diff] [blame] | 59 | set(omp_version_possible_values 41 40 30) |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 60 | set(lib_type_possible_values normal profile stubs) |
| 61 | set(mic_arch_possible_values knf knc) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 62 | |
| Andrey Churbanov | 17cce42 | 2015-01-13 14:35:23 +0000 | [diff] [blame] | 63 | # Below, cmake will try and determine the operating system and architecture for you. |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 64 | # These values are set in CMakeCache.txt when cmake is first run (-Dvar_name=... will take precedence) |
| 65 | # parameter | default value |
| 66 | # ---------------------------- |
| 67 | # Right now, this build system considers os=lin to mean "Unix-like that is not MAC" |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 68 | # Apple goes first because CMake considers Mac to be a Unix based |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 69 | # operating system, while libomp considers it a special case |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 70 | if(${APPLE}) |
| Andrey Churbanov | 17cce42 | 2015-01-13 14:35:23 +0000 | [diff] [blame] | 71 | set(temp_os mac) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 72 | elseif(${UNIX}) |
| Andrey Churbanov | 17cce42 | 2015-01-13 14:35:23 +0000 | [diff] [blame] | 73 | set(temp_os lin) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 74 | elseif(${WIN32}) |
| Andrey Churbanov | 17cce42 | 2015-01-13 14:35:23 +0000 | [diff] [blame] | 75 | set(temp_os win) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 76 | else() |
| Andrey Churbanov | 17cce42 | 2015-01-13 14:35:23 +0000 | [diff] [blame] | 77 | set(temp_os lin) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 78 | endif() |
| 79 | |
| Andrey Churbanov | 17cce42 | 2015-01-13 14:35:23 +0000 | [diff] [blame] | 80 | # If adding a new architecture, take a look at cmake/GetArchitecture.cmake |
| 81 | get_architecture(detected_arch) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 82 | |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 83 | set(LIBOMP_OS ${temp_os} CACHE STRING |
| 84 | "The operating system to build for (lin/mac/win)") |
| 85 | set(LIBOMP_ARCH ${detected_arch} CACHE STRING |
| 86 | "The architecture to build for (32e/32/arm/ppc64/ppc64le/aarch64/mic). 32e is Intel(R) 64 architecture, 32 is IA-32 architecture") |
| 87 | set(LIBOMP_LIB_TYPE normal CACHE STRING |
| 88 | "Performance,Profiling,Stubs library (normal/profile/stubs)") |
| 89 | set(LIBOMP_VERSION 5 CACHE STRING |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 90 | "Produce libguide (version 4) or libomp (version 5)") |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 91 | set(LIBOMP_OMP_VERSION 41 CACHE STRING |
| 92 | "The OpenMP version (41/40/30)") |
| 93 | set(LIBOMP_MIC_ARCH knc CACHE STRING |
| 94 | "Intel(R) Many Integrated Core Architecture (Intel(R) MIC Architecture) (knf/knc). Ignored if not Intel(R) MIC Architecture build.") |
| 95 | set(LIBOMP_FORTRAN_MODULES false CACHE BOOL |
| 96 | "Create Fortran module files? (requires fortran compiler)") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 97 | |
| 98 | # - These tests are little tests performed after the library is formed. |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 99 | # - The library won't be copied to the exports directory |
| 100 | # until it has passed/skipped all below tests |
| 101 | # - To skip these tests, just pass -DLIBOMP_MICRO_TESTS=OFF to cmake |
| 102 | set(LIBOMP_TEST_TOUCH true CACHE BOOL |
| 103 | "Perform a small touch test?") |
| 104 | set(LIBOMP_TEST_RELO true CACHE BOOL |
| 105 | "Perform a relocation test for dynamic libraries?") |
| 106 | set(LIBOMP_TEST_EXECSTACK true CACHE BOOL |
| 107 | "Perform a execstack test for linux dynamic libraries?") |
| 108 | set(LIBOMP_TEST_INSTR true CACHE BOOL |
| 109 | "Perform an instruction test for Intel(R) MIC Architecture libraries?") |
| 110 | set(LIBOMP_TEST_DEPS true CACHE BOOL |
| 111 | "Perform a library dependency test?") |
| 112 | set(LIBOMP_MICRO_TESTS false CACHE BOOL |
| 113 | "Perform touch, relo, execstack, instr, and deps tests?") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 114 | |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 115 | # - stats-gathering enables OpenMP stats where things like the number of |
| 116 | # parallel regions, clock ticks spent in particular openmp regions are recorded. |
| 117 | set(LIBOMP_STATS false CACHE BOOL |
| 118 | "Stats-Gathering functionality?") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 119 | |
| Jonathan Peyton | 92907c2 | 2015-05-29 16:13:56 +0000 | [diff] [blame] | 120 | # - Support for universal fat binary builds on Mac |
| 121 | # - Having this extra variable allows people to build this library as a universal library |
| 122 | # without forcing a universal build of the llvm/clang compiler. |
| 123 | set(LIBOMP_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING |
| 124 | "For Mac builds, semicolon separated list of architectures to build for universal fat binary.") |
| 125 | set(CMAKE_OSX_ARCHITECTURES ${LIBOMP_OSX_ARCHITECTURES}) |
| 126 | |
| Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 127 | # OMPT-support |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 128 | set(LIBOMP_OMPT_SUPPORT false CACHE BOOL |
| 129 | "OMPT-support?") |
| 130 | set(LIBOMP_OMPT_BLAME true CACHE BOOL |
| 131 | "OMPT-blame?") |
| 132 | set(LIBOMP_OMPT_TRACE true CACHE BOOL |
| 133 | "OMPT-trace?") |
| Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 134 | |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 135 | # User specified flags. These are appended to the predetermined flags found |
| 136 | # in CommonFlags.cmake and ${CMAKE_C_COMPILER_ID}/*Flags.cmake (e.g., GNU/CFlags.cmake) |
| 137 | set(LIBOMP_CFLAGS "" CACHE STRING |
| 138 | "Appended user specified C compiler flags.") |
| 139 | set(LIBOMP_CXXFLAGS "" CACHE STRING |
| 140 | "Appended user specified C++ compiler flags.") |
| 141 | set(LIBOMP_CPPFLAGS "" CACHE STRING |
| 142 | "Appended user specified C preprocessor flags.") |
| 143 | set(LIBOMP_ASMFLAGS "" CACHE STRING |
| 144 | "Appended user specified assembler flags.") |
| 145 | set(LIBOMP_LDFLAGS "" CACHE STRING |
| 146 | "Appended user specified linker flags.") |
| 147 | set(LIBOMP_LIBFLAGS "" CACHE STRING |
| 148 | "Appended user specified linked libs flags. (e.g., -lm)") |
| 149 | set(LIBOMP_FFLAGS "" CACHE STRING |
| 150 | "Appended user specified Fortran compiler flags. These are only used if LIBOMP_FORTRAN_MODULES==true.") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 151 | |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 152 | # Should the libomp library and generated headers be copied into the original source exports/ directory |
| Andrey Churbanov | 708fa8e | 2015-05-14 12:54:08 +0000 | [diff] [blame] | 153 | # Turning this to false aids parallel builds to not interfere with each other. |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 154 | set(LIBOMP_COPY_EXPORTS true CACHE STRING |
| 155 | "Should exports be copied into source exports/ directory?") |
| Andrey Churbanov | 708fa8e | 2015-05-14 12:54:08 +0000 | [diff] [blame] | 156 | |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 157 | # - Allow three build types: Release, Debug, RelWithDebInfo (these relate to build.pl's release, debug, and diag settings respectively) |
| 158 | # - default is Release (when CMAKE_BUILD_TYPE is not defined) |
| 159 | # - CMAKE_BUILD_TYPE affects the -O and -g flags (CMake magically includes correct version of them on per compiler basis) |
| 160 | # - typical: Release = -O3 -DNDEBUG |
| 161 | # RelWithDebInfo = -O2 -g -DNDEBUG |
| 162 | # Debug = -g |
| 163 | if(CMAKE_BUILD_TYPE) |
| 164 | # CMAKE_BUILD_TYPE was defined, check for validity |
| 165 | string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lowercase) |
| 166 | check_variable(cmake_build_type_lowercase "${build_type_possible_values}") |
| 167 | else() |
| 168 | # CMAKE_BUILD_TYPE was not defined, set default to Release |
| 169 | unset(CMAKE_BUILD_TYPE CACHE) |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 170 | set(CMAKE_BUILD_TYPE Release CACHE STRING |
| 171 | "Choose the type of build, options are: Release/Debug/RelWithDebInfo") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 172 | string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lowercase) |
| 173 | check_variable(cmake_build_type_lowercase "${build_type_possible_values}") |
| 174 | endif() |
| 175 | |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 176 | if(${LIBOMP_STANDALONE_BUILD}) |
| Jonathan Peyton | 9919dfc | 2015-06-11 17:36:16 +0000 | [diff] [blame] | 177 | # Allow user to choose a suffix for the installation directory, or if part of |
| 178 | # LLVM build then just use LLVM_LIBDIR_SUFFIX |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 179 | set(LIBOMP_LIBDIR_SUFFIX "" CACHE STRING |
| 180 | "suffix of lib installation directory e.g., 64 => lib64") |
| Jonathan Peyton | 9919dfc | 2015-06-11 17:36:16 +0000 | [diff] [blame] | 181 | # Should assertions be enabled? They are on by default, or it part of |
| 182 | # LLVM build then just use LLVM_ENABLE_ASSERTIONS |
| 183 | set(LIBOMP_ENABLE_ASSERTIONS TRUE CACHE BOOL |
| 184 | "enable assertions?") |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 185 | else() |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 186 | set(LIBOMP_LIBDIR_SUFFIX ${LLVM_LIBDIR_SUFFIX}) |
| Jonathan Peyton | 9919dfc | 2015-06-11 17:36:16 +0000 | [diff] [blame] | 187 | set(LIBOMP_ENABLE_ASSERTIONS ${LLVM_ENABLE_ASSERTIONS}) |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 188 | endif() |
| 189 | |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 190 | # Check valid values |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 191 | check_variable(LIBOMP_OS "${os_possible_values}") |
| 192 | check_variable(LIBOMP_ARCH "${arch_possible_values}") |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 193 | check_variable(LIBOMP_OMP_VERSION "${omp_version_possible_values}") |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 194 | check_variable(LIBOMP_LIB_TYPE "${lib_type_possible_values}") |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 195 | if("${LIBOMP_ARCH}" STREQUAL "mic") |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 196 | check_variable(LIBOMP_MIC_ARCH "${mic_arch_possible_values}") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 197 | endif() |
| 198 | # Get the build number from kmp_version.c |
| Andrey Churbanov | 708fa8e | 2015-05-14 12:54:08 +0000 | [diff] [blame] | 199 | get_build_number("${CMAKE_CURRENT_SOURCE_DIR}" build_number) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 200 | |
| 201 | # Getting time and date |
| 202 | # As of now, no timestamp will be created. |
| 203 | set(date "No Timestamp") |
| 204 | |
| 205 | ################################################################# |
| 206 | # Set some useful flags variables for other parts of cmake to use |
| 207 | # Operating System |
| 208 | set(LINUX FALSE) |
| 209 | set(MAC FALSE) |
| 210 | set(WINDOWS FALSE) |
| 211 | set(MIC FALSE) |
| 212 | set(FREEBSD FALSE) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 213 | if("${LIBOMP_OS}" STREQUAL "lin") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 214 | set(LINUX TRUE) |
| 215 | set(real_os lin) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 216 | elseif("${LIBOMP_OS}" STREQUAL "mac") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 217 | set(MAC TRUE) |
| 218 | set(real_os mac) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 219 | elseif("${LIBOMP_OS}" STREQUAL "win") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 220 | set(WINDOWS TRUE) |
| 221 | set(real_os win) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 222 | endif() |
| 223 | if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") |
| 224 | set(FREEBSD TRUE) |
| 225 | endif() |
| 226 | |
| 227 | # Architecture |
| 228 | set(IA32 FALSE) |
| 229 | set(INTEL64 FALSE) |
| 230 | set(ARM FALSE) |
| Andrey Churbanov | cbda868 | 2015-01-13 14:43:35 +0000 | [diff] [blame] | 231 | set(AARCH64 FALSE) |
| Andrey Churbanov | d1c5504 | 2015-01-19 18:29:35 +0000 | [diff] [blame] | 232 | set(PPC64BE FALSE) |
| 233 | set(PPC64LE FALSE) |
| Jim Cownie | 3051f97 | 2014-08-07 10:12:54 +0000 | [diff] [blame] | 234 | set(PPC64 FALSE) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 235 | if("${LIBOMP_ARCH}" STREQUAL "32") # IA-32 architecture |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 236 | set(IA32 TRUE) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 237 | elseif("${LIBOMP_ARCH}" STREQUAL "32e") # Intel(R) 64 architecture |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 238 | set(INTEL64 TRUE) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 239 | elseif("${LIBOMP_ARCH}" STREQUAL "arm") # ARM architecture |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 240 | set(ARM TRUE) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 241 | elseif("${LIBOMP_ARCH}" STREQUAL "ppc64") # PPC64BE architecture |
| Andrey Churbanov | d1c5504 | 2015-01-19 18:29:35 +0000 | [diff] [blame] | 242 | set(PPC64BE TRUE) |
| 243 | set(PPC64 TRUE) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 244 | elseif("${LIBOMP_ARCH}" STREQUAL "ppc64le") # PPC64LE architecture |
| Andrey Churbanov | d1c5504 | 2015-01-19 18:29:35 +0000 | [diff] [blame] | 245 | set(PPC64LE TRUE) |
| 246 | set(PPC64 TRUE) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 247 | elseif("${LIBOMP_ARCH}" STREQUAL "aarch64") # AARCH64 architecture |
| Andrey Churbanov | cbda868 | 2015-01-13 14:43:35 +0000 | [diff] [blame] | 248 | set(AARCH64 TRUE) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 249 | elseif("${LIBOMP_ARCH}" STREQUAL "mic") # Intel(R) Many Integrated Core Architecture |
| Andrey Churbanov | 19be978 | 2015-01-16 13:05:23 +0000 | [diff] [blame] | 250 | set(MIC TRUE) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 251 | endif() |
| 252 | |
| 253 | # Set some flags based on build_type |
| 254 | # cmake_build_type_lowercase is based off of CMAKE_BUILD_TYPE, just put in lowercase. |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 255 | set(RELEASE_BUILD FALSE) |
| 256 | set(DEBUG_BUILD FALSE) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 257 | set(RELWITHDEBINFO_BUILD FALSE) |
| 258 | if("${cmake_build_type_lowercase}" STREQUAL "release") |
| 259 | set(RELEASE_BUILD TRUE) |
| 260 | elseif("${cmake_build_type_lowercase}" STREQUAL "debug") |
| 261 | set(DEBUG_BUILD TRUE) |
| 262 | elseif("${cmake_build_type_lowercase}" STREQUAL "relwithdebinfo") |
| 263 | set(RELWITHDEBINFO_BUILD TRUE) |
| 264 | endif() |
| 265 | |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 266 | # Include itt notify interface? Right now, always. |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 267 | set(LIBOMP_USE_ITT_NOTIFY TRUE) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 268 | |
| 269 | # normal, profile, stubs library. |
| 270 | set(NORMAL_LIBRARY FALSE) |
| 271 | set(STUBS_LIBRARY FALSE) |
| 272 | set(PROFILE_LIBRARY FALSE) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 273 | if("${LIBOMP_LIB_TYPE}" STREQUAL "normal") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 274 | set(NORMAL_LIBRARY TRUE) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 275 | elseif("${LIBOMP_LIB_TYPE}" STREQUAL "profile") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 276 | set(PROFILE_LIBRARY TRUE) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 277 | elseif("${LIBOMP_LIB_TYPE}" STREQUAL "stubs") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 278 | set(STUBS_LIBRARY TRUE) |
| 279 | endif() |
| 280 | |
| 281 | ############################################### |
| 282 | # Features for compilation and build in general |
| 283 | |
| 284 | # - Does the compiler support a 128-bit floating point data type? Default is false |
| 285 | # - If a compiler does, then change it in the CMakeCache.txt file (or using the cmake GUI) |
| 286 | # or send to cmake -DCOMPILER_SUPPORTS_QUAD_PRECISION=true |
| 287 | # - If COMPILER_SUPPORTS_QUAD_PRECISION is true, then a corresponding COMPILER_QUAD_TYPE must be given |
| 288 | # This is the compiler's quad-precision data type. |
| 289 | # ** TODO: This isn't complete yet. Finish it. Requires changing macros in kmp_os.h ** |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 290 | set(LIBOMP_COMPILER_SUPPORTS_QUAD_PRECISION false CACHE BOOL |
| 291 | "*INCOMPLETE* Does the compiler support a 128-bit floating point type?") |
| 292 | set(LIBOMP_COMPILER_QUAD_TYPE "" CACHE STRING |
| 293 | "*INCOMPLETE* The quad precision data type (e.g., for gcc, __float128)") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 294 | |
| 295 | # - Should the orignal build rules for builds be used? (cmake/OriginalBuildRules.cmake). This setting is off by default. |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 296 | # - This always compiles with -g. And if it is a release build, the debug info is stripped out via objcopy and put into libomp.dbg. |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 297 | set(LIBOMP_USE_BUILDPL_RULES false CACHE BOOL |
| 298 | "Should the build follow build.pl rules/recipes?") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 299 | |
| 300 | # - Should the build use the predefined linker flags (OS-dependent) in CommonFlags.cmake? |
| 301 | # - these predefined linker flags should work for Windows, Mac, and True Linux for the most popular compilers/linkers |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 302 | set(LIBOMP_USE_PREDEFINED_LINKER_FLAGS true CACHE BOOL |
| 303 | "Should the build use the predefined linker flags in CommonFlags.cmake?") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 304 | |
| Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 305 | # - On multinode systems, larger alignment is desired to avoid false sharing |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 306 | set(LIBOMP_USE_INTERNODE_ALIGNMENT false CACHE BOOL |
| 307 | "Should larger alignment (4096 bytes) be used for some locks and data structures?") |
| Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 308 | |
| 309 | # - libgomp drop-in compatibility |
| 310 | if(${LINUX} AND NOT ${PPC64}) |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 311 | set(LIBOMP_USE_VERSION_SYMBOLS true CACHE BOOL |
| 312 | "Should version symbols be used? These provide binary compatibility with libgomp.") |
| Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 313 | else() |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 314 | set(LIBOMP_USE_VERSION_SYMBOLS false) |
| Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 315 | endif() |
| 316 | |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 317 | # - TSX based locks have __asm code which can be troublesome for some compilers. This feature is also x86 specific. |
| Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 318 | if(${IA32} OR ${INTEL64}) |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 319 | set(LIBOMP_USE_ADAPTIVE_LOCKS true CACHE BOOL |
| 320 | "Should TSX-based lock be compiled (adaptive lock in kmp_lock.cpp). These are x86 specific.") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 321 | else() |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 322 | set(LIBOMP_USE_ADAPTIVE_LOCKS false) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 323 | endif() |
| 324 | |
| 325 | ################################## |
| 326 | # Error checking the configuration |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 327 | if(${LIBOMP_STATS} AND (${WINDOWS} OR ${MAC})) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 328 | error_say("Stats-gathering functionality is only supported on x86-Linux and Intel(R) MIC Architecture") |
| 329 | endif() |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 330 | if(${LIBOMP_STATS} AND NOT (${IA32} OR ${INTEL64} OR ${MIC})) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 331 | error_say("Stats-gathering functionality is only supported on x86-Linux and Intel(R) MIC Architecture") |
| 332 | endif() |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 333 | if(${LIBOMP_USE_ADAPTIVE_LOCKS} AND NOT(${IA32} OR ${INTEL64})) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 334 | error_say("Adaptive locks (TSX) functionality is only supported on x86 Architecture") |
| 335 | endif() |
| Jonathan Peyton | b689ded | 2015-06-17 15:43:34 +0000 | [diff] [blame^] | 336 | if(${LIBOMP_OMPT_SUPPORT} AND ${WINDOWS}) |
| 337 | error_say("OpenMP Tools Interface is not supported on Windows") |
| 338 | endif() |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 339 | |
| 340 | ############################################### |
| 341 | # - Create the suffix for the export directory |
| 342 | # - Only add to suffix when not a default value |
| 343 | # - Example suffix: .deb.30.s1 |
| 344 | # final export directory: exports/lin_32e.deb.30.s1/lib |
| 345 | # - These suffixes imply the build is a Debug, OpenMP 3.0, Stats-Gathering version of the library |
| 346 | if(NOT "${cmake_build_type_lowercase}" STREQUAL "release") |
| 347 | string(SUBSTRING "${cmake_build_type_lowercase}" 0 3 build_type_suffix) |
| 348 | set(suffix "${suffix}.${build_type_suffix}") |
| 349 | endif() |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 350 | if(NOT "${LIBOMP_OMP_VERSION}" STREQUAL "41") |
| 351 | set(suffix "${suffix}.${LIBOMP_OMP_VERSION}") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 352 | endif() |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 353 | if(${LIBOMP_STATS}) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 354 | set(suffix "${suffix}.s1") |
| 355 | endif() |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 356 | if(${LIBOMP_OMPT_SUPPORT}) |
| Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 357 | set(suffix "${suffix}.ompt") |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 358 | if(NOT ${LIBOMP_OMPT_BLAME}) |
| Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 359 | set(suffix "${suffix}.no-ompt-blame") |
| 360 | endif() |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 361 | if(NOT ${LIBOMP_OMPT_TRACE}) |
| Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 362 | set(suffix "${suffix}.no-ompt-trace") |
| 363 | endif() |
| 364 | endif() |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 365 | |
| 366 | #################################### |
| 367 | # Setting file extensions / suffixes |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 368 | set(obj ${CMAKE_C_OUTPUT_EXTENSION}) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 369 | set(lib ${CMAKE_STATIC_LIBRARY_SUFFIX}) |
| 370 | set(dll ${CMAKE_SHARED_LIBRARY_SUFFIX}) |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 371 | set(exe ${CMAKE_EXECUTABLE_SUFFIX}) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 372 | |
| 373 | ###################### |
| 374 | # Find perl executable |
| 375 | # Perl is used to create omp.h (and other headers) along with kmp_i18n_id.inc and kmp_i18n_default.inc (see below in Rules section) |
| 376 | if(NOT "${PERL_FOUND}") # variable is defined in FindPerl Standard CMake Module |
| 377 | error_say("Error: Could not find valid perl") |
| 378 | endif() |
| 379 | |
| 380 | ######################### |
| 381 | # Setting directory names |
| Andrey Churbanov | 19be978 | 2015-01-16 13:05:23 +0000 | [diff] [blame] | 382 | if(${MIC}) |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 383 | set(platform "${real_os}_${LIBOMP_MIC_ARCH}") # e.g., lin_knf, lin_knc |
| Andrey Churbanov | 19be978 | 2015-01-16 13:05:23 +0000 | [diff] [blame] | 384 | else() |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 385 | set(platform "${real_os}_${LIBOMP_ARCH}") # e.g., lin_32e, mac_32 |
| Andrey Churbanov | 19be978 | 2015-01-16 13:05:23 +0000 | [diff] [blame] | 386 | endif() |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 387 | # build directory (Where CMakeCache.txt is created, build files generated) |
| 388 | set(build_dir "${CMAKE_CURRENT_BINARY_DIR}") |
| 389 | set(src_dir "${CMAKE_CURRENT_SOURCE_DIR}/src") |
| 390 | set(tools_dir "${CMAKE_CURRENT_SOURCE_DIR}/tools") |
| 391 | set(export_dir "${CMAKE_CURRENT_SOURCE_DIR}/exports") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 392 | set(export_ptf_dir "${export_dir}/${platform}${suffix}") |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 393 | set(export_cmn_dir "${export_dir}/common${suffix}/include") |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 394 | set(export_inc_dir "${export_ptf_dir}/include") |
| 395 | set(export_mod_dir "${export_ptf_dir}/include_compat") |
| Andrey Churbanov | 19be978 | 2015-01-16 13:05:23 +0000 | [diff] [blame] | 396 | _export_lib_dir(${platform} export_lib_dir) # set exports directory (relative to build_dir) e.g., ../exports/lin_32e/lib/ |
| 397 | # or ../exports/mac_32e/lib.thin/ for mac |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 398 | if(${MAC}) |
| 399 | # macs use lib.thin/ subdirectory for non-fat libraries that only contain one architecture |
| 400 | # macs use lib/ subdirectory for fat libraries that contain both IA-32 architecture and Intel(R) 64 architecture code. |
| 401 | _export_lib_fat_dir(${platform} export_lib_fat_dir) |
| 402 | endif() |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 403 | set(inc_dir "${src_dir}/include/${LIBOMP_OMP_VERSION}") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 404 | |
| 405 | ############################ |
| 406 | # Setting final library name |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 407 | set(lib_item "libomp") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 408 | if(${PROFILE_LIBRARY}) |
| 409 | set(lib_item "${lib_item}prof") |
| 410 | endif() |
| 411 | if(${STUBS_LIBRARY}) |
| 412 | set(lib_item "${lib_item}stubs") |
| 413 | endif() |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 414 | if(${WINDOWS}) |
| 415 | set(lib_item "${lib_item}md") |
| 416 | endif() |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 417 | set(LIBOMP_LIB_NAME "${lib_item}" CACHE STRING "OMP library name") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 418 | set(lib_ext "${dll}") |
| 419 | # ${lib_file} is real library name: |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 420 | # libomp.so for Linux |
| 421 | # libomp.dylib for Mac |
| 422 | # libompmd.dll for Windows |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 423 | set(lib_file "${LIBOMP_LIB_NAME}${lib_ext}") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 424 | |
| 425 | ######################################## |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 426 | # Setting export file names |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 427 | if(${WINDOWS}) |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 428 | set(imp_file "${lib_item}${lib}") # this is exported (libomp.lib) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 429 | set(def_file "${lib_item}.def") # this is not exported |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 430 | if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR |
| 431 | "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo" OR |
| 432 | ${LIBOMP_USE_BUILDPL_RULES}) |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 433 | set(pdb_file "${lib_file}.pdb") # this is exported if it exists (libompmd.dll.pdb) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 434 | endif() |
| 435 | endif() |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 436 | set(export_lib_files "${lib_file}" "${imp_file}" "${pdb_file}") |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 437 | set(export_mod_files "omp_lib.mod" "omp_lib_kinds.mod") |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 438 | set(export_cmn_files "omp.h" "omp_lib.h" "omp_lib.f" "omp_lib.f90") |
| Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 439 | |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 440 | if(${LIBOMP_OMPT_SUPPORT}) |
| Jonathan Peyton | 227e1ae | 2015-06-01 03:05:13 +0000 | [diff] [blame] | 441 | set(export_cmn_files ${export_cmn_files} "ompt.h") |
| Andrey Churbanov | e5f4492 | 2015-04-29 16:22:07 +0000 | [diff] [blame] | 442 | endif() |
| 443 | |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 444 | if("${export_lib_fat_dir}") |
| 445 | set(export_lib_fat_files "${lib_file}" "${imp_file}") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 446 | endif() |
| 447 | |
| 448 | ######################### |
| 449 | # Getting legal type/arch |
| 450 | set_legal_type(legal_type) |
| 451 | set_legal_arch(legal_arch) |
| 452 | |
| 453 | ################################################# |
| 454 | # Preprocessor Definitions (cmake/Definitions.cmake) |
| 455 | # Preprocessor Includes |
| 456 | # Compiler (C/C++) Flags (cmake/CommonFlags.cmake) |
| 457 | # Assembler Flags (cmake/CommonFlags.cmake) |
| 458 | # Fortran Flags (cmake/CommonFlags.cmake) |
| 459 | # Linker Flags (cmake/CommonFlags.cmake) |
| 460 | # Archiver Flags (cmake/CommonFlags.cmake) |
| 461 | # Helper Perl Script Flags (cmake/PerlFlags.cmake) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 462 | # * Inside the cmake/CommonFlags.cmake file, the LIBOMP_*FLAGS are added. |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 463 | # * Cannot use CMAKE_*_FLAGS directly because -x c++ is put in the linker command and mangles the linking phase. |
| 464 | |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 465 | # Grab compiler-dependent flags |
| 466 | # Cmake will look for cmake/${CMAKE_C_COMPILER_ID}/CFlags.cmake to append additional c, cxx, and linker flags. |
| 467 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_C_COMPILER_ID} ${CMAKE_MODULE_PATH}) |
| 468 | find_file(compiler_specific_include_file_found CFlags.cmake ${CMAKE_MODULE_PATH}) |
| 469 | if(compiler_specific_include_file_found) |
| 470 | include(CFlags) # COMPILER_SUPPORTS_QUAD_PRECISION changed in here |
| 471 | append_compiler_specific_c_and_cxx_flags(C_FLAGS CXX_FLAGS) |
| 472 | append_compiler_specific_linker_flags(LD_FLAGS LD_LIB_FLAGS) |
| 473 | else() |
| 474 | warning_say("Could not find cmake/${CMAKE_C_COMPILER_ID}/CFlags.cmake: will only use default flags") |
| 475 | endif() |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 476 | # Grab assembler-dependent flags |
| 477 | # CMake will look for cmake/${CMAKE_ASM_COMPILER_ID}/AsmFlags.cmake to append additional assembler flags. |
| 478 | if(${WINDOWS}) |
| 479 | # Windows based systems use CMAKE_ASM_MASM_COMPILER |
| 480 | # The windows assembly files are in MASM format, and they require a tool that can handle MASM syntax (ml.exe or ml64.exe typically) |
| 481 | enable_language(ASM_MASM) |
| 482 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_ASM_MASM_COMPILER_ID} ${CMAKE_MODULE_PATH}) |
| 483 | find_file(assembler_specific_include_file_found AsmFlags.cmake ${CMAKE_MODULE_PATH}) |
| 484 | if(assembler_specific_include_file_found) |
| 485 | include(AsmFlags) |
| 486 | append_assembler_specific_asm_flags(ASM_FLAGS) |
| 487 | else() |
| 488 | warning_say("Could not find cmake/${CMAKE_ASM_MASM_COMPILER_ID}/AsmFlags.cmake: will only use default flags") |
| 489 | endif() |
| 490 | else() |
| 491 | # Unix (including Mac) based systems use CMAKE_ASM_COMPILER |
| 492 | # Unix assembly files can be handled by compiler usually. |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 493 | find_file(assembler_specific_include_file_found AsmFlags.cmake ${CMAKE_MODULE_PATH}) |
| 494 | if(assembler_specific_include_file_found) |
| 495 | include(AsmFlags) |
| 496 | append_assembler_specific_asm_flags(ASM_FLAGS) |
| 497 | else() |
| 498 | warning_say("Could not find cmake/${CMAKE_ASM_COMPILER_ID}/AsmFlags.cmake: will only use default flags") |
| 499 | endif() |
| 500 | endif() |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 501 | |
| 502 | # Grab all the compiler-independent flags |
| 503 | append_c_and_cxx_flags_common(C_FLAGS CXX_FLAGS) |
| 504 | append_asm_flags_common(ASM_FLAGS) |
| 505 | append_fort_flags_common(F_FLAGS) |
| 506 | append_linker_flags_common(LD_FLAGS LD_LIB_FLAGS) |
| 507 | append_archiver_flags_common(AR_FLAGS) |
| 508 | append_cpp_flags(DEFINITIONS_FLAGS) |
| 509 | |
| 510 | # Setup the flags correctly for cmake (covert to string) |
| 511 | # Pretty them up (STRIP any beginning and trailing whitespace) |
| 512 | list_to_string("${DEFINITIONS_FLAGS}" DEFINITIONS_FLAGS) |
| Jonathan Peyton | fbb1514 | 2015-05-26 17:27:01 +0000 | [diff] [blame] | 513 | list_to_string("${C_FLAGS}" C_FLAGS) |
| 514 | list_to_string("${CXX_FLAGS}" CXX_FLAGS) |
| 515 | list_to_string("${ASM_FLAGS}" ASM_FLAGS) |
| 516 | list_to_string("${LD_FLAGS}" LD_FLAGS) |
| 517 | list_to_string("${LD_LIB_FLAGS}" LD_LIB_FLAGS) |
| 518 | # Windows specific for creating import library |
| 519 | list_to_string("${AR_FLAGS}" AR_FLAGS) |
| 520 | string(STRIP "${DEFINITIONS_FLAGS}" DEFINITIONS_FLAGS) |
| 521 | string(STRIP "${C_FLAGS}" C_FLAGS) |
| 522 | string(STRIP "${CXX_FLAGS}" CXX_FLAGS) |
| 523 | string(STRIP "${ASM_FLAGS}" ASM_FLAGS) |
| 524 | string(STRIP "${LD_FLAGS}" LD_FLAGS) |
| 525 | string(STRIP "${LD_LIB_FLAGS}" LD_LIB_FLAGS) |
| 526 | # Windows specific for creating import library |
| 527 | string(STRIP "${AR_FLAGS}" AR_FLAGS) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 528 | |
| 529 | # Grab the Perl flags |
| 530 | set_ev_flags(ev_flags) # expand-vars.pl flags |
| 531 | set_gd_flags(gd_flags) # generate-def.pl flags (Windows only) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 532 | set(oa_opts "--os=${real_os}" "--arch=${LIBOMP_ARCH}") # sent to the perl scripts |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 533 | |
| 534 | ######################################################### |
| 535 | # Getting correct source files (cmake/SourceFiles.cmake) |
| 536 | set_c_files(lib_c_items) |
| 537 | set_cpp_files(lib_cxx_items) |
| 538 | set_asm_files(lib_asm_items) |
| 539 | set_imp_c_files(imp_c_items) # Windows-specific |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 540 | set(lib_src_files "${lib_c_items}" "${lib_cxx_items}" "${lib_asm_items}") |
| 541 | set(imp_src_files "${imp_c_items}") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 542 | |
| 543 | ##################################################################### |
| 544 | # Debug print outs. Will print "variable = ${variable}" if GLOBAL_DEBUG == 1 |
| 545 | if(GLOBAL_DEBUG) |
| 546 | include(CMakePrintSystemInformation) |
| 547 | endif() |
| 548 | debug_say_var(CMAKE_ASM_COMPILE_OBJECT) |
| 549 | debug_say_var(CMAKE_RC_COMPILER) |
| 550 | debug_say_var(CMAKE_C_COMPILER_ID) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 551 | debug_say_var(date) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 552 | debug_say_var(LIBOMP_STATS) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 553 | debug_say_var(lib_file) |
| 554 | debug_say_var(export_lib_files) |
| 555 | debug_say_var(DEFINITIONS_FLAGS) |
| 556 | debug_say_var(C_FLAGS) |
| 557 | debug_say_var(CXX_FLAGS) |
| 558 | debug_say_var(ASM_FLAGS) |
| 559 | debug_say_var(F_FLAGS) |
| 560 | debug_say_var(LD_FLAGS) |
| 561 | debug_say_var(LD_LIB_FLAGS) |
| 562 | debug_say_var(AR_FLAGS) |
| 563 | debug_say_var(ev_flags) |
| 564 | debug_say_var(gd_flags) |
| 565 | debug_say_var(oa_opts) |
| 566 | debug_say_var(lib_c_items) |
| 567 | debug_say_var(lib_cxx_items) |
| 568 | debug_say_var(lib_asm_items) |
| 569 | debug_say_var(imp_c_items) |
| 570 | debug_say_var(lib_src_files) |
| 571 | debug_say_var(imp_src_files) |
| 572 | |
| 573 | #################################################################### |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 574 | # Print configuration after all variables are set. |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 575 | if(${LIBOMP_STANDALONE_BUILD}) |
| 576 | say("LIBOMP: Operating System -- ${LIBOMP_OS}") |
| 577 | say("LIBOMP: Target Architecture -- ${LIBOMP_ARCH}") |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 578 | if(${MIC}) |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 579 | say("LIBOMP: Intel(R) MIC Architecture -- ${LIBOMP_MIC_ARCH}") |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 580 | endif() |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 581 | say("LIBOMP: Build Type -- ${CMAKE_BUILD_TYPE}") |
| 582 | say("LIBOMP: OpenMP Version -- ${LIBOMP_OMP_VERSION}") |
| 583 | say("LIBOMP: Lib Type -- ${LIBOMP_LIB_TYPE}") |
| 584 | say("LIBOMP: Fortran Modules -- ${LIBOMP_FORTRAN_MODULES}") |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 585 | # will say development if all zeros |
| 586 | if("${build_number}" STREQUAL "00000000") |
| 587 | set(build "development") |
| 588 | else() |
| 589 | set(build "${build_number}") |
| 590 | endif() |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 591 | say("LIBOMP: Build -- ${build}") |
| 592 | say("LIBOMP: Stats-Gathering -- ${LIBOMP_STATS}") |
| 593 | say("LIBOMP: OMPT-support -- ${LIBOMP_OMPT_SUPPORT}") |
| 594 | if(${LIBOMP_OMPT_SUPPORT}) |
| 595 | say("LIBOMP: OMPT-blame -- ${LIBOMP_OMPT_BLAME}") |
| 596 | say("LIBOMP: OMPT-trace -- ${LIBOMP_OMPT_TRACE}") |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 597 | endif() |
| Jonathan Peyton | 7979a07 | 2015-05-20 22:33:24 +0000 | [diff] [blame] | 598 | say("LIBOMP: Use build.pl rules -- ${LIBOMP_USE_BUILDPL_RULES}") |
| 599 | say("LIBOMP: Adaptive locks -- ${LIBOMP_USE_ADAPTIVE_LOCKS}") |
| 600 | say("LIBOMP: Use predefined linker flags -- ${LIBOMP_USE_PREDEFINED_LINKER_FLAGS}") |
| 601 | say("LIBOMP: Compiler supports quad precision -- ${LIBOMP_COMPILER_SUPPORTS_QUAD_PRECISION}") |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 602 | endif() |
| Andrey Churbanov | 648467e | 2015-05-05 20:02:52 +0000 | [diff] [blame] | 603 | |
| Jonathan Peyton | 5215890 | 2015-06-11 17:23:57 +0000 | [diff] [blame] | 604 | add_subdirectory(src) |
| Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 605 | |