From 827de87a22de64d94a05237df3f05506e7da1872 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 5 Jan 2026 22:15:33 -0500 Subject: [PATCH] xo-arena: empty scaffold (builds, but empty!) [WIP] --- xo-arena/CMakeLists.txt | 41 ++++++ xo-arena/cmake/xo-bootstrap-macros.cmake | 33 +++++ xo-arena/cmake/xo_arenaConfig.cmake.in | 12 ++ xo-arena/include/xo/arena/.gitkeep | 0 xo-cmake/bin/scaffold-headeronly | 167 +++++++++++++++++++++++ 5 files changed, 253 insertions(+) create mode 100644 xo-arena/CMakeLists.txt create mode 100644 xo-arena/cmake/xo-bootstrap-macros.cmake create mode 100644 xo-arena/cmake/xo_arenaConfig.cmake.in create mode 100644 xo-arena/include/xo/arena/.gitkeep create mode 100755 xo-cmake/bin/scaffold-headeronly diff --git a/xo-arena/CMakeLists.txt b/xo-arena/CMakeLists.txt new file mode 100644 index 00000000..70e8d6d9 --- /dev/null +++ b/xo-arena/CMakeLists.txt @@ -0,0 +1,41 @@ +# xo-arena/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(xo_arena VERSION 1.0) +enable_language(CXX) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +# one-time project-specific c++ flags. usually empty +set(PROJECT_CXX_FLAGS "") +add_definitions(${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- +# output targets + +#add_subdirectory(utest) + +# ---------------------------------------------------------------- +# header-only library + +set(SELF_LIB xo_arena) +xo_add_headeronly_library(${SELF_LIB}) +xo_install_library4(${SELF_LIB} ${PROJECT_NAME}Targets) +xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) + +# ---------------------------------------------------------------- +# input dependencies +# +# NOTE: dependency set here must be kept consistent with +# xo-arena/cmake/xo_arenaConfig.cmake.in + +#xo_headeronly_dependency(${SELF_LIB} xo_flatstring) + +# end CMakeLists.txt diff --git a/xo-arena/cmake/xo-bootstrap-macros.cmake b/xo-arena/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..2cf387e5 --- /dev/null +++ b/xo-arena/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,33 @@ +# ---------------------------------------------------------------- +# for example: +# $ PREFIX=/usr/local # for example +# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=$PREFIX -B .build +# +# will get +# CMAKE_MODULE_PATH +# from xo-cmake-config --cmake-module-path +# +# and expect .cmake macros in +# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake +# ---------------------------------------------------------------- + +find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED) + +if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix")) + message(FATAL "could not find xo-cmake-config executable") +endif() + +if (NOT XO_SUBMODULE_BUILD) + if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # default to typical install location for xo-project-macros + execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) + message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + endif() +endif() + +# needs to have been installed somewhere on CMAKE_MODULE_PATH, +# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) +# +include(xo_macros/xo_cxx) + +xo_cxx_bootstrap_message() diff --git a/xo-arena/cmake/xo_arenaConfig.cmake.in b/xo-arena/cmake/xo_arenaConfig.cmake.in new file mode 100644 index 00000000..b5c3cd5c --- /dev/null +++ b/xo-arena/cmake/xo_arenaConfig.cmake.in @@ -0,0 +1,12 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# note: changes to find_dependency() calls here +# must coordinate with xo_dependency() calls +# in CMakeLists.txt +# +#find_dependency(xo_flatstring) + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/xo-arena/include/xo/arena/.gitkeep b/xo-arena/include/xo/arena/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/xo-cmake/bin/scaffold-headeronly b/xo-cmake/bin/scaffold-headeronly new file mode 100755 index 00000000..636dad47 --- /dev/null +++ b/xo-cmake/bin/scaffold-headeronly @@ -0,0 +1,167 @@ +#!/usr/bin/env bash +# +# scaffold-headeronly.sh - Create a new xo header-only subdirectory +# +# Usage: scaffold-headeronly.sh +# where is the short name (e.g., "arena" creates "xo-arena") +# + +set -euo pipefail + +usage() { + echo "Usage: $0 " + echo " Creates xo-/ with header-only library scaffolding" + echo "" + echo "Example: $0 arena" + echo " Creates xo-arena/CMakeLists.txt" + echo " xo-arena/cmake/xo-bootstrap-macros.cmake" + echo " xo-arena/cmake/xo_arenaConfig.cmake.in" + echo " xo-arena/include/xo/arena/" + exit 1 +} + +if [[ $# -ne 1 ]]; then + usage +fi + +NAME="$1" + +# Validate name: alphanumeric and underscores only +if [[ ! "$NAME" =~ ^[a-zA-Z][a-zA-Z0-9_]*$ ]]; then + echo "Error: name must start with letter and contain only alphanumeric/underscores" + exit 1 +fi + +# Derive names +DIR_NAME="xo-${NAME}" +LIB_NAME="xo_${NAME}" +PROJECT_NAME="xo_${NAME}" + +# Get script directory to find umbrella root +XO_UMBRELLA_ROOT=$(git rev-parse --show-toplevel) + +TARGET_DIR="${XO_UMBRELLA_ROOT}/${DIR_NAME}" + +if [[ -d "$TARGET_DIR" ]]; then + echo "Error: ${TARGET_DIR} already exists" + exit 1 +fi + +echo "Creating ${DIR_NAME} in ${XO_UMBRELLA_ROOT}..." + +# Create directories +mkdir -p "${TARGET_DIR}/cmake" +mkdir -p "${TARGET_DIR}/include/xo/${NAME}" + +# Create CMakeLists.txt +cat > "${TARGET_DIR}/CMakeLists.txt" << EOF +# ${DIR_NAME}/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(${PROJECT_NAME} VERSION 1.0) +enable_language(CXX) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +# one-time project-specific c++ flags. usually empty +set(PROJECT_CXX_FLAGS "") +add_definitions(\${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- +# output targets + +#add_subdirectory(utest) + +# ---------------------------------------------------------------- +# header-only library + +set(SELF_LIB ${LIB_NAME}) +xo_add_headeronly_library(\${SELF_LIB}) +xo_install_library4(\${SELF_LIB} \${PROJECT_NAME}Targets) +xo_export_cmake_config(\${PROJECT_NAME} \${PROJECT_VERSION} \${PROJECT_NAME}Targets) + +# ---------------------------------------------------------------- +# input dependencies +# +# NOTE: dependency set here must be kept consistent with +# ${DIR_NAME}/cmake/${LIB_NAME}Config.cmake.in + +#xo_headeronly_dependency(\${SELF_LIB} xo_flatstring) + +# end CMakeLists.txt +EOF + +# Create cmake/xo-bootstrap-macros.cmake +cat > "${TARGET_DIR}/cmake/xo-bootstrap-macros.cmake" << EOF +# ---------------------------------------------------------------- +# for example: +# $ PREFIX=/usr/local # for example +# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=\$PREFIX -B .build +# +# will get +# CMAKE_MODULE_PATH +# from xo-cmake-config --cmake-module-path +# +# and expect .cmake macros in +# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake +# ---------------------------------------------------------------- + +find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED) + +if (("\${CMAKE_MODULE_PATH}" STREQUAL "") OR ("\${CMAKE_MODULE_PATH}" STREQUAL "prefix")) + message(FATAL "could not find xo-cmake-config executable") +endif() + +if (NOT XO_SUBMODULE_BUILD) + if (("\${CMAKE_MODULE_PATH}" STREQUAL "") OR ("\${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # default to typical install location for xo-project-macros + execute_process(COMMAND \${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) + message(STATUS "CMAKE_MODULE_PATH=\${CMAKE_MODULE_PATH}") + endif() +endif() + +# needs to have been installed somewhere on CMAKE_MODULE_PATH, +# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) +# +include(xo_macros/xo_cxx) + +xo_cxx_bootstrap_message() +EOF + +# Create cmake/xo_${NAME}Config.cmake.in +cat > "${TARGET_DIR}/cmake/${LIB_NAME}Config.cmake.in" << EOF +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# note: changes to find_dependency() calls here +# must coordinate with xo_dependency() calls +# in CMakeLists.txt +# +#find_dependency(xo_flatstring) + +include("\${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") +EOF + +# Create placeholder .gitkeep in include dir +touch "${TARGET_DIR}/include/xo/${NAME}/.gitkeep" + +echo "" +echo "Created ${DIR_NAME}/ with:" +echo " ${DIR_NAME}/CMakeLists.txt" +echo " ${DIR_NAME}/cmake/xo-bootstrap-macros.cmake" +echo " ${DIR_NAME}/cmake/${LIB_NAME}Config.cmake.in" +echo " ${DIR_NAME}/include/xo/${NAME}/" +echo "" +echo "Next steps:" +echo " 1. Add header files to ${DIR_NAME}/include/xo/${NAME}/" +echo " 2. Add ${DIR_NAME} to umbrella CMakeLists.txt" +echo " 3. Uncomment dependencies as needed in CMakeLists.txt and Config.cmake.in"