forked from ooc-lang/greg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
33 lines (26 loc) · 949 Bytes
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
cmake_minimum_required(VERSION 2.8)
if(POLICY CMP0026)
cmake_policy(SET CMP0026 OLD) # allow LOCATION usage
endif(POLICY CMP0026)
project(greg)
set(sources greg.c compile.c tree.c)
if (NOT MSVC)
add_definitions(-g -Wall -O3 -DNDEBUG)
else()
add_subdirectory(wingetopt)
include_directories(${CMAKE_CURRENT_LIST_DIR}/wingetopt/src)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
# build as C++ for MSVC because C99 require VS2013+.
set_source_files_properties(${sources} PROPERTIES LANGUAGE CXX)
endif()
add_executable(greg ${sources})
if (MSVC)
target_link_libraries(greg wingetopt)
endif()
# grammar
get_target_property(greg_loc greg LOCATION)
set(greg_c "${CMAKE_CURRENT_LIST_DIR}/greg.c")
set(greg_g "${CMAKE_CURRENT_LIST_DIR}/greg.g")
add_custom_target(grammar COMMAND ${greg_loc} -o ${greg_c} ${greg_g})
# install
install(TARGETS greg RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)