-
Notifications
You must be signed in to change notification settings - Fork 54
/
CMakeLists.txt
125 lines (108 loc) · 3.71 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
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
120
121
122
123
124
125
#
# Basic CMake configuration file for bspline-fortran
#
cmake_minimum_required(VERSION 3.11)
set( CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/install"
CACHE STRING "Select where to install the library." )
project(bspline-fortran NONE)
# Real and Integer kinds
SET(BSPLINE_REAL_KIND "REAL64" CACHE STRING "Real kind parameter")
SET_PROPERTY(CACHE BSPLINE_REAL_KIND PROPERTY STRINGS REAL32 REAL64 REAL128)
if(${BSPLINE_REAL_KIND} MATCHES "REAL32")
add_definitions(-DREAL32)
elseif(${BSPLINE_REAL_KIND} MATCHES "REAL64")
add_definitions(-DREAL64)
elseif(${BSPLINE_REAL_KIND} MATCHES "REAL128")
add_definitions(-DREAL128)
endif()
SET(BSPLINE_INT_KIND "INT32" CACHE STRING "Integer kind parameter")
SET_PROPERTY(CACHE BSPLINE_INT_KIND PROPERTY STRINGS INT8 INT16 INT32 INT64)
if(${BSPLINE_INT_KIND} MATCHES "INT8")
add_definitions(-DINT8)
elseif(${BSPLINE_INT_KIND} MATCHES "INT16")
add_definitions(-DINT16)
elseif(${BSPLINE_INT_KIND} MATCHES "INT32")
add_definitions(-DINT32)
elseif(${BSPLINE_INT_KIND} MATCHES "INT64")
add_definitions(-DINT64)
endif()
# Use MSVS folders to organize projects on windows
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set( LIB_NAME ${PROJECT_NAME} )
set( PROJECT_DESCRIPTION
"Multidimensional B-Spline Interpolation of Data on a Regular Grid" )
set( PROJECT_URL "https://github.com/jacobwilliams/bspline-fortran" )
set( CMAKE_CONFIGURATION_TYPES "Debug" "Release" "MinSizeRel" "RelWithDebInfo" )
set( CMAKE_BUILD_TYPE "Release"
CACHE STRING "Select which configuration to build." )
enable_language(Fortran)
set( SOURCES
src/bspline_blas_module.F90
src/bspline_defc_module.F90
src/bspline_kinds_module.F90
src/bspline_module.f90
src/bspline_oo_module.f90
src/bspline_sub_module.f90 )
set(INSTALL_MOD_DIR "lib")
set(INSTALL_LIB_DIR "${INSTALL_MOD_DIR}")
set(ABS_LIB_INSTALL_DIR "\${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}")
set(MODULE_DIR "${CMAKE_BINARY_DIR}/lib")
if( "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" )
set( ENABLE_DYLIBS_USE_RPATH TRUE CACHE BOOL
"Enable @rpath install name for dylibs" )
mark_as_advanced( ENABLE_DYLIBS_USE_RPATH )
endif()
if( ENABLE_DYLIBS_USE_RPATH )
set( CMAKE_MACOSX_RPATH TRUE )
else()
set( CMAKE_INSTALL_NAME_DIR
"${ABS_LIB_INSTALL_DIR}" )
endif()
add_library( ${LIB_NAME} SHARED ${SOURCES} )
add_library( ${LIB_NAME}-static STATIC ${SOURCES} )
set_target_properties(${LIB_NAME}-static
PROPERTIES
OUTPUT_NAME "${LIB_NAME}"
if(NOT MSVC_IDE)
PREFIX lib
endif()
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
Fortran_MODULE_DIRECTORY ${MODULE_DIR})
set_target_properties(${LIB_NAME}
PROPERTIES
OUTPUT_NAME "${LIB_NAME}"
if(NOT MSVC_IDE)
PREFIX lib
endif()
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR})
# install library:
install( TARGETS ${LIB_NAME} ${LIB_NAME}-static
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" )
install( DIRECTORY "${MODULE_DIR}/" DESTINATION "${INSTALL_MOD_DIR}" )
# Windows settings:
if(MSVC_IDE)
INCLUDE_DIRECTORIES("src")
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp")
endif()
# Add ctest commands, to build all test programs (that do not depend on pyplot_module)
# Thus, tests can all be run with `make test`
enable_testing()
foreach(prog_name
# bspline_extrap_test
bspline_test_2
bspline_test
# dbint4_test
# knot_tests
# speed_test
# speed_test_oo
stack_size_test_oo
test_integrate
test_oo
test_regrid)
add_executable(${prog_name} test/${prog_name}.f90)
target_link_libraries(${prog_name} ${LIB_NAME}-static)
add_test(NAME ${prog_name}
COMMAND ${prog_name})
endforeach()