forked from precice/precice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerateVersionInformation.cmake
52 lines (46 loc) · 1.88 KB
/
GenerateVersionInformation.cmake
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
#
# This script generates the version information used in versions.hpp.in
#
# We use an internal cache to keep the code below a bit more sane
set(preCICE_VERSION_INFORMATION "" CACHE INTERNAL "")
# Adds a NAME=VALUE pair to the version information
function(precice_vi_add_value NAME VALUE)
if(preCICE_VERSION_INFORMATION)
# We have to use \; as separator to prevent the list-escaping of cmake
# to remove the ; and escape the whitespaces
set(preCICE_VERSION_INFORMATION "${preCICE_VERSION_INFORMATION}\;${NAME}=${VALUE}" CACHE INTERNAL "")
else()
set(preCICE_VERSION_INFORMATION "${NAME}=${VALUE}" CACHE INTERNAL "")
endif()
endfunction()
# Adds a boolean option to the version information
function(precice_vi_add_option NAME)
set(PVI_VAL "N")
if(${NAME})
set(PVI_VAL "Y")
endif()
precice_vi_add_value(${NAME} ${PVI_VAL})
endfunction()
precice_vi_add_option(PRECICE_FEATURE_MPI_COMMUNICATION)
precice_vi_add_option(PRECICE_FEATURE_PETSC_MAPPING)
precice_vi_add_option(PRECICE_FEATURE_GINKGO_MAPPING)
precice_vi_add_option(PRECICE_FEATURE_PYTHON_ACTIONS)
precice_vi_add_option(PRECICE_BINDINGS_C)
precice_vi_add_option(PRECICE_BINDINGS_FORTRAN)
precice_vi_add_value(CXX "${CMAKE_CXX_COMPILER_ID}")
# Add compiler flags
if(CMAKE_BUILD_TYPE STREQUAL "")
precice_vi_add_value(CXXFLAGS "${CMAKE_CXX_FLAGS}")
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
precice_vi_add_value(CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
precice_vi_add_value(CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
precice_vi_add_value(CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
endif()
# Add linker flags
if(BUILD_SHARED_LIBS)
precice_vi_add_value(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else()
precice_vi_add_value(LDFLAGS "${CMAKE_STATIC_LINKER_FLAGS}")
endif()