aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AGENTS/ARCH.md4
-rw-r--r--CMakeLists.txt8
-rw-r--r--README.md16
-rw-r--r--cmake/Install.cmake.in27
4 files changed, 47 insertions, 8 deletions
diff --git a/AGENTS/ARCH.md b/AGENTS/ARCH.md
index f235295..fb33471 100644
--- a/AGENTS/ARCH.md
+++ b/AGENTS/ARCH.md
@@ -84,6 +84,10 @@ Windows PowerShell 5.1; its Windows actions have only been reviewed statically.
The `doc` target uses CMake's `WIN32` target-platform detection: Windows generates
standalone HTML with inline styles at `build/doc/cpsc.html`; other platforms
generate `build/doc/cpsc.1`. Both render the same `doc/cpsc.md` using Pandoc.
+Windows `mingw32-make -C build install` builds the HTML manual and invokes
+`install.ps1` through Windows PowerShell with the build directory and
+`CMAKE_INSTALL_PREFIX`. The default Windows prefix is the per-user Programs
+directory above; explicit prefixes are preserved. Unix still invokes `install.sh`.
Build pin: developed and tested against **LLVM 18**. (The historical LLVM 19 breakage —
`ArithmeticHandler.cc` touching `llvm::Module` through a transitive include — is gone
diff --git a/CMakeLists.txt b/CMakeLists.txt
index baf337a..508e61a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,14 @@
cmake_minimum_required(VERSION 3.13)
project(cps_compiler)
+if(WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ if("$ENV{LOCALAPPDATA}" STREQUAL "")
+ message(FATAL_ERROR "LOCALAPPDATA is unset; specify -DCMAKE_INSTALL_PREFIX explicitly")
+ endif()
+ file(TO_CMAKE_PATH "$ENV{LOCALAPPDATA}/Programs/cpsc" cpsc_default_prefix)
+ set(CMAKE_INSTALL_PREFIX "${cpsc_default_prefix}" CACHE PATH "Installation directory" FORCE)
+endif()
+
set(CPSC_RUN_MODE "" CACHE STRING "Execution mode: PATH, EMBEDDED or NONE (required)")
set_property(CACHE CPSC_RUN_MODE PROPERTY STRINGS PATH EMBEDDED NONE)
if(NOT CPSC_RUN_MODE MATCHES "^(PATH|EMBEDDED|NONE)$")
diff --git a/README.md b/README.md
index 939d6f6..35a856f 100644
--- a/README.md
+++ b/README.md
@@ -203,8 +203,20 @@ For a custom prefix, add its `bin` directory to PATH; `man` normally discovers t
adjacent `share/man` directory from PATH. If your man configuration overrides this,
use `man -M "$HOME/.local/share/man" cpsc` for the local prefix.
-On Windows, `install.ps1` installs for the current user without administrator
-rights. Its source directory must contain `cpsc.exe` and `doc/cpsc.html`:
+On Windows, install from an existing MinGW build with:
+
+```powershell
+cmake --build build --target install
+```
+
+This is equivalent to `mingw32-make -C build install`: it generates the HTML
+manual with Pandoc and calls `install.ps1`. The Windows default
+`CMAKE_INSTALL_PREFIX` is `%LOCALAPPDATA%\Programs\cpsc`; an explicitly configured
+prefix is preserved. To change it, run
+`cmake -S . -B build -DCMAKE_INSTALL_PREFIX="D:/My Programs/cpsc"` before installing.
+
+You can also call `install.ps1` directly. It installs for the current user without
+administrator rights. Its source directory must contain `cpsc.exe` and `doc/cpsc.html`:
```powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\install.ps1 -SourceDir .\build
diff --git a/cmake/Install.cmake.in b/cmake/Install.cmake.in
index 68ecb46..b4d2c8f 100644
--- a/cmake/Install.cmake.in
+++ b/cmake/Install.cmake.in
@@ -7,12 +7,27 @@ if(NOT cpsc_doc_result STREQUAL "0")
message(FATAL_ERROR "Cannot build the manual; make sure Pandoc is installed")
endif()
-execute_process(
- COMMAND sh "@CMAKE_CURRENT_SOURCE_DIR@/install.sh"
- --source-dir "@CMAKE_CURRENT_BINARY_DIR@"
- --prefix "${CMAKE_INSTALL_PREFIX}"
- RESULT_VARIABLE cpsc_install_result
-)
+set(cpsc_install_windows "@WIN32@")
+if(cpsc_install_windows)
+ find_program(cpsc_powershell NAMES powershell.exe)
+ if(NOT cpsc_powershell)
+ message(FATAL_ERROR "Windows installation requires Windows PowerShell (powershell.exe)")
+ endif()
+ execute_process(
+ COMMAND "${cpsc_powershell}" -NoProfile -NonInteractive -ExecutionPolicy Bypass
+ -File "@CMAKE_CURRENT_SOURCE_DIR@/install.ps1"
+ -SourceDir "@CMAKE_CURRENT_BINARY_DIR@"
+ -Prefix "${CMAKE_INSTALL_PREFIX}"
+ RESULT_VARIABLE cpsc_install_result
+ )
+else()
+ execute_process(
+ COMMAND sh "@CMAKE_CURRENT_SOURCE_DIR@/install.sh"
+ --source-dir "@CMAKE_CURRENT_BINARY_DIR@"
+ --prefix "${CMAKE_INSTALL_PREFIX}"
+ RESULT_VARIABLE cpsc_install_result
+ )
+endif()
if(NOT cpsc_install_result STREQUAL "0")
message(FATAL_ERROR "cpsc installation failed (${cpsc_install_result})")
endif()