rapidjson: fix Apple M1 build (#31291)

This commit is contained in:
Adam J. Stewart 2022-06-28 01:29:46 -07:00 committed by GitHub
parent 8f3aa27e25
commit 15f736e104
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 94 additions and 131 deletions

View File

@ -1,68 +0,0 @@
From dda5029e62d107c424b062f4792439ee32fd7380 Mon Sep 17 00:00:00 2001
From: Rob Latham <robl@mcs.anl.gov>
Date: Mon, 4 Mar 2019 20:32:30 -0600
Subject: [PATCH] turn off Werror
---
CMakeLists.txt | 4 ++--
example/CMakeLists.txt | 4 ++--
test/unittest/CMakeLists.txt | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ceda71b1..fbf8c692 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,7 +50,7 @@ if(CCACHE_FOUND)
endif(CCACHE_FOUND)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -Werror")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra")
if (RAPIDJSON_BUILD_CXX11)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
@@ -73,7 +73,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
endif()
endif()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -Werror -Wno-missing-field-initializers")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -Wno-missing-field-initializers")
if (RAPIDJSON_BUILD_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index 4d448ccc..47d19edc 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -26,9 +26,9 @@ include_directories("../include/")
add_definitions(-D__STDC_FORMAT_MACROS)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Werror -Wall -Wextra -Weffc++ -Wswitch-default")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -Wextra -Weffc++ -Wswitch-default")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough -Weverything")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough -Weverything")
endif()
foreach (example ${EXAMPLES})
diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt
index b3204d6c..d1c0add2 100644
--- a/test/unittest/CMakeLists.txt
+++ b/test/unittest/CMakeLists.txt
@@ -37,9 +37,9 @@ if(CCACHE_FOUND)
endif(CCACHE_FOUND)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough -Weverything")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough -Weverything")
# If the user is running a newer version of Clang that includes the
# -Wdouble-promotion, we will ignore that warning.
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.7)
--
2.17.1

View File

