Skip to content
Snippets Groups Projects
Verified Commit 5397b357 authored by Nils Friess's avatar Nils Friess Committed by Santiago Ospina De Los Ríos
Browse files

Add `HAVE_STDBOOL_H` define for Alberta when `stdbool.h` is available

In older versions of Alberta, it tries to fix the issues around not having
proper bool in C by redefining bool as _Bool or vice versa, depending
on the language that it is compiled with (C or C++). Clang's stdbool header
does essentially the same and we end up with `typedef bool bool` which is a
compile error. This whole bool/_Bool logic is inside an ifdef in
Albert that is active if HAVE_STDBOOL_H is not defined, in which case
it just includes stdbool.h and uses that. So we can check during
CMake config if that header is available and set the flag accordingly.
parent c75f2b61
Branches
No related tags found
1 merge request!769Add `HAVE_STDBOOL_H` define for Alberta when `stdbool.h` is available
......@@ -109,8 +109,17 @@ find_package_handle_standard_args("Alberta"
)
if(Alberta_FOUND)
include(CheckIncludeFileCXX)
check_include_file_cxx("stdbool.h" HAVE_STDBOOL_H_HEADER)
foreach(dim ${ALBERTA_WORLD_DIMS})
if(NOT Alberta::AlbertaGrid${dim}D)
if (${HAVE_STDBOOL_H_HEADER})
# Tell Alberta that we have a stdbool.h header so that it doesn't
# try to define `bool` itself (which would lead to a `typedef bool bool`
# and hence a compile error in clang).
target_compile_definitions(PkgConfig::Alberta${dim}D INTERFACE -DHAVE_STDBOOL_H)
endif()
add_library(Alberta::AlbertaGrid${dim}D ALIAS PkgConfig::Alberta${dim}D)
endif()
endforeach(dim)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment