Skip to content

Commit ed51cb2

Browse files
committed
build: update minimum required CMake to 3.13
1 parent 94c8d05 commit ed51cb2

File tree

15 files changed

+74
-170
lines changed

15 files changed

+74
-170
lines changed

CMakeLists.txt

+37-35
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,41 @@
1414
# limitations under the License.
1515
#===============================================================================
1616

17-
cmake_minimum_required(VERSION 2.8.12)
17+
cmake_minimum_required(VERSION 3.13)
1818

19+
# Use INTERFACE_LINK_LIBRARIES as the source of the link interface
1920
if(POLICY CMP0022)
2021
cmake_policy(SET CMP0022 NEW)
2122
endif()
2223

24+
# Do not mix INTERFACE_LINK_LIBRARIES signatures
25+
if(POLICY CMP0023)
26+
cmake_policy(SET CMP0023 NEW)
27+
endif()
28+
29+
# Compiler id for Apple's Clang is now AppleClang
30+
if(POLICY CMP0025)
31+
cmake_policy(SET CMP0025 NEW)
32+
endif()
33+
2334
# Foo::Bar always refers to an IMPORTED target
2435
if(POLICY CMP0028)
2536
cmake_policy(SET CMP0028 NEW)
2637
endif()
2738

28-
if(POLICY CMP0054)
29-
cmake_policy(SET CMP0054 NEW)
30-
endif()
31-
3239
# Enable RPATH on MacOS/OSX
3340
if(POLICY CMP0042)
3441
cmake_policy(SET CMP0042 NEW)
3542
endif()
3643

37-
# Do not export symbols from executables
38-
if(POLICY CMP0065)
39-
cmake_policy(SET CMP0065 NEW)
44+
# The project() command manages VERSION variables
45+
if(POLICY CMP0042)
46+
cmake_policy(SET CMP0048 NEW)
47+
endif()
48+
49+
# Interpret unquoted if() arguments as variables or keywords
50+
if(POLICY CMP0054)
51+
cmake_policy(SET CMP0054 NEW)
4052
endif()
4153

4254
# Pass linker flags to try_compile
@@ -49,6 +61,11 @@ if(POLICY CMP0060)
4961
cmake_policy(SET CMP0060 NEW)
5062
endif()
5163

64+
# Do not export symbols from executables
65+
if(POLICY CMP0065)
66+
cmake_policy(SET CMP0065 NEW)
67+
endif()
68+
5269
# Pass compiler flags to try_compile
5370
if(POLICY CMP0066)
5471
cmake_policy(SET CMP0066 NEW)
@@ -82,12 +99,7 @@ set(PROJECT_NAME "oneDNN")
8299
set(PROJECT_FULL_NAME "oneAPI Deep Neural Network Library (oneDNN)")
83100
set(PROJECT_VERSION "3.7.0")
84101

85-
if (CMAKE_VERSION VERSION_LESS 3.0)
86-
project(${PROJECT_NAME} C CXX)
87-
else()
88-
cmake_policy(SET CMP0048 NEW)
89-
project(${PROJECT_NAME} VERSION "${PROJECT_VERSION}" LANGUAGES C CXX)
90-
endif()
102+
project(${PROJECT_NAME} VERSION "${PROJECT_VERSION}" LANGUAGES C CXX)
91103

92104
if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
93105
message(FATAL_ERROR "oneDNN supports 64 bit platforms only")
@@ -141,28 +153,18 @@ include("cmake/host_compiler.cmake")
141153
include("cmake/configuring_primitive_list.cmake")
142154

