build(meson): much more robust build system
This commit is contained in:
@@ -1,32 +1,34 @@
|
||||
cmake = import('cmake')
|
||||
cvode_cmake_options = cmake.subproject_options()
|
||||
|
||||
cvode_cmake_options.add_cmake_defines({
|
||||
'CMAKE_CXX_FLAGS' : '-Wno-deprecated-declarations',
|
||||
'CMAKE_C_FLAGS' : '-Wno-deprecated-declarations',
|
||||
'BUILD_SHARED_LIBS' : 'OFF',
|
||||
'BUILD_STATIC_LIBS' : 'ON',
|
||||
'EXAMPLES_ENABLE_C' : 'OFF',
|
||||
'CMAKE_POSITION_INDEPENDENT_CODE': true,
|
||||
'CMAKE_PLATFORM_NO_VERSIONED_SONAME': 'ON',
|
||||
'SUNDIALS_LOGGING_LEVEL': 1
|
||||
|
||||
})
|
||||
sundials_hidden_flags = '-Wno-deprecated-declarations -fvisibility=hidden -fvisibility-inlines-hidden'
|
||||
|
||||
cvode_cmake_options.add_cmake_defines({
|
||||
'CMAKE_INSTALL_LIBDIR': get_option('libdir'),
|
||||
'CMAKE_INSTALL_INCLUDEDIR': get_option('includedir')
|
||||
})
|
||||
'CMAKE_CXX_FLAGS' : sundials_hidden_flags,
|
||||
'CMAKE_C_FLAGS' : sundials_hidden_flags,
|
||||
'BUILD_SHARED_LIBS' : 'OFF',
|
||||
'BUILD_STATIC_LIBS' : 'ON',
|
||||
'EXAMPLES_ENABLE_C' : 'OFF',
|
||||
'CMAKE_POSITION_INDEPENDENT_CODE': true,
|
||||
'CMAKE_PLATFORM_NO_VERSIONED_SONAME': 'ON',
|
||||
'SUNDIALS_LOGGING_LEVEL': 1
|
||||
|
||||
})
|
||||
|
||||
cvode_cmake_options.add_cmake_defines({
|
||||
'CMAKE_INSTALL_LIBDIR': get_option('libdir'),
|
||||
'CMAKE_INSTALL_INCLUDEDIR': get_option('includedir')
|
||||
})
|
||||
|
||||
cvode_cmake_options.set_install(false)
|
||||
|
||||
if meson.is_cross_build() and host_machine.system() == 'emscripten'
|
||||
cvode_cmake_options.add_cmake_defines({
|
||||
'CMAKE_C_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1',
|
||||
'CMAKE_CXX_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1',
|
||||
'CMAKE_SHARED_LINKER_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1',
|
||||
'CMAKE_EXE_LINKER_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1'
|
||||
})
|
||||
cvode_cmake_options.add_cmake_defines({
|
||||
'CMAKE_C_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1',
|
||||
'CMAKE_CXX_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1',
|
||||
'CMAKE_SHARED_LINKER_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1',
|
||||
'CMAKE_EXE_LINKER_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1'
|
||||
})
|
||||
endif
|
||||
|
||||
cvode_sp = cmake.subproject(
|
||||
@@ -41,11 +43,11 @@ sundials_sunmatrixdense_tgt = cvode_sp.target('sundials_sunmatrixdense_static')
|
||||
sundials_sunlinsoldense_tgt = cvode_sp.target('sundials_sunlinsoldense_static')
|
||||
|
||||
cvode_objs = [
|
||||
sundials_core_tgt.extract_all_objects(recursive: true),
|
||||
sundials_cvode_tgt.extract_all_objects(recursive: true),
|
||||
sundials_nvecserial_tgt.extract_all_objects(recursive: true),
|
||||
sundials_sunmatrixdense_tgt.extract_all_objects(recursive: true),
|
||||
sundials_sunlinsoldense_tgt.extract_all_objects(recursive: true),
|
||||
sundials_core_tgt.extract_all_objects(recursive: true),
|
||||
sundials_cvode_tgt.extract_all_objects(recursive: true),
|
||||
sundials_nvecserial_tgt.extract_all_objects(recursive: true),
|
||||
sundials_sunmatrixdense_tgt.extract_all_objects(recursive: true),
|
||||
sundials_sunlinsoldense_tgt.extract_all_objects(recursive: true),
|
||||
]
|
||||
|
||||
sundials_core_includes = cvode_sp.include_directories('sundials_core_static')
|
||||
@@ -55,35 +57,29 @@ sundials_sunmatrixdense_includes = cvode_sp.include_directories('sundials_sunmat
|
||||
sundials_sunlinsoldense_includes = cvode_sp.include_directories('sundials_sunlinsoldense_static')
|
||||
|
||||
cvode_includes = [
|
||||
sundials_core_includes,
|
||||
sundials_cvode_includes,
|
||||
sundials_nvecserial_includes,
|
||||
sundials_sunmatrixdense_includes,
|
||||
sundials_sunlinsoldense_includes
|
||||
sundials_core_includes,
|
||||
sundials_cvode_includes,
|
||||
sundials_nvecserial_includes,
|
||||
sundials_sunmatrixdense_includes,
|
||||
sundials_sunlinsoldense_includes
|
||||
]
|
||||
|
||||
|
||||
empty_cvode_file = configure_file(
|
||||
output: 'cvode_dummy_ar.cpp',
|
||||
command: ['echo'],
|
||||
capture: true
|
||||
)
|
||||
|
||||
output: 'cvode_dummy_ar.cpp',
|
||||
command: ['echo'],
|
||||
capture: true
|
||||
)
|
||||
|
||||
|
||||
libcvode_static = static_library(
|
||||
'cvode-static',
|
||||
empty_cvode_file,
|
||||
objects: cvode_objs,
|
||||
include_directories: cvode_includes,
|
||||
pic: true,
|
||||
install: false
|
||||
'cvode-static',
|
||||
empty_cvode_file,
|
||||
objects: cvode_objs,
|
||||
include_directories: cvode_includes,
|
||||
pic: true,
|
||||
install: false
|
||||
)
|
||||
|
||||
|
||||
cvode_dep = declare_dependency(
|
||||
link_with: libcvode_static,
|
||||
include_directories: cvode_includes,
|
||||
include_directories: cvode_includes,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -3,20 +3,20 @@ cmake = import('cmake')
|
||||
kinsol_cmake_options = cmake.subproject_options()
|
||||
|
||||
kinsol_cmake_options.add_cmake_defines({
|
||||
'CMAKE_CXX_FLAGS' : '-Wno-deprecated-declarations',
|
||||
'CMAKE_C_FLAGS' : '-Wno-deprecated-declarations',
|
||||
'BUILD_SHARED_LIBS' : 'OFF',
|
||||
'BUILD_STATIC_LIBS' : 'ON',
|
||||
'EXAMPLES_ENABLE_C' : 'OFF',
|
||||
'CMAKE_POSITION_INDEPENDENT_CODE': true,
|
||||
'CMAKE_PLATFORM_NO_VERSIONED_SONAME': 'ON',
|
||||
'SUNDIALS_LOGGING_LEVEL': 1
|
||||
})
|
||||
'CMAKE_CXX_FLAGS' : '-Wno-deprecated-declarations -fvisibility=hidden -fvisibility-inlines-hidden',
|
||||
'CMAKE_C_FLAGS' : '-Wno-deprecated-declarations -fvisibility=hidden -fvisibility-inlines-hidden',
|
||||
'BUILD_SHARED_LIBS' : 'OFF',
|
||||
'BUILD_STATIC_LIBS' : 'ON',
|
||||
'EXAMPLES_ENABLE_C' : 'OFF',
|
||||
'CMAKE_POSITION_INDEPENDENT_CODE': true,
|
||||
'CMAKE_PLATFORM_NO_VERSIONED_SONAME': 'ON',
|
||||
'SUNDIALS_LOGGING_LEVEL': 1
|
||||
})
|
||||
|
||||
kinsol_cmake_options.add_cmake_defines({
|
||||
'CMAKE_INSTALL_LIBDIR': get_option('libdir'),
|
||||
'CMAKE_INSTALL_INCLUDEDIR': get_option('includedir')
|
||||
})
|
||||
'CMAKE_INSTALL_LIBDIR': get_option('libdir'),
|
||||
'CMAKE_INSTALL_INCLUDEDIR': get_option('includedir')
|
||||
})
|
||||
|
||||
kinsol_cmake_options.set_install(false)
|
||||
|
||||
@@ -31,25 +31,22 @@ kinsol_includes = kinsol_sp.include_directories('sundials_kinsol_obj_static')
|
||||
kinsol_objs = [sundials_kinsol_static_tgt.extract_all_objects(recursive: false)]
|
||||
|
||||
empty_kinsol_file = configure_file(
|
||||
output: 'kinsol_dummy_ar.cpp',
|
||||
command: ['echo'],
|
||||
capture: true
|
||||
)
|
||||
output: 'kinsol_dummy_ar.cpp',
|
||||
command: ['echo'],
|
||||
capture: true
|
||||
)
|
||||
|
||||
|
||||
libkinsol_static = static_library(
|
||||
'kinsol_static',
|
||||
empty_kinsol_file,
|
||||
objects: kinsol_objs,
|
||||
include_directories: kinsol_includes,
|
||||
pic: true,
|
||||
install: false
|
||||
'kinsol_static',
|
||||
empty_kinsol_file,
|
||||
objects: kinsol_objs,
|
||||
include_directories: kinsol_includes,
|
||||
pic: true,
|
||||
install: false
|
||||
)
|
||||
|
||||
|
||||
kinsol_dep = declare_dependency(
|
||||
link_with: libkinsol_static,
|
||||
include_directories: kinsol_includes
|
||||
include_directories: kinsol_includes
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -7,3 +7,11 @@ sundials_dep = declare_dependency(
|
||||
kinsol_dep,
|
||||
],
|
||||
)
|
||||
|
||||
# Vendor the SUNDIALS public headers (see vendor/meson.build). GridFire's
|
||||
# installed public headers #include <sundials/...> etc., so consumers of
|
||||
# gridfire.pc must compile against exactly the headers this build used --
|
||||
# never whatever SUNDIALS happens to be in /usr/local/include (which may be
|
||||
# a different version or configuration, e.g. an MPI-enabled build whose
|
||||
# sundials_config.h pulls in <mpi.h>).
|
||||
subdir('vendor')
|
||||
|
||||
46
build-config/sundials/vendor/meson.build
vendored
Normal file
46
build-config/sundials/vendor/meson.build
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
sundials_src_include = meson.project_source_root() / 'subprojects' / 'cvode-7.5.0' / 'include'
|
||||
kinsol_src_include = meson.project_source_root() / 'subprojects' / 'kinsol-7.5.0' / 'include'
|
||||
|
||||
sundials_vendor_dirs = [
|
||||
'sundials', # core (includes sundials/priv/)
|
||||
'cvode',
|
||||
'nvector',
|
||||
'sunmatrix',
|
||||
'sunlinsol',
|
||||
'sunnonlinsol',
|
||||
'sunmemory',
|
||||
'sunadaptcontroller',
|
||||
]
|
||||
|
||||
foreach d : sundials_vendor_dirs
|
||||
custom_target(
|
||||
'vendor_sundials_' + d,
|
||||
command: copytree_cmd + [sundials_src_include / d, '@OUTPUT@'],
|
||||
output: d,
|
||||
install: true,
|
||||
install_dir: gridfire_vendor_includedir,
|
||||
)
|
||||
endforeach
|
||||
|
||||
custom_target(
|
||||
'vendor_sundials_kinsol',
|
||||
command: copytree_cmd + [kinsol_src_include / 'kinsol', '@OUTPUT@'],
|
||||
output: 'kinsol',
|
||||
install: true,
|
||||
install_dir: gridfire_vendor_includedir,
|
||||
)
|
||||
|
||||
sundials_cmake_include = meson.global_build_root() / 'subprojects' / 'cvode-7.5.0' / '__CMake_build' / 'include' / 'sundials'
|
||||
|
||||
custom_target(
|
||||
'vendor_sundials_generated',
|
||||
command: copyfiles_cmd + [
|
||||
sundials_cmake_include / 'sundials_config.h',
|
||||
sundials_cmake_include / 'sundials_export.h',
|
||||
'@OUTDIR@',
|
||||
],
|
||||
output: ['sundials_config.h', 'sundials_export.h'],
|
||||
depends: libcvode_static,
|
||||
install: true,
|
||||
install_dir: gridfire_vendor_includedir / 'sundials',
|
||||
)
|
||||
Reference in New Issue
Block a user