Skip to content

Commit

Permalink
bugfix, clang12, link with libc++. CMAKE_CXX_FLAGS
Browse files Browse the repository at this point in the history
  • Loading branch information
yssource committed Jun 23, 2021
1 parent 2e41f97 commit a93af11
Show file tree
Hide file tree
Showing 10 changed files with 294 additions and 531 deletions.
101 changes: 34 additions & 67 deletions binding/abquant/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,86 +8,53 @@

# The name of the generated bindings module (as imported in Python). You can change the name
# to something relevant for your project.
set(bindings_library "pyabquant")

# set(CMAKE_CXX_FLAGS_RELEASE "-O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_SQL_LIB")

set(binding_library "pyabquant")
set(pyabquant_include_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../cxx/include)
set(tree_includes "/usr/include/treefrog/")
# set(tree_lib "/usr/lib/libtreefrog.so")
set(abquant_lib_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../lib)

set(sample_library "${abquant_lib_dir}/libabqcontroller.so;${abquant_lib_dir}/libabqhelper.so;${abquant_lib_dir}/libabqmodel.so;${abquant_lib_dir}/libabqaction.a;/usr/lib/libtreefrog.so")
set(bindings_library_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/)
set(core_libraries "${abquant_lib_dir}/libabqcontroller.so;${abquant_lib_dir}/libabqhelper.so;${abquant_lib_dir}/libabqmodel.so;${abquant_lib_dir}/libabqaction.so;/usr/lib/libtreefrog.so")
set(binding_library_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/)


# ==================================== RPATH configuration ====================================


# =============================================================================================
# !!! (The section below is deployment related, so in a real world application you will want to
# take care of this properly with some custom script or tool).
# =============================================================================================
# Enable rpaths so that the built shared libraries find their dependencies.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH ${CMAKE_CURRENT_SOURCE_DIR} ${QtCore_libdir})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# =============================================================================================
# !!! End of dubious section.
# =============================================================================================


# # ====================== Shiboken target for generating binding C++ files ====================
# get_target_property(qtcore_M_QT5_INCLUDES Qt5::Core INTERFACE_INCLUDE_DIRECTORIES)
set(qtcore_M_QT5_INCLUDES ${Qt5Core_INCLUDE_DIRS})

list(JOIN qtcore_M_QT5_INCLUDES ";-I" M_QT5_INCLUDES)

message(STATUS "${M_QT5_INCLUDES}")
set(M_QT5_INCLUDES ${M_QT5_INCLUDES})


# =============================== CMake target - bindings_library =============================
# =============================== CMake target - binding_library =============================

# Set the cpp files which will be used for the bindings library.
set(${bindings_library}_sources main.cpp)
set(${binding_library}_sources main.cpp)

# Define and build the bindings library.
# add_library(${bindings_library} MODULE ${${bindings_library}_sources})
pybind11_add_module(${bindings_library} SHARED ${${bindings_library}_sources} NO_EXTRAS)
# add_library(${binding_library} MODULE ${${binding_library}_sources})
pybind11_add_module(${binding_library} SHARED ${${binding_library}_sources} NO_EXTRAS)

# target_include_directories(${bindings_library} PUBLIC ${CONAN_INCLUDE_DIRS})
# target_include_directories(${binding_library} PUBLIC ${CONAN_INCLUDE_DIRS})

# Apply relevant include and link flags.
target_include_directories(${bindings_library} PUBLIC ${python_include_dir})
target_include_directories(${bindings_library} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${bindings_library} PUBLIC ${pyabquant_include_dir})
target_include_directories(${bindings_library} PUBLIC ${tree_includes})

target_include_directories(${bindings_library} PUBLIC "${Qt5Core_INCLUDE_DIRS}")
target_include_directories(${bindings_library} PUBLIC "${Qt5Network_INCLUDE_DIRS}")
target_include_directories(${bindings_library} PUBLIC "${Qt5Sql_INCLUDE_DIRS}")
target_include_directories(${bindings_library} PUBLIC "${Qt5Xml_INCLUDE_DIRS}")
target_include_directories(${bindings_library} PUBLIC "${Qt5Qml_INCLUDE_DIRS}")
# target_include_directories(${bindings_library} PUBLIC "${QtTest_INCLUDE_DIRS}")
target_include_directories(${bindings_library} PUBLIC ${pybind11_INCLUDE_DIRS})

target_link_libraries(${bindings_library} PUBLIC ${sample_library} ${CONAN_LIBS})
set_property(TARGET ${bindings_library} PROPERTY CXX_STANDARD 17)
target_include_directories(${binding_library} PUBLIC ${PYTHON_INCLUDE_DIRS})
target_include_directories(${binding_library} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${binding_library} PUBLIC ${pyabquant_include_dir})
target_include_directories(${binding_library} PUBLIC ${tree_includes})

target_include_directories(${binding_library} PUBLIC "${Qt5Core_INCLUDE_DIRS}")
target_include_directories(${binding_library} PUBLIC "${Qt5Network_INCLUDE_DIRS}")
target_include_directories(${binding_library} PUBLIC "${Qt5Sql_INCLUDE_DIRS}")
target_include_directories(${binding_library} PUBLIC "${Qt5Xml_INCLUDE_DIRS}")
target_include_directories(${binding_library} PUBLIC "${Qt5Qml_INCLUDE_DIRS}")
target_include_directories(${binding_library} PUBLIC ${pybind11_INCLUDE_DIRS})

target_link_libraries(${binding_library} PUBLIC ${core_libraries} ${CONAN_LIBS})
set_property(TARGET ${binding_library} PROPERTY CXX_STANDARD 17)

# Adjust the name of generated module.
set_property(TARGET ${bindings_library} PROPERTY PREFIX "")
set_property(TARGET ${bindings_library} PROPERTY OUTPUT_NAME
"${bindings_library}${PYTHON_EXTENSION_SUFFIX}")
set_property(TARGET ${binding_library} PROPERTY PREFIX "")
set_property(TARGET ${binding_library} PROPERTY OUTPUT_NAME
"${binding_library}${PYTHON_EXTENSION_SUFFIX}")
if(WIN32)
set_property(TARGET ${bindings_library} PROPERTY SUFFIX ".pyd")
set_property(TARGET ${binding_library} PROPERTY SUFFIX ".pyd")
endif()

# Make sure the linker doesn't complain about not finding Python symbols on macOS.
if(APPLE)
set_target_properties(${bindings_library} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
set_target_properties(${binding_library} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif(APPLE)

# Find and link to the python import library only on Windows.
Expand All @@ -97,7 +64,7 @@ if (WIN32)
list(GET python_linking_data 0 python_libdir)
list(GET python_linking_data 1 python_lib)
find_library(python_link_flags ${python_lib} PATHS ${python_libdir} HINTS ${python_libdir})
target_link_libraries(${bindings_library} PUBLIC ${python_link_flags})
target_link_libraries(${binding_library} PUBLIC ${python_link_flags})
endif()


Expand All @@ -107,15 +74,15 @@ endif()
# =============================================================================================
# Install the library and the bindings module into the source folder near the main.py file, so
# that the Python interpeter successfully imports the used module.
# install(TARGETS ${bindings_library} ${sample_library}
# install(TARGETS ${binding_library} ${core_libraries}
# LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}
# RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}
# )
install(TARGETS ${bindings_library}
LIBRARY DESTINATION ${bindings_library_dir}
RUNTIME DESTINATION ${bindings_library_dir}
install(TARGETS ${binding_library}
LIBRARY DESTINATION ${binding_library_dir}
RUNTIME DESTINATION ${binding_library_dir}
)

add_custom_command(TARGET ${bindings_library} POST_BUILD
add_custom_command(TARGET ${binding_library} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:${bindings_library}> ${abquant_lib_dir})
$<TARGET_FILE:${binding_library}> ${abquant_lib_dir})
100 changes: 34 additions & 66 deletions binding/emconceptbase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,86 +8,54 @@

# The name of the generated bindings module (as imported in Python). You can change the name
# to something relevant for your project.
set(bindings_library "pyabqemconceptbase")

# set(CMAKE_CXX_FLAGS_RELEASE "-O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_SQL_LIB")
set(binding_library "pyabqemconceptbase")

set(pyabqemconceptbase_include_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../cxx/include)
set(tree_includes "/usr/include/treefrog/")
# set(tree_lib "/usr/lib/libtreefrog.so")
set(abquant_lib_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../lib)
set(core_libraries "${abquant_lib_dir}/libabqcontroller.so;${abquant_lib_dir}/libabqhelper.so;${abquant_lib_dir}/libabqmodel.so;${abquant_lib_dir}/libabqaction.so;/usr/lib/libtreefrog.so")
set(binding_library_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/)

set(sample_library "${abquant_lib_dir}/libabqcontroller.so;${abquant_lib_dir}/libabqhelper.so;${abquant_lib_dir}/libabqmodel.so;${abquant_lib_dir}/libabqaction.a;/usr/lib/libtreefrog.so")
set(bindings_library_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/)


# ==================================== RPATH configuration ====================================


# =============================================================================================
# !!! (The section below is deployment related, so in a real world application you will want to
# take care of this properly with some custom script or tool).
# =============================================================================================
# Enable rpaths so that the built shared libraries find their dependencies.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH ${CMAKE_CURRENT_SOURCE_DIR} ${QtCore_libdir})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# =============================================================================================
# !!! End of dubious section.
# =============================================================================================


# # ====================== Shiboken target for generating binding C++ files ====================
# get_target_property(qtcore_M_QT5_INCLUDES Qt5::Core INTERFACE_INCLUDE_DIRECTORIES)
set(qtcore_M_QT5_INCLUDES ${Qt5Core_INCLUDE_DIRS})

list(JOIN qtcore_M_QT5_INCLUDES ";-I" M_QT5_INCLUDES)

message(STATUS "${M_QT5_INCLUDES}")
set(M_QT5_INCLUDES ${M_QT5_INCLUDES})


# =============================== CMake target - bindings_library =============================
# =============================== CMake target - binding_library =============================

# Set the cpp files which will be used for the bindings library.
set(${bindings_library}_sources main.cpp)
set(${binding_library}_sources main.cpp)

# Define and build the bindings library.
# add_library(${bindings_library} MODULE ${${bindings_library}_sources})
pybind11_add_module(${bindings_library} SHARED ${${bindings_library}_sources} NO_EXTRAS)
# add_library(${binding_library} MODULE ${${binding_library}_sources})
pybind11_add_module(${binding_library} SHARED ${${binding_library}_sources} NO_EXTRAS)

# target_include_directories(${bindings_library} PRIVATE ${CONAN_INCLUDE_DIRS})
# target_include_directories(${binding_library} PRIVATE ${CONAN_INCLUDE_DIRS})

# Apply relevant include and link flags.
target_include_directories(${bindings_library} PRIVATE ${python_include_dir})
target_include_directories(${bindings_library} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${bindings_library} PRIVATE ${pyabqemconceptbase_include_dir})
target_include_directories(${bindings_library} PRIVATE ${tree_includes})

target_include_directories(${bindings_library} PRIVATE "${Qt5Core_INCLUDE_DIRS}")
target_include_directories(${bindings_library} PRIVATE "${Qt5Network_INCLUDE_DIRS}")
target_include_directories(${bindings_library} PRIVATE "${Qt5Sql_INCLUDE_DIRS}")
target_include_directories(${bindings_library} PRIVATE "${Qt5Xml_INCLUDE_DIRS}")
target_include_directories(${bindings_library} PRIVATE "${Qt5Qml_INCLUDE_DIRS}")
# target_include_directories(${bindings_library} PRIVATE "${QtTest_INCLUDE_DIRS}")
target_include_directories(${bindings_library} PRIVATE ${pybind11_INCLUDE_DIRS})

target_link_libraries(${bindings_library} PRIVATE ${sample_library} ${CONAN_LIBS})
set_property(TARGET ${bindings_library} PROPERTY CXX_STANDARD 17)
target_include_directories(${binding_library} PRIVATE ${PYTHON_INCLUDE_DIRS})
target_include_directories(${binding_library} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${binding_library} PRIVATE ${pyabqemconceptbase_include_dir})
target_include_directories(${binding_library} PRIVATE ${tree_includes})

target_include_directories(${binding_library} PRIVATE "${Qt5Core_INCLUDE_DIRS}")
target_include_directories(${binding_library} PRIVATE "${Qt5Network_INCLUDE_DIRS}")
target_include_directories(${binding_library} PRIVATE "${Qt5Sql_INCLUDE_DIRS}")
target_include_directories(${binding_library} PRIVATE "${Qt5Xml_INCLUDE_DIRS}")
target_include_directories(${binding_library} PRIVATE "${Qt5Qml_INCLUDE_DIRS}")
target_include_directories(${binding_library} PRIVATE ${pybind11_INCLUDE_DIRS})

target_link_libraries(${binding_library} PRIVATE ${core_libraries} ${CONAN_LIBS})
set_property(TARGET ${binding_library} PROPERTY CXX_STANDARD 17)

# Adjust the name of generated module.
set_property(TARGET ${bindings_library} PROPERTY PREFIX "")
set_property(TARGET ${bindings_library} PROPERTY OUTPUT_NAME
"${bindings_library}${PYTHON_EXTENSION_SUFFIX}")
set_property(TARGET ${binding_library} PROPERTY PREFIX "")
set_property(TARGET ${binding_library} PROPERTY OUTPUT_NAME
"${binding_library}${PYTHON_EXTENSION_SUFFIX}")
if(WIN32)
set_property(TARGET ${bindings_library} PROPERTY SUFFIX ".pyd")
set_property(TARGET ${binding_library} PROPERTY SUFFIX ".pyd")
endif()

# Make sure the linker doesn't complain about not finding Python symbols on macOS.
if(APPLE)
set_target_properties(${bindings_library} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
set_target_properties(${binding_library} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif(APPLE)

# Find and link to the python import library only on Windows.
Expand All @@ -97,7 +65,7 @@ if (WIN32)
list(GET python_linking_data 0 python_libdir)
list(GET python_linking_data 1 python_lib)
find_library(python_link_flags ${python_lib} PATHS ${python_libdir} HINTS ${python_libdir})
target_link_libraries(${bindings_library} PRIVATE ${python_link_flags})
target_link_libraries(${binding_library} PRIVATE ${python_link_flags})
endif()


Expand All @@ -107,15 +75,15 @@ endif()
# =============================================================================================
# Install the library and the bindings module into the source folder near the main.py file, so
# that the Python interpeter successfully imports the used module.
# install(TARGETS ${bindings_library} ${sample_library}
# install(TARGETS ${binding_library} ${core_libraries}
# LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}
# RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}
# )
install(TARGETS ${bindings_library}
LIBRARY DESTINATION ${bindings_library_dir}
RUNTIME DESTINATION ${bindings_library_dir}
install(TARGETS ${binding_library}
LIBRARY DESTINATION ${binding_library_dir}
RUNTIME DESTINATION ${binding_library_dir}
)

add_custom_command(TARGET ${bindings_library} POST_BUILD
add_custom_command(TARGET ${binding_library} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:${bindings_library}> ${abquant_lib_dir})
$<TARGET_FILE:${binding_library}> ${abquant_lib_dir})
Loading

0 comments on commit a93af11

Please sign in to comment.