-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
52 lines (46 loc) · 1.73 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
cmake_minimum_required(VERSION 3.17)
project(libarvo LANGUAGES Fortran)
# Fetch stdlib
set(CMAKE_MAXIMUM_RANK 2)
set(BUILD_TESTING OFF)
set(WITH_QP OFF)
set(WITH_XDP OFF)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/stdlib/CMakeLists.txt")
add_subdirectory(stdlib)
else()
set(stdlib-url "https://github.com/fortran-lang/stdlib")
message(STATUS "Retrieving stdlib from ${stdlib-url}")
include(FetchContent)
FetchContent_Declare(
fortran_stdlib
GIT_REPOSITORY ${stdlib-url}
GIT_TAG "HEAD"
)
FetchContent_GetProperties(fortran_stdlib)
if(NOT fortran_stdlib_POPULATED)
FetchContent_Populate(fortran_stdlib)
add_subdirectory(${fortran_stdlib_SOURCE_DIR} ${fortran_stdlib_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endif()
# Set up shared library target
set(srcs)
add_subdirectory(src)
add_library(arvo SHARED ${srcs})
target_link_libraries(arvo fortran_stdlib)
# Install
if(SKBUILD)
if(WIN32)
# Set flags for Windows compatibility
set_target_properties(arvo PROPERTIES LIBRARY_PREFIX "lib")
set_target_properties(arvo PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Link statically against dependencies for Windows
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
target_link_options(arvo PRIVATE "-static")
endif()
endif()
message(STATUS "The project is built using scikit-build")
install(TARGETS arvo LIBRARY DESTINATION libarvo ARCHIVE DESTINATION libarvo RUNTIME DESTINATION libarvo)
else()
set_target_properties(arvo PROPERTIES PUBLIC_HEADER "include/arvo.h")
install(TARGETS arvo LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libarvo)
endif()