2015-08-05 22:23:15 +00:00
|
|
|
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)
|
|
|
|
|
2015-08-05 23:22:21 +00:00
|
|
|
project(zig C CXX)
|
2015-08-05 22:23:15 +00:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
|
|
|
|
2015-08-05 22:46:40 +00:00
|
|
|
set(ZIG_VERSION_MAJOR 0)
|
2015-08-05 22:23:15 +00:00
|
|
|
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})
|
|
|
|
|
2015-08-05 22:46:40 +00:00
|
|
|
include_directories(
|
|
|
|
${CMAKE_SOURCE_DIR}
|
|
|
|
${CMAKE_BINARY_DIR}
|
|
|
|
)
|
|
|
|
|
2015-11-04 05:31:27 +00:00
|
|
|
set(GRAMMAR_TXT "${CMAKE_BINARY_DIR}/simple.txt")
|
|
|
|
|
2015-08-05 22:23:15 +00:00
|
|
|
set(ZIG_SOURCES
|
2015-08-06 04:47:08 +00:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/buffer.cpp"
|
2015-11-05 07:05:25 +00:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/error.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/main.cpp"
|
2015-11-05 00:15:46 +00:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/parser.cpp"
|
2015-11-05 07:05:25 +00:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/tokenizer.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/util.cpp"
|
2015-11-24 05:47:25 +00:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/codegen.cpp"
|
2015-11-24 20:00:38 +00:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/zig_llvm.cpp"
|
2015-11-24 20:51:36 +00:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/os.cpp"
|
2015-08-05 22:23:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
2015-08-05 23:22:21 +00:00
|
|
|
set(EXE_CFLAGS "-std=c++11 -Werror -Wall -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes")
|
2015-08-05 22:23:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
2015-11-04 05:31:27 +00:00
|
|
|
|