-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
84 lines (67 loc) · 2.61 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
# set minimum cmake version required
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(xeus-asm LANGUAGES CXX
VERSION 0.0.1
DESCRIPTION "Jupyter Kernel for ASM"
HOMEPAGE_URL "https://github.com/itssingh/xeus-asm")
set(EXECUTABLE_NAME xasm)
# Configuration
# =============
include(GNUInstallDirs)
# We generate the kernel.json file, given the installation prefix and the executable name
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xasm/kernel.json.in"
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xasm/kernel.json")
option(XEUS_STATIC_DEPENDENCIES "link statically with xeus dependencies" OFF)
if (XEUS_STATIC_DEPENDENCIES)
set(xeus_target "xeus-static")
else ()
set(xeus_target "xeus")
endif ()
# Dependencies
# ============
# Be sure to use recent versions
set(xeus_REQUIRED_VERSION 0.19.1)
set(cppzmq_REQUIRED_VERSION 4.3.0)
find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED)
find_package(cppzmq ${cppzmq_REQUIRED_VERSION} REQUIRED)
find_package(Threads)
# Flags
# =====
include(CheckCXXCompilerFlag)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
CHECK_CXX_COMPILER_FLAG("-std=c++17" HAS_CPP17_FLAG)
if (HAS_CPP17_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
else ()
message(FATAL_ERROR "Unsupported compiler -- xeus requires C++17 support!")
endif ()
endif ()
# Target and link
# ===============
# My kernel executable
add_executable(${EXECUTABLE_NAME} "")
target_sources(${EXECUTABLE_NAME} PRIVATE src/main.cc src/instruction.cc src/interpreter.cc src/utils.cc src/xasm_interpreter.cc)
target_include_directories(${EXECUTABLE_NAME}
PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include)
target_link_libraries(${EXECUTABLE_NAME} PRIVATE ${xeus_target} Threads::Threads)
if (APPLE)
set_target_properties(${EXECUTABLE_NAME} PROPERTIES MACOSX_RPATH ON)
else ()
set_target_properties(${EXECUTABLE_NAME} PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
SKIP_BUILD_RPATH FALSE)
endif ()
set_target_properties(${EXECUTABLE_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
# Installation
# ============
# Install xasm
install(TARGETS ${EXECUTABLE_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# Configuration and data directories for jupyter and xasm
set(XJUPYTER_DATA_DIR "share/jupyter" CACHE STRING "Jupyter data directory")
# Install Jupyter kernelspecs
set(xasmSPEC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels)
install(DIRECTORY ${xasmSPEC_DIR}
DESTINATION ${XJUPYTER_DATA_DIR}
PATTERN "*.in" EXCLUDE)