Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: More reliable definition of C standard in CMakeLists #605

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
Loading