143155
if(UNIX OR MINGW)
144-
if(CMAKE_VERSION VERSION_LESS "3.1.0")
145-
# No CMAKE_<lang>_STANDARD, so add directly to CMAKE_<lang>_FLAGS
146-
# (prepended so the user can override)
147-
set(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
148-
# Let SYCL to choose the C++ standard it needs.
149-
if(NOT DNNL_WITH_SYCL)
150-
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
151-
endif()
152-
else()
153-
# CMAKE_<lang>_STANDARD support, so set it to our defaults, unless
154-
# overridden by the user
155-
if(NOT DEFINED CMAKE_C_STANDARD)
156-
set(CMAKE_C_STANDARD 99)
157-
endif()
158-
if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT DNNL_WITH_SYCL)
159-
set(CMAKE_CXX_STANDARD 11)
160-
endif()
161-
162-
# Disable -std=gnuXX and -std=gnu++XX
163-
set(CMAKE_C_EXTENSIONS OFF)
164-
set(CMAKE_CXX_EXTENSIONS OFF)
156+
# CMAKE_<lang>_STANDARD support, so set it to our defaults, unless
157+
# overridden by the user
158+
if(NOT DEFINED CMAKE_C_STANDARD)
159+
set(CMAKE_C_STANDARD 99)
160+
endif()
161+
if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT DNNL_WITH_SYCL)
162+
set(CMAKE_CXX_STANDARD 11)
165163
endif()
164+
165+
# Disable -std=gnuXX and -std=gnu++XX
166+
set(CMAKE_C_EXTENSIONS OFF)
167+
set(CMAKE_CXX_EXTENSIONS OFF)
166168
endif()
167169

168170
# Handle cases when OpenMP runtime is requested but not found: override CPU

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ The library is optimized for the following GPUs:
127127
oneDNN supports systems meeting the following requirements:
128128
* Operating system with Intel 64 / Arm 64 / Power / IBMz architecture support
129129
* C++ compiler with C++11 standard support
130-
* [CMake] 2.8.12 or later
130+
* [CMake] 3.13 or later
131131

132132
The following tools are required to build oneDNN documentation:
133133
* [Doxygen] 1.8.5 or later

cmake/OpenMP.cmake

+1-17
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,22 @@ endif()
2323
set(OpenMP_cmake_included true)
2424
include("cmake/Threading.cmake")
2525

26-
if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
26+
if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
2727
# OSX Clang doesn't have OpenMP by default.
2828
# But we still want to build the library.
2929
set(_omp_severity "WARNING")
3030
else()
3131
set(_omp_severity "FATAL_ERROR")
3232
endif()
3333

