From 268586961793281a0db9ea64323a0b07f42aa5d2 Mon Sep 17 00:00:00 2001
From: Carl Klemm <carl@uvos.xyz>
Date: Mon, 25 Apr 2022 10:20:38 +0200
Subject: [PATCH] rename eisgenerator, make a shared libary

---
 CMakeLists.txt                                | 36 ++++++++++++++-----
 cap.h => eisgenerator/cap.h                   |  0
 componant.h => eisgenerator/componant.h       |  0
 .../constantphase.h                           |  0
 model.h => eisgenerator/model.h               |  0
 .../paralellseriel.h                          |  0
 resistor.h => eisgenerator/resistor.h         |  0
 tokenize.h => eisgenerator/tokenize.h         |  0
 warburg.h => eisgenerator/warburg.h           |  0
 main.cpp                                      |  2 +-
 model.cpp                                     |  2 +-
 11 files changed, 30 insertions(+), 10 deletions(-)
 rename cap.h => eisgenerator/cap.h (100%)
 rename componant.h => eisgenerator/componant.h (100%)
 rename constantphase.h => eisgenerator/constantphase.h (100%)
 rename model.h => eisgenerator/model.h (100%)
 rename paralellseriel.h => eisgenerator/paralellseriel.h (100%)
 rename resistor.h => eisgenerator/resistor.h (100%)
 rename tokenize.h => eisgenerator/tokenize.h (100%)
 rename warburg.h => eisgenerator/warburg.h (100%)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 214e293..006c316 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,8 @@
 cmake_minimum_required(VERSION 3.20)
 
-project(ehigeneratorsa)
+project(eisgenerator)
 
 set(SRC_FILES
-	main.cpp
 	componant.cpp
 	cap.cpp
 	resistor.cpp
@@ -14,12 +13,33 @@ set(SRC_FILES
 	paralellseriel.cpp
 )
 
-find_package(PkgConfig REQUIRED)
-pkg_check_modules(SPICE REQUIRED ngspice)
+set(API_HEADERS
+	eisgenerator/componant.h
+	eisgenerator/cap.h
+	eisgenerator/resistor.h
+	eisgenerator/constantphase.h
+	eisgenerator/warburg.h
+	eisgenerator/model.h
+	eisgenerator/tokenize.h
+	eisgenerator/paralellseriel.h
+)
 
-add_executable(${PROJECT_NAME} ${SRC_FILES})
-target_link_libraries(${PROJECT_NAME} ${SPICE_LIBRARIES})
-target_include_directories(${PROJECT_NAME} PUBLIC ${SPICE_CFLAGS} .)
+add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
+target_link_libraries(${PROJECT_NAME} ${LIBS})
+target_include_directories(${PROJECT_NAME} PUBLIC eisgenerator)
 set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-std=c++20 -Wall -O3 -march=native -g" LINK_FLAGS "-flto")
 
-install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
+set(CMAKE_INSTALL_PREFIX "/usr")
+install(TARGETS ${PROJECT_NAME} DESTINATION lib)
+install(FILES ${API_HEADERS} DESTINATION include/${PROJECT_NAME})
+
+link_directories(${CMAKE_CURRENT_BINARY_DIR})
+set(SRC_FILES_TEST_APP main.cpp)
+set(LIBS_TEST -l${PROJECT_NAME})
+add_executable(${PROJECT_NAME}_test ${SRC_FILES_TEST_APP})
+add_dependencies(${PROJECT_NAME}_test ${PROJECT_NAME})
+target_link_libraries(${PROJECT_NAME}_test ${LIBS_TEST})
+target_include_directories(${PROJECT_NAME}_test PUBLIC eisgenerator)
+set_target_properties(${PROJECT_NAME}_test PROPERTIES COMPILE_FLAGS "-std=c++20 -Wall -O3 -march=native -g" LINK_FLAGS "-flto")
+
+install(TARGETS ${PROJECT_NAME}_test DESTINATION bin)
diff --git a/cap.h b/eisgenerator/cap.h
similarity index 100%
rename from cap.h
rename to eisgenerator/cap.h
diff --git a/componant.h b/eisgenerator/componant.h
similarity index 100%
rename from componant.h
rename to eisgenerator/componant.h
diff --git a/constantphase.h b/eisgenerator/constantphase.h
similarity index 100%
rename from constantphase.h
rename to eisgenerator/constantphase.h
diff --git a/model.h b/eisgenerator/model.h
similarity index 100%
rename from model.h
rename to eisgenerator/model.h
diff --git a/paralellseriel.h b/eisgenerator/paralellseriel.h
similarity index 100%
rename from paralellseriel.h
rename to eisgenerator/paralellseriel.h
diff --git a/resistor.h b/eisgenerator/resistor.h
similarity index 100%
rename from resistor.h
rename to eisgenerator/resistor.h
diff --git a/tokenize.h b/eisgenerator/tokenize.h
similarity index 100%
rename from tokenize.h
rename to eisgenerator/tokenize.h
diff --git a/warburg.h b/eisgenerator/warburg.h
similarity index 100%
rename from warburg.h
rename to eisgenerator/warburg.h
diff --git a/main.cpp b/main.cpp
index 055d9cf..4c554b8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -77,6 +77,6 @@ void runSweep()
 int main(int argc, char** argv)
 {
 	runSingle();
-	//runSweep();
+	runSweep();
 	return 0;
 }
diff --git a/model.cpp b/model.cpp
index 604ffbf..7b7bfb8 100644
--- a/model.cpp
+++ b/model.cpp
@@ -258,7 +258,7 @@ bool Model::sweepParams(const std::vector<Range>& componantRanges, const Range&
 	{
 		if(componantRanges[i].count == 0 || (componantRanges[i].count < 2 && componantRanges[i].start != componantRanges[i].end))
 		{
-			std::cout<<"Error: paramter range must specify at least one paramter point if only one paramer point is specified star and end must be the same\n";
+			std::cout<<"Error: paramter range must specify at least one paramter point if only one paramer point is specified start and end must be the same\n";
 			return false;
 		}
 		else if(componantRanges[i].start > componantRanges[i].end)
-- 
GitLab