-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
71 lines (61 loc) · 2.3 KB
/
CMakeLists.txt
File metadata and controls
71 lines (61 loc) · 2.3 KB
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
cmake_minimum_required (VERSION 3.13)
project(julia-cpp LANGUAGES CXX)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
include(FetchContent)
set(FETCHCONTENT_QUIET OFF)
option(ENABLE_TESTS "Enable unit tests" ON)
option(ENABLE_COVERAGE "Enable code coverage for unit tests" OFF)
option(DOWNLOAD_LOCAL_JULIA "Download a local Julia installation rather than using the Julia version installed on the system" OFF)
# C++ settings
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Wextra -Wpedantic -Werror -fPIC)
endif()
# Julia
if(DOWNLOAD_LOCAL_JULIA)
cmake_policy(SET CMP0135 NEW)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
FetchContent_Declare(
julia
URL https://julialang-s3.julialang.org/bin/linux/x64/1.8/julia-1.8.5-linux-x86_64.tar.gz
URL_HASH SHA256=e71a24816e8fe9d5f4807664cbbb42738f5aa9fe05397d35c81d4c5d649b9d05
)
else()
FetchContent_Declare(
julia
URL https://julialang-s3.julialang.org/bin/linux/x86/1.8/julia-1.8.5-linux-i686.tar.gz
URL_HASH SHA256=f0edd61970710333cb5ac6491fbbc859436e5e9e84b014ae04f291bddf6a7e21
)
endif()
FetchContent_MakeAvailable(julia)
set(Julia_PREFIX ${julia_SOURCE_DIR})
endif()
find_package(Julia REQUIRED)
include_directories(src ${Julia_INCLUDE_DIRS})
link_libraries(${Julia_LIBRARY})
# Juliapp target
add_library(juliapp SHARED src/value.cpp src/symbol.cpp src/init.cpp src/module.cpp src/eval.cpp src/global.cpp src/errors.cpp)
link_libraries(juliapp)
set_target_properties(juliapp PROPERTIES CMAKE_CXX_CLANG_TIDY clang-tidy)
# Coverage
if(ENABLE_COVERAGE)
target_compile_options(juliapp PRIVATE --coverage -O0)
target_link_libraries(juliapp PRIVATE gcov)
endif()
# Demo target
add_executable(demo demo/demo.cpp)
if(ENABLE_TESTS)
# Catch2
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.2.1
OVERRIDE_FIND_PACKAGE
)
find_package(Catch2 3 REQUIRED CONFIG)
# Tests target
add_executable(tests tests/symbol.cpp tests/module.cpp tests/value.cpp tests/boxing.cpp tests/global.cpp tests/eval.cpp)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
endif()