-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
119 lines (100 loc) · 3.24 KB
/
Copy pathCMakeLists.txt
File metadata and controls
119 lines (100 loc) · 3.24 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
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
cmake_minimum_required(VERSION 3.13)
project(morpho-zeromq)
# Build the library as a plugin
add_library(zeromq MODULE "")
# Suppress 'lib' prefix
set_target_properties(zeromq PROPERTIES PREFIX "")
# Add sources
add_subdirectory(src)
find_path(MORPHO_INCLUDE_DIR
NAMES morpho.h morpho/morpho.h
HINTS
$ENV{MORPHO_INCLUDE_DIR}
/usr/local/opt/morpho/include
/opt/homebrew/opt/morpho/include
/home/linuxbrew/.linuxbrew/include/morpho
/home/linuxbrew/.linuxbrew/include
/usr/local/include/morpho
/usr/local/include
/opt/homebrew/include
)
find_library(MORPHO_LIBRARY
NAMES morpho libmorpho
HINTS
$ENV{MORPHO_LIBRARY}
/usr/local/opt/morpho/lib
/opt/homebrew/opt/morpho/lib
/home/linuxbrew/.linuxbrew/lib
/usr/local/lib
/opt/homebrew/lib
)
find_path(ZMQ_INCLUDE_DIR
NAMES zmq.h
HINTS
/opt/homebrew/include
/usr/local/include
/home/linuxbrew/.linuxbrew/include
)
find_library(ZMQ_LIBRARY
NAMES zmq libzmq
HINTS
/opt/homebrew/lib
/usr/local/lib
/home/linuxbrew/.linuxbrew/lib
)
find_path(CZMQ_INCLUDE_DIR
NAMES czmq.h
HINTS
/opt/homebrew/include
/usr/local/include
/home/linuxbrew/.linuxbrew/include
)
find_library(CZMQ_LIBRARY
NAMES czmq libczmq
HINTS
/opt/homebrew/lib
/usr/local/lib
/home/linuxbrew/.linuxbrew/lib
)
if(NOT MORPHO_INCLUDE_DIR)
message(FATAL_ERROR
"Could not find Morpho headers (morpho.h). "
"Install Morpho or set MORPHO_INCLUDE_DIR to the include directory "
"that contains morpho.h or morpho/morpho.h.")
endif()
if(NOT MORPHO_LIBRARY)
message(FATAL_ERROR
"Could not find libmorpho. "
"Install Morpho or set MORPHO_LIBRARY to the full path of the Morpho library.")
endif()
if(NOT ZMQ_INCLUDE_DIR OR NOT ZMQ_LIBRARY)
message(FATAL_ERROR
"Could not find ZeroMQ (libzmq). "
"Install it (e.g. brew install zeromq) or set ZMQ_INCLUDE_DIR / ZMQ_LIBRARY.")
endif()
if(NOT CZMQ_INCLUDE_DIR OR NOT CZMQ_LIBRARY)
message(FATAL_ERROR
"Could not find CZMQ (libczmq). "
"Install it (e.g. brew install czmq) or set CZMQ_INCLUDE_DIR / CZMQ_LIBRARY.")
endif()
get_filename_component(MORPHO_INCLUDE_PARENT ${MORPHO_INCLUDE_DIR} DIRECTORY)
# Allow #include <morpho.h>, <classes.h>, <czmq.h>, etc.
target_include_directories(zeromq PUBLIC
${MORPHO_INCLUDE_DIR}
${MORPHO_INCLUDE_PARENT}
${ZMQ_INCLUDE_DIR}
${CZMQ_INCLUDE_DIR}
)
file(GLOB morpho_subdirectories LIST_DIRECTORIES true ${MORPHO_INCLUDE_DIR}/*)
foreach(dir ${morpho_subdirectories})
if(IS_DIRECTORY ${dir})
target_include_directories(zeromq PUBLIC ${dir})
endif()
endforeach()
target_link_libraries(zeromq ${MORPHO_LIBRARY} ${ZMQ_LIBRARY} ${CZMQ_LIBRARY})
# Install into this package by default (Morpho looks under <package>/lib).
# Also override CMake's cached /usr/local default so make install can't escape the package.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "Install prefix" FORCE)
endif()
install(TARGETS zeromq LIBRARY DESTINATION lib/)