This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git
The following commit(s) were added to refs/heads/main by this push:
new 567748de chore: More reliable definition of C standard in CMakeLists
(#605)
567748de is described below
commit 567748de42aaa2f763af8a8cf1e342c91478cf26
Author: Dewey Dunnington <[email protected]>
AuthorDate: Wed Sep 11 12:28:37 2024 -0300
chore: More reliable definition of C standard in CMakeLists (#605)
Some local update on my local machine resulted in nanoarrow not
compiling because clang gave a warning for the C11 extensions in the
flatcc generated code. I believe this was because the C standard had
already been set to C99 at the beginning of the file, whereas the check
to update it to C11 only happened after this had already been set.
---
CMakeLists.txt | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f880d996..e4f677ac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,11 +18,6 @@
message(STATUS "Building using CMake version: ${CMAKE_VERSION}")
cmake_minimum_required(VERSION 3.14)
-if(NOT DEFINED CMAKE_C_STANDARD)
- set(CMAKE_C_STANDARD 99)
- set(CMAKE_C_STANDARD_REQUIRED ON)
-endif()
-
set(NANOARROW_VERSION "0.6.0-SNAPSHOT")
string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" NANOARROW_BASE_VERSION
"${NANOARROW_VERSION}")
@@ -59,6 +54,18 @@ option(NANOARROW_CODE_COVERAGE "Enable coverage reporting"
OFF)
option(NANOARROW_ARROW_STATIC
"Use a statically-linked Arrow C++ build when linking tests" OFF)
+if(NOT DEFINED CMAKE_C_STANDARD)
+ if(NANOARROW_IPC)
+ # flatcc requires C11 for alignas() and static_assert() in
flatcc_generated.h
+ # It may be possible to use C99 mode to build the runtime and/or generated
header
+ # should this cause problems for users.
+ set(CMAKE_C_STANDARD 11)
+ else()
+ set(CMAKE_C_STANDARD 99)
+ endif()
+ set(CMAKE_C_STANDARD_REQUIRED ON)
+endif()
+
if(NANOARROW_NAMESPACE)
set(NANOARROW_NAMESPACE_DEFINE "#define NANOARROW_NAMESPACE
${NANOARROW_NAMESPACE}")
else()
@@ -150,14 +157,6 @@ target_include_directories(nanoarrow
install(FILES ${NANOARROW_INSTALL_HEADERS} DESTINATION include/nanoarrow)
if(NANOARROW_IPC)
- # flatcc requires C11 for alignas() and static_assert() in flatcc_generated.h
- # It may be possible to use C99 mode to build the runtime and/or generated
header
- # should this cause problems for users.
- if(NOT DEFINED CMAKE_C_STANDARD)
- set(CMAKE_C_STANDARD 11)
- set(CMAKE_C_STANDARD_REQUIRED ON)
- endif()
-
# Add the flatcc (runtime) dependency
set(FLATCC_RTONLY
ON