From 6eafb5ac34ddfa9efe00bc1214a5d3640224ee5f Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Fri, 21 Aug 2026 17:56:33 +0000 Subject: [PATCH 01/13] Get TCL paths from cmake modules instead of reading them from tea leaves. --- CMakeLists.txt | 16 +++------------- COMMONmakefile | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ad5c84..e71748d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,6 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) endif() message(INFO " cmake build type ${CMAKE_BUILD_TYPE}") -set(TCLSH_VERSION_STRING, "8.6") - # Determine if cpptcl is built as a subproject (using add_subdirectory) # or if it is the master project. set(CPPTCL_MASTER_PROJECT OFF) @@ -38,17 +36,9 @@ endif() include (CTest) -set(TCL_VERSION_MAJOR "8" CACHE STRING "TCL Major version") -set(TCL_VERSION_MINOR "6" CACHE STRING "TCL Minor version") -set(TCL_TCLSH "tclsh${TCL_VERSION_MAJOR}.${TCL_VERSION_MINOR}") -set(TCL_VER "${TCL_VERSION_MAJOR}.${TCL_VERSION_MINOR}") -set(TCL_VER_BSD "${TCL_VERSION_MAJOR}${TCL_VERSION_MINOR}") - -message(INFO " TCL_VER ${TCL_VER}") - -find_path(TCL_INCLUDE_PATH tcl.h PATHS /usr/local/include/tcl${TCL_VER} /usr/local/include /usr/include/tcl${TCL_VER} /usr/include NO_DEFAULT_PATH) -find_library(TCL_LIBRARY NAMES tcl${TCL_VER} tcl${TCL_VER_BSD} PATHS /usr/local/lib /usr/lib) -find_library(TCL_STUB_LIBRARY NAMES tclstub${TCL_VER} tclstub${TCL_VER_BSD} PATHS /usr/local/lib /usr/lib) +find_package(TCL) +find_package(TclStub) +find_package(Tclsh) message(INFO " Tcl include ${TCL_INCLUDE_PATH}") message(INFO " Tcl library ${TCL_LIBRARY}") diff --git a/COMMONmakefile b/COMMONmakefile index 3074936..a28aad5 100644 --- a/COMMONmakefile +++ b/COMMONmakefile @@ -3,7 +3,7 @@ CPPTCL_LIBRARY = build/libcpptcl.so all: $(CPPTCL_LIBRARY) build/Makefile: CMakeLists.txt - (mkdir -p build; cd build; cmake -DTCL_VERSION_MINOR:STRING=$${TCL_VERSION_MINOR:-6} ..) + (mkdir -p build; cd build; ..) debug: CMakeLists.txt (mkdir -p build; cd build; cmake -DCMAKE_BUILD_TYPE=Debug ..) From dff64ca98440a5c66d302a1b33a1042dce5d2bca Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Fri, 21 Aug 2026 18:06:01 +0000 Subject: [PATCH 02/13] Fix editing error --- COMMONmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/COMMONmakefile b/COMMONmakefile index a28aad5..396eb93 100644 --- a/COMMONmakefile +++ b/COMMONmakefile @@ -3,7 +3,7 @@ CPPTCL_LIBRARY = build/libcpptcl.so all: $(CPPTCL_LIBRARY) build/Makefile: CMakeLists.txt - (mkdir -p build; cd build; ..) + (mkdir -p build; cd build; cmake ..) debug: CMakeLists.txt (mkdir -p build; cd build; cmake -DCMAKE_BUILD_TYPE=Debug ..) From fab32f62bda76cefa1d517baaf75069d51952a8f Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Fri, 21 Aug 2026 18:37:34 +0000 Subject: [PATCH 03/13] tcl9 doesn't have make_safe TODO find out what the ramificatios are --- test/test1.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test1.cc b/test/test1.cc index d848398..9796fdf 100644 --- a/test/test1.cc +++ b/test/test1.cc @@ -26,7 +26,9 @@ int fun5(char const *s) { return std::string(s).size(); } void test1() { Tcl_Interp * interp = Tcl_CreateInterp(); interpreter i(interp, true); +#if (TCL_MAJOR_VERSION < 9) i.make_safe(); +#endif std::string s = i.eval("return \"ala ma kota\""); assert(s == "ala ma kota"); From 0235848fb0b9245670c9f68c9568aaacbfed57cb Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Mon, 14 Sep 2026 18:32:41 +0000 Subject: [PATCH 04/13] Rename CI to "tcl8" builds --- .github/workflows/{linux-ci.yml => linux-8-build.yml} | 2 +- .github/workflows/{mac-ci.yml => mac-8-build.yml} | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) rename .github/workflows/{linux-ci.yml => linux-8-build.yml} (96%) rename .github/workflows/{mac-ci.yml => mac-8-build.yml} (52%) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-8-build.yml similarity index 96% rename from .github/workflows/linux-ci.yml rename to .github/workflows/linux-8-build.yml index cb9f84c..26eed32 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-8-build.yml @@ -1,4 +1,4 @@ -name: Linux CI +name: Linux TCL8 build on: push: diff --git a/.github/workflows/mac-ci.yml b/.github/workflows/mac-8-build.yml similarity index 52% rename from .github/workflows/mac-ci.yml rename to .github/workflows/mac-8-build.yml index 02cde94..6c7d761 100644 --- a/.github/workflows/mac-ci.yml +++ b/.github/workflows/mac-8-build.yml @@ -16,12 +16,7 @@ jobs: - name: Install dependencies run: | brew update - brew install tcl-tk || true - sudo mkdir -p /usr/local - sudo ln -sf /usr/local/opt/tcl-tk/include/tcl-tk /usr/local/include/tcl8.6 - sudo install /usr/local/opt/tcl-tk/lib/libtcl* /usr/local/lib - sudo ln -sf /usr/local/opt/tcl-tk/bin/tclsh8.6 /usr/local/bin/tclsh - sudo ln -sf /usr/local/opt/tcl-tk/bin/tclsh8.6 /usr/local/bin/tclsh8.6 + brew reinstall tcl-tk@8 - name: make run: make - name: install From 24037bf773bf78ff77a88c3483197a515255ba27 Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Mon, 14 Sep 2026 18:38:43 +0000 Subject: [PATCH 05/13] Look for the correct TCL --- .github/workflows/mac-8-build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mac-8-build.yml b/.github/workflows/mac-8-build.yml index 6c7d761..a269d22 100644 --- a/.github/workflows/mac-8-build.yml +++ b/.github/workflows/mac-8-build.yml @@ -18,7 +18,11 @@ jobs: brew update brew reinstall tcl-tk@8 - name: make - run: make + run: | + PREFIX=/opt/homebrew/opt/tcl-tk@8 + export LDFLAGS="-L$PREFIX/lib" + export CPPFLAGS="-I$PREFIX/include" + make - name: install run: sudo make install - name: make test From 4c811a4a944aee44a9b401c84751fd53c1964a58 Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Mon, 14 Sep 2026 18:45:57 +0000 Subject: [PATCH 06/13] More tweaks to force cmake to cooperate --- .github/workflows/mac-8-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/mac-8-build.yml b/.github/workflows/mac-8-build.yml index a269d22..0ca7f07 100644 --- a/.github/workflows/mac-8-build.yml +++ b/.github/workflows/mac-8-build.yml @@ -22,6 +22,7 @@ jobs: PREFIX=/opt/homebrew/opt/tcl-tk@8 export LDFLAGS="-L$PREFIX/lib" export CPPFLAGS="-I$PREFIX/include" + export TCL_ROOT=$PREFIX make - name: install run: sudo make install From 3d755b0c7ed929168d7dc73569a78453707ca587 Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Mon, 14 Sep 2026 18:50:44 +0000 Subject: [PATCH 07/13] Set cmake_policy(CMP0074) to allow forcing the TCL_ROOT --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e71748d..23a2171 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ include(cmake/version.cmake) load_git_properties(cpptcl ${CMAKE_BINARY_DIR}/generated) set(CPPTCL_VERSION 2.2.8) +cmake_policy(CMP0074) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to Release as none was specified.") From 3c016c25cdc0f0354d84af330fc9042e08ecb1d6 Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Mon, 14 Sep 2026 18:53:35 +0000 Subject: [PATCH 08/13] Syntax my old foe --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23a2171..191d4a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ include(cmake/version.cmake) load_git_properties(cpptcl ${CMAKE_BINARY_DIR}/generated) set(CPPTCL_VERSION 2.2.8) -cmake_policy(CMP0074) +cmake_policy(SET CMP0074 NEW) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to Release as none was specified.") From 3825d40421c809efcfde360895d9ec2e17bb32db Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Mon, 14 Sep 2026 18:57:35 +0000 Subject: [PATCH 09/13] Log output on test failure --- COMMONmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/COMMONmakefile b/COMMONmakefile index 396eb93..a3e102e 100644 --- a/COMMONmakefile +++ b/COMMONmakefile @@ -15,7 +15,7 @@ install: all (cd build; make install) test: build/Makefile - (cd build; ctest) + (cd build; ctest --output-on-failure) examples: build/Makefile (cd build; make examples) From 84939cec7f993c49da6a659e5e25eeeee017e9ee Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Mon, 14 Sep 2026 19:19:55 +0000 Subject: [PATCH 10/13] Allow higher versions of Tcl. --- cpptcl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpptcl.cc b/cpptcl.cc index e7a7aeb..1a04d9e 100644 --- a/cpptcl.cc +++ b/cpptcl.cc @@ -654,7 +654,7 @@ interpreter::interpreter(Tcl_Interp *interp, bool owner) { interp_ = interp; owner_ = owner; if (!defaultInterpreter) { - if (Tcl_InitStubs(interp, "8.6", 0) == NULL) { + if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { throw tcl_error("Failed to initialize stubs"); } // Make a copy From 57a71be42581f9fcf3dae682dc911e0b19e3d211 Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Mon, 14 Sep 2026 19:25:07 +0000 Subject: [PATCH 11/13] Don't initialize stubs if there are no stubs to initialize. --- cpptcl.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpptcl.cc b/cpptcl.cc index 1a04d9e..efff5fc 100644 --- a/cpptcl.cc +++ b/cpptcl.cc @@ -654,9 +654,13 @@ interpreter::interpreter(Tcl_Interp *interp, bool owner) { interp_ = interp; owner_ = owner; if (!defaultInterpreter) { +#ifdef USE_TCL_STUBS +//#ifndef CPPTCL_NO_TCL_STUBS if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { throw tcl_error("Failed to initialize stubs"); } +//#endif +#endif // Make a copy defaultInterpreter = new interpreter(*this); } From 220829d68cb612e97d5c0ab4e02749b123c47608 Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Mon, 14 Sep 2026 19:28:32 +0000 Subject: [PATCH 12/13] hash-define me uarder --- cpptcl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpptcl.cc b/cpptcl.cc index efff5fc..8c9f206 100644 --- a/cpptcl.cc +++ b/cpptcl.cc @@ -655,11 +655,11 @@ interpreter::interpreter(Tcl_Interp *interp, bool owner) { owner_ = owner; if (!defaultInterpreter) { #ifdef USE_TCL_STUBS -//#ifndef CPPTCL_NO_TCL_STUBS +#ifndef CPPTCL_NO_TCL_STUBS if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { throw tcl_error("Failed to initialize stubs"); } -//#endif +#endif #endif // Make a copy defaultInterpreter = new interpreter(*this); From 8239a2bd83f7104d56de6803f498da15bfd11775 Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Mon, 14 Sep 2026 20:36:47 +0000 Subject: [PATCH 13/13] More stub updates. --- cpptcl.cc | 4 ---- cpptcl/cpptcl.h | 2 +- examples/example2.cc | 2 +- examples/example6.cc | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cpptcl.cc b/cpptcl.cc index 8c9f206..1a04d9e 100644 --- a/cpptcl.cc +++ b/cpptcl.cc @@ -654,13 +654,9 @@ interpreter::interpreter(Tcl_Interp *interp, bool owner) { interp_ = interp; owner_ = owner; if (!defaultInterpreter) { -#ifdef USE_TCL_STUBS -#ifndef CPPTCL_NO_TCL_STUBS if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { throw tcl_error("Failed to initialize stubs"); } -#endif -#endif // Make a copy defaultInterpreter = new interpreter(*this); } diff --git a/cpptcl/cpptcl.h b/cpptcl/cpptcl.h index 40318dd..d610887 100644 --- a/cpptcl/cpptcl.h +++ b/cpptcl/cpptcl.h @@ -523,7 +523,7 @@ inline std::ostream & operator<<(std::ostream &os, const object& obj) #define CPPTCL_MODULE(name, i) \ void name##_cpptcl_Init(Tcl::interpreter &i); \ extern "C" int name##_Init(Tcl_Interp *interp) { \ - Tcl_InitStubs(interp, "8.3", 0); \ + Tcl_InitStubs(interp, "8.6-", 0); \ Tcl::interpreter i(interp, false); \ name##_cpptcl_Init(i); \ return TCL_OK; \ diff --git a/examples/example2.cc b/examples/example2.cc index 6d48986..685506e 100644 --- a/examples/example2.cc +++ b/examples/example2.cc @@ -12,7 +12,7 @@ using namespace Tcl; void hello() { cout << "Hello C++/Tcl!" << endl; } int main() { - Tcl_Interp * interp = Tcl_CreateInterpWithStubs("8.6", 0); + Tcl_Interp * interp = Tcl_CreateInterpWithStubs("8.6-", 0); interpreter i(interp, true); i.def("hello", hello); diff --git a/examples/example6.cc b/examples/example6.cc index 6a5c545..3792fa4 100644 --- a/examples/example6.cc +++ b/examples/example6.cc @@ -8,7 +8,7 @@ using namespace std; using namespace Tcl; int main() { - Tcl_Interp * interp = Tcl_CreateInterpWithStubs("8.6", 0); + Tcl_Interp * interp = Tcl_CreateInterpWithStubs("8.6-", 0); interpreter i(interp, true); int numbers[] = {5, 7, 1, 6, 3, 9, 7};