Fix C++ build

Map the target_pointer_width cfg's used for the opaque ffi interpreter
data structures to #ifdefs in CMake, to avoid that cbindgen generates
them multiple times without guard.
This commit is contained in:
Simon Hausmann 2021-03-25 09:36:22 +01:00
parent 4ee0a02366
commit 272a87ccf1
2 changed files with 14 additions and 0 deletions

View file

@ -24,6 +24,13 @@ add_library(SixtyFPS INTERFACE)
add_library(SixtyFPS::SixtyFPS ALIAS SixtyFPS)
target_link_libraries(SixtyFPS INTERFACE sixtyfps-cpp)
target_compile_features(SixtyFPS INTERFACE cxx_std_17)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
target_compile_definitions(SixtyFPS INTERFACE SIXTYFPS_TARGET_64)
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
target_compile_definitions(SixtyFPS INTERFACE SIXTYFPS_TARGET_32)
else()
message(FATAL_ERROR "Unsupported CPU target architecture where the pointer size is neiter 4 nor 8")
endif()
file(GLOB api_headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")

View file

@ -33,6 +33,13 @@ fn default_config() -> cbindgen::Config {
.collect(),
..Default::default()
},
defines: [
("target_pointer_width = 64".into(), "SIXTYFPS_TARGET_64".into()),
("target_pointer_width = 32".into(), "SIXTYFPS_TARGET_32".into()),
]
.iter()
.cloned()
.collect(),
..Default::default()
}
}