-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
executable file
·135 lines (116 loc) · 7.23 KB
/
Copy pathCMakeLists.txt
File metadata and controls
executable file
·135 lines (116 loc) · 7.23 KB
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
126
127
128
129
130
131
132
133
134
135
# CMakeLists for project "rainflow"
# 2026, Andreas Martin
# See `README.rst` for build and installation hints.
cmake_minimum_required(VERSION 3.16)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW) # The project() command manages VERSION variables.
endif ()
if (POLICY CMP0076)
cmake_policy(SET CMP0076 NEW) # The target_sources() command converts relative paths to absolute.
endif ()
if (POLICY CMP0091)
cmake_policy(SET CMP0091 NEW) # MSVC runtime library flags are selected by an abstraction.
endif ()
# Project name and version
project(rainflow VERSION 0.5.2 LANGUAGES C CXX)
# C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_VERBOSE_MAKEFILE OFF)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
endif ()
if (CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo")
message(STATUS "Rainflow: Adding debug flags for build type ${CMAKE_BUILD_TYPE}")
add_definitions(-DDEBUG -D_DEBUG)
endif ()
# Compiler dependencies
if (MSVC)
# Turn off misguided "secure CRT" warnings in MSVC.
# Microsoft wants people to use the MS-specific <function>_s
# versions of certain C functions but this is difficult to do
# in platform-independent code.
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif ()
# Math library
find_library(LIBM_LIBRARY NAMES m)
if (NOT LIBM_LIBRARY)
set(LIBM_LIBRARY "")
endif ()
# Options valid, if project compiled as standalone only
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
message(STATUS "Build ${PROJECT_NAME} as main project")
option(RFC_MINIMAL "Build module with as few features as possible" OFF)
option(RFC_USE_INTEGRAL_COUNTS "Use integral (non-floating) data type for counts" OFF)
option(RFC_USE_HYSTERESIS_FILTER "Use hysteresis filtering" ON)
option(RFC_USE_DELEGATES "Use delegates (functors)" ON)
option(RFC_GLOBAL_EXTREMA "Always calculate global extrema" ON)
option(RFC_HCM_SUPPORT "Support HCM (Clormann/Seeger) algorithm" ON)
option(RFC_ASTM_SUPPORT "Support ASTM E 1049-85 algorithm" ON)
option(RFC_TP_SUPPORT "Support turning points" ON)
option(RFC_DH_SUPPORT "Support \"spread damage\" over turning points and damage history" ON)
option(RFC_AT_SUPPORT "Support amplitude transformation regarding mean load influence on fatigue strength" ON)
option(RFC_AR_SUPPORT "Support automatic growth of counting buffers" ON)
option(RFC_DAMAGE_FAST "Enables fast damage calculation (per look-up table)" ON)
option(RFC_DEBUG_FLAGS "Enables flags for detailed examination" OFF)
option(RFC_EXPORT_MEX "Export a function wrapper for MATLAB(R)" ON)
option(RFC_EXPORT_PY "Export a function wrapper for Python" ON)
option(RFC_UNIT_TEST "Generate rainflow testing program for unit test" ON)
set(RFC_VALUE_TYPE double CACHE STRING "Value type of input data to be processed")
set(RFC_PYTHON_VERSION "3.9" CACHE STRING "Expected Python version")
set(RFC_NUMPY_VERSION "" CACHE STRING "NumPy version to link to")
else ()
message(STATUS "Build ${PROJECT_NAME} as subsequent project")
set(RFC_EXPORT_MEX OFF CACHE BOOL "" FORCE)
set(RFC_EXPORT_PY OFF CACHE BOOL "" FORCE)
endif ()
set(RFC_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(RFC_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(RFC_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(RFC_VERSION_POSTFIX "" CACHE STRING "Optional version postfix, e.g. 'rc1', '.dev1', '.post1'")
set(RFC_VERSION "${RFC_VERSION_MAJOR}.${RFC_VERSION_MINOR}.${RFC_VERSION_PATCH}${RFC_VERSION_POSTFIX}")
# Save options in configuration file
configure_file(${CMAKE_CURRENT_LIST_DIR}/src/lib/config.h.in ${CMAKE_CURRENT_LIST_DIR}/src/lib/config.h)
# Generate Python version file and documentation from templates
configure_file(${CMAKE_CURRENT_LIST_DIR}/src/python/version.py.in ${CMAKE_CURRENT_LIST_DIR}/src/python/version.py)
configure_file(${CMAKE_CURRENT_LIST_DIR}/docs/index.rst.in ${CMAKE_CURRENT_LIST_DIR}/docs/index.rst @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/docs/installation.rst.in ${CMAKE_CURRENT_LIST_DIR}/docs/installation.rst @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/docs/references.rst.in ${CMAKE_CURRENT_LIST_DIR}/docs/references.rst @ONLY)
# Targets
add_subdirectory(src)
# Unit tests
if (RFC_UNIT_TEST)
enable_testing()
include(CTest)
add_subdirectory(test) # EXCLUDE_FROM_ALL)
add_test(NAME rfc_unit_test COMMAND rfc_test)
endif ()
#[[
CMake Structure
rainflow/
├── CMakeLists.txt (root: project config, options, compiler flags)
├── src/
│ ├── CMakeLists.txt (orchestrates lib, matlab, python subdirs)
│ ├── lib/CMakeLists.txt (rfc_core static library)
│ ├── matlab/CMakeLists.txt (MATLAB MEX wrapper)
│ └── python/
│ ├── CMakeLists.txt (Python rfcnt extension module)
│ └── cmake/rfcnt_target_functions.cmake (helper functions)
├── test/CMakeLists.txt (rfc_test unit test executable)
├── sf/CMakeLists.txt (legacy build, v0.2)
└── minimal/CMakeLists.txt (legacy build, v0.2)
Key Targets
┌──────────┬───────────────────┬─────────────────────────────────────────────────┐
│ Target │ Type │ Description │
├──────────┼───────────────────┼─────────────────────────────────────────────────┤
│ rfc_core │ Static library │ Core rainflow counting library (C) │
├──────────┼───────────────────┼─────────────────────────────────────────────────┤
│ rfc_test │ Executable │ Unit tests (C/C++), links rfc_core + greatest │
├──────────┼───────────────────┼─────────────────────────────────────────────────┤
│ rfc_mex │ MEX file │ MATLAB wrapper (conditional on RFC_EXPORT_MEX) │
├──────────┼───────────────────┼─────────────────────────────────────────────────┤
│ rfcnt │ Shared lib (.pyd) │ Python extension (conditional on RFC_EXPORT_PY) │
└──────────┴───────────────────┴─────────────────────────────────────────────────┘
#]]