-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
61 lines (53 loc) · 1.65 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
60
61
cmake_minimum_required(VERSION 3.12)
project(bmif
VERSION 2.0.2
LANGUAGES Fortran
)
# Use system-specific install directories
include(GNUInstallDirs)
# Match the module name set in "bmi.f90".
set(mod_name "${CMAKE_PROJECT_NAME}_\
${CMAKE_PROJECT_VERSION_MAJOR}_${CMAKE_PROJECT_VERSION_MINOR}")
configure_file(
${CMAKE_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.pc.cmake
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc
@ONLY
)
# Create static and shared libraries.
set(static_lib ${CMAKE_PROJECT_NAME}_static)
set(shared_lib ${CMAKE_PROJECT_NAME}_shared)
add_library(${static_lib} bmi.f90)
add_library(${shared_lib} SHARED bmi.f90)
# Change the output names of the libraries. On Windows, they can't
# have the same name, so change the shared library name.
set_target_properties(${static_lib} PROPERTIES
OUTPUT_NAME ${CMAKE_PROJECT_NAME})
if(WIN32)
set_target_properties(${shared_lib} PROPERTIES
OUTPUT_NAME ${CMAKE_PROJECT_NAME}_win)
else()
set_target_properties(${shared_lib} PROPERTIES
OUTPUT_NAME ${CMAKE_PROJECT_NAME})
endif()
set_target_properties(${static_lib} PROPERTIES
VERSION ${CMAKE_PROJECT_VERSION}
)
set_target_properties(${shared_lib} PROPERTIES
VERSION ${CMAKE_PROJECT_VERSION}
PUBLIC_HEADER ${CMAKE_BINARY_DIR}/${mod_name}.mod
)
install(
TARGETS ${static_lib}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
TARGETS ${shared_lib}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
FILES ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)