34-
macro(set_openmp_values_for_old_cmake)
35-
#newer version for findOpenMP (>= v. 3.9)
36-
if(CMAKE_VERSION VERSION_LESS "3.9" AND OPENMP_FOUND)
37-
if(${CMAKE_MAJOR_VERSION} VERSION_LESS "3" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
38-
# Override FindOpenMP flags for Intel Compiler (otherwise deprecated)
39-
set(OpenMP_CXX_FLAGS "-fopenmp")
40-
set(OpenMP_C_FLAGS "-fopenmp")
41-
endif()
42-
set(OpenMP_C_FOUND true)
43-
set(OpenMP_CXX_FOUND true)
44-
endif()
45-
endmacro()
46-
4734
if(DPCPP_HOST_COMPILER_KIND STREQUAL "DEFAULT")
4835
# XXX: workaround: when -fsycl is specified the compiler doesn't define
4936
# _OPENMP macro causing `find_package(OpenMP)` to fail.
5037
# Use -fno-sycl option to disable SYCL. The rationale: dpcpp driver sets
5138
# the -fsycl option by default so it has to be explicitly disabled.
5239
set(_omp_original_cmake_cxx_flags "${CMAKE_CXX_FLAGS}")
5340
string(REGEX REPLACE "-fsycl" "-fno-sycl" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
54-
5541
find_package(OpenMP)
56-
set_openmp_values_for_old_cmake()
57-
5842
set(CMAKE_CXX_FLAGS "${_omp_original_cmake_cxx_flags}")
5943
endif()
6044

cmake/SDL.cmake

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ if(UNIX)
6868
sdl_gnu_common_ccxx_flags(ONEDNN_SDL_COMPILER_FLAGS CMAKE_CXX_COMPILER_VERSION)
6969
sdl_gnu_src_ccxx_flags(CMAKE_SRC_CCXX_FLAGS)
7070
sdl_gnu_example_ccxx_flags(CMAKE_EXAMPLE_CCXX_FLAGS)
71-
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
71+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
7272
get_filename_component(CXX_CMD_NAME ${CMAKE_CXX_COMPILER} NAME)
7373
# Fujitsu CXX compiler does not support "-fstack-protector-all".
7474
if(NOT CXX_CMD_NAME STREQUAL "FCC")
@@ -85,13 +85,13 @@ if(UNIX)
8585
append(ONEDNN_SDL_LINKER_FLAGS "-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
8686
endif()
8787
elseif(WIN32)
88-
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
88+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
8989
append(ONEDNN_SDL_COMPILER_FLAGS "/GS /Gy /guard:cf /DYNAMICBASE /sdl")
9090
append(ONEDNN_SDL_LINKER_FLAGS "/NXCOMPAT /LTCG")
9191
elseif(CMAKE_BASE_NAME STREQUAL "icx")
9292
append(ONEDNN_SDL_COMPILER_FLAGS "/GS /Gy /guard:cf /Wformat /Wformat-security")
9393
append(ONEDNN_SDL_LINKER_FLAGS "/link /NXCOMPAT")
94-
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
94+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
9595
append(ONEDNN_SDL_COMPILER_FLAGS "-Wformat -Wformat-security")
9696
if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
9797
append(ONEDNN_SDL_COMPILER_FLAGS "-D_FORTIFY_SOURCE=2")
@@ -113,7 +113,7 @@ elseif(WIN32)
113113
if(CMAKE_BASE_NAME STREQUAL "icx")
114114
# add ICX-style linker flags
115115
append(ONEDNN_SDL_LINKER_FLAGS "/link /DEPENDENTLOADFLAG:0x2000")
116-
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
116+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
117117
# add Clang-style linker flags
118118
append(ONEDNN_SDL_LINKER_FLAGS "-Xlinker /DEPENDENTLOADFLAG:0x2000")
119119
else()

cmake/SYCL.cmake

+1-8
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,7 @@ endif()
136136
# #pragma message("The Intel extensions have been moved into cl_ext.h.
137137
# Please include cl_ext.h directly.")
138138
if(NOT WIN32)
139-
if(${CMAKE_VERSION} VERSION_LESS "3.1.0")
140-
# Prior to CMake 3.1 the Makefile generators did not escape # correctly
141-
# inside make variable assignments used in generated makefiles, causing
142-
# them to be treated as comments. This is a workaround.
143-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-\\#pragma-messages")
144-
else()
145-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-#pragma-messages")
146-
endif()
139+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-#pragma-messages")
147140
endif()
148141

149142
add_definitions_with_host_compiler("-DCL_TARGET_OPENCL_VERSION=300")

cmake/coverage.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#===============================================================================
2-
# Copyright 2019-2020 Intel Corporation
2+
# Copyright 2019-2024 Intel Corporation
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ if("${DNNL_CODE_COVERAGE}" STREQUAL "GCOV")
3636
message(FATAL_ERROR "GCOV not found in path")
3737
endif()
3838

39-
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
39+
if(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
4040
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3)
4141
message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
4242
endif()
@@ -49,7 +49,7 @@ if("${DNNL_CODE_COVERAGE}" STREQUAL "GCOV")
4949

5050
if(NOT CMAKE_BUILD_TYPE MATCHES "[Dd]ebug")
5151
message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading")
52-
endif()
52+
endif()
5353

5454
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
5555
link_libraries(gcov)

cmake/platform.cmake

+4-6
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ if(MSVC)
153153
# disable: icpc deprecation notice
154154
append(CMAKE_CXX_FLAGS_DEBUG "-Qdiag-disable:10441")
155155
endif()
156-
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
156+
if(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
157157
append(CMAKE_CCXX_NOEXCEPT_FLAGS "-fno-exceptions")
158158
# Clang cannot vectorize some loops with #pragma omp simd and gets
159159
# very upset. Tell it that it's okay and that we love it
@@ -237,7 +237,7 @@ elseif(UNIX OR MINGW)
237237
platform_unix_and_mingw_common_cxx_flags(CMAKE_CXX_FLAGS)
238238
platform_unix_and_mingw_noexcept_ccxx_flags(CMAKE_CMAKE_CCXX_NOEXCEPT_FLAGS)
239239
# compiler specific settings
240-
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
240+
if(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
241241
if(DNNL_TARGET_ARCH STREQUAL "AARCH64")
242242
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
243243
set(DEF_ARCH_OPT_FLAGS "-O3")
@@ -313,9 +313,7 @@ elseif(UNIX OR MINGW)
313313
"-fsanitize-blacklist=${PROJECT_SOURCE_DIR}/.clang-ignorelist")
314314
endif()
315315

316-
if (DNNL_USE_CLANG_TIDY MATCHES "(CHECK|FIX)" AND ${CMAKE_VERSION} VERSION_LESS "3.6.0")
317-
message(FATAL_ERROR "Using clang-tidy requires CMake 3.6.0 or newer")
318-
elseif(DNNL_USE_CLANG_TIDY MATCHES "(CHECK|FIX)")
316+
if(DNNL_USE_CLANG_TIDY MATCHES "(CHECK|FIX)")
319317
find_program(CLANG_TIDY NAMES clang-tidy)
320318
if(NOT CLANG_TIDY)
321319
message(FATAL_ERROR "Clang-tidy not found")
@@ -462,7 +460,7 @@ if (DNNL_TARGET_ARCH STREQUAL "RV64")
462460
endif()
463461

464462
# Old compiler versions do not support warnings available on newer compilers.
465-
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0.0)
463+
if(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0.0)
466464
append(CMAKE_CCXX_FLAGS "-Wno-unknown-warning-option")
467465
endif()
468466

cmake/utils.cmake

+1-28
Original file line numberDiff line numberDiff line change
@@ -142,35 +142,8 @@ macro(append_to_windows_path_list path_list path)
142142
endif()
143143
endmacro()
144144

145-
function(target_link_libraries_build target list)
146-
# Foreach is required for compatibility with 2.8.11 ways
147-
foreach(lib ${list})
148-
target_link_libraries(${target} LINK_PUBLIC
149-
"$<BUILD_INTERFACE:${lib}>")
150-
endforeach(lib)
151-
endfunction()
152-
153-
function(target_link_libraries_install target list)
154-
# Foreach is required for compatibility with 2.8.11 ways
155-
foreach(lib ${list})
156-
get_filename_component(base "${lib}" NAME)
157-
target_link_libraries(${target} LINK_PUBLIC
158-
"$<INSTALL_INTERFACE:${base}>")
159-
endforeach(lib)
160-
endfunction()
161-
162145
function(find_libm var)
163-
# This is to account for the linker cache in OSX11. might work
164-
# with lower than 3.9.4, but was not able to test with anything
165-
# between 2.8 and 3.9. See here for more details:
166-
# https://gitlab.kitware.com/cmake/cmake/-/issues/20863
167-
if (APPLE AND (${CMAKE_HOST_SYSTEM_VERSION} VERSION_GREATER "20.0.0")
168-
AND (${CMAKE_VERSION} VERSION_LESS "3.9.4"))
169-
message(INFO "Using OSX11 and above with CMAKE older than 3.18 can cause linking issues.")
170-
set(OSX11_AND_OLDER_CMAKE TRUE)
171-
endif()
172-
173-
if(UNIX AND (NOT (APPLE AND OSX11_AND_OLDER_CMAKE)))
146+
if(UNIX)
174147
find_library(${var} m REQUIRED)
175148
endif()
176149
endfunction()

0 commit comments

Comments
 (0)