Massive CMake refactoring... No code changes. (0.37.55)
This commit is contained in:
parent
a63aff3daa
commit
501be417e8
22 changed files with 513 additions and 568 deletions
14
cmake/Dependencies.cmake
Normal file
14
cmake/Dependencies.cmake
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Common dependency discovery used across the project
|
||||
|
||||
# Threads (used by demos and optionally by the runtime)
|
||||
if(UNIX)
|
||||
find_package(Threads QUIET)
|
||||
endif()
|
||||
|
||||
# Python for helper scripts
|
||||
find_package(Python3 QUIET COMPONENTS Interpreter)
|
||||
if(Python3_Interpreter_FOUND)
|
||||
set(_FUN_PY "${Python3_EXECUTABLE}")
|
||||
else()
|
||||
set(_FUN_PY "python3")
|
||||
endif()
|
||||
17
cmake/Extensions/CURL.cmake
Normal file
17
cmake/Extensions/CURL.cmake
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# CURL
|
||||
option(FUN_WITH_CURL "Enable libcurl HTTP client support" OFF)
|
||||
set(CURL_INCLUDE_DIRS "")
|
||||
set(CURL_LINK_LIBS "")
|
||||
if(FUN_WITH_CURL)
|
||||
add_definitions(-DFUN_WITH_CURL)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(LIBCURL QUIET libcurl)
|
||||
endif()
|
||||
if(LIBCURL_FOUND)
|
||||
list(APPEND CURL_INCLUDE_DIRS ${LIBCURL_INCLUDE_DIRS})
|
||||
list(APPEND CURL_LINK_LIBS ${LIBCURL_LIBRARIES})
|
||||
else()
|
||||
list(APPEND CURL_LINK_LIBS curl)
|
||||
endif()
|
||||
endif()
|
||||
39
cmake/Extensions/Extensions.cmake
Normal file
39
cmake/Extensions/Extensions.cmake
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# Toggleable optional features live in per-file modules. These populate *_INCLUDE_DIRS and *_LINK_LIBS
|
||||
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
|
||||
|
||||
# Helper to report feature status nicely
|
||||
function(_fun_print_feature name flag)
|
||||
if(${flag})
|
||||
message(STATUS " ${name}: ENABLED")
|
||||
else()
|
||||
message(STATUS " ${name}: DISABLED")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Include each extension module
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/TCLTK.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/SQLITE.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/PCSC.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/JSON.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/INI.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/XML2.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/LIBSQL.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/PCRE2.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/CURL.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/NOTCURSES.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/REPL.cmake)
|
||||
|
||||
# Summary of extension toggles
|
||||
message(STATUS "---- Fun extension summary ----")
|
||||
_fun_print_feature("Tcl/Tk (FUN_WITH_TCLTK)" FUN_WITH_TCLTK)
|
||||
_fun_print_feature("SQLite (FUN_WITH_SQLITE)" FUN_WITH_SQLITE)
|
||||
_fun_print_feature("PCSC (FUN_WITH_PCSC)" FUN_WITH_PCSC)
|
||||
_fun_print_feature("JSON-C (FUN_WITH_JSON)" FUN_WITH_JSON)
|
||||
_fun_print_feature("INI/iniparser (FUN_WITH_INI)" FUN_WITH_INI)
|
||||
_fun_print_feature("libxml2 (FUN_WITH_XML2)" FUN_WITH_XML2)
|
||||
_fun_print_feature("libsql (FUN_WITH_LIBSQL)" FUN_WITH_LIBSQL)
|
||||
_fun_print_feature("PCRE2 (FUN_WITH_PCRE2)" FUN_WITH_PCRE2)
|
||||
_fun_print_feature("libcurl (FUN_WITH_CURL)" FUN_WITH_CURL)
|
||||
_fun_print_feature("Notcurses (FUN_WITH_NOTCURSES)" FUN_WITH_NOTCURSES)
|
||||
_fun_print_feature("REPL (FUN_WITH_REPL)" FUN_WITH_REPL)
|
||||
message(STATUS "--------------------------------")
|
||||
27
cmake/Extensions/INI.cmake
Normal file
27
cmake/Extensions/INI.cmake
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# INI (iniparser)
|
||||
option(FUN_WITH_INI "Enable INI (iniparser) support" OFF)
|
||||
set(INIPARSER_INCLUDE_DIRS "")
|
||||
set(INIPARSER_LINK_LIBS "")
|
||||
if(FUN_WITH_INI)
|
||||
add_definitions(-DFUN_WITH_INI)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(INIPARSER QUIET iniparser)
|
||||
endif()
|
||||
if(INIPARSER_FOUND)
|
||||
list(APPEND INIPARSER_INCLUDE_DIRS ${INIPARSER_INCLUDE_DIRS} ${INIPARSER_INCLUDE_DIRS})
|
||||
list(APPEND INIPARSER_LINK_LIBS ${INIPARSER_LINK_LIBS} ${INIPARSER_LIBRARIES})
|
||||
else()
|
||||
find_path(INIPARSER_INCLUDE_DIR iniparser.h)
|
||||
find_library(INIPARSER_LIB NAMES iniparser)
|
||||
if(INIPARSER_INCLUDE_DIR)
|
||||
list(APPEND INIPARSER_INCLUDE_DIRS ${INIPARSER_INCLUDE_DIR})
|
||||
endif()
|
||||
if(INIPARSER_LIB)
|
||||
list(APPEND INIPARSER_LINK_LIBS ${INIPARSER_LIB})
|
||||
endif()
|
||||
if(NOT INIPARSER_INCLUDE_DIRS OR NOT INIPARSER_LINK_LIBS)
|
||||
message(FATAL_ERROR "iniparser not found. Install iniparser (>=4.2.6) or disable FUN_WITH_INI.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
17
cmake/Extensions/JSON.cmake
Normal file
17
cmake/Extensions/JSON.cmake
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# JSON (json-c)
|
||||
option(FUN_WITH_JSON "Enable JSON (json-c) support" OFF)
|
||||
set(JSONC_INCLUDE_DIRS "")
|
||||
set(JSONC_LINK_LIBS "")
|
||||
if(FUN_WITH_JSON)
|
||||
add_definitions(-DFUN_WITH_JSON)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(JSONC QUIET json-c)
|
||||
endif()
|
||||
if(JSONC_FOUND)
|
||||
list(APPEND JSONC_INCLUDE_DIRS ${JSONC_INCLUDE_DIRS} ${JSONC_INCLUDE_DIRS})
|
||||
list(APPEND JSONC_LINK_LIBS ${JSONC_LINK_LIBS} ${JSONC_LIBRARIES})
|
||||
else()
|
||||
list(APPEND JSONC_LINK_LIBS json-c)
|
||||
endif()
|
||||
endif()
|
||||
27
cmake/Extensions/LIBSQL.cmake
Normal file
27
cmake/Extensions/LIBSQL.cmake
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# libsql
|
||||
option(FUN_WITH_LIBSQL "Enable libsql (Turso) client support" OFF)
|
||||
set(LIBSQL_INCLUDE_DIRS "")
|
||||
set(LIBSQL_LINK_LIBS "")
|
||||
if(FUN_WITH_LIBSQL)
|
||||
add_definitions(-DFUN_WITH_LIBSQL)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(LIBSQL QUIET libsql)
|
||||
if(NOT LIBSQL_FOUND)
|
||||
pkg_check_modules(LIBSQL_CLIENT QUIET libsql-client)
|
||||
if(LIBSQL_CLIENT_FOUND)
|
||||
set(LIBSQL_FOUND TRUE)
|
||||
set(LIBSQL_INCLUDE_DIRS ${LIBSQL_CLIENT_INCLUDE_DIRS})
|
||||
set(LIBSQL_LINK_LIBS ${LIBSQL_CLIENT_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(NOT LIBSQL_FOUND)
|
||||
find_library(LIBSQL_LIB sqlite3)
|
||||
if(LIBSQL_LIB)
|
||||
list(APPEND LIBSQL_LINK_LIBS ${LIBSQL_LIB})
|
||||
else()
|
||||
message(FATAL_ERROR "libsql not found. Install libsql (or compatible sqlite3 client) or disable FUN_WITH_LIBSQL.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
20
cmake/Extensions/NOTCURSES.cmake
Normal file
20
cmake/Extensions/NOTCURSES.cmake
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Notcurses
|
||||
option(FUN_WITH_NOTCURSES "Enable Notcurses TUI support" OFF)
|
||||
set(NOTCURSES_INCLUDE_DIRS "")
|
||||
set(NOTCURSES_LINK_LIBS "")
|
||||
if(FUN_WITH_NOTCURSES)
|
||||
add_definitions(-DFUN_WITH_NOTCURSES)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PkgConfig_FOUND)
|
||||
pkg_check_modules(NOTCURSES QUIET notcurses)
|
||||
if(NOT NOTCURSES_FOUND)
|
||||
pkg_check_modules(NOTCURSES QUIET notcurses-core)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT NOTCURSES_FOUND)
|
||||
message(FATAL_ERROR "FUN_WITH_NOTCURSES=ON but notcurses was not found via pkg-config (tried notcurses and notcurses-core). Install notcurses or configure with -DFUN_WITH_NOTCURSES=OFF")
|
||||
else()
|
||||
list(APPEND NOTCURSES_INCLUDE_DIRS ${NOTCURSES_INCLUDE_DIRS} ${NOTCURSES_INCLUDE_DIRS})
|
||||
list(APPEND NOTCURSES_LINK_LIBS ${NOTCURSES_LINK_LIBS} ${NOTCURSES_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
17
cmake/Extensions/PCRE2.cmake
Normal file
17
cmake/Extensions/PCRE2.cmake
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# PCRE2
|
||||
option(FUN_WITH_PCRE2 "Enable PCRE2 (Perl Compatible Regular Expressions) support" OFF)
|
||||
set(PCRE2_INCLUDE_DIRS "")
|
||||
set(PCRE2_LINK_LIBS "")
|
||||
if(FUN_WITH_PCRE2)
|
||||
add_definitions(-DFUN_WITH_PCRE2)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PCRE2 QUIET libpcre2-8)
|
||||
endif()
|
||||
if(PCRE2_FOUND)
|
||||
list(APPEND PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIRS} ${PCRE2_INCLUDE_DIRS})
|
||||
list(APPEND PCRE2_LINK_LIBS ${PCRE2_LINK_LIBS} ${PCRE2_LIBRARIES})
|
||||
else()
|
||||
list(APPEND PCRE2_LINK_LIBS pcre2-8)
|
||||
endif()
|
||||
endif()
|
||||
13
cmake/Extensions/PCSC.cmake
Normal file
13
cmake/Extensions/PCSC.cmake
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# PCSC
|
||||
option(FUN_WITH_PCSC "Enable PCSC (pcsclite) support" OFF)
|
||||
set(PCSC_LINK_LIBS "")
|
||||
set(PCSC_INCLUDE_DIRS "")
|
||||
if(FUN_WITH_PCSC)
|
||||
add_definitions(-DFUN_WITH_PCSC)
|
||||
if(APPLE)
|
||||
list(APPEND PCSC_LINK_LIBS "-framework PCSC")
|
||||
else()
|
||||
list(APPEND PCSC_INCLUDE_DIRS "/usr/include/PCSC")
|
||||
list(APPEND PCSC_LINK_LIBS pcsclite)
|
||||
endif()
|
||||
endif()
|
||||
2
cmake/Extensions/REPL.cmake
Normal file
2
cmake/Extensions/REPL.cmake
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# REPL toggle (affects sources of the fun executable)
|
||||
option(FUN_WITH_REPL "Enable interactive REPL in the fun CLI" OFF)
|
||||
22
cmake/Extensions/SQLITE.cmake
Normal file
22
cmake/Extensions/SQLITE.cmake
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# SQLite
|
||||
option(FUN_WITH_SQLITE "Enable SQLite (sqlite3) support" OFF)
|
||||
set(SQLITE3_INCLUDE_DIRS "")
|
||||
set(SQLITE3_LINK_LIBS "")
|
||||
if(FUN_WITH_SQLITE)
|
||||
add_definitions(-DFUN_WITH_SQLITE)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(SQLITE3 QUIET sqlite3)
|
||||
endif()
|
||||
if(SQLITE3_FOUND)
|
||||
list(APPEND SQLITE3_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIRS} ${SQLITE3_INCLUDE_DIRS})
|
||||
list(APPEND SQLITE3_LINK_LIBS ${SQLITE3_LINK_LIBS} ${SQLITE3_LIBRARIES})
|
||||
else()
|
||||
find_library(SQLITE3_LIB sqlite3)
|
||||
if(SQLITE3_LIB)
|
||||
list(APPEND SQLITE3_LINK_LIBS ${SQLITE3_LIB})
|
||||
else()
|
||||
message(FATAL_ERROR "sqlite3 not found. Install sqlite3 (dev headers) or disable FUN_WITH_SQLITE.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
46
cmake/Extensions/TCLTK.cmake
Normal file
46
cmake/Extensions/TCLTK.cmake
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# Tcl/Tk GUI support
|
||||
option(FUN_WITH_TCLTK "Enable Tcl/Tk GUI support" OFF)
|
||||
set(TCL_INCLUDE_DIRS "")
|
||||
set(TCL_LINK_LIBS "")
|
||||
if(FUN_WITH_TCLTK)
|
||||
add_definitions(-DFUN_WITH_TCLTK)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(TCL QUIET tcl)
|
||||
pkg_check_modules(TK QUIET tk)
|
||||
endif()
|
||||
if(TCL_FOUND OR TK_FOUND)
|
||||
if(TCL_FOUND)
|
||||
list(APPEND TCL_INCLUDE_DIRS ${TCL_INCLUDE_DIRS} ${TCL_INCLUDE_DIRS})
|
||||
list(APPEND TCL_LINK_LIBS ${TCL_LINK_LIBS} ${TCL_LIBRARIES})
|
||||
endif()
|
||||
if(TK_FOUND)
|
||||
list(APPEND TCL_INCLUDE_DIRS ${TCL_INCLUDE_DIRS} ${TK_INCLUDE_DIRS})
|
||||
list(APPEND TCL_LINK_LIBS ${TCL_LINK_LIBS} ${TK_LIBRARIES})
|
||||
endif()
|
||||
else()
|
||||
find_path(TCL_INCLUDE_DIR tcl.h PATH_SUFFIXES tcl8.7 tcl8.6 include)
|
||||
find_library(TCL_LIB NAMES tcl8.7 tcl8.6 tcl)
|
||||
find_library(TK_LIB NAMES tk8.7 tk8.6 tk)
|
||||
if(TCL_INCLUDE_DIR)
|
||||
list(APPEND TCL_INCLUDE_DIRS ${TCL_INCLUDE_DIR})
|
||||
endif()
|
||||
if(TCL_LIB)
|
||||
list(APPEND TCL_LINK_LIBS ${TCL_LIB})
|
||||
endif()
|
||||
if(TK_LIB)
|
||||
list(APPEND TCL_LINK_LIBS ${TK_LIB})
|
||||
endif()
|
||||
if(APPLE)
|
||||
# macOS frameworks often unnecessary when using Homebrew tcl/tk
|
||||
elseif(WIN32)
|
||||
list(APPEND TCL_LINK_LIBS user32 gdi32 comctl32)
|
||||
else()
|
||||
find_package(X11 QUIET)
|
||||
if(X11_FOUND)
|
||||
list(APPEND TCL_INCLUDE_DIRS ${X11_INCLUDE_DIR})
|
||||
list(APPEND TCL_LINK_LIBS ${X11_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
25
cmake/Extensions/XML2.cmake
Normal file
25
cmake/Extensions/XML2.cmake
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# XML (libxml2)
|
||||
option(FUN_WITH_XML2 "Enable XML (libxml2) support" OFF)
|
||||
set(LIBXML2_INCLUDE_DIRS "")
|
||||
set(LIBXML2_LINK_LIBS "")
|
||||
if(FUN_WITH_XML2)
|
||||
add_definitions(-DFUN_WITH_XML2)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(LIBXML2 QUIET libxml-2.0)
|
||||
endif()
|
||||
if(LIBXML2_FOUND)
|
||||
list(APPEND LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS})
|
||||
list(APPEND LIBXML2_LINK_LIBS ${LIBXML2_LINK_LIBS} ${LIBXML2_LIBRARIES})
|
||||
else()
|
||||
find_library(LIBXML2_LIB NAMES xml2 libxml2)
|
||||
if(LIBXML2_LIB)
|
||||
list(APPEND LIBXML2_LINK_LIBS ${LIBXML2_LIB})
|
||||
if(EXISTS "/usr/include/libxml2")
|
||||
list(APPEND LIBXML2_INCLUDE_DIRS "/usr/include/libxml2")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "libxml2 not found. Install libxml2 (dev headers) or disable FUN_WITH_XML2.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
35
cmake/Options.cmake
Normal file
35
cmake/Options.cmake
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# Global options and defaults
|
||||
|
||||
# Convenience: default path to bundled stdlib
|
||||
set(FUN_LIB "${CMAKE_SOURCE_DIR}/lib" CACHE PATH "Path to bundled Fun stdlib")
|
||||
|
||||
# Optional: build using musl libc instead of glibc on Linux (OFF by default)
|
||||
option(FUN_USE_MUSL "Use musl libc toolchain when available (Linux only)" OFF)
|
||||
|
||||
# Platform-specific configuration (DEFAULT_LIB_DIR defaults, libc defines/toolchain tweaks)
|
||||
if(WIN32)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Platform/Windows.cmake)
|
||||
elseif(APPLE)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Platform/macOS.cmake)
|
||||
elseif(UNIX)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Platform/Linux.cmake)
|
||||
endif()
|
||||
|
||||
# If user provided DEFAULT_LIB_DIR, keep it; otherwise it should be set by platform include above
|
||||
set(DEFAULT_LIB_DIR "${DEFAULT_LIB_DIR}" CACHE PATH "Default library directory for Fun stdlib (override with -DDEFAULT_LIB_DIR=...)" FORCE)
|
||||
|
||||
# Ensure trailing slash for DEFAULT_LIB_DIR if it is defined
|
||||
if(DEFINED DEFAULT_LIB_DIR AND NOT DEFAULT_LIB_DIR STREQUAL "")
|
||||
if(NOT DEFAULT_LIB_DIR MATCHES "/$")
|
||||
set(DEFAULT_LIB_DIR "${DEFAULT_LIB_DIR}/")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Static linking is deprecated/unsupported: always build dynamically
|
||||
option(FUN_LINK_STATIC "(Deprecated) Attempt to link statically — ignored; dynamic linking is enforced" OFF)
|
||||
if(FUN_LINK_STATIC)
|
||||
message(WARNING "FUN_LINK_STATIC is deprecated and ignored. Building with dynamic linking.")
|
||||
endif()
|
||||
|
||||
# Debug option to enable verbose parser/VM logging
|
||||
option(FUN_DEBUG "Enable extra debug logging in Fun" OFF)
|
||||
24
cmake/Platform/Linux.cmake
Normal file
24
cmake/Platform/Linux.cmake
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Linux-specific configuration for Fun
|
||||
|
||||
# Default library directory (only set if not provided by user)
|
||||
if(NOT DEFINED DEFAULT_LIB_DIR OR DEFAULT_LIB_DIR STREQUAL "")
|
||||
set(DEFAULT_LIB_DIR "/usr/share/fun/lib" CACHE PATH "Default library directory for Fun stdlib (override with -DDEFAULT_LIB_DIR=...)" FORCE)
|
||||
endif()
|
||||
|
||||
# Handle musl toolchain selection when requested
|
||||
if(FUN_USE_MUSL)
|
||||
find_program(_FUN_MUSL_CC NAMES musl-gcc musl-clang)
|
||||
if(_FUN_MUSL_CC)
|
||||
message(STATUS "FUN_USE_MUSL=ON: using musl toolchain: ${_FUN_MUSL_CC}")
|
||||
set(CMAKE_C_COMPILER "${_FUN_MUSL_CC}" CACHE FILEPATH "C compiler" FORCE)
|
||||
set(FUN_LIBC "musl" CACHE STRING "Selected C library")
|
||||
add_compile_definitions(FUN_LIBC_MUSL)
|
||||
else()
|
||||
message(WARNING "FUN_USE_MUSL=ON but no musl toolchain (musl-gcc or musl-clang) found. Falling back to default compiler (likely glibc).")
|
||||
set(FUN_LIBC "glibc" CACHE STRING "Selected C library")
|
||||
add_compile_definitions(FUN_LIBC_GLIBC)
|
||||
endif()
|
||||
else()
|
||||
set(FUN_LIBC "glibc" CACHE STRING "Selected C library")
|
||||
add_compile_definitions(FUN_LIBC_GLIBC)
|
||||
endif()
|
||||
10
cmake/Platform/Windows.cmake
Normal file
10
cmake/Platform/Windows.cmake
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Windows-specific configuration for Fun
|
||||
|
||||
# Default library directory (only set if not provided by user)
|
||||
if(NOT DEFINED DEFAULT_LIB_DIR OR DEFAULT_LIB_DIR STREQUAL "")
|
||||
set(DEFAULT_LIB_DIR "C:/Users/Public/fun/lib" CACHE PATH "Default library directory for Fun stdlib (override with -DDEFAULT_LIB_DIR=...)" FORCE)
|
||||
endif()
|
||||
|
||||
# libc macro (non-musl path)
|
||||
set(FUN_LIBC "glibc" CACHE STRING "Selected C library")
|
||||
add_compile_definitions(FUN_LIBC_GLIBC)
|
||||
10
cmake/Platform/macOS.cmake
Normal file
10
cmake/Platform/macOS.cmake
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# macOS-specific configuration for Fun
|
||||
|
||||
# Default library directory (only set if not provided by user)
|
||||
if(NOT DEFINED DEFAULT_LIB_DIR OR DEFAULT_LIB_DIR STREQUAL "")
|
||||
set(DEFAULT_LIB_DIR "/Library/Application Support/fun/lib" CACHE PATH "Default library directory for Fun stdlib (override with -DDEFAULT_LIB_DIR=...)" FORCE)
|
||||
endif()
|
||||
|
||||
# libc macro (non-musl path)
|
||||
set(FUN_LIBC "glibc" CACHE STRING "Selected C library")
|
||||
add_compile_definitions(FUN_LIBC_GLIBC)
|
||||
130
cmake/Targets.cmake
Normal file
130
cmake/Targets.cmake
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
# Targets for Fun project (moved from src/CMakeLists.txt)
|
||||
|
||||
# Core VM/library sources
|
||||
add_library(fun_core
|
||||
${CMAKE_SOURCE_DIR}/src/bytecode.c
|
||||
${CMAKE_SOURCE_DIR}/src/parser.c
|
||||
${CMAKE_SOURCE_DIR}/src/value.c
|
||||
${CMAKE_SOURCE_DIR}/src/vm.c
|
||||
)
|
||||
|
||||
# NOTE: Do not compile src/vm/*/*.c as independent units.
|
||||
# Those files are meant to be included by src/vm.c inside a big switch.
|
||||
|
||||
target_include_directories(fun_core PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
# Apply options to core
|
||||
if(FUN_DEBUG)
|
||||
message(STATUS "FUN_DEBUG enabled: building with verbose debug logging")
|
||||
target_compile_definitions(fun_core PUBLIC FUN_VERSION="${PROJECT_VERSION}")
|
||||
target_compile_definitions(fun_core PUBLIC FUN_DEBUG=1)
|
||||
endif()
|
||||
|
||||
# Provide default stdlib directory and version to the runtime
|
||||
target_compile_definitions(fun_core PUBLIC FUN_VERSION="${PROJECT_VERSION}")
|
||||
target_compile_definitions(fun_core PUBLIC DEFAULT_LIB_DIR="${DEFAULT_LIB_DIR}")
|
||||
|
||||
# Apply extension include/link variables discovered in cmake/Extensions
|
||||
foreach(var_pair
|
||||
PCSC
|
||||
JSONC
|
||||
PCRE2
|
||||
CURL
|
||||
SQLITE3
|
||||
INIPARSER
|
||||
LIBSQL
|
||||
LIBXML2
|
||||
TCL
|
||||
NOTCURSES)
|
||||
if(${var_pair}_INCLUDE_DIRS)
|
||||
target_include_directories(fun_core PRIVATE ${${var_pair}_INCLUDE_DIRS})
|
||||
endif()
|
||||
if(${var_pair}_LINK_LIBS)
|
||||
target_link_libraries(fun_core PUBLIC ${${var_pair}_LINK_LIBS})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Ensure feature compile definitions are applied to fun_core so
|
||||
# conditional code blocks (#ifdef FUN_WITH_*) are compiled as expected.
|
||||
|
||||
# Feature-specific sources and compile definitions
|
||||
if(FUN_WITH_PCSC)
|
||||
target_compile_definitions(fun_core PUBLIC FUN_WITH_PCSC=1)
|
||||
endif()
|
||||
|
||||
if(FUN_WITH_JSON)
|
||||
target_compile_definitions(fun_core PUBLIC FUN_WITH_JSON=1)
|
||||
endif()
|
||||
|
||||
if(FUN_WITH_INI)
|
||||
target_compile_definitions(fun_core PUBLIC FUN_WITH_INI=1)
|
||||
endif()
|
||||
|
||||
if(FUN_WITH_XML2)
|
||||
target_compile_definitions(fun_core PUBLIC FUN_WITH_XML2=1)
|
||||
endif()
|
||||
|
||||
if(FUN_WITH_LIBSQL)
|
||||
target_compile_definitions(fun_core PUBLIC FUN_WITH_LIBSQL=1)
|
||||
endif()
|
||||
|
||||
if(FUN_WITH_PCRE2)
|
||||
target_compile_definitions(fun_core PUBLIC FUN_WITH_PCRE2=1)
|
||||
endif()
|
||||
|
||||
if(FUN_WITH_CURL)
|
||||
target_compile_definitions(fun_core PUBLIC FUN_WITH_CURL=1)
|
||||
endif()
|
||||
|
||||
if(FUN_WITH_NOTCURSES)
|
||||
target_compile_definitions(fun_core PUBLIC FUN_WITH_NOTCURSES=1)
|
||||
endif()
|
||||
|
||||
if(FUN_WITH_SQLITE)
|
||||
target_compile_definitions(fun_core PUBLIC FUN_WITH_SQLITE=1)
|
||||
endif()
|
||||
|
||||
if(FUN_WITH_TCLTK)
|
||||
target_compile_definitions(fun_core PUBLIC FUN_WITH_TCLTK=1)
|
||||
endif()
|
||||
|
||||
# Special case for libxml2 system include path if enabled
|
||||
if(FUN_WITH_XML2)
|
||||
if(EXISTS "/usr/include/libxml2")
|
||||
target_include_directories(fun_core PRIVATE "/usr/include/libxml2")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Link threads if available on UNIX
|
||||
if(Threads_FOUND)
|
||||
target_link_libraries(fun_core PUBLIC Threads::Threads)
|
||||
endif()
|
||||
|
||||
# Link libm for C99 math functions if available
|
||||
find_library(M_LIB m)
|
||||
if(M_LIB)
|
||||
target_link_libraries(fun_core PUBLIC ${M_LIB})
|
||||
endif()
|
||||
|
||||
# Executable: fun (CLI)
|
||||
add_executable(fun
|
||||
${CMAKE_SOURCE_DIR}/src/fun.c
|
||||
)
|
||||
if(FUN_WITH_REPL)
|
||||
target_compile_definitions(fun PRIVATE FUN_WITH_REPL=1)
|
||||
target_sources(fun PRIVATE ${CMAKE_SOURCE_DIR}/src/repl.c)
|
||||
endif()
|
||||
target_link_libraries(fun PRIVATE fun_core)
|
||||
|
||||
# Internal test programs
|
||||
add_executable(fun_test
|
||||
${CMAKE_SOURCE_DIR}/src/fun_test.c)
|
||||
target_link_libraries(fun_test PRIVATE fun_core)
|
||||
|
||||
add_executable(test_opcodes
|
||||
${CMAKE_SOURCE_DIR}/src/test_opcodes.c)
|
||||
target_link_libraries(test_opcodes PRIVATE fun_core)
|
||||
|
||||
# Static linking flags are intentionally not applied (deprecated behavior)
|
||||
Loading…
Add table
Add a link
Reference in a new issue