aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-16 07:54:06 +0000
committer_ov4 <ov4@ov4.org>2026-10-16 07:54:06 +0000
commit9226e87baacece10ea4971a9588d46e30cc23492 (patch)
treefe2729d2bf6c07366e71a6d39421ff05b239b713 /CMakeLists.txt
parentc4565386553ea86308a9487650d2435804893ed0 (diff)
feat(driver): embed native compilation and link resources
Link LLVM, the Clang driver and LLD statically, and embed native link inputs so executable generation needs no installed development toolchain. Keep glibc dynamically linked on Linux. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt26
1 files changed, 14 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 76b76a7..f875856 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,38 +65,40 @@ add_library(CPSCodeGen STATIC
lib/CodeGen/FileHandler.cc
)
-llvm_map_components_to_libnames(llvm_libs core support)
+llvm_map_components_to_libnames(llvm_libs core support native passes)
if(CPSC_RUN_MODE STREQUAL "EMBEDDED")
- llvm_map_components_to_libnames(llvm_libs core support native mcjit)
+ llvm_map_components_to_libnames(llvm_libs core support native passes mcjit)
foreach(llvm_lib IN LISTS llvm_libs)
get_target_property(llvm_type ${llvm_lib} TYPE)
if(NOT llvm_type STREQUAL "STATIC_LIBRARY")
message(FATAL_ERROR "EMBEDDED requires static LLVM libraries: ${llvm_lib}")
endif()
endforeach()
- include(cmake/EmbeddedLLVM.cmake)
endif()
+include(cmake/EmbeddedLLVM.cmake)
add_executable(cpsc tools/driver/main.cc)
target_compile_definitions(cpsc PRIVATE CPSC_RUN_${CPSC_RUN_MODE})
if(CPSC_RUN_MODE STREQUAL "EMBEDDED")
target_sources(cpsc PRIVATE tools/driver/EmbeddedRunner.cc)
- if(MINGW)
- target_link_options(cpsc PRIVATE -static)
- elseif(APPLE)
- # LLVM's support interface can include unused Homebrew dylibs such as Z3.
- target_link_options(cpsc PRIVATE -Wl,-dead_strip_dylibs)
- elseif(UNIX AND NOT APPLE)
- target_link_options(cpsc PRIVATE -static-libstdc++ -static-libgcc -Wl,--as-needed)
- endif()
endif()
-target_link_libraries(cpsc
+if(MINGW)
+ target_link_options(cpsc PRIVATE -static)
+elseif(APPLE)
+ # LLVM's support interface can include unused Homebrew dylibs such as Z3.
+ target_link_options(cpsc PRIVATE -Wl,-dead_strip_dylibs)
+elseif(UNIX AND NOT APPLE)
+ target_link_options(cpsc PRIVATE -static-libstdc++ -static-libgcc -Wl,--as-needed)
+endif()
+target_link_libraries(cpsc PRIVATE
CPSCodeGen
CPSParser
CPSLexer
${llvm_libs}
)
+include(cmake/NativeCompiler.cmake)
+
include(cmake/Manual.cmake)
configure_file(cmake/Install.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/Install.cmake" @ONLY)