-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
120 lines (105 loc) · 3.59 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
cmake_minimum_required(VERSION 3.11)
project (Wren
VERSION 0.4.0
DESCRIPTION "Wren: A small, fast, class-based concurrent scripting language"
HOMEPAGE_URL "https://github.com/wren-lang/wren"
LANGUAGES C
)
# Options
option(WREN_META "Wren Meta Class" ON)
option(WREN_RANDOM "Wren Random Class" ON)
option(WREN_BUILD_STATIC "Wren Static Library" ON)
option(WREN_BUILD_SHARED "Wren Shared Library" OFF)
option(WREN_BUILD_TEST "Build Wren Tests" OFF)
# Source Files
message(STATUS ${CMAKE_CURRENT_SOURCE_DIR})
set(WREN_SRC ${SRC_DIR}/src)
file(GLOB WREN_SRC_VM_FILES ${WREN_SRC}/vm/*.c)
file(GLOB WREN_SRC_OPTIONAL_FILES ${WREN_SRC}/optional/*.c)
set(WREN_SRC_FILES ${WREN_SRC_VM_FILES} ${WREN_SRC_OPTIONAL_FILES})
set(WREN_INCLUDE_DIRS
${WREN_SRC}/include
${WREN_SRC}/optional
${WREN_SRC}/vm
)
set(WREN_HEADERS
${WREN_SRC}/include/wren.h
${WREN_SRC}/include/wren.hpp
)
# Defines
set(WREN_DEFINES WREN_API_DLLEXPORT)
if (WREN_META)
list(APPEND WREN_DEFINES WREN_OPT_META)
endif()
if (WREN_RANDOM)
list(APPEND WREN_DEFINES WREN_OPT_RANDOM)
endif()
set(WREN_TARGETS "")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=generic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic")
endif()
# Wren Libraries
if (WREN_BUILD_STATIC)
if (CMAKE_HOST_WIN32)
SET(OUTPUT_NAME "wren-static")
else()
SET(OUTPUT_NAME "wren")
endif()
add_library(wren-static STATIC ${WREN_SRC_FILES})
target_include_directories(wren-static PUBLIC ${WREN_INCLUDE_DIRS})
target_compile_definitions(wren-static PUBLIC ${WREN_DEFINES})
set_target_properties(wren-static PROPERTIES
PUBLIC_HEADER "${WREN_HEADERS}"
PREFIX ""
VERSION "0.4.0"
SOVERSION "0"
OUTPUT_NAME "lib${OUTPUT_NAME}")
list(APPEND WREN_TARGETS wren-static)
# if (APPLE)
# set_target_properties(wren-static PROPERTIES
# MACOSX_RPATH ON
# )
# else ()
# set_target_properties(wren-static PROPERTIES
# BUILD_WITH_INSTALL_RPATH 1
# SKIP_BUILD_RPATH FALSE
# )
# endif ()
# set_target_properties(wren-static PROPERTIES
# INSTALL_RPATH_USE_LINK_PATH TRUE
# )
endif()
if (WREN_BUILD_SHARED)
add_library(wren SHARED ${WREN_SRC_FILES})
target_include_directories(wren PUBLIC ${WREN_INCLUDE_DIRS})
target_compile_definitions(wren PUBLIC ${WREN_DEFINES})
set_target_properties(wren PROPERTIES
PUBLIC_HEADER "${WREN_HEADERS}"
PREFIX ""
VERSION "0.4.0"
SOVERSION "0"
OUTPUT_NAME "libwren")
list(APPEND WREN_TARGETS wren)
if (APPLE)
set_target_properties(wren PROPERTIES
MACOSX_RPATH ON
)
else ()
set_target_properties(wren PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
SKIP_BUILD_RPATH FALSE
)
endif ()
set_target_properties(wren PROPERTIES
INSTALL_RPATH_USE_LINK_PATH TRUE
)
endif()
MESSAGE(STATUS "HEADERS " ${WREN_HEADERS})
include(GNUInstallDirs)
install(TARGETS ${WREN_TARGETS}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})