-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
59 lines (44 loc) · 1.47 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
cmake_minimum_required(VERSION 3.13)
project(morpho-gmsh)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Build the library as a plugin
add_library(gmshapi MODULE "")
# Suppress 'lib' prefix
set_target_properties(gmshapi 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(gmshapi PUBLIC ${MORPHO_INCLUDE})
# Add general header search paths
target_include_directories(gmshapi PUBLIC /usr/local/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(gmshapi PUBLIC ${dir})
ELSE()
CONTINUE()
ENDIF()
endforeach()
# Locate libmorpho
find_library(MORPHO_LIBRARY
NAMES morpho libmorpho
)
# Locate gmsh
find_library(GMSH_LIBRARY
NAMES gmsh libgmsh
)
target_link_libraries(gmshapi ${MORPHO_LIBRARY} ${GMSH_LIBRARY})
set(CMAKE_INSTALL_PREFIX ..)
# Install the resulting binary
install(TARGETS gmshapi LIBRARY DESTINATION lib/)