forked from fabianishere/brainfuck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
49 lines (41 loc) · 1.79 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
cmake_minimum_required(VERSION 2.6)
project(brainfuck C)
set(brainfuck_VERSION_MAJOR 2)
set(brainfuck_VERSION_MINOR 7)
set(brainfuck_VERSION_PATCH 1)
option(ENABLE_DEBUG "Enable the debug extension for brainfuck.")
option(BUILD_SHARED_LIB "Build a shared library.")
option(INSTALL_EXAMPLES "Install the examples in $CMAKE_INSTALL_PREFIX/share/brainfuck.")
option(BUILD_STATIC_LIB "Build a static library." ON)
option(ENABLE_EDITLINE "Enable GNU readline functionality provided by the editline library." ON)
include_directories(include/)
add_definitions("-Wall -Wextra -O2 -std=c89")
add_executable(brainfuck src/main.c src/brainfuck.c)
install(TARGETS brainfuck RUNTIME DESTINATION bin)
install(FILES include/brainfuck.h DESTINATION "include")
install(FILES man/brainfuck.1 DESTINATION "share/man/man1")
if(INSTALL_EXAMPLES)
set(examples_dir "share/brainfuck")
file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${examples_dir})
install(DIRECTORY examples DESTINATION ${examples_dir})
endif()
if(ENABLE_EDITLINE)
add_definitions("-DBRAINFUCK_EDITLINE_LIB")
target_link_libraries(brainfuck -ledit)
endif()
if(ENABLE_DEBUG)
add_definitions("-DBRAINFUCK_EXTENSION_DEBUG")
endif()
if(BUILD_STATIC_LIB)
add_library(libbrainfuck_static STATIC src/brainfuck.c)
set_target_properties(libbrainfuck_static PROPERTIES PREFIX "")
set_target_properties(libbrainfuck_static PROPERTIES OUTPUT_NAME "libbrainfuck")
target_link_libraries(brainfuck libbrainfuck_static)
install(TARGETS libbrainfuck_static ARCHIVE DESTINATION lib)
endif()
if(BUILD_SHARED_LIB)
add_library(libbrainfuck_shared SHARED src/brainfuck.c)
set_target_properties(libbrainfuck_shared PROPERTIES PREFIX "")
set_target_properties(libbrainfuck_shared PROPERTIES OUTPUT_NAME "libbrainfuck")
install(TARGETS libbrainfuck_shared LIBRARY DESTINATION lib)
endif()