-platforms/unix/*.eo
-platforms/unix/*.o
-platforms/unix/pfdicdat.h
-platforms/unix/pforth
-platforms/unix/pforth.dic
-platforms/unix/pforth_standalone
-platforms/win32/**/.vs
-platforms/win32/**/Debug
-platforms/win32/**/Release
+platform/unix/*.eo
+platform/unix/*.o
+platform/unix/pfdicdat.h
+platform/unix/pforth
+platform/unix/pforth.dic
+platform/unix/pforth_standalone
+platform/win32/**/.vs
+platform/win32/**/Debug
+platform/win32/**/Release
fth/fatest1.txt
fth/pforth.dic
**/.DS_Store
+build/
+
+CMakeCache.txt
+CMakeFiles/
+CTestTestfile.cmake
+Makefile
+cmake_install.cmake
+csrc/CMakeFiles/
+csrc/CTestTestfile.cmake
+csrc/Makefile
+csrc/cmake_install.cmake
+csrc/libPforth_lib.a
+csrc/libPforth_lib_sd.a
+csrc/pfdicdat.h
+pforth
+pforth_standalone
--- /dev/null
+# NAME/CMakeLists.txt
+# Original file by Robin Rowe 2020-05-01
+# Extended by Phil Burk 2021-10-31
+# License: BSD Zero
+
+# To build pforth:
+#
+# cmake .
+# make
+#
+# That will create the following files:
+# fth/pforth # executable that loads pforth.dic
+# fth/pforth.dic
+# fth/pforth_standalone # executable that does not need a .dic file
+#
+# The build has several steps
+# 1. Build pforth executable
+# 2. Build pforth.dic by compiling system.fth
+# 3. Create a pfdicdat.h header containing a precompiled dictionary
+# as C source code.
+# 4. Build pforth_standalone using the precompiled dictionary.
+
+cmake_minimum_required(VERSION 3.6)
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
+# Put pforth in the fth folder so we can load the Forth code more easily.
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/fth)
+
+project(PForth)
+message("Configuring ${PROJECT_NAME}...")
+enable_testing()
+
+if(WIN32)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ message("Warning: _CRT_SECURE_NO_WARNINGS")
+endif(WIN32)
+
+add_subdirectory(csrc)
+if(NOT WIN32 AND NOT APPLE)
+ link_libraries(rt pthread)
+endif(NOT WIN32 AND NOT APPLE)
+
+option(UNISTD "Enable libunistd" false)
+if(UNISTD)
+ set(LIBUNISTD_PATH /code/github/libunistd)
+ if(WIN32)
+ include_directories(${LIBUNISTD_PATH}/unistd)
+ link_directories(${LIBUNISTD_PATH}/build/unistd/Release)
+ link_libraries(libunistd)
+ endif(WIN32)
+endif(UNISTD)
+
+# 1. Build pforth executable
+add_executable(pforth csrc/pf_main.c)
+target_link_libraries(pforth ${PROJECT_NAME}_lib)
+
+# 2. Build pforth.dic by compiling system.fth
+set(PFORTH_DIC "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/pforth.dic")
+add_custom_command(OUTPUT ${PFORTH_DIC}
+ COMMAND ./pforth -i system.fth
+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ DEPENDS pforth
+ COMMENT Building pforth.dic
+ VERBATIM
+ )
+add_custom_target(pforth_dic DEPENDS ${PFORTH_DIC})
+
+# 3. Create a pfdicdat.h header containing a precompiled dictionary
+# as C source code.
+set(PFORTH_DIC_HEADER "csrc/pfdicdat.h")
+add_custom_command(OUTPUT ${PFORTH_DIC_HEADER}
+ COMMAND ./pforth mkdicdat.fth
+ COMMAND mv pfdicdat.h ../csrc/.
+ WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ DEPENDS pforth_dic
+ COMMENT Building pfdicdat.h
+ VERBATIM
+ )
+add_custom_target(pforth_dic_header DEPENDS ${PFORTH_DIC_HEADER})
+add_dependencies(${PROJECT_NAME}_lib_sd pforth_dic_header)
+
+# 4. Build pforth_standalone using the precompiled dictionary.
+add_executable(pforth_standalone csrc/pf_main.c)
+target_link_libraries(pforth_standalone ${PROJECT_NAME}_lib_sd)
+target_compile_definitions(pforth_standalone PRIVATE PF_STATIC_DIC)
+add_dependencies(pforth_standalone pforth_dic_header)
+
+
+
--- /dev/null
+# pforth/csrc/CMakeLists.txt
+# Extended by Phil Burk 2021-10-31
+# License: BSD Zero
+
+file(STRINGS sources.cmake SOURCES)
+
+if(WIN32)
+set(PLATFORM stdio/pf_fileio_stdio.c win32_console/pf_io_win32_console.c )
+endif(WIN32)
+
+if(UNIX OR APPLE)
+set(PLATFORM posix/pf_io_posix.c stdio/pf_fileio_stdio.c)
+endif(UNIX OR APPLE)
+
+if (MSVC)
+ # warning level 4 and all warnings as errors
+ add_compile_options(/W4 /WX)
+else()
+ # lots of warnings and all warnings as errors
+ add_compile_options(
+# --std=c89
+ -fsigned-char
+ -fno-builtin
+ -fno-unroll-loops
+ -pedantic
+ -Wcast-qual
+ -Wall
+ -Werror
+ -Wwrite-strings
+ -Winline
+ -Wmissing-prototypes
+ -Wmissing-declarations
+ )
+endif()
+
+add_library(${PROJECT_NAME}_lib ${SOURCES} ${PLATFORM})
+
+# Compile the same library but with an option for the static dictionary.
+add_library(${PROJECT_NAME}_lib_sd STATIC ${SOURCES} ${PLATFORM})
+target_compile_definitions(${PROJECT_NAME}_lib_sd PRIVATE PF_STATIC_DIC)