From: Pat Thoyts Date: Fri, 9 Jul 2021 15:31:59 +0000 (+0100) Subject: Added CMake build support X-Git-Url: https://privyetmir.co.uk/gitweb.cgi?a=commitdiff_plain;h=HEAD;p=Random Added CMake build support --- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1589d6d --- /dev/null +++ b/CMakeLists.txt @@ -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 $]]\n") diff --git a/generic/subtractive.c b/generic/subtractive.c index 4270cf9..8c3ca8e 100644 --- a/generic/subtractive.c +++ b/generic/subtractive.c @@ -8,6 +8,7 @@ */ #include "random.h" +#include static Tcl_MathProc RandProc; static Tcl_MathProc SrandProc;