about summary refs log tree commit diff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorArun Isaac2021-02-05 15:00:27 +0530
committerArun Isaac2021-02-05 15:00:27 +0530
commitc31a57815be4d3ef5f6fd28cc9a34b3be55bfe56 (patch)
treec1be91a98018535ea5fd934e1986c3d3e5ba0128 /CMakeLists.txt
parent7352aa8150d0012d10be7b1aaa341be7c459a05a (diff)
downloadnsmc-c31a57815be4d3ef5f6fd28cc9a34b3be55bfe56.tar.gz
nsmc-c31a57815be4d3ef5f6fd28cc9a34b3be55bfe56.tar.lz
nsmc-c31a57815be4d3ef5f6fd28cc9a34b3be55bfe56.zip
Migrate C source to SC.
sph-sc is a scheme-like S-expression syntax for C. It elements much of
the pain and repetition involved in writing C syntax.

* src/extent-sampling.c, src/gaussian-nd-random.c, src/nd-random.c,
src/oracles.c, src/utils.c: Delete files.
* src/extent-sampling.sc, src/gaussian-nd-random.sc,
src/macros/macros.sc, src/nd-random.sc, src/oracles.sc, src/utils.sc:
New files.
* CMakeLists.txt: Generate C source files from SC source files.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt20
1 files changed, 18 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 94264c7..fc3a296 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,24 @@ cmake_minimum_required(VERSION 3.10)
 project(extent-sampling VERSION 0.1)
 
 find_package(GSL REQUIRED)
+# TODO: Make indent optional
+find_program(INDENT NAMES indent REQUIRED)
+find_program(SC NAMES sc REQUIRED)
+
+# Generate C source files from SC source files.
+file(GLOB SC_SOURCES "src/*.sc")
+foreach(sc_source ${SC_SOURCES})
+  get_filename_component(source_basename ${sc_source} NAME_WE)
+  set(c_file ${source_basename}.c)
+  add_custom_command(
+    OUTPUT ${c_file}
+    COMMAND ${SC} ${sc_source} ${c_file}
+    COMMAND ${INDENT} ${c_file}
+    DEPENDS ${sc_source}
+    VERBATIM)
+  list(APPEND C_SOURCES ${c_file})
+endforeach()
 
 include_directories("include")
-file(GLOB SOURCES "src/*.c")
 
-add_library(extentsampling SHARED ${SOURCES})
+add_library(extentsampling SHARED ${C_SOURCES})