Skip to content

Commit

Permalink
cmake fixes to static providers (#44326)
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jul 22, 2021
1 parent 9af959a commit 30e3f46
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 65 deletions.
5 changes: 0 additions & 5 deletions src/core/CMakeLists.txt
Expand Up @@ -2091,11 +2091,6 @@ if (HAVE_PDAL)
endif()

if (FORCE_STATIC_LIBS)
include_directories(
${CMAKE_SOURCE_DIR}/src/providers/wms
${CMAKE_SOURCE_DIR}/src/providers/postgres
)

target_link_libraries(qgis_core
provider_wms_a
provider_postgres_a
Expand Down
5 changes: 0 additions & 5 deletions src/gui/CMakeLists.txt
Expand Up @@ -1507,11 +1507,6 @@ target_link_libraries(qgis_gui
)

if (FORCE_STATIC_LIBS)
include_directories(
${CMAKE_SOURCE_DIR}/src/providers/wms
${CMAKE_SOURCE_DIR}/src/providers/postgres
)

target_link_libraries(qgis_gui
provider_wms_gui_a
provider_postgres_gui_a
Expand Down
68 changes: 35 additions & 33 deletions src/providers/postgres/CMakeLists.txt
Expand Up @@ -37,32 +37,16 @@ set(PG_HDRS
########################################################
# Build

include_directories(SYSTEM
# static library
add_library (provider_postgres_a STATIC ${PG_SRCS} ${PG_HDRS})

target_include_directories(provider_postgres_a SYSTEM PRIVATE
${POSTGRES_INCLUDE_DIR}
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
${GDAL_INCLUDE_DIR}
${SPATIALINDEX_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)

if (WITH_GUI)
include_directories(SYSTEM
${QSCINTILLA_INCLUDE_DIR}
)
include_directories (
${CMAKE_BINARY_DIR}/src/providers/postgres
${CMAKE_SOURCE_DIR}/src/providers/postgres
${CMAKE_BINARY_DIR}/src/providers/postgres/raster
${CMAKE_SOURCE_DIR}/src/providers/postgres/raster
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_BINARY_DIR}/src/ui
)
endif()

# static library
add_library (provider_postgres_a STATIC ${PG_SRCS} ${PG_HDRS})
target_include_directories(provider_postgres_a PUBLIC
${CMAKE_SOURCE_DIR}/src/providers/postgres
)

# require c++17
target_compile_features(provider_postgres_a PRIVATE cxx_std_17)
Expand All @@ -81,6 +65,14 @@ if (WITH_GUI)

add_library(provider_postgres_gui_a STATIC ${PG_GUI_SRCS} ${PG_UIS_H})

target_include_directories(provider_postgres_gui_a SYSTEM PRIVATE
${POSTGRES_INCLUDE_DIR}
)

target_include_directories(provider_postgres_gui_a PUBLIC
${CMAKE_BINARY_DIR}/src/providers/postgres
)

# require c++17
target_compile_features(provider_postgres_gui_a PRIVATE cxx_std_17)

Expand All @@ -106,20 +98,20 @@ set(PGRASTER_SRCS
# static library
add_library (provider_postgresraster_a STATIC ${PGRASTER_SRCS} ${PG_HDRS})

target_include_directories(provider_postgresraster_a SYSTEM PRIVATE
${POSTGRES_INCLUDE_DIR}
)
target_include_directories(provider_postgresraster_a PUBLIC
${CMAKE_SOURCE_DIR}/src/providers/postgres/raster
)

# require c++17
target_compile_features(provider_postgresraster_a PRIVATE cxx_std_17)

target_link_libraries (provider_postgresraster_a
qgis_core
provider_postgres_a
${POSTGRES_LIBRARY}
${${QT_VERSION_BASE}Xml_LIBRARIES}
${${QT_VERSION_BASE}Core_LIBRARIES}
${${QT_VERSION_BASE}Svg_LIBRARIES}
${${QT_VERSION_BASE}Network_LIBRARIES}
${${QT_VERSION_BASE}Sql_LIBRARIES}
${${QT_VERSION_BASE}Concurrent_LIBRARIES}
${${QT_VERSION_BASE}Gui_LIBRARIES}
${${QT_VERSION_BASE}Widgets_LIBRARIES}
)

if (WITH_GUI)
Expand All @@ -143,18 +135,28 @@ else()
add_library(provider_postgres MODULE ${PG_SRCS} ${PG_GUI_SRCS} ${PG_HDRS})
add_library(provider_postgresraster MODULE ${PGRASTER_SRCS} ${PG_HDRS})

target_include_directories(provider_postgres SYSTEM PRIVATE
${POSTGRES_INCLUDE_DIR}
)
target_include_directories(provider_postgresraster SYSTEM PRIVATE
${POSTGRES_INCLUDE_DIR}
)
target_include_directories(provider_postgresraster PRIVATE
${CMAKE_SOURCE_DIR}/src/providers/postgres
)

# require c++17
target_compile_features(provider_postgres PRIVATE cxx_std_17)
target_compile_features(provider_postgresraster PRIVATE cxx_std_17)

target_link_libraries(provider_postgres
${POSTGRES_LIBRARY}
qgis_core
${POSTGRES_LIBRARY}
)

target_link_libraries(provider_postgresraster
${POSTGRES_LIBRARY}
qgis_core
${POSTGRES_LIBRARY}
)

if (WITH_GUI)
Expand Down
30 changes: 8 additions & 22 deletions src/providers/wms/CMakeLists.txt
Expand Up @@ -25,18 +25,14 @@ endif()
# static library
add_library(provider_wms_a STATIC ${WMS_SRCS})

target_include_directories(provider_wms_a PUBLIC
${CMAKE_SOURCE_DIR}/src/providers/wms
)

# require c++17
target_compile_features(provider_wms_a PRIVATE cxx_std_17)

if (WITH_GUI)
include_directories (
${CMAKE_BINARY_DIR}/src/providers/wms
${CMAKE_SOURCE_DIR}/src/providers/wms
${CMAKE_BINARY_DIR}/src/ui
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)

if (WITH_QT6)
QT6_WRAP_UI(WMS_UIS_H ${WMS_UIS})
else()
Expand All @@ -45,6 +41,10 @@ if (WITH_GUI)

add_library(provider_wms_gui_a STATIC ${WMS_GUI_SRCS} ${WMS_UIS_H})

target_include_directories (provider_wms_gui_a PUBLIC
${CMAKE_BINARY_DIR}/src/providers/wms
)

# require c++17
target_compile_features(provider_wms_gui_a PRIVATE cxx_std_17)

Expand All @@ -54,27 +54,13 @@ endif()

target_link_libraries(provider_wms_a
qgis_core
${${QT_VERSION_BASE}Xml_LIBRARIES}
${${QT_VERSION_BASE}Core_LIBRARIES}
${${QT_VERSION_BASE}Svg_LIBRARIES}
${${QT_VERSION_BASE}Network_LIBRARIES}
${${QT_VERSION_BASE}Sql_LIBRARIES}
${${QT_VERSION_BASE}Concurrent_LIBRARIES}
)
target_compile_definitions(provider_wms_a PRIVATE "-DQT_NO_FOREACH")

if (WITH_GUI)
target_link_libraries(provider_wms_gui_a
qgis_gui
provider_wms_a
${${QT_VERSION_BASE}Xml_LIBRARIES}
${${QT_VERSION_BASE}Core_LIBRARIES}
${${QT_VERSION_BASE}Svg_LIBRARIES}
${${QT_VERSION_BASE}Network_LIBRARIES}
${${QT_VERSION_BASE}Sql_LIBRARIES}
${${QT_VERSION_BASE}Concurrent_LIBRARIES}
${${QT_VERSION_BASE}Gui_LIBRARIES}
${${QT_VERSION_BASE}Widgets_LIBRARIES}
)
target_compile_definitions(provider_wms_gui_a PRIVATE "-DQT_NO_FOREACH")
endif()
Expand Down

0 comments on commit 30e3f46

Please sign in to comment.