-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
140 lines (118 loc) · 5.32 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
cmake_minimum_required(VERSION 3.1.0)
project (ice_script)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Custom options
#option(ICESCRIPT_BUILD_AS_LIBRARY "ICESCRIPT_BUILD_AS_LIBRARY" FALSE)
option(ICESCRIPT_BUILD_TESTS "ICESCRIPT_BUILD_TESTS" FALSE)
option(ICESCRIPT_BUILD_BENCHMARKS "ICESCRIPT_BUILD_BENCHMARKS" FALSE)
option(ICESCRIPT_ENABLE_DEBUG_LOGGING "ICESCRIPT_ENABLE_DEBUG_LOGGING" FALSE)
option(ICESCRIPT_ENABLE_TRACE_LOGGING "ICESCRIPT_ENABLE_TRACE_LOGGING" FALSE)
# Dependencies
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED)
find_package(range-v3 REQUIRED)
if(MSVC)
# find_package(llvm-core REQUIRED)
find_package(LLVM REQUIRED)
else()
find_package(LLVM REQUIRED)
endif()
if(UNIX AND NOT APPLE)
# find_package(X11 REQUIRED)
find_package(Threads REQUIRED)
elseif(APPLE)
find_library(QUARTZCORE_LIBRARY QuartzCore REQUIRED)
find_library(METAL_LIBRARY Metal REQUIRED)
find_library(APPKIT_LIBRARY AppKit REQUIRED)
find_library(APPSERV_LIBRARY ApplicationServices REQUIRED)
find_library(CARBON_LIBRARY Carbon REQUIRED)
find_library(COREAUDIO_LIBRARY CoreAudio REQUIRED)
find_library(FORCEFEEDBACK_LIBRARY ForceFeedback REQUIRED)
find_library(IOK_LIBRARY IOKit REQUIRED)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox REQUIRED)
find_library(ICONV_LIBRARY iconv REQUIRED)
endif()
# Set our runtime library locations
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN")
if(APPLE)
set(CMAKE_INSTALL_RPATH "./")
set(CMAKE_MACOSX_RPATH ON)
endif()
# Source
file(GLOB_RECURSE SOURCES "src/*.cpp")
# Generate library
#if(ICESCRIPT_BUILD_AS_LIBRARY)
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/Main.cpp")
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
# add_library(ice_script SHARED ${SOURCES})
add_library(ice_script OBJECT ${SOURCES})
#else()
# add_executable(ice_script ${SOURCES})
#endif()
# Headers
target_include_directories(ice_script PUBLIC include)
#target_include_directories(ice_script PUBLIC ${LLVM_INCLUDE_DIRS})
#separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
#target_compile_definitions(ice_script PUBLIC ${LLVM_DEFINITIONS})
target_compile_options(ice_script PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/EHsc>)
target_compile_options(ice_script PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/MP16>)
target_compile_options(ice_script PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/bigobj>)
target_compile_options(ice_script PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/Od>)
#target_compile_options(ice_script PRIVATE $<$<AND:$<CONFIG:DEBUG>,$<CXX_COMPILER_ID:MSVC>>: /bigobj>)
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo OR ICESCRIPT_ENABLE_DEBUG_LOGGING)
target_compile_definitions(ice_script PRIVATE -D ICESCRIPT_ENABLE_DEBUG_LOGGING=1)
endif()
if(ICESCRIPT_ENABLE_TRACE_LOGGING)
target_compile_definitions(ice_script PRIVATE -D ICESCRIPT_ENABLE_TRACE_LOGGING=1)
endif()
target_precompile_headers(ice_script PRIVATE include/pch.hpp)
#llvm_map_components_to_libnames(llvm_libs support core irreader)
target_link_libraries(ice_script PUBLIC Boost::system)
target_link_libraries(ice_script PUBLIC Boost::chrono)
target_link_libraries(ice_script PUBLIC Boost::atomic)
target_link_libraries(ice_script PUBLIC Boost::thread)
target_link_libraries(ice_script PUBLIC Boost::program_options)
target_link_libraries(ice_script PUBLIC Boost::filesystem)
target_link_libraries(ice_script PUBLIC Boost::log)
target_link_libraries(ice_script PUBLIC Boost::log_setup)
target_link_libraries(ice_script PUBLIC Boost::date_time)
target_link_libraries(ice_script PUBLIC Boost::regex)
target_link_libraries(ice_script PUBLIC Boost::serialization)
target_link_libraries(ice_script PUBLIC Boost::wave)
target_link_libraries(ice_script PUBLIC range-v3::range-v3)
target_link_libraries(ice_script PUBLIC llvm-core::interpreter)
target_link_libraries(ice_script PUBLIC llvm-core::orcjit)
target_link_libraries(ice_script PUBLIC llvm-core::x86asmparser)
target_link_libraries(ice_script PUBLIC llvm-core::x86codegen)
target_link_libraries(ice_script PUBLIC llvm-core::core)
target_link_libraries(ice_script PUBLIC llvm-core::support)
target_link_libraries(ice_script PUBLIC llvm-core::core)
target_link_libraries(ice_script PUBLIC llvm-core::irreader)
if(APPLE)
target_link_libraries(ice_script PUBLIC ${QUARTZCORE_LIBRARY})
target_link_libraries(ice_script PUBLIC ${METAL_LIBRARY})
target_link_libraries(ice_script PUBLIC ${APPKIT_LIBRARY})
target_link_libraries(ice_script PUBLIC ${APPSERV_LIBRARY})
target_link_libraries(ice_script PUBLIC ${CARBON_LIBRARY})
target_link_libraries(ice_script PUBLIC ${COREAUDIO_LIBRARY})
target_link_libraries(ice_script PUBLIC ${FORCEFEEDBACK_LIBRARY})
target_link_libraries(ice_script PUBLIC ${IOK_LIBRARY})
target_link_libraries(ice_script PUBLIC ${AUDIOTOOLBOX_LIBRARY})
target_link_libraries(ice_script PUBLIC ${ICONV_LIBRARY})
endif()
if (ICESCRIPT_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
if (ICESCRIPT_BUILD_BENCHMARKS)
enable_testing()
add_subdirectory(benchmarks)
endif()
# Disable Position Independent Executable - this is starting to be enabled by default,
# which is causing issues
#target_link_libraries(test PUBLIC $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: -no-pie>)
# Set install dir
install(TARGETS ice_script DESTINATION /usr/lib)