-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
186 lines (136 loc) · 4.19 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
cmake_minimum_required(VERSION 3.12)
#[=======================================================================[.rst:
Build jluna
-----------
This cmake attempts to automatically detect the Julia image.
If this is not possible, manually specify the path to the Julia binary using:
``-DJULIA_BINDIR=/path/to/.../julia/bin``
If you are unsure of the location of this folder, you can access
it from within the REPL using:
``println(Sys.BINDIR)``
Options
^^^^^^^
``jluna_DEVELOPER_MODE``
enable building test and benchmark executables. Off by default
``BUILD_TESTING``
build jluna_test, as CTest. On by default
``BUILD_BENCHMARK``
build jluna_benchmark. Off by default
#]=======================================================================]
project(jluna VERSION 1.0.0 LANGUAGES CXX)
include(cmake/project-is-top-level.cmake)
if(PROJECT_IS_TOP_LEVEL)
option(jluna_DEVELOPER_MODE "Enable developer mode" OFF)
endif()
### Find Julia ###
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/find")
find_package(Julia 1.7.0 REQUIRED)
### Find Threads ###
find_package(Threads)
### Configure Files ###
set(SHARED_LIBRARY_NAME "${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX}jluna${CMAKE_SHARED_LIBRARY_SUFFIX}")
# c.f. .src/include_julia.inl.in
file(READ include/julia/jluna_01.jl JLUNA_01)
file(READ include/julia/jluna_02.jl JLUNA_02)
file(READ include/julia/jluna_03.jl JLUNA_03)
file(READ include/julia/jluna_04.jl JLUNA_04)
file(READ include/julia/jluna_05.jl JLUNA_05)
file(READ include/julia/jluna_06.jl JLUNA_06)
configure_file("${CMAKE_SOURCE_DIR}/.src/include_julia.inl.in" "${CMAKE_SOURCE_DIR}/.src/include_julia.inl" @ONLY)
### Declare Library ###
add_library(jluna SHARED
jluna.hpp
include/exceptions.hpp
.src/exceptions.cpp
include/typedefs.hpp
.src/typedefs.inl
include/unsafe_utilities.hpp
.src/unsafe_utilities.inl
.src/unsafe_utilities.cpp
include/safe_utilities.hpp
.src/safe_utilities.inl
.src/safe_utilities.cpp
include/concepts.hpp
include/box.hpp
.src/box.inl
include/unbox.hpp
.src/unbox.inl
include/proxy.hpp
.src/proxy.cpp
.src/proxy.inl
include/array.hpp
.src/array.inl
.src/array_iterator.inl
include/cppcall.hpp
.src/cppcall.inl
include/module.hpp
.src/module.cpp
.src/module.inl
include/symbol.hpp
.src/symbol.cpp
.src/symbol.inl
include/type.hpp
.src/type.cpp
.src/type.inl
include/generator_expression.hpp
.src/generator_expression.cpp
include/usertype.hpp
.src/usertype.inl
include/multi_threading.hpp
.src/multi_threading.inl
include/mutex.hpp
.src/mutex.cpp
.src/c_adapter.hpp
.src/c_adapter.cpp
)
target_compile_features(jluna PUBLIC cxx_std_20)
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(jluna PUBLIC "-fpic")
endif()
target_include_directories(jluna PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>")
target_link_libraries(jluna PUBLIC
"$<BUILD_INTERFACE:Julia::Julia>"
"$<BUILD_INTERFACE:Threads::Threads>"
)
set_target_properties(jluna PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS "YES" # TODO: Why is this necessary?
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION}"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
)
### Install rules ###
if(NOT CMAKE_SKIP_INSTALL_RULES)
include(cmake/install-rules.cmake)
endif()
include(CTest)
### Declare Test ###
option(BUILD_TESTING "Enable jluna_test" ON)
if (BUILD_TESTING)
add_executable(
jluna_test
.test/main.cpp
.test/test.hpp
)
target_link_libraries(jluna_test PRIVATE jluna)
add_test(NAME jluna_test COMMAND jluna_test)
endif()
### Developer mode ###
if(NOT jluna_DEVELOPER_MODE)
return()
elseif(NOT PROJECT_IS_TOP_LEVEL)
message(
AUTHOR_WARNING
"Developer mode is intended for developers of jluna"
)
endif()
### Declare Benchmark ###
option(BUILD_BENCHMARK "Enable jluna_benchmark" OFF)
if (BUILD_BENCHMARK)
add_executable(
jluna_benchmark
.benchmark/main.cpp
.benchmark/benchmark.hpp
.benchmark/benchmark_aux.hpp
)
target_link_libraries(jluna_benchmark PRIVATE jluna)
endif()