From e2555e5fedd8894e7f6208f5f5defb7695880cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6ger?= Date: Fri, 18 Jun 2021 11:49:35 +0100 Subject: [PATCH] fix paths of includes in clib.c With the module search path cleverly handled with different install.h configurations, the genstatic script inserted absolute paths into the generated clib.c file. This didn't fail on Windows CI as this is an in-source build. For out-of-source builds, it's crucial that clib.c can refer to both .c files in the source directory and those generated in the build directory. As a fix, the genstatic invocation now uses the -I flag. This patch also improves the handling of include paths to find the .c. files mentioned above by trimming down the scope of this property to clib.c only. Also, there is no need to manually tell the preprocessor where to look for generated .c, as they live relative to clib.c anyhow. --- CMakeLists.txt | 17 +++++++++++------ contrib/chibi-genstatic-helper.cmake | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e962c70a..d8524908 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,6 @@ if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE) endif() - # # Features # @@ -284,6 +283,17 @@ if (NOT BUILD_SHARED_LIBS) ${genstatic-helper} ${slds}) + # The generated file will #include both manually written files in + # the source directory as well as files generated by chibi-ffi in + # the build directory. The latter can be found without special flags, + # as they are relative to the clib.c, but the preprocessor needs + # help for the former. As only clib.c needs this flag, we set it + # as locally as possible, i.e., not as a target property. + set_source_files_properties(${clibout} + PROPERTIES + INCLUDE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR}) + target_compile_definitions(libchibi-scheme PUBLIC SEXP_USE_STATIC_LIBS=1) @@ -291,11 +301,6 @@ if (NOT BUILD_SHARED_LIBS) target_sources(libchibi-scheme PUBLIC ${clibout}) - - target_include_directories(libchibi-common - INTERFACE - $ - $) endif() # diff --git a/contrib/chibi-genstatic-helper.cmake b/contrib/chibi-genstatic-helper.cmake index abddb9d3..ff480ed4 100644 --- a/contrib/chibi-genstatic-helper.cmake +++ b/contrib/chibi-genstatic-helper.cmake @@ -16,7 +16,7 @@ if(NOT OUT) endif() execute_process( - COMMAND ${EXEC} ${GENSTATIC} --no-inline + COMMAND ${EXEC} -q -I ./lib ${GENSTATIC} --no-inline INPUT_FILE ${STUBS} OUTPUT_FILE ${OUT} RESULT_VARIABLE rr