The C/Fortran linking test always fails with C compilers which do not implement implicit function declarations (a language feature removed in C99; future compilers are likely to disable them by default because they are a programmer hazard). Something like this is needed:
diff -up bionetgen-BioNetGen-2.8.4/bng2/Network3/cvode-2.6.0/config/SundialsFortran.cmake.c99 bionetgen-BioNetGen-2.8.4/bng2/Network3/cvode-2.6.0/config/SundialsFortran.cmake
--- bionetgen-BioNetGen-2.8.4/bng2/Network3/cvode-2.6.0/config/SundialsFortran.cmake.c99 2009-05-10 02:02:59.000000000 +0200
+++ bionetgen-BioNetGen-2.8.4/bng2/Network3/cvode-2.6.0/config/SundialsFortran.cmake 2022-12-11 18:44:28.015918587 +0100
@@ -111,7 +111,7 @@ if(CMAKE_Fortran_COMPILER)
# Get the current list entry (current scheme)
list(GET options ${iopt} opt)
# Generate C source which calls the "mysub" function using the current scheme
- file(WRITE ${FortranTest_DIR}/ctest1.c "int main(){${opt}();return(0);}\n")
+ file(WRITE ${FortranTest_DIR}/ctest1.c "char ${opt}(void); int main(){${opt}();return(0);}\n")
# Use TRY_COMPILE to make the "ctest1" executable from the current C source
# and linking to the previously created "flib" library.
try_compile(CTEST_OK ${FortranTest_DIR} ${FortranTest_DIR}
@@ -149,7 +149,7 @@ if(CMAKE_Fortran_COMPILER)
set(iopt 0)
while(${iopt} LESS ${imax})
list(GET options ${iopt} opt)
- file(WRITE ${FortranTest_DIR}/ctest2.c "int main(){${opt}();return(0);}\n")
+ file(WRITE ${FortranTest_DIR}/ctest2.c "char ${opt}(void); int main(){${opt}();return(0);}\n")
try_compile(CTEST_OK ${FortranTest_DIR} ${FortranTest_DIR}
ctest2 OUTPUT_VARIABLE MY_OUTPUT)
file(REMOVE_RECURSE ${FortranTest_DIR}/CMakeFiles)
Ordinarily I would send a PR, but the sources are contained in a tarball in the repository. I couldn't find any pre-existing patches.
Upstream CVODE has resolved it in pretty much the same way (although they use void ${opt}(void);; the char return type is the autoconf way).
The C/Fortran linking test always fails with C compilers which do not implement implicit function declarations (a language feature removed in C99; future compilers are likely to disable them by default because they are a programmer hazard). Something like this is needed:
Ordinarily I would send a PR, but the sources are contained in a tarball in the repository. I couldn't find any pre-existing patches.
Upstream CVODE has resolved it in pretty much the same way (although they use
void ${opt}(void);
; thechar
return type is the autoconf way).Found as part of: