This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 2fdebacac9d70c372e0b6926ffd4ff73728c93ec (commit)
from 1baf3245a6e8d30613ebcf943142fc884e3d8b6a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2fdebacac9d70c372e0b6926ffd4ff73728c93ec
Author: Paul Cercueil <pa...@cr...>
Date: Wed Jul 17 05:33:52 2024 +0200
CMake: Support romdisks in C++ projects (#677)
* bin2c: Generate code compilable with C++ compiler
Mark the variables as "extern C" so that the generated source file can
be compiled with a C++ compiler and still link properly with KallistiOS.
Signed-off-by: Paul Cercueil <pa...@cr...>
* CMake: Support generating romdisk in C++-only projects
When the project is C++ only, any .c file added to the target sources
will be ignored by CMake. This meant that the source file generated by
kos_add_romdisk() macro would not be compiled.
Address this issue by changing the extension of the generated source
file to .cpp when a C++ compiler is used.
Signed-off-by: Paul Cercueil <pa...@cr...>
---------
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
utils/bin2c/bin2c.c | 3 +++
utils/cmake/dreamcast.cmake | 8 +++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/utils/bin2c/bin2c.c b/utils/bin2c/bin2c.c
index 66924a26..7ba8847d 100644
--- a/utils/bin2c/bin2c.c
+++ b/utils/bin2c/bin2c.c
@@ -26,7 +26,10 @@ void convert(char *ifn, char *ofn, char *prefix) {
fseek(i, 0, SEEK_SET);
setbuf(o, buf);
+ fprintf(o, "#ifdef __cplusplus\nextern \"C\"\n#endif\n");
fprintf(o, "const int %s_size = %d;\n", prefix, left);
+
+ fprintf(o, "#ifdef __cplusplus\nextern \"C\"\n#endif\n");
fprintf(o, "const unsigned char %s_data[%d] =", prefix, left);
fprintf(o, "{\n\t");
diff --git a/utils/cmake/dreamcast.cmake b/utils/cmake/dreamcast.cmake
index 9781bdfe..a8f7b5a4 100644
--- a/utils/cmake/dreamcast.cmake
+++ b/utils/cmake/dreamcast.cmake
@@ -66,7 +66,13 @@ function(kos_add_romdisk target romdiskPath)
file(REAL_PATH "${romdiskPath}" romdiskPath)
- set(c_tmp ${CMAKE_CURRENT_BINARY_DIR}/${romdiskName}_tmp.c)
+ if(CMAKE_CXX_COMPILER_LOADED)
+ set(tmpExt cpp)
+ else()
+ set(tmpExt c)
+ endif()
+
+ set(c_tmp ${CMAKE_CURRENT_BINARY_DIR}/${romdiskName}_tmp.${tmpExt})
set(img ${CMAKE_CURRENT_BINARY_DIR}/${romdiskName}.img)
# Variable holding all files in the romdiskPath folder
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|