diff --git a/CMakeLists.txt b/CMakeLists.txt index c21e30a630..0654dfb5a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,7 +196,11 @@ find_package(PkgConfig REQUIRED) if (NOT PKG_CONFIG_FOUND) message (SEND_ERROR "pkg-config not found, but is required") -endif (NOT PKG_CONFIG_FOUND) + endif (NOT PKG_CONFIG_FOUND) + +if (CMAKE_VERSION VERSION_LESS 3.6) + include(GncPkgConfig) +endif() # glib et al. pkg_check_modules (GLIB2 REQUIRED glib-2.0>=2.40) @@ -209,31 +213,42 @@ pkg_check_modules (LIBXML2 REQUIRED libxml-2.0>=2.7.0) pkg_check_modules (LIBXSLT REQUIRED libxslt) if (WITH_GNUCASH) if (WIN32 OR APPLE) - pkg_check_modules (WEBKIT1 REQUIRED webkitgtk-3.0) - set(WEBKIT1 1) - set(WEBKIT_CFLAGS ${WEBKIT2_CFLAGS}) - set(WEBKIT_INCLUDE_DIRS ${WEBKIT1_INCLUDE_DIRS}) - set(WEBKIT_LDFLAGS ${WEBKIT1_LDFLAGS}) - set(WEBKIT_LIBRARIES ${WEBKIT1_LIBRARIES}) + if (NOT CMAKE_VERSION VERSION_LESS 3.6) + pkg_check_modules (WEBKIT REQUIRED IMPORTED_TARGET webkitgtk-3.0) + else() + pkg_check_modules (WEBKIT REQUIRED webkitgtk-3.0) + endif() + set(WEBKIT1 1 CACHE INTERNAL "WebKitGtk") + _pkg_create_imp_target(WEBKIT) else (WIN32 OR APPLE) - pkg_check_modules (WEBKIT2_4 webkit2gtk-4.0) - if (NOT WEBKIT2_4_FOUND) - pkg_check_modules (WEBKIT2_3 REQUIRED webkit2gtk-3.0) - set(WEBKIT2_3 1) - set(WEBKIT_CFLAGS ${WEBKIT2_3_CFLAGS}) - set(WEBKIT_INCLUDE_DIRS ${WEBKIT2_3_INCLUDE_DIRS}) - set(WEBKIT_LDFLAGS ${WEBKIT2_3_LDFLAGS}) - set(WEBKIT_LIBRARIES ${WEBKIT2_3_LIBRARIES}) - else (NOT WEBKIT2_4_FOUND) - set(WEBKIT2_4 1) - set(WEBKIT_CFLAGS ${WEBKIT2_4_CFLAGS}) - set(WEBKIT_INCLUDE_DIRS ${WEBKIT2_4_INCLUDE_DIRS}) - set(WEBKIT_LDFLAGS ${WEBKIT2_4_LDFLAGS}) - set(WEBKIT_LIBRARIES ${WEBKIT2_4_LIBRARIES}) - endif (NOT WEBKIT2_4_FOUND) + If (NOT CMAKE_VERSION VERSION_LESS 3.6) + pkg_check_modules (WEBKIT IMPORTED_TARGET webkit2gtk-4.0) + else() + pkg_check_modules (WEBKIT webkit2gtk-4.0) + endif() + if (NOT WEBKIT_FOUND) + if (NOT CMAKE_VERSION VERSION_LESS 3.6) + pkg_check_modules (WEBKIT REQUIRED IMPORTED_TARGET webkit2gtk-3.0) + else() + pkg_check_modules (WEBKIT REQUIRED webkit2gtk-3.0) + endif() + set(WEBKIT2_3 1 CACHE INTERNAL "WebKit2Gtk3") + else (NOT WEBKIT_FOUND) + if (NOT WEBKIT2_3) + set(WEBKIT2_4 1 CACHE INTERNAL "WebKit2Gtk4") + endif(NOT WEBKIT2_3) + endif (NOT WEBKIT_FOUND) + if (CMAKE_VERSION VERSION_LESS 3.6) + _pkg_create_imp_target(WEBKIT) + endif() endif (WIN32 OR APPLE) - pkg_check_modules (GTK3 REQUIRED gtk+-3.0>=3.10.0) + if (NOT CMAKE_VERSION VERSION_LESS 3.6) + pkg_check_modules (GTK3 REQUIRED IMPORTED_TARGET gtk+-3.0>=3.10.0) + else() + pkg_check_modules (GTK3 REQUIRED gtk+-3.0>=3.10.0) + _pkg_create_imp_target(GTK3) + endif() endif (WITH_GNUCASH) pkg_check_modules (ZLIB REQUIRED zlib) diff --git a/common/cmake_modules/GncPkgConfig.cmake b/common/cmake_modules/GncPkgConfig.cmake new file mode 100644 index 0000000000..8dc88aaac1 --- /dev/null +++ b/common/cmake_modules/GncPkgConfig.cmake @@ -0,0 +1,52 @@ +#Pinched from FindPkgConfig in CMake 3.6 because we need to do this in +#CMake 3.5. Delete this file and the corresponding calls in master +#after merging up. + +# given directories, and create an imported target from them +function(_pkg_create_imp_target _prefix) + unset(_libs) + unset(_find_opts) + + # set the options that are used as long as the .pc file does not provide a library + # path to look into + + foreach (flag IN LISTS ${_prefix}_LDFLAGS) + if (flag MATCHES "^-L(.*)") + # only look into the given paths from now on + set(_find_opts "HINTS ${${CMAKE_MATCH_1}} NO_DEFAULT_PATH") + continue() + endif() + if (flag MATCHES "^-l(.*)") + set(_pkg_search "${CMAKE_MATCH_1}") + else() + continue() + endif() + + find_library(pkgcfg_lib_${_prefix}_${_pkg_search} + NAMES ${_pkg_search} + ${_find_opts}) + list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}") + endforeach() + + # only create the target if it is linkable, i.e. no executables + if (NOT TARGET PkgConfig::${_prefix} + AND ( ${_prefix}_INCLUDE_DIRS OR _libs OR ${_prefix}_CFLAGS_OTHER )) + add_library(PkgConfig::${_prefix} INTERFACE IMPORTED) + + unset(_props) + if(${_prefix}_INCLUDE_DIRS) + set_property(TARGET PkgConfig::${_prefix} PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}") + endif() + if(_libs) + set_property(TARGET PkgConfig::${_prefix} PROPERTY + INTERFACE_LINK_LIBRARIES "${_libs}") + endif() + if(${_prefix}_CFLAGS_OTHER) + set_property(TARGET PkgConfig::${_prefix} PROPERTY + INTERFACE_COMPILE_OPTIONS "${${_prefix}_CFLAGS_OTHER}") + endif() + endif() +endfunction() + + diff --git a/gnucash/CMakeLists.txt b/gnucash/CMakeLists.txt index 179a3a66ce..e2761c7d03 100644 --- a/gnucash/CMakeLists.txt +++ b/gnucash/CMakeLists.txt @@ -65,9 +65,9 @@ if (BUILDING_FROM_VCS) endif (BUILDING_FROM_VCS) target_link_libraries (gnucash - gncmod-ledger-core gncmod-report-gnome gnc-gnome gncmod-gnome-utils gncmod-app-utils - gncmod-engine gnc-module gnc-core-utils gncmod-report-system - ${GUILE_LDFLAGS} ${GLIB2_LDFLAGS} ${GTK3_LDFLAGS} ${GTK_MAC_LDFLAGS} + gncmod-ledger-core gncmod-report-gnome gnc-gnome gncmod-gnome-utils + gncmod-app-utils gncmod-engine gnc-module gnc-core-utils gncmod-report-system + PkgConfig::GTK3 ${GUILE_LDFLAGS} ${GLIB2_LDFLAGS} ${GTK_MAC_LDFLAGS} ) # Get glib executable for generating the gresource file diff --git a/gnucash/gnome-search/CMakeLists.txt b/gnucash/gnome-search/CMakeLists.txt index dc58d3218b..f45c0a046d 100644 --- a/gnucash/gnome-search/CMakeLists.txt +++ b/gnucash/gnome-search/CMakeLists.txt @@ -46,7 +46,7 @@ add_library (gncmod-gnome-search ${gnome_search_noinst_HEADERS} ) -target_link_libraries(gncmod-gnome-search gncmod-gnome-utils ${GTK3_LDFLAGS}) +target_link_libraries(gncmod-gnome-search gncmod-gnome-utils PkgConfig::GTK3) target_compile_definitions(gncmod-gnome-search PRIVATE -DG_LOG_DOMAIN=\"gnc.gui.search\") diff --git a/gnucash/gnome-utils/CMakeLists.txt b/gnucash/gnome-utils/CMakeLists.txt index 4d5c6688f2..3c9c6d195c 100644 --- a/gnucash/gnome-utils/CMakeLists.txt +++ b/gnucash/gnome-utils/CMakeLists.txt @@ -211,8 +211,8 @@ add_library (gncmod-gnome-utils ${gnome_utils_noinst_HEADERS} ) -target_link_libraries(gncmod-gnome-utils gncmod-app-utils gncmod-engine gnc-backend-xml-utils - ${CMAKE_DL_LIBS} ${GTK3_LDFLAGS} ${LIBSECRET_LDFLAGS} ${GTK_MAC_LDFLAGS}) +target_link_libraries(gncmod-gnome-utils gncmod-app-utils gncmod-engine gnc-backend-xml-utils ${GTK3_LDFLAGS} + ${CMAKE_DL_LIBS} ${LIBSECRET_LDFLAGS} ${GTK_MAC_LDFLAGS}) target_compile_options(gncmod-gnome-utils PRIVATE -Wno-deprecated-declarations) target_compile_definitions(gncmod-gnome-utils PUBLIC ${GTK_MAC_CFLAGS_OTHER} diff --git a/gnucash/gnome-utils/test/CMakeLists.txt b/gnucash/gnome-utils/test/CMakeLists.txt index fc47735ab5..25e82319c5 100644 --- a/gnucash/gnome-utils/test/CMakeLists.txt +++ b/gnucash/gnome-utils/test/CMakeLists.txt @@ -16,7 +16,7 @@ set(GNOME_UTILS_GUI_TEST_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/common ${CMAKE_SOURCE_DIR}/gnucash/gnome-utils ${CMAKE_SOURCE_DIR}/libgnucash/engine - ${GTK3_INCLUDE_DIRS} +# ${GTK3_INCLUDE_DIRS} ) set(GNOME_UTILS_GUI_TEST_LIBS ${GNOME_UTILS_TEST_LIBS} diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt index 444f20439d..0a02924750 100644 --- a/gnucash/gnome/CMakeLists.txt +++ b/gnucash/gnome/CMakeLists.txt @@ -125,7 +125,7 @@ set_source_files_properties (${gnc_gnome_SOURCES} PROPERTIES OBJECT_DEPENDS ${CO add_library (gnc-gnome ${gnc_gnome_SOURCES} ${gnc_gnome_noinst_HEADERS} ${SWIG_GNOME_C}) target_link_libraries(gnc-gnome gncmod-gnome-search gncmod-ledger-core gncmod-report-gnome gncmod-report-system - gncmod-register-gnome gncmod-register-core gncmod-gnome-utils gncmod-engine ${GTK3_LDFLAGS} ${GTK_MAC_LDFLAGS}) + gncmod-register-gnome gncmod-register-core gncmod-gnome-utils gncmod-engine PkgConfig::GTK3 ${GTK_MAC_LDFLAGS}) target_compile_definitions (gnc-gnome PRIVATE -DG_LOG_DOMAIN=\"gnc.gui\" ${GTK_MAC_CFLAGS_OTHER}) target_compile_options(gnc-gnome PRIVATE -Wno-deprecated-declarations) diff --git a/gnucash/html/CMakeLists.txt b/gnucash/html/CMakeLists.txt index 9dc8687c1b..834cc8f4a3 100644 --- a/gnucash/html/CMakeLists.txt +++ b/gnucash/html/CMakeLists.txt @@ -40,15 +40,14 @@ add_library (gncmod-html ${html_HEADERS} ) -target_link_libraries(gncmod-html gncmod-engine gnc-module gncmod-gnome-utils ${WEBKIT_LDFLAGS} ${GUILE_LDFLAGS}) +target_link_libraries(gncmod-html gncmod-engine gnc-module gncmod-gnome-utils + PkgConfig::GTK3 PkgConfig::WEBKIT ${GUILE_LDFLAGS}) target_compile_definitions(gncmod-html PRIVATE -DG_LOG_DOMAIN=\"gnc.html\") target_include_directories (gncmod-html PUBLIC - ${GTK3_INCLUDE_DIRS} - ${WEBKIT_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/gnucash/html/gnc-html.c b/gnucash/html/gnc-html.c index a143688387..3b97ec22d2 100644 --- a/gnucash/html/gnc-html.c +++ b/gnucash/html/gnc-html.c @@ -71,10 +71,10 @@ G_DEFINE_ABSTRACT_TYPE(GncHtml, gnc_html, GTK_TYPE_BIN) static void gnc_html_class_init( GncHtmlClass* klass ); static void gnc_html_dispose( GObject* obj ); static void gnc_html_finalize( GObject* obj ); - -//#define GNC_HTML_GET_PRIVATE(o) \ +/* +#define GNC_HTML_GET_PRIVATE(o) \ ((GncHtmlPrivate*)g_type_instance_get_private((GTypeInstance*)o, GNC_TYPE_HTML)) - +*/ #define GNC_HTML_GET_PRIVATE(o) (GNC_HTML(o)->priv) #include "gnc-html-p.h" diff --git a/gnucash/import-export/CMakeLists.txt b/gnucash/import-export/CMakeLists.txt index cca8359a26..4138898787 100644 --- a/gnucash/import-export/CMakeLists.txt +++ b/gnucash/import-export/CMakeLists.txt @@ -51,7 +51,7 @@ add_library (gncmod-generic-import ${generic_import_noinst_HEADERS} ) -target_link_libraries(gncmod-generic-import gncmod-gnome-utils gncmod-engine ${GTK3_LDFLAGS} ${GLIB2_LDFLAGS}) +target_link_libraries(gncmod-generic-import gncmod-gnome-utils gncmod-engine PkgConfig::GTK3 ${GLIB2_LDFLAGS}) target_compile_definitions (gncmod-generic-import PRIVATE -DG_LOG_DOMAIN=\"gnc.import\") diff --git a/gnucash/import-export/log-replay/CMakeLists.txt b/gnucash/import-export/log-replay/CMakeLists.txt index 5fd8b0f8ea..b7bb5d7a68 100644 --- a/gnucash/import-export/log-replay/CMakeLists.txt +++ b/gnucash/import-export/log-replay/CMakeLists.txt @@ -16,7 +16,7 @@ set(log_replay_noinst_HEADERS add_library(gncmod-log-replay ${log_replay_SOURCES} ${log_replay_noinst_HEADERS}) target_link_libraries(gncmod-log-replay gncmod-gnome-utils gncmod-app-utils gncmod-engine - gnc-core-utils gnc-module ${GTK3_LDFLAGS}) + gnc-core-utils gnc-module PkgConfig::GTK3) target_compile_definitions(gncmod-log-replay PRIVATE -DG_LOG_DOMAIN=\"gnc.import.log-replay\") diff --git a/gnucash/register/ledger-core/CMakeLists.txt b/gnucash/register/ledger-core/CMakeLists.txt index ea26a993ee..9721067344 100644 --- a/gnucash/register/ledger-core/CMakeLists.txt +++ b/gnucash/register/ledger-core/CMakeLists.txt @@ -43,7 +43,7 @@ set_source_files_properties (${ledger_core_SOURCES} PROPERTIES OBJECT_DEPENDS ${ add_library (gncmod-ledger-core ${ledger_core_SOURCES} ${ledger_core_HEADERS}) target_link_libraries(gncmod-ledger-core gncmod-register-gnome gncmod-register-core gncmod-gnome-utils - gncmod-engine gnc-core-utils ${GTK3_LDFLAGS}) + gncmod-engine gnc-core-utils PkgConfig::GTK3) target_compile_definitions (gncmod-ledger-core PRIVATE -DG_LOG_DOMAIN=\"gnc.register.ledger\") diff --git a/gnucash/register/register-gnome/CMakeLists.txt b/gnucash/register/register-gnome/CMakeLists.txt index f3527484ba..5aa82ffa34 100644 --- a/gnucash/register/register-gnome/CMakeLists.txt +++ b/gnucash/register/register-gnome/CMakeLists.txt @@ -55,13 +55,13 @@ set_source_files_properties (${register_gnome_SOURCES} PROPERTIES OBJECT_DEPENDS add_library (gncmod-register-gnome ${register_gnome_SOURCES} ${register_gnome_noinst_HEADERS}) -target_link_libraries(gncmod-register-gnome gncmod-register-core ${GTK3_LDFLAGS}) +target_link_libraries(gncmod-register-gnome gncmod-register-core PkgConfig::GTK3) target_compile_definitions(gncmod-register-gnome PRIVATE -DG_LOG_DOMAIN=\"gnc.register.gnome\") target_include_directories(gncmod-register-gnome PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_SOURCE_DIR}/gnucash/register/ledger-core ${GTK3_INCLUDE_DIRS} + PRIVATE ${CMAKE_SOURCE_DIR}/gnucash/register/ledger-core ) if (APPLE) diff --git a/gnucash/report/report-gnome/CMakeLists.txt b/gnucash/report/report-gnome/CMakeLists.txt index 7f20c3fa0f..959a3c8262 100644 --- a/gnucash/report/report-gnome/CMakeLists.txt +++ b/gnucash/report/report-gnome/CMakeLists.txt @@ -29,7 +29,7 @@ add_library (gncmod-report-gnome ${SWIG_REPORT_GNOME_C} ) target_link_libraries(gncmod-report-gnome gncmod-report-system gncmod-html gncmod-gnome-utils - ${GUILE_LDFLAGS} ${GTK3_LDFLAGS}) + PkgConfig::GTK3 ${GUILE_LDFLAGS} ) target_compile_definitions (gncmod-report-gnome PRIVATE -DG_LOG_DOMAIN=\"gnc.report.gui\") target_compile_options(gncmod-report-gnome PRIVATE -Wno-deprecated-declarations) diff --git a/gnucash/report/report-system/CMakeLists.txt b/gnucash/report/report-system/CMakeLists.txt index c5c57902f7..c9dcf1eba7 100644 --- a/gnucash/report/report-system/CMakeLists.txt +++ b/gnucash/report/report-system/CMakeLists.txt @@ -23,10 +23,10 @@ add_library (gncmod-report-system target_compile_definitions(gncmod-report-system PRIVATE -DG_LOG_DOMAIN=\"gnc.report.core\") -target_link_libraries(gncmod-report-system gnc-module gncmod-app-utils ${GTK3_LDFLAGS} ${GUILE_LDFLAGS}) +target_link_libraries(gncmod-report-system gnc-module gncmod-app-utils PkgConfig::GTK3 ${GUILE_LDFLAGS}) target_include_directories (gncmod-report-system - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${GTK3_INCLUDE_DIRS} + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/gnucash/report/stylesheets/CMakeLists.txt b/gnucash/report/stylesheets/CMakeLists.txt index 285662cb86..3f1fa748c8 100644 --- a/gnucash/report/stylesheets/CMakeLists.txt +++ b/gnucash/report/stylesheets/CMakeLists.txt @@ -12,7 +12,7 @@ set(stylesheets_noinst_HEADERS add_library(gncmod-stylesheets MODULE ${stylesheets_SOURCES} ${stylesheets_noinst_HEADERS}) target_link_libraries(gncmod-stylesheets gncmod-report-gnome gncmod-report-system gncmod-gnome-utils gnc-module - ${GUILE_LDFLAGS} ${GTK3_LDFLAGS} ${GLIB2_LDFLAGS}) + PkgConfig::GTK3 ${GUILE_LDFLAGS} ${GLIB2_LDFLAGS}) target_compile_definitions(gncmod-stylesheets PRIVATE -DG_LOG_DOMAIN=\"gnc.report.core\")