From 8044c18f84b6d8e60e89637bccc9ee5771f43624 Mon Sep 17 00:00:00 2001
From: Jaron Kent-Dobias <jaron@kent-dobias.com>
Date: Wed, 7 Jun 2017 14:58:29 -0400
Subject: make the cmake file more sensible

---
 CMakeLists.txt | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 76eb685..3cb6aeb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,18 +5,15 @@ project(fracture)
 include_directories(src ~/.local/include)
 link_directories(~/.local/lib)
 
-file(GLOB SOURCES lib/*.c)
-add_executable(fracture src/fracture.c ${SOURCES})
-add_executable(big_anal_process src/big_anal_process.c ${SOURCES})
-add_executable(anal_process src/anal_process.c ${SOURCES})
-add_executable(cen_anal_process src/cen_anal_process.c ${SOURCES})
-add_executable(long_anal_process src/long_anal_process.c ${SOURCES})
-add_executable(corr_test src/corr_test.c ${SOURCES})
+file(GLOB LIB_SOURCES lib/*.c)
 
-target_link_libraries(fracture gsl c cblas lapack dl pthread cholmod amd colamd suitesparseconfig camd ccolamd rt metis m jst tcmalloc profiler)
-target_link_libraries(big_anal_process gsl c cblas lapack dl pthread cholmod amd colamd suitesparseconfig camd ccolamd rt metis m jst tcmalloc profiler)
-target_link_libraries(cen_anal_process gsl c cblas lapack dl pthread cholmod amd colamd suitesparseconfig camd ccolamd rt metis m jst tcmalloc profiler)
-target_link_libraries(long_anal_process gsl c cblas lapack dl pthread cholmod amd colamd suitesparseconfig camd ccolamd rt metis m jst tcmalloc profiler)
-target_link_libraries(corr_test gsl c cblas lapack dl pthread cholmod amd colamd suitesparseconfig camd ccolamd rt metis m jst tcmalloc profiler)
-target_link_libraries(anal_process gsl c cblas lapack dl pthread cholmod amd colamd suitesparseconfig camd ccolamd rt metis m jst tcmalloc profiler)
+add_library(fracture_stuff ${LIB_SOURCES})
+
+file(GLOB EXE_SOURCES src/*.c)
+
+foreach( src_file ${EXE_SOURCES} )
+  string( REGEX REPLACE ".*/src/(.*)\.c" "\\1" exe_name ${src_file} )
+  add_executable( ${exe_name} ${src_file} )
+  target_link_libraries(${exe_name} fracture_stuff gsl c cblas lapack dl pthread cholmod amd colamd suitesparseconfig camd ccolamd rt metis m jst tcmalloc profiler)
+endforeach( src_file ${EXE_SOURCES} )
 
-- 
cgit v1.2.3-70-g09d2