forked from starseeker/tinyscheme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
150 lines (130 loc) · 4.84 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# This file contains the top level CMakeLists.txt logic for the
# TinyScheme software package.
# Minimum required version of CMake
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
if(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0003 NEW)
CMAKE_POLICY(SET CMP0007 OLD)
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}
VERSION_GREATER 2.8.3)
CMAKE_POLICY(SET CMP0017 OLD)
endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}
VERSION_GREATER 2.8.3)
endif(COMMAND CMAKE_POLICY)
# Project name
project(TINYSCHEME)
# Version information
set(TINYSCHEME_VERSION 1.41)
#---------------------------------------------------------------------
# Features
# convenience macro
macro(TS_OPT define default helpstring)
if(NOT DEFINED ENABLE_${define})
set(ENABLE_${define} ${default})
endif(NOT DEFINED ENABLE_${define})
if(ENABLE_${define})
add_definitions(-DUSE_${define}=1)
endif(ENABLE_${define})
set(ENABLE_${define} ${ENABLE_${define}} CACHE BOOL "${helpstring}")
endmacro(TS_OPT)
# Enables dynamically loaded routines. If you define this symbol,
# need to add dynload.c in your compile.
if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif(NOT DEFINED BUILD_SHARED_LIBS)
if(BUILD_SHARED_LIBS)
add_definitions(-DUSE_DL=1)
endif(BUILD_SHARED_LIBS)
if(NOT DEFINED ENABLE_STANDALONE)
set(ENABLE_STANDALONE OFF)
endif(NOT DEFINED ENABLE_STANDALONE)
if(ENABLE_STANDALONE)
add_definitions(-DSTANDALONE=1)
else(ENABLE_STANDALONE)
add_definitions(-DSTANDALONE=0)
endif(ENABLE_STANDALONE)
set(ENABLE_STANDALONE ${ENABLE_STANDALONE} CACHE BOOL "Define this to produce a standalone interpreter.")
TS_OPT(MATH ON "Includes math routines.")
TS_OPT(CHAR_CLASSIFIERS ON "Includes character classifier procedures.")
TS_OPT(ASCII_NAMES ON "Enable extended character notation based on ASCII names.")
TS_OPT(STRING_PORTS ON "Enables string ports.")
TS_OPT(ERROR_HOOK OFF "Force system errors through user-defined error handling.")
TS_OPT(TRACING OFF "Enable the use of TRACING.")
TS_OPT(COLON_HOOK OFF "Enable use of qualified identifiers.")
TS_OPT(PLIST OFF "Enables property lists.")
TS_OPT(STRCASECMP OFF "Defines stricmp as strcasecmp, for Unix.")
TS_OPT(SCHEME_STACK OFF "Enables 'cons' stack.")
if(NOT DEFINED ENABLE_TINYSCHEME_REPL)
set(ENABLE_TINYSCHEME_REPL ON CACHE BOOL "Build scheme REPL application." )
else(NOT DEFINED ENABLE_TINYSCHEME_REPL)
set(ENABLE_TINYSCHEME_REPL ${ENABLE_TINYSCHEME_REPL} CACHE BOOL "Build scheme REPL application." )
endif(NOT DEFINED ENABLE_TINYSCHEME_REPL)
if(WIN32)
# Informs TinyScheme that stdio translates "\n" to "\r\n".
add_definitions(-DSTDIO_ADDS_CR=1)
endif(WIN32)
if(CYGWIN)
add_definitions(-DUSE_STRLWR=0)
endif(CYGWIN)
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS(m cos "" HAVE_M_LIBRARY)
if(HAVE_M_LIBRARY)
set(SYS_LIBS ${SYS_LIBS} m)
endif(HAVE_M_LIBRARY)
CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_STD_DLOPEN)
IF(HAVE_STD_DLOPEN)
set(SYS_LIBS ${SYS_LIBS} dl)
ELSE(HAVE_STD_DLOPEN)
CHECK_LIBRARY_EXISTS(c dlopen "" HAVE_C_DLOPEN)
IF(HAVE_C_DLOPEN)
set(SYS_LIBS ${SYS_LIBS} c)
ENDIF(HAVE_C_DLOPEN)
ENDIF(HAVE_STD_DLOPEN)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
# Rather than load the init.scm file at run time,
# with the uncertainties as to where exactly the file
# resides, use William Ahern's hexdump to generate
# an embeddable version. Build our own copy of hexdump
# to ensure consistent behavior and portability.
# See http://25thandclement.com/~william/projects/hexdump.c.html
add_executable(initfiletohex hexdump.c)
set_property(TARGET initfiletohex APPEND PROPERTY COMPILE_DEFINITIONS "HEXDUMP_MAIN")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/init_scm.h
COMMAND initfiletohex -i ${CMAKE_CURRENT_SOURCE_DIR}/init.scm > ${CMAKE_CURRENT_BINARY_DIR}/init_scm.h
DEPENDS initfiletohex ${CMAKE_CURRENT_SOURCE_DIR}/init.scm
)
add_custom_target(init_hdr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/init_scm.h)
if(BUILD_SHARED_LIBS)
set(tinyscheme_srcs scheme.c dynload.c)
add_library(tinyscheme SHARED ${tinyscheme_srcs})
if(SYS_LIBS)
target_link_libraries(tinyscheme ${SYS_LIBS})
endif(SYS_LIBS)
add_dependencies(tinyscheme init_hdr)
endif(BUILD_SHARED_LIBS)
if(BUILD_STATIC_LIBS)
add_library(tinyscheme-static STATIC scheme.c)
if(NOT MSVC)
set_target_properties(tinyscheme-static PROPERTIES OUTPUT_NAME "tinyscheme")
endif(NOT MSVC)
add_dependencies(tinyscheme-static init_hdr)
endif(BUILD_STATIC_LIBS)
if(ENABLE_TINYSCHEME_REPL)
add_executable(scheme ${tinyscheme_srcs})
if(SYS_LIBS)
target_link_libraries(scheme ${SYS_LIBS})
endif(SYS_LIBS)
add_dependencies(scheme init_hdr)
endif(ENABLE_TINYSCHEME_REPL)
mark_as_advanced(EXECUTABLE_OUTPUT_PATH)
mark_as_advanced(LIBRARY_OUTPUT_PATH)
# Local Variables:
# tab-width: 8
# mode: cmake
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8