mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
link against LLVM
This commit is contained in:
parent
8e08cf4bec
commit
50f0ed918c
6 changed files with 78 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
build/
|
||||||
41
CMakeLists.txt
Normal file
41
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
|
||||||
|
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
||||||
|
|
||||||
|
project(zig C)
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
|
set(ZIG_VERSION_MAJOR 1)
|
||||||
|
set(ZIG_VERSION_MINOR 0)
|
||||||
|
set(ZIG_VERSION_PATCH 0)
|
||||||
|
set(ZIG_VERSION "${ZIG_VERSION_MAJOR}.${ZIG_VERSION_MINOR}.${ZIG_VERSION_PATCH}")
|
||||||
|
message("Configuring zig version ${ZIG_VERSION}")
|
||||||
|
|
||||||
|
find_package(llvm)
|
||||||
|
include_directories(${LLVM_INCLUDE_DIR})
|
||||||
|
|
||||||
|
set(ZIG_SOURCES
|
||||||
|
"${CMAKE_SOURCE_DIR}/src/main.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CONFIGURE_OUT_FILE "${CMAKE_BINARY_DIR}/config.h")
|
||||||
|
configure_file (
|
||||||
|
"${CMAKE_SOURCE_DIR}/src/config.h.in"
|
||||||
|
${CONFIGURE_OUT_FILE}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-unused-variable -Wno-unused-but-set-variable")
|
||||||
|
|
||||||
|
set(EXE_CFLAGS "-std=c11 -Werror -Wall -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes")
|
||||||
|
set(TEST_CFLAGS "-std=c99 -Werror -Wall")
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(zig ${ZIG_SOURCES})
|
||||||
|
set_target_properties(zig PROPERTIES
|
||||||
|
LINKER_LANGUAGE C
|
||||||
|
COMPILE_FLAGS ${EXE_CFLAGS})
|
||||||
|
target_link_libraries(zig LINK_PUBLIC
|
||||||
|
${LLVM_LIBRARIES}
|
||||||
|
)
|
||||||
|
install(TARGETS zig DESTINATION bin)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
# zig lang
|
||||||
21
cmake/Findllvm.cmake
Normal file
21
cmake/Findllvm.cmake
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Copyright (c) 2014 Andrew Kelley
|
||||||
|
# This file is MIT licensed.
|
||||||
|
# See http://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# LLVM_FOUND
|
||||||
|
# LLVM_INCLUDE_DIR
|
||||||
|
# LLVM_LIBRARIES
|
||||||
|
|
||||||
|
find_path(LLVM_INCLUDE_DIR NAMES llvm-c/Core.h)
|
||||||
|
|
||||||
|
find_program(LLVM_CONFIG_EXE llvm-config)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${LLVM_CONFIG_EXE} --libs
|
||||||
|
OUTPUT_VARIABLE LLVM_LIBRARIES
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(LLVM DEFAULT_MSG LLVM_LIBRARIES LLVM_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced(LLVM_INCLUDE_DIR LLVM_LIBRARIES)
|
||||||
9
src/config.h.in
Normal file
9
src/config.h.in
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef ZIG_CONFIG_H
|
||||||
|
#define ZIG_CONFIG_H
|
||||||
|
|
||||||
|
#define ZIG_VERSION_MAJOR @ZIG_VERSION_MAJOR@
|
||||||
|
#define ZIG_VERSION_MINOR @ZIG_VERSION_MINOR@
|
||||||
|
#define ZIG_VERSION_PATCH @ZIG_VERSION_PATCH@
|
||||||
|
#define ZIG_VERSION_STRING "@ZIG_VERSION@"
|
||||||
|
|
||||||
|
#endif
|
||||||
5
src/main.c
Normal file
5
src/main.c
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue