Commit 5962e987 authored by Nikola Dinev's avatar Nikola Dinev

Add workaround for building with libc++

parent 68c9de12
Pipeline #296833 passed with stages
in 70 minutes and 18 seconds
......@@ -51,12 +51,29 @@ if (ELSA_BUILD_PYTHON_BINDINGS)
get_filename_component(CMAKE_CURRENT_LIST_DIR_LAST_PART ${CMAKE_CURRENT_LIST_DIR} NAME)
get_filename_component(LLVM_CONFIG_DIR ${LLVM_CONFIG} DIRECTORY)
get_filename_component(LLVM_LIB_DIR ${LLVM_LIBRARY} DIRECTORY)
file(APPEND ${PROJECT_BINARY_DIR}/elsa/__init__.py "from .${CMAKE_CURRENT_LIST_DIR_LAST_PART} import *\n")
# when compiling with libc++ as the STL, the path to the STL headers must be specified
set(ADDITIONAL_SYSTEM_INCLUDE_PATHS_FIX "")
get_target_property(TARGET_COMPILE_OPTIONS ${TARGET_NAME} COMPILE_OPTIONS)
if (CMAKE_CXX_FLAGS)
string(REPLACE " " ";" CXX_FLAGS_LIST ${CMAKE_CXX_FLAGS})
endif()
# search through the global and target specific compile options for the "-stdlib=libc++" flag
foreach(COMPILE_OPTION IN LISTS CXX_FLAGS_LIST TARGET_COMPILE_OPTIONS)
if (${COMPILE_OPTION} MATCHES "-stdlib=libc\\+\\+.*")
set(ADDITIONAL_SYSTEM_INCLUDE_PATHS_FIX --extra-arg-before=-cxx-isystem --extra-arg-before=${LLVM_LIB_DIR}/../include/c++/v1)
break()
endif()
endforeach(COMPILE_OPTION)
add_custom_command(OUTPUT ${BINDINGS_CODE_PATH}
COMMAND ${PROJECT_BINARY_DIR}/tools/bindings_generation/pybind11_generator
${ARGN}
${ADDITIONAL_SYSTEM_INCLUDE_PATHS_FIX}
--extra-arg=-I${PYTHON_INCLUDE_DIRS}
--extra-arg=-I${PYBIND11_INCLUDE_DIR}
--extra-arg=-I${LLVM_CONFIG_DIR}/../lib/clang/${LLVM_VERSION}/include
......
......@@ -13,6 +13,13 @@ else()
target_compile_features(pybind11_generator PUBLIC cxx_std_17)
target_include_directories(pybind11_generator PUBLIC ${LLVM_INCLUDE_DIR})
# linking fails if the generator is built using libc++
# force use of libstdc++ instead when compiling with clang
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(pybind11_generator PUBLIC -stdlib=libstdc++)
target_link_options(pybind11_generator PUBLIC -stdlib=libstdc++ -lstdc++)
endif()
if (LLVM_SHARED_MODE STREQUAL "shared")
target_link_libraries(pybind11_generator PUBLIC ${LLVM_LIBRARY} ${CLANG_CPP_LIBRARY} stdc++fs)
elseif (LLVM_SHARED_MODE STREQUAL "static")
......
......@@ -158,6 +158,7 @@ protected:
return elsa::Module::Function::RQ_RVAL;
default:
assert(false && ("ref-qualifier kind not supported"));
return elsa::Module::Function::RQ_NONE;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment