|
1 |
| -# Copyright (C) 2022-2023 Intel Corporation |
| 1 | +# Copyright (C) 2022-2025 Intel Corporation |
2 | 2 | # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
|
3 | 3 | # See LICENSE.TXT
|
4 | 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
5 | 5 |
|
6 | 6 | cmake_minimum_required(VERSION 3.20.0 FATAL_ERROR)
|
7 | 7 | project(unified-runtime VERSION 0.12.0)
|
| 8 | +cmake_policy(SET CMP0083 NEW) # PROPERTY POSITION_INDEPENDENT_CODE |
8 | 9 |
|
9 | 10 | # Check if unified runtime is built as a standalone project.
|
10 | 11 | if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR UR_STANDALONE_BUILD)
|
11 | 12 | set(UR_STANDALONE_BUILD TRUE)
|
12 | 13 | endif()
|
13 | 14 |
|
| 15 | +# Ubuntu's gcc uses --enable-default-pie. For the sake of a consistent build |
| 16 | +# across different gcc versions, set it globally for all targets |
| 17 | +# https://wiki.ubuntu.com/ToolChain/CompilerFlags#A-fPIE |
| 18 | +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
| 19 | + set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 20 | +endif() |
| 21 | + |
14 | 22 | include(GNUInstallDirs)
|
15 | 23 | include(CheckCXXSourceCompiles)
|
16 | 24 | include(CMakePackageConfigHelpers)
|
@@ -151,9 +159,6 @@ if(UR_ENABLE_TRACING)
|
151 | 159 |
|
152 | 160 | FetchContent_MakeAvailable(xpti)
|
153 | 161 |
|
154 |
| - # set -fPIC for xpti since we are linking it with a shared library |
155 |
| - set_target_properties(xpti PROPERTIES POSITION_INDEPENDENT_CODE ON) |
156 |
| - |
157 | 162 | # fetch the xptifw dispatcher, mostly used for testing
|
158 | 163 | # these variables need to be set for xptifw to compile
|
159 | 164 | set(XPTI_SOURCE_DIR ${xpti_SOURCE_DIR})
|
|
0 commit comments