Skip to content

Commit

Permalink
Fix pugixml build on linux (#57)
Browse files Browse the repository at this point in the history
* fix pugixml build on linux

* shadows

* lint

* attempt lib64

* more attempt

* pugixml fpic

* fpic plugin-support.a
  • Loading branch information
royshil committed Nov 22, 2023
1 parent b1c6a70 commit 684a19d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
2 changes: 2 additions & 0 deletions cmake/BuildInja.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ set(BUILD_TESTING OFF)
set(INJA_BUILD_TESTS OFF)
set(BUILD_BENCHMARK OFF)
set(COVERALLS OFF)
# inja uses a lot of shadowing
add_compile_options(-Wno-shadow)
add_subdirectory(${CMAKE_SOURCE_DIR}/vendor/inja ${CMAKE_BINARY_DIR}/inja EXCLUDE_FROM_ALL)
1 change: 1 addition & 0 deletions cmake/BuildLexbor.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ExternalProject_Add(
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_LINKER=${CMAKE_LINKER}
-DCMAKE_INSTALL_MESSAGE=NEVER
${LEXBOR_CMAKE_PLATFORM_OPTIONS})

ExternalProject_Get_Property(lexbor_build INSTALL_DIR)
Expand Down
24 changes: 13 additions & 11 deletions cmake/BuildPugiXML.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,34 @@ include(ExternalProject)
if(APPLE)
set(PUGIXML_CMAKE_PLATFORM_OPTIONS -DCMAKE_OSX_ARCHITECTURES=x86_64$<SEMICOLON>arm64)
else()
set(PUGIXML_CMAKE_PLATFORM_OPTIONS "")
if(UNIX)
set(PUGIXML_CMAKE_PLATFORM_OPTIONS -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
else()
set(PUGIXML_CMAKE_PLATFORM_OPTIONS "")
endif()
endif()

set(pugixml_lib_filename ${CMAKE_STATIC_LIBRARY_PREFIX}pugixml${CMAKE_STATIC_LIBRARY_SUFFIX})

ExternalProject_Add(
pugixml_build
URL https://github.com/zeux/pugixml/releases/download/v1.13/pugixml-1.13.tar.gz
URL_MD5 3e4c588e03bdca140844f3c47c1a995e
CMAKE_GENERATOR ${CMAKE_GENERATOR}
INSTALL_BYPRODUCTS <INSTALL_DIR>/lib/${CMAKE_STATIC_LIBRARY_PREFIX}pugixml${CMAKE_STATIC_LIBRARY_SUFFIX}
INSTALL_BYPRODUCTS <INSTALL_DIR>/include
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/${pugixml_lib_filename}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DBUILD_SHARED_LIBS=OFF -DPUGIXML_BUILD_TESTS=OFF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${PUGIXML_CMAKE_PLATFORM_OPTIONS})
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${PUGIXML_CMAKE_PLATFORM_OPTIONS} -DCMAKE_INSTALL_LIBDIR=lib)

ExternalProject_Get_Property(pugixml_build INSTALL_DIR)

message(STATUS "pugixml will be installed to ${INSTALL_DIR}")

# find the library
set(pugixml_lib_filename ${CMAKE_STATIC_LIBRARY_PREFIX}pugixml${CMAKE_STATIC_LIBRARY_SUFFIX})
set(pugixml_lib_location ${INSTALL_DIR}/lib/${pugixml_lib_filename})

message(STATUS "pugixml library expected at ${pugixml_lib_location}")

add_library(pugixml_internal STATIC IMPORTED)
add_dependencies(pugixml_internal pugixml_build)
set_target_properties(pugixml_internal PROPERTIES IMPORTED_LOCATION ${pugixml_lib_location})
target_include_directories(pugixml_internal INTERFACE ${INSTALL_DIR}/include)

add_library(libpugixml_internal INTERFACE)
add_dependencies(libpugixml_internal pugixml_build)
add_dependencies(libpugixml_internal pugixml_build pugixml_internal)
target_link_libraries(libpugixml_internal INTERFACE pugixml_internal)
set_target_properties(libpugixml_internal PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
4 changes: 4 additions & 0 deletions cmake/common/helpers_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,8 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/plugin-support.c.in")
PRIVATE plugin-support.c
PUBLIC src/plugin-support.h)
target_include_directories(plugin-support PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
if(UNIX AND NOT APPLE)
# add fPIC on Linux to prevent shared object errors
set_property(TARGET plugin-support PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
endif()
9 changes: 5 additions & 4 deletions src/ui/RequestBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,12 @@ RequestBuilder::RequestBuilder(url_source_request_data *request_data,

// Save the headers from ui->tableView_headers's model
request_data_for_saving->headers.clear();
QStandardItemModel *model = (QStandardItemModel *)ui->tableView_headers->model();
for (int i = 0; i < model->rowCount(); i++) {
QStandardItemModel *itemModel =
(QStandardItemModel *)ui->tableView_headers->model();
for (int i = 0; i < itemModel->rowCount(); i++) {
request_data_for_saving->headers.push_back(
std::make_pair(model->item(i, 0)->text().toStdString(),
model->item(i, 1)->text().toStdString()));
std::make_pair(itemModel->item(i, 0)->text().toStdString(),
itemModel->item(i, 1)->text().toStdString()));
}

// Save the output parsing options
Expand Down

0 comments on commit 684a19d

Please sign in to comment.