summaryrefslogtreecommitdiffstats
path: root/chello/CMakeLists.txt
diff options
context:
space:
mode:
authorBernhard Guillon <Bernhard.Guillon@begu.org>2026-06-30 21:02:59 +0200
committerBernhard Guillon <Bernhard.Guillon@begu.org>2026-06-30 21:02:59 +0200
commit17a7b6d602ec4e0bf39078a3a9a03ef71d65cf10 (patch)
treeec4cd3a180133e2f691f154bd05dcdbe69f0b4ca /chello/CMakeLists.txt
parent9bb17da786318cf6c056bdc8a5bfb100ae7ae81c (diff)
downloadcsharp-cmake-17a7b6d602ec4e0bf39078a3a9a03ef71d65cf10.tar.gz
csharp-cmake-17a7b6d602ec4e0bf39078a3a9a03ef71d65cf10.zip
Add C hello library with P/Invoke from Baz
Diffstat (limited to 'chello/CMakeLists.txt')
-rw-r--r--chello/CMakeLists.txt15
1 files changed, 15 insertions, 0 deletions
diff --git a/chello/CMakeLists.txt b/chello/CMakeLists.txt
new file mode 100644
index 0000000..f7a276f
--- /dev/null
+++ b/chello/CMakeLists.txt
@@ -0,0 +1,15 @@
+find_program(CMAKE_C_COMPILER NAMES gcc cc)
+if(NOT CMAKE_C_COMPILER)
+ message(FATAL_ERROR "C compiler not found!")
+endif()
+
+set(OUTPUT_FILE ${CMAKE_BINARY_DIR}/libhello_c.so)
+
+add_custom_command(
+ OUTPUT ${OUTPUT_FILE}
+ COMMAND ${CMAKE_C_COMPILER} -shared -fPIC -o ${OUTPUT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/hello.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/hello.c
+ COMMENT "Compiling hello_c shared library..."
+)
+
+add_custom_target(hello_c ALL DEPENDS ${OUTPUT_FILE})