mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-12 14:10:34 +05:00
Merge branch 'propagate_gcc_abi_version_flag' into 'master'
Propagate -fabi-version=xx when compiling with GCC See merge request ngsolve/netgen!642
This commit is contained in:
commit
5e54efb57b
@ -23,8 +23,28 @@ if(EMSCRIPTEN)
|
||||
target_compile_options(ngcore PUBLIC -sNO_DISABLE_EXCEPTION_CATCHING)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)
|
||||
target_link_libraries(ngcore PUBLIC stdc++fs)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
# Python packages on Linux are compiled with the old ABI,
|
||||
# make sure that the same ABI is used in plugins aswell
|
||||
try_run(
|
||||
ret_val can_compile
|
||||
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/_get_glibcxx_use_cxx11_abi.cpp
|
||||
RUN_OUTPUT_VARIABLE use_glibcxx_cxx11_abi
|
||||
)
|
||||
target_compile_definitions(ngcore PUBLIC -D_GLIBCXX_USE_CXX11_ABI=${use_glibcxx_cxx11_abi})
|
||||
if(USE_PYTHON)
|
||||
try_run(
|
||||
ret_val can_compile
|
||||
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/_get_gxx_abi.cpp
|
||||
RUN_OUTPUT_VARIABLE cxx_abi_version
|
||||
)
|
||||
if(${can_compile} AND (${ret_val} EQUAL 0))
|
||||
# Different python modules using pybind11 need to use the same C++ ABI version
|
||||
# for compatibility
|
||||
message(STATUS "GNU C++ ABI version: ${cxx_abi_version}")
|
||||
target_compile_options(ngcore PUBLIC "-fabi-version=${cxx_abi_version}")
|
||||
endif()
|
||||
endif(USE_PYTHON)
|
||||
endif()
|
||||
|
||||
if(USE_PYTHON)
|
||||
|
13
libsrc/core/_get_glibcxx_use_cxx11_abi.cpp
Normal file
13
libsrc/core/_get_glibcxx_use_cxx11_abi.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
#ifdef _GLIBCXX_USE_CXX11_ABI
|
||||
if(_GLIBCXX_USE_CXX11_ABI)
|
||||
std::cout << 1;
|
||||
else
|
||||
std::cout << 0;
|
||||
#else // _GLIBCXX_USE_CXX11_ABI
|
||||
std::cout << 0;
|
||||
#endif // _GLIBCXX_USE_CXX11_ABI
|
||||
return 0;
|
||||
}
|
7
libsrc/core/_get_gxx_abi.cpp
Normal file
7
libsrc/core/_get_gxx_abi.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
if (__GXX_ABI_VERSION >= 2000 || __GXX_ABI_VERSION < 1000) return 1;
|
||||
std::cout << (__GXX_ABI_VERSION % 100);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user