Skip to content
Snippets Groups Projects
Commit 525e04aa authored by Nils Friess's avatar Nils Friess
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 2749fc2f
No related branches found
No related tags found
No related merge requests found
......@@ -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