@ -1,15 +0,0 @@
diff -ru spack-src/CMakeLists.txt spack-src.new/CMakeLists.txt
--- spack-src/CMakeLists.txt 2019-07-24 15:44:41.200676445 +0900
+++ spack-src.new/CMakeLists.txt 2019-07-24 15:43:52.140673234 +0900
@@ -50,7 +50,10 @@
endif(CCACHE_FOUND)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
+ if(NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
+ endif()
if (RAPIDJSON_BUILD_CXX11)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")

View File

@ -0,0 +1,14 @@
--- a/CMakeLists.txt 2015-04-21 19:26:03.000000000 -0700
+++ b/CMakeLists.txt 2022-06-25 11:12:22.000000000 -0700
@@ -26,9 +26,9 @@
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
endif()

View File

@ -0,0 +1,20 @@
--- a/CMakeLists.txt 2016-08-25 00:59:05.000000000 -0700
+++ b/CMakeLists.txt 2022-06-25 11:17:40.000000000 -0700
@@ -50,7 +50,7 @@
endif(CCACHE_FOUND)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -Werror")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
if (RAPIDJSON_BUILD_CXX11)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
@@ -73,7 +73,7 @@
endif()
endif()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -Werror -Wno-missing-field-initializers")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-missing-field-initializers")
if (RAPIDJSON_BUILD_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

View File

@ -0,0 +1,45 @@
--- a/CMakeLists.txt 2022-06-25 11:22:02.000000000 -0700
+++ b/CMakeLists.txt 2022-06-25 11:23:42.000000000 -0700
@@ -45,8 +45,6 @@
option(RAPIDJSON_BUILD_ASAN "Build rapidjson with address sanitizer (gcc/clang)" OFF)
option(RAPIDJSON_BUILD_UBSAN "Build rapidjson with undefined behavior sanitizer (gcc/clang)" OFF)
-option(RAPIDJSON_ENABLE_INSTRUMENTATION_OPT "Build rapidjson with -march or -mcpu options" ON)
-
option(RAPIDJSON_HAS_STDSTRING "" OFF)
if(RAPIDJSON_HAS_STDSTRING)
add_definitions(-DRAPIDJSON_HAS_STDSTRING)
@@ -67,15 +65,7 @@
endif(CCACHE_FOUND)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
- if(RAPIDJSON_ENABLE_INSTRUMENTATION_OPT AND NOT CMAKE_CROSSCOMPILING)
- if(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=native")
- else()
- #FIXME: x86 is -march=native, but doesn't mean every arch is this option. To keep original project's compatibility, I leave this except POWER.
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
- endif()
- endif()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(EXTRA_CXX_FLAGS -Weffc++ -Wswitch-default -Wfloat-equal -Wconversion -Wsign-conversion)
if (RAPIDJSON_BUILD_CXX11 AND CMAKE_VERSION VERSION_LESS 3.1)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7.0")
@@ -101,15 +91,7 @@
endif()
endif()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- if(NOT CMAKE_CROSSCOMPILING)
- if(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=native")
- else()
- #FIXME: x86 is -march=native, but doesn't mean every arch is this option. To keep original project's compatibility, I leave this except POWER.
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
- endif()
- endif()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-missing-field-initializers")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-missing-field-initializers")
set(EXTRA_CXX_FLAGS -Weffc++ -Wswitch-default -Wfloat-equal -Wconversion -Wimplicit-fallthrough)
if (RAPIDJSON_BUILD_CXX11 AND CMAKE_VERSION VERSION_LESS 3.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

View File

@ -11,48 +11,26 @@ class Rapidjson(CMakePackage):
homepage = "https://rapidjson.org"
url = "https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz"
git = "https://github.com/Tencent/rapidjson.git"
version(
"1.2.0-2022-03-09",
git="https://github.com/Tencent/rapidjson.git",
commit="8261c1ddf43f10de00fd8c9a67811d1486b2c784"
)
version(
"1.2.0-2021-08-13",
git="https://github.com/Tencent/rapidjson.git",
commit="00dbcf2c6e03c47d6c399338b6de060c71356464",
)
version(
"1.1.0",
sha256="bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e",
)
version(
"1.0.2",
sha256="c3711ed2b3c76a5565ee9f0128bb4ec6753dbcc23450b713842df8f236d08666",
)
version(
"1.0.1",
sha256="a9003ad5c6384896ed4fd1f4a42af108e88e1b582261766df32d717ba744ee73",
)
version(
"1.0.0",
sha256="4189b32b9c285f34b37ffe4c0fd5627c1e59c2444daacffe5a96fdfbf08d139b",
)
version("1.2.0-2022-03-09", commit="8261c1ddf43f10de00fd8c9a67811d1486b2c784")
version("1.2.0-2021-08-13", commit="00dbcf2c6e03c47d6c399338b6de060c71356464")
version("1.1.0", sha256="bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e")
version("1.0.2", sha256="c3711ed2b3c76a5565ee9f0128bb4ec6753dbcc23450b713842df8f236d08666")
version("1.0.1", sha256="a9003ad5c6384896ed4fd1f4a42af108e88e1b582261766df32d717ba744ee73")
version("1.0.0", sha256="4189b32b9c285f34b37ffe4c0fd5627c1e59c2444daacffe5a96fdfbf08d139b")
# released versions compile with -Werror and fail with gcc-7
# branch-fall-through warnings
patch("0001-turn-off-Werror.patch", when="@1.0.0:1.1.0")
patch("arm.patch", when="@1.1.0 target=aarch64: %gcc@:5.9")
# Not correspond to define '-march=native' with Fujitsu compiler.
patch("remove_march.patch", when="%fj")
variant('doc', default=False,
description='Build and install documentation')
variant('doc', default=False, description='Build and install documentation')
depends_on('doxygen+graphviz', when='+doc')
# -march=native causes issues on ARM, with older GCC, and with Fujitsu
# Spack injects the appropriate optimization flags anyway
# https://github.com/Tencent/rapidjson/issues/1816
patch('no_march-1.2.patch', when='@1.2')
patch('no_march-1.1.patch', when='@1.1')
patch('no_march-1.0.patch', when='@1.0')
def cmake_args(self):
args = []
args.append(self.define_from_variant('RAPIDJSON_BUILD_DOC', 'doc'))

View File

@ -1,11 +0,0 @@
--- spack-src/CMakeLists.txt.org 2020-01-08 17:39:08.831616711 +0900
+++ spack-src/CMakeLists.txt 2020-01-08 17:39:27.431716190 +0900
@@ -73,7 +73,7 @@
endif()
endif()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -Wno-missing-field-initializers")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-missing-field-initializers")
if (RAPIDJSON_BUILD_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()