Import GLIB2 as a target, and use it to simplify the CMakeLists

This commit is contained in:
Richard Cohen 2023-02-21 11:22:55 +00:00
parent 17648ac91f
commit bddb4468fa
27 changed files with 26 additions and 54 deletions

View File

@ -196,7 +196,7 @@ if (NOT PKG_CONFIG_FOUND)
endif()
# glib et al.
pkg_check_modules (GLIB2 REQUIRED glib-2.0>=2.56.1)
pkg_check_modules (GLIB2 REQUIRED IMPORTED_TARGET glib-2.0>=2.56.1)
pkg_check_modules (GIO REQUIRED gio-2.0)
pkg_check_modules (GOBJECT REQUIRED gobject-2.0)
pkg_check_modules (GMODULE REQUIRED gmodule-2.0)

View File

@ -69,7 +69,6 @@ target_include_directories(gnucash-guile
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${GUILE_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS}
PRIVATE
${CMAKE_SOURCE_DIR}/common
${CMAKE_BINARY_DIR}/common)
@ -81,7 +80,7 @@ target_link_libraries(gnucash-guile
gnc-core-utils
gnc-engine
gnc-app-utils
${GLIB2_LDFLAGS})
PkgConfig::GLIB2)
install(TARGETS gnucash-guile
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
@ -95,15 +94,14 @@ add_library(gnc-expressions-guile SHARED
target_include_directories(gnc-expressions-guile
PUBLIC
${CMAKE_SOURCE_DIR}/libgnucash/expressions
${GUILE_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS})
${GUILE_INCLUDE_DIRS})
target_link_libraries(gnc-expressions-guile
gnc-expressions
gnc-engine
gnc-app-utils
${GUILE_LDFLAGS}
${GLIB2_LDFLAGS})
PkgConfig::GLIB2)
install(TARGETS gnc-expressions-guile
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

View File

@ -8,7 +8,6 @@ set(ENGINE_TEST_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/common/test-core # for unittest-support.h
${CMAKE_SOURCE_DIR}/libgnucash/app-utils
${CMAKE_SOURCE_DIR}/bindings/guile # for gnc-engine-guile.h
${GLIB2_INCLUDE_DIRS}
${GUILE_INCLUDE_DIRS}
)

View File

@ -14,7 +14,6 @@ include_directories(
${CMAKE_SOURCE_DIR}/libgnucash/engine
${CMAKE_SOURCE_DIR}/common/test-core
${GLIB2_INCLUDE_DIRS}
${GUILE_INCLUDE_DIRS}
)
@ -22,7 +21,7 @@ set_dist_list(test_core_DIST ${test_core_SOURCES} ${test_core_noinst_HEADERS} CM
unittest-support.i unittest-support.scm)
add_library(test-core STATIC ${test_core_SOURCES} ${test_core_noinst_HEADERS})
target_link_libraries(test-core gnc-engine ${GLIB2_LDFLAGS})
target_link_libraries(test-core gnc-engine PkgConfig::GLIB2)
if (UNIX)
target_compile_options(test-core PRIVATE -fPIC)
endif()
@ -41,7 +40,7 @@ gnc_add_swig_python_command (swig-unittest-support-python
)
add_library(test-core-guile ${SWIG_UNITTEST_SUPPORT_GUILE_C})
target_link_libraries(test-core-guile test-core ${GUILE_LDFLAGS} ${GLIB2_LDFLAGS})
target_link_libraries(test-core-guile test-core ${GUILE_LDFLAGS} PkgConfig::GLIB2)
add_dependencies (test-core-guile swig-unittest-support-guile-c )
if (WITH_PYTHON)

View File

@ -109,7 +109,7 @@ target_link_libraries (gnucash
gnc-engine gnc-module gnc-core-utils gnucash-guile
gnc-qif-import gnc-csv-import gnc-csv-export gnc-log-replay
gnc-bi-import gnc-customer-import gnc-report
PkgConfig::GTK3 ${GUILE_LDFLAGS} ${GLIB2_LDFLAGS}
PkgConfig::GTK3 ${GUILE_LDFLAGS} PkgConfig::GLIB2
${Boost_LIBRARIES}
)
@ -142,7 +142,7 @@ target_compile_definitions(gnucash-cli PRIVATE -DG_LOG_DOMAIN=\"gnc.bin\")
target_link_libraries (gnucash-cli
gnc-gnome-utils gnc-app-utils
gnc-engine gnc-core-utils gnucash-guile gnc-report
${GUILE_LDFLAGS} ${GLIB2_LDFLAGS}
${GUILE_LDFLAGS} PkgConfig::GLIB2
${Boost_LIBRARIES}
)

View File

@ -3,7 +3,6 @@ set(GNOME_UTILS_GUI_TEST_INCLUDE_DIRS
${CMAKE_BINARY_DIR}/common
${CMAKE_SOURCE_DIR}/gnucash/gnome-utils
${CMAKE_SOURCE_DIR}/libgnucash/engine
${GLIB2_INCLUDE_DIRS}
${GUILE_INCLUDE_DIRS}
)
set(GNOME_UTILS_GUI_TEST_LIBS
@ -36,7 +35,6 @@ set(test_autoclear_SOURCES
set(test_autoclear_INCLUDE_DIRS
${CMAKE_BINARY_DIR}/common
${CMAKE_SOURCE_DIR}/libgnucash/engine
${GLIB2_INCLUDE_DIRS}
)
set(test_autoclear_LIBS

View File

@ -50,7 +50,7 @@ add_library (gnc-generic-import
${generic_import_noinst_HEADERS}
)
target_link_libraries(gnc-generic-import gnc-gnome-utils gnc-engine PkgConfig::GTK3 ${GLIB2_LDFLAGS})
target_link_libraries(gnc-generic-import gnc-gnome-utils gnc-engine PkgConfig::GTK3 PkgConfig::GLIB2)
target_compile_definitions (gnc-generic-import PRIVATE -DG_LOG_DOMAIN=\"gnc.import\")

View File

@ -14,7 +14,6 @@ set(test_aqb_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/libgnucash/engine
${CMAKE_SOURCE_DIR}/libgnucash/core-utils
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
${GLIB2_INCLUDE_DIRS}
${AQBANKING_INCLUDE_DIRS}
)
@ -22,7 +21,6 @@ set(test_aqb_LIBS
gncmod-aqbanking gnc-generic-import gnc-gnome gnc-gnome-utils
gnc-ledger-core gnc-app-utils
gncmod-backend-xml-utils gnc-engine gnc-core-utils gnc-module
${GLIB2_LDFLAGS}
)
set_dist_list(test_aqb_DIST ${test_aqb_SOURCES} file-book.gnucash

View File

@ -4,14 +4,13 @@ set(CSV_IMP_TEST_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/common
${CMAKE_SOURCE_DIR}/libgnucash/engine
${CMAKE_SOURCE_DIR}/common/test-core
${GLIB2_INCLUDE_DIRS}
)
set(CSV_IMP_TEST_LIBS gnc-csv-import gnc-engine test-core)
# This test does not run in Win32
if (NOT WIN32)
set(MODULEPATH ${CMAKE_SOURCE_DIR}/gnucash/import-export/csv-imp)
set(gtest_csv_imp_LIBS gnc-csv-import ${GLIB2_LDFLAGS} gtest)
set(gtest_csv_imp_LIBS gnc-csv-import PkgConfig::GLIB2 gtest)
set(gtest_csv_imp_INCLUDES
${MODULEPATH}
${CSV_IMP_TEST_INCLUDE_DIRS})

View File

@ -22,7 +22,7 @@ target_link_libraries(gnc-customer-import
gnc-app-utils
gnc-engine
gnc-core-utils
${GLIB2_LDFLAGS})
PkgConfig::GLIB2)
target_include_directories(gnc-customer-import
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}

View File

@ -6,7 +6,6 @@ set(GENERIC_IMPORT_TEST_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/common/test-core
${CMAKE_SOURCE_DIR}/libgnucash/engine
${CMAKE_SOURCE_DIR}/libgnucash/engine/test-core
${GLIB2_INCLUDE_DIRS}
${GUILE_INCLUDE_DIRS}
)
@ -25,7 +24,6 @@ set(IMPORT_ACCOUNT_MATCHER_TEST_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/libgnucash/engine
${CMAKE_SOURCE_DIR}/libgnucash/app-utils
${CMAKE_SOURCE_DIR}/gnucash/gnome-utils
${GLIB2_INCLUDE_DIRS}
${GTEST_INCLUDE_DIR}
)

View File

@ -9,7 +9,6 @@ set(SPLIT_REG_TEST_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/gnucash/register/ledger-core
${CMAKE_BINARY_DIR}/common # for config.h
${CMAKE_SOURCE_DIR}/common/test-core # for unittest-support.h
${GLIB2_INCLUDE_DIRS}
)
set(SPLIT_REG_TEST_LIBS

View File

@ -76,7 +76,6 @@ target_link_libraries(gnc-app-utils ${app_utils_ALL_LIBRARIES})
target_include_directories (gnc-app-utils
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${GLIB2_INCLUDE_DIRS}
PRIVATE
${app_utils_ALL_INCLUDES}
)
@ -127,7 +126,6 @@ target_include_directories(gnc-expressions
${CMAKE_SOURCE_DIR}/bindings/guile
${CMAKE_SOURCE_DIR}/libgnucash/app-utils
${GUILE_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS}
PRIVATE
${CMAKE_SOURCE_DIR}/common
${CMAKE_BINARY_DIR}/common)
@ -138,7 +136,7 @@ target_link_libraries(gnc-expressions
gnc-app-utils
gnucash-guile
${GUILE_LDFLAGS}
${GLIB2_LDFLAGS})
PkgConfig::GLIB2)
install(TARGETS gnc-expressions
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

View File

@ -8,7 +8,6 @@ set(BACKEND_DBI_TEST_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/libgnucash/engine/test-core
${CMAKE_SOURCE_DIR}/common/test-core
${LIBDBI_INCLUDE_PATH}
${GLIB2_INCLUDE_DIRS}
)
set(BACKEND_DBI_TEST_LIBS gnc-backend-sql gnc-engine gnc-test-engine test-core ${Boost_REGEX_LIBRARY} ${LIBDBI_LIBRARY})

View File

@ -4,7 +4,6 @@ set(BACKEND_SQL_TEST_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/libgnucash/backend/sql
${CMAKE_SOURCE_DIR}/libgnucash/engine
${CMAKE_SOURCE_DIR}/common/test-core
${GLIB2_INCLUDE_DIRS}
)
set(test_backend_sql_SOURCES test-sqlbe.cpp utest-gnc-backend-sql.cpp)

View File

@ -105,7 +105,7 @@ set_source_files_properties (${libgncmod_backend_xml_SOURCES} PROPERTIES OBJECT_
add_library(gncmod-backend-xml MODULE ${libgncmod_backend_xml_SOURCES})
target_link_libraries(gncmod-backend-xml gnc-backend-xml-utils gnc-engine
gnc-core-utils ${LIBXML2_LDFLAGS} ${GLIB2_LDFLAGS} ${ZLIB_LIBRARY})
gnc-core-utils ${LIBXML2_LDFLAGS} PkgConfig::GLIB2 ${ZLIB_LIBRARY})
target_compile_definitions (gncmod-backend-xml PRIVATE -DG_LOG_DOMAIN=\"gnc.backend.xml\" -DU_SHOW_CPLUSPLUS_API=0)
@ -129,5 +129,5 @@ install(TARGETS gncmod-backend-xml
# Special normal (non-MODULE) library for cutecash only
add_library(gncmod-backend-xml-utils ${libgncmod_backend_xml_SOURCES})
target_link_libraries(gncmod-backend-xml-utils gnc-backend-xml-utils gnc-engine
gnc-core-utils ${LIBXML2_LDFLAGS} ${GLIB2_LDFLAGS} ${ZLIB_LIBRARY})
gnc-core-utils ${LIBXML2_LDFLAGS} PkgConfig::GLIB2 ${ZLIB_LIBRARY})
target_compile_definitions (gncmod-backend-xml-utils PRIVATE -DG_LOG_DOMAIN=\"gnc.backend.xml\" -DU_SHOW_CPLUSPLUS_API=0)

View File

@ -8,7 +8,6 @@ set(XML_TEST_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/libgnucash/engine/test-core
${CMAKE_BINARY_DIR}/common # for config.h
${CMAKE_SOURCE_DIR}/common/test-core # for unittest-support.h
${GLIB2_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
)

View File

@ -44,14 +44,14 @@ target_include_directories(gnc-core-utils
${CMAKE_BINARY_DIR}/common
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${GLIB2_INCLUDE_DIRS}
PRIVATE
${GTK_MAC_INCLUDE_DIRS})
target_link_libraries(gnc-core-utils
PUBLIC
PkgConfig::GLIB2
PRIVATE
${Boost_LIBRARIES}
${GLIB2_LDFLAGS}
${GOBJECT_LDFLAGS}
${GTK_MAC_LDFLAGS}
"$<$<BOOL:${MAC_INTEGRATION}>:${OSX_EXTRA_LIBRARIES}>")

View File

@ -4,7 +4,6 @@ set(CORE_UTILS_TEST_INCLUDE_DIRS
${CMAKE_BINARY_DIR}/common # for config.h
${MODULEPATH}
${CMAKE_SOURCE_DIR}/common/test-core
${GLIB2_INCLUDE_DIRS}
${GTK_MAC_INCLUDE_DIRS}
)
set(CORE_UTILS_TEST_LIBS gnc-core-utils test-core)
@ -32,11 +31,10 @@ set(gtest_core_utils_INCLUDES
${CMAKE_BINARY_DIR}/common # for config.h
${CMAKE_SOURCE_DIR}/common # for platform.h
${CMAKE_BINARY_DIR}/libgnucash/core-utils # for gncla-dir.h
${GLIB2_INCLUDE_DIRS}
)
set(gtest_core_utils_LIBS
${GLIB2_LDFLAGS}
PkgConfig::GLIB2
${Boost_LIBRARIES}
${GTHREAD_LDFLAGS}
gtest)

View File

@ -241,7 +241,7 @@ target_link_libraries(gnc-engine
${ICU4C_I18N_LDFLAGS}
${REGEX_LDFLAGS}
${GMODULE_LDFLAGS}
${GLIB2_LDFLAGS}
PkgConfig::GLIB2
${GOBJECT_LDFLAGS}
$<$<BOOL:${WIN32}>:bcrypt.lib>)
@ -254,7 +254,6 @@ target_include_directories (gnc-engine
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/common # for config.h
${CMAKE_SOURCE_DIR}/common # for platform.h
${GLIB2_INCLUDE_DIRS}
${LIBINTL_INCLUDE_PATH}
${REGEX_INCLUDE_PATH}
${CMAKE_SOURCE_DIR}/borrowed/libc # for strptime.h

View File

@ -6,7 +6,6 @@ set(ENGINE_TEST_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/libgnucash/engine/test-core
${CMAKE_BINARY_DIR}/common # for config.h
${CMAKE_SOURCE_DIR}/common/test-core # for unittest-support.h
${GLIB2_INCLUDE_DIRS}
)
set(ENGINE_TEST_LIBS gnc-engine gnc-test-engine test-core ${LIBXML2_LDFLAGS} -lm)
@ -83,12 +82,12 @@ add_engine_test(test-numeric "${test_numeric_SOURCES}")
set(MODULEPATH ${CMAKE_SOURCE_DIR}/libgnucash/engine)
set(gtest_old_engine_LIBS
gnc-engine
${GLIB2_LDFLAGS}
PkgConfig::GLIB2
${Boost_LIBRARIES}
gtest)
set(gtest_qof_LIBS
${GLIB2_LDFLAGS}
PkgConfig::GLIB2
${GOBJECT_LDFLAGS}
${GMODULE_LDFLAGS}
${GTHREAD_LDFLAGS}
@ -101,7 +100,6 @@ set(gtest_engine_INCLUDES
${CMAKE_SOURCE_DIR}/libgnucash/core-utils
${CMAKE_BINARY_DIR}/common # for config.h
${CMAKE_SOURCE_DIR}/common # for platform.h
${GLIB2_INCLUDE_DIRS}
../../../borrowed/libc
)

View File

@ -17,7 +17,7 @@ add_library (gnc-module
${gnc_module_HEADERS}
)
target_link_libraries(gnc-module ${GMODULE_LDFLAGS} ${GLIB2_LDFLAGS})
target_link_libraries(gnc-module ${GMODULE_LDFLAGS} PkgConfig::GLIB2)
target_compile_definitions (gnc-module PRIVATE -DG_LOG_DOMAIN=\"gnc.module\")
@ -25,7 +25,6 @@ target_include_directories (gnc-module
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/common
${CMAKE_BINARY_DIR}/common # for config.h
${GLIB2_INCLUDE_DIRS}
)
install(TARGETS gnc-module

View File

@ -7,7 +7,6 @@ set(GNC_MODULE_TEST_INCLUDE_DIRS
${CMAKE_BINARY_DIR}/common # for config.h
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
${CMAKE_SOURCE_DIR}/common/test-core
${GLIB2_INCLUDE_DIRS}
)
set(GNC_MODULE_TEST_LIBS

View File

@ -1,17 +1,16 @@
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
${GLIB2_INCLUDE_DIRS}
)
add_library(gncmod-agedver EXCLUDE_FROM_ALL agedver.c)
target_link_libraries(gncmod-agedver ${GLIB2_LDFLAGS})
target_link_libraries(gncmod-agedver PkgConfig::GLIB2)
add_library(gncmod-futuremodsys EXCLUDE_FROM_ALL futuremodsys.c)
target_link_libraries(gncmod-futuremodsys ${GLIB2_LDFLAGS})
target_link_libraries(gncmod-futuremodsys PkgConfig::GLIB2)
add_library(gncmod-incompatdep EXCLUDE_FROM_ALL incompatdep.c)
target_link_libraries(gncmod-incompatdep gnc-module ${GLIB2_LDFLAGS})
target_link_libraries(gncmod-incompatdep gnc-module PkgConfig::GLIB2)
set_target_properties(gncmod-agedver gncmod-incompatdep PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test

View File

@ -9,7 +9,6 @@ target_include_directories(gncmod-ordinary PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/common
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
${GLIB2_INCLUDE_DIRS}
${GUILE_INCLUDE_DIRS}
)

View File

@ -15,7 +15,6 @@ target_include_directories(gncmod-withdep PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/common
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
${GLIB2_INCLUDE_DIRS}
${GUILE_INCLUDE_DIRS}
)

View File

@ -10,15 +10,14 @@ target_link_libraries(gnc-locale-tax
gnc-engine
gnc-app-utils
gnucash-guile
${GLIB2_LDFLAGS}
PkgConfig::GLIB2
${GUILE_LDFLAGS})
target_include_directories(gnc-locale-tax
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_BINARY_DIR}/common
${GUILE_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS})
${GUILE_INCLUDE_DIRS})
if (APPLE)
set_target_properties (gnc-locale-tax PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}")