--- /dev/null
+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")