-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
54 lines (40 loc) · 1.48 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
cmake_minimum_required(VERSION 3.13)
project(morpho-bytecodeoptimizer)
# Build the library as a plugin
add_library(bytecodeoptimizer MODULE "")
# Suppress 'lib' prefix
set_target_properties(bytecodeoptimizer PROPERTIES PREFIX "")
# Add sources
add_subdirectory(src)
###
# Locate the morpho.h header file and store in MORPHO_HEADER
find_file(MORPHO_HEADER
morpho.h
HINTS
/usr/local/opt/morpho
/opt/homebrew/opt/morpho
/usr/local/include/morpho
)
# Identify folder that morpho.h is located in from MORPHO_HEADER and store in MORPHO_INCLUDE
get_filename_component(MORPHO_INCLUDE ${MORPHO_HEADER} DIRECTORY)
# Add morpho headers to MORPHO_INCLUDE
target_include_directories(bytecodeoptimizer PUBLIC ${MORPHO_INCLUDE})
# Add general header search paths
target_include_directories(bytecodeoptimizer PUBLIC /usr/local/include /opt/homebrew/include)
# Add morpho headers in subfolders to MORPHO_INCLUDE
file(GLOB morpho_subdirectories LIST_DIRECTORIES true ${MORPHO_INCLUDE}/*)
foreach(dir ${morpho_subdirectories})
IF(IS_DIRECTORY ${dir})
target_include_directories(zeromq PUBLIC ${dir})
ELSE()
CONTINUE()
ENDIF()
endforeach()
# Locate libmorpho
find_library(MORPHO_LIBRARY
NAMES morpho libmorpho
)
target_link_libraries(bytecodeoptimizer ${MORPHO_LIBRARY} ${ZMQ_LIBRARY} ${CZMQ_LIBRARY})
set(CMAKE_INSTALL_PREFIX ..)
# Install the resulting binary
install(TARGETS bytecodeoptimizer LIBRARY DESTINATION lib/)