Added CMake build support master
authorPat Thoyts <patthoyts@users.sourceforge.net>
Fri, 9 Jul 2021 15:31:59 +0000 (16:31 +0100)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Fri, 9 Jul 2021 15:31:59 +0000 (16:31 +0100)
CMakeLists.txt [new file with mode: 0644]
generic/subtractive.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1589d6d
--- /dev/null
@@ -0,0 +1,44 @@
+cmake_minimum_required(VERSION 3.12)
+cmake_policy(SET CMP0048 NEW)
+
+project(Random VERSION 1.2.0)
+
+set (PKG_VERSION ${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}${PROJECT_VERSION_PATCH})
+set (PKG_DOT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
+
+find_package(TclStub REQUIRED)
+
+set (TARGETNAME ${PROJECT_NAME}${PKG_VERSION})
+set (SOURCES
+  generic/random.c
+  generic/subtractive.c
+  generic/rand_mt.c
+  generic/rand_isaac.c
+  isaac/randport.c
+  generic/random.h
+  isaac/standard.h
+  isaac/rand.h
+)
+
+add_library(${TARGETNAME} SHARED ${SOURCES})
+
+target_include_directories(${TARGETNAME} PRIVATE
+  ${TCL_INCLUDE_PATH}
+  ${TK_INCLUDE_PATH}
+  generic
+  isaac)
+target_compile_definitions(${TARGETNAME} PRIVATE
+  -DUSE_TCL_STUBS
+  -DVERSION="${PKG_DOT_VERSION}"
+)
+target_link_libraries(${TARGETNAME} ${TCL_STUB_LIBRARY})
+
+#target_compile_definitions(${TARGETNAME} PRIVATE
+#  -DPACKAGE_VERSION="${PKG_DOT_VERSION}"
+#  -DCOMMAVERSION=${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0
+#  -DDOTVERSION="${PKG_DOT_VERSION}"
+#)
+
+file(GENERATE
+    OUTPUT "pkgIndex.tcl"
+    CONTENT "package ifneeded ${PROJECT_NAME} ${PKG_DOT_VERSION} [list load [file join $dir $<TARGET_FILE_NAME:${TARGETNAME}>]]\n")
index 4270cf9ecdd5248e95edd3acd09b731a8fb95fb1..8c3ca8e3eaa220b8a765f64eba886d6d1c1c941c 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include "random.h"
  */
 
 #include "random.h"
+#include <string.h>
 
 static Tcl_MathProc         RandProc;
 static Tcl_MathProc         SrandProc;
 
 static Tcl_MathProc         RandProc;
 static Tcl_MathProc         SrandProc;