aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2021-02-09 16:50:23 +0530
committerArun Isaac2021-02-09 16:50:23 +0530
commitd88045a3b7c592d07c168d1bca060e3e26d61b73 (patch)
treea0f30a1428ed761b7792562978a258967bc1a2e2
parente151e74563aa2fe9ef4609ca85f5e049cb90d4c4 (diff)
downloadnsmc-d88045a3b7c592d07c168d1bca060e3e26d61b73.tar.gz
nsmc-d88045a3b7c592d07c168d1bca060e3e26d61b73.tar.lz
nsmc-d88045a3b7c592d07c168d1bca060e3e26d61b73.zip
Make indentation of generated C sources optional.
This is so as to not make indent a build dependency. * CMakeLists.txt: Indent generated C sources only when the indent program is found. Don't fail when indent is not found.
-rw-r--r--CMakeLists.txt26
1 files changed, 17 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 168eb01..360b931 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,21 +2,29 @@ cmake_minimum_required(VERSION 3.10)
project(extent-sampling VERSION 0.1.0)
find_package(GSL REQUIRED)
-# TODO: Make indent optional
-find_program(INDENT NAMES indent REQUIRED)
find_program(SC NAMES sc REQUIRED)
+find_program(INDENT NAMES indent)
-# Generate C source files from SC source files.
+# Generate C source files from SC source files, and optionally indent
+# them.
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} src/macros/macros.sc
- VERBATIM)
+ if(${INDENT} STREQUAL INDENT-NOTFOUND)
+ add_custom_command(
+ OUTPUT ${c_file}
+ COMMAND ${SC} ${sc_source} ${c_file}
+ DEPENDS ${sc_source} src/macros/macros.sc
+ VERBATIM)
+ else()
+ add_custom_command(
+ OUTPUT ${c_file}
+ COMMAND ${SC} ${sc_source} ${c_file}
+ COMMAND ${INDENT} ${c_file}
+ DEPENDS ${sc_source} src/macros/macros.sc
+ VERBATIM)
+ endif()
list(APPEND C_SOURCES ${c_file})
endforeach()