-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
55 lines (47 loc) · 1.54 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
cmake_minimum_required(VERSION 3.18)
project(libdlfind LANGUAGES Fortran)
# Follow GNU conventions for installing directories
include(GNUInstallDirs)
# Turn on preprocessing
set(CMAKE_Fortran_PREPROCESS ON)
# Find BLAS and LAPACK
include(CMakeFindDependencyMacro)
find_dependency(BLAS)
find_dependency(LAPACK)
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
# Build shared library
set(srcs)
add_subdirectory(src)
add_library(dlfind SHARED ${srcs})
target_link_libraries(dlfind ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
# Set compiler arguments
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
target_compile_options(dlfind PRIVATE -std=legacy)
endif()
# Install
if(SKBUILD)
if(WIN32)
# Set flags for Windows compatibility
set_target_properties(dlfind PROPERTIES LIBRARY_PREFIX "lib")
set_target_properties(dlfind PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Link statically against dependencies for Windows
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
target_link_options(dlfind PRIVATE "-static")
endif()
endif()
message(STATUS "The project is built using scikit-build")
install(
TARGETS dlfind
LIBRARY DESTINATION libdlfind
ARCHIVE DESTINATION libdlfind
RUNTIME DESTINATION libdlfind)
else()
set_target_properties(dlfind PROPERTIES PUBLIC_HEADER "include/libdlfind.h")
install(
TARGETS dlfind
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()