aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-28 16:15:23 +0200
committerRobert Tari <robert@tari.in>2021-09-02 13:21:07 +0200
commit7cb304774fdeef0b2a674aaa54d394872512335a (patch)
tree681714b76525162633e4ac9c4bdf30c840737cf7
parent890f7117640c9557dc2ff011e6d2498b95e1e665 (diff)
downloadlibayatana-common-7cb304774fdeef0b2a674aaa54d394872512335a.tar.gz
libayatana-common-7cb304774fdeef0b2a674aaa54d394872512335a.tar.bz2
libayatana-common-7cb304774fdeef0b2a674aaa54d394872512335a.zip
GIR and Vala bindings: Properly detect GObjectIntrospection and Vala and disable GIR and Vala if not found.
-rw-r--r--CMakeLists.txt15
-rw-r--r--src/CMakeLists.txt66
-rw-r--r--tests/CMakeLists.txt15
3 files changed, 58 insertions, 38 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 751bf36..4dfc038 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,6 +51,10 @@ pkg_check_modules(
)
include_directories(${URLDISPATCHER_INCLUDE_DIRS})
+# for GIR and Vala bindings
+find_package (GObjectIntrospection QUIET)
+find_package (Vala QUIET)
+
set(CC_WARNING_ARGS " -Wall -pedantic -Wextra -Wno-missing-field-initializers")
add_subdirectory(src)
@@ -76,3 +80,14 @@ endif()
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Unit tests: ${ENABLE_TESTS}")
message(STATUS "Build with -Werror: ${ENABLE_WERROR}")
+
+if (INTROSPECTION_FOUND)
+ message(STATUS "Build GObjectIntrospection: YES")
+ if (VALA_COMPILER)
+ message(STATUS "Build Vala bindings: YES")
+ else()
+ message(STATUS "Build Vala bindings: NO")
+ endif()
+else()
+ message(STATUS "Build GObjectIntrospection: NO")
+endif() \ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 637ce9f..39682a7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -30,41 +30,43 @@ install(TARGETS ayatana-common DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
# AyatanaCommon.gir
-find_package(GObjectIntrospection REQUIRED QUIET)
-
-add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.gir"
- DEPENDS "ayatana-common"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND
- ${INTROSPECTION_SCANNER}
- utils.c utils.h
- --namespace=AyatanaCommon
- --c-include=ayatana/common/utils.h
- --quiet
- --warn-all
- --include=GLib-2.0
- --library="ayatana-common"
- --library-path=${CMAKE_CURRENT_BINARY_DIR}
- --output "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.gir"
-)
-
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.gir" DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/gir-1.0")
+if (INTROSPECTION_FOUND)
+ add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.gir"
+ DEPENDS "ayatana-common"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND
+ ${INTROSPECTION_SCANNER}
+ utils.c utils.h
+ --namespace=AyatanaCommon
+ --c-include=ayatana/common/utils.h
+ --quiet
+ --warn-all
+ --include=GLib-2.0
+ --library="ayatana-common"
+ --library-path=${CMAKE_CURRENT_BINARY_DIR}
+ --output "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.gir"
+ )
+
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.gir" DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/gir-1.0")
# AyatanaCommon.vapi
-find_package(Vala REQUIRED QUIET)
+ if (VALA_COMPILER)
+ add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.vapi"
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.gir"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND
+ ${VAPI_GEN}
+ --library=AyatanaCommon
+ AyatanaCommon.gir
+ )
-add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.vapi"
- DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.gir"
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- COMMAND
- ${VAPI_GEN}
- --library=AyatanaCommon
- AyatanaCommon.gir
-)
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.vapi" DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/vala/vapi")
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.vapi" DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/vala/vapi")
+ add_custom_target("src" ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.vapi")
-add_custom_target("src" ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaCommon.vapi")
+ endif()
+
+endif()
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index ecb3c12..002e4db 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -56,10 +56,13 @@ add_custom_command(
# tst_utils_vala
-add_executable("tst_utils_vala" "${CMAKE_CURRENT_BINARY_DIR}/tst_utils.c")
-target_include_directories("tst_utils_vala" PUBLIC "${GLIB_INCLUDE_DIRS};${CMAKE_BINARY_DIR}/src")
-target_link_libraries("tst_utils_vala" "${GLIB_LIBRARIES} -layatana-common -L${CMAKE_BINARY_DIR}/src")
-target_link_directories("tst_utils_vala" PUBLIC "${CMAKE_BINARY_DIR}/src")
-add_dependencies("tst_utils_vala" "src")
+if (VALA_COMPILER)
-add_test(NAME "TstUtilsVala" COMMAND "${CMAKE_CURRENT_BINARY_DIR}/tst_utils_vala" "${CMAKE_CURRENT_BINARY_DIR}")
+ add_executable("tst_utils_vala" "${CMAKE_CURRENT_BINARY_DIR}/tst_utils.c")
+ target_include_directories("tst_utils_vala" PUBLIC "${GLIB_INCLUDE_DIRS};${CMAKE_BINARY_DIR}/src")
+ target_link_libraries("tst_utils_vala" "${GLIB_LIBRARIES} -layatana-common -L${CMAKE_BINARY_DIR}/src")
+ target_link_directories("tst_utils_vala" PUBLIC "${CMAKE_BINARY_DIR}/src")
+ add_dependencies("tst_utils_vala" "src")
+
+ add_test(NAME "TstUtilsVala" COMMAND "${CMAKE_CURRENT_BINARY_DIR}/tst_utils_vala" "${CMAKE_CURRENT_BINARY_DIR}")
+endif()