diff options
author | Robert Tari <robert@tari.in> | 2021-02-05 14:09:34 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-04-21 20:57:03 +0200 |
commit | 9f96225dc93a97467f1e2107e23b79cb10744917 (patch) | |
tree | 07d5b8bfecf3c629d41e4924c58cc4dccd8fda1f | |
parent | b74d4016bd84bfe1c97c3ec0f2cfcadfda296a28 (diff) | |
download | ayatana-ido-9f96225dc93a97467f1e2107e23b79cb10744917.tar.gz ayatana-ido-9f96225dc93a97467f1e2107e23b79cb10744917.tar.bz2 ayatana-ido-9f96225dc93a97467f1e2107e23b79cb10744917.zip |
Add CMakeLists.txt files.
-rw-r--r-- | CMakeLists.txt | 58 | ||||
-rw-r--r-- | data/CMakeLists.txt | 9 | ||||
-rw-r--r-- | example/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/CMakeLists.txt | 175 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 13 |
5 files changed, 256 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7fee81b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 3.16) +project(ayatana-ido C CXX) + +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}") + +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + SET(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE) +endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + +option(MAINTAINER_MODE "Enable all tests and checks" OFF) + +# Check for prerequisites + +set(DEPS glib-2.0>=2.64 gtk+-3.0>=3.24) + +if(MAINTAINER_MODE) + # We also need gcovr and lcov + set(DEPS ${DEPS} gtest>=1.10) + set(CMAKE_BUILD_TYPE "Coverage") +else() + set(CMAKE_BUILD_TYPE "Release") +endif() + +find_package (PkgConfig REQUIRED) +pkg_check_modules(PROJECT_DEPS REQUIRED ${DEPS}) + +# Set global variables + +include(GNUInstallDirs) +set(PROJECT_VERSION "0.8.2") + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Weverything") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-c++98-compat -Wno-padded") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-documentation") + +else() + + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall") + +endif() + +# Make everything + +add_subdirectory(src) +add_subdirectory(data) + +if(MAINTAINER_MODE) + enable_testing() + add_subdirectory(example) + add_subdirectory(tests) +endif() + +# Display config info + +message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") +message(STATUS "Maintainer mode: ${MAINTAINER_MODE}") diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index d423718..2f15bf6 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -1,7 +1,4 @@ -# Create the .pc +# libayatana-ido3-0.4.pc -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libayatana-ido3-0.4.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libayatana-ido3-0.4.pc") - -# Install - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libayatana-ido3-0.4.pc" DESTINATION "${LIB_DIR_PATH}/pkgconfig/") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libayatana-ido3-0.4.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libayatana-ido3-0.4.pc" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libayatana-ido3-0.4.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig/") diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000..fed6750 --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,7 @@ +# menus + +set_source_files_properties(menus.c PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS}) +add_executable("menus" menus.c) +target_include_directories("menus" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_link_libraries("menus" ${PROJECT_DEPS_LIBRARIES} "-L${CMAKE_BINARY_DIR}/src" -layatana-ido3-0.4) +target_include_directories("menus" PUBLIC "${CMAKE_SOURCE_DIR}/src") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..ac46096 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,175 @@ +# ayatanamenuitemfactory.h +# idocalendarmenuitem.h +# idoentrymenuitem.h +# idorange.h +# idoscalemenuitem.h +# idoswitchmenuitem.h +# idotimeline.h +# libayatana-ido.h + +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/ayatanamenuitemfactory.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-ido3-0.4/libayatana-ido") +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/idocalendarmenuitem.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-ido3-0.4/libayatana-ido") +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/idoentrymenuitem.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-ido3-0.4/libayatana-ido") +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/idorange.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-ido3-0.4/libayatana-ido") +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/idoscalemenuitem.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-ido3-0.4/libayatana-ido") +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/idoswitchmenuitem.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-ido3-0.4/libayatana-ido") +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/idotimeline.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-ido3-0.4/libayatana-ido") +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/libayatana-ido.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libayatana-ido3-0.4/libayatana-ido") + +set(HEADERS + idorange.h + idoappointmentmenuitem.h + idousermenuitem.h + idoalarmmenuitem.h + idotimestampmenuitem.h + idoplaybackmenuitem.h + idoremovablemenuitem.h + ayatanamenuitemfactory.h + idobasicmenuitem.h + idoapplicationmenuitem.h + idotimeline.h + idosourcemenuitem.h + idoactionhelper.h + idocalendarmenuitem.h + idolocationmenuitem.h + idoprogressmenuitem.h + libayatana-ido.h + idomediaplayermenuitem.h + idoswitchmenuitem.h + idoscalemenuitem.h + idodetaillabel.h + idoentrymenuitem.h +) + +set(SOURCES + idotimestampmenuitem.c + idodetaillabel.c + libayatana-ido.c + idomenuitemfactory.c + idoactionhelper.c + idoapplicationmenuitem.c + idoplaybackmenuitem.c + idomediaplayermenuitem.c + idocalendarmenuitem.c + ayatanamenuitemfactory.c + idoprogressmenuitem.c + idolocationmenuitem.c + idoscalemenuitem.c + idoentrymenuitem.c + idoalarmmenuitem.c + idorange.c + idoappointmentmenuitem.c + idoswitchmenuitem.c + idoremovablemenuitem.c + idobasicmenuitem.c + idousermenuitem.c + idosourcemenuitem.c + idotimeline.c + ${CMAKE_CURRENT_BINARY_DIR}/idotypebuiltins.c +) + +# idotypebuiltins.h + +find_program(GLIB_MKENUMS glib-mkenums) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/idotypebuiltins.h" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND + ${GLIB_MKENUMS} + --template idotypebuiltins.h.template ${HEADERS} + --output="${CMAKE_CURRENT_BINARY_DIR}/idotypebuiltins.h" +) + +# idotypebuiltins.c + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/idotypebuiltins.c" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/idotypebuiltins.h" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND + ${GLIB_MKENUMS} + --template idotypebuiltins.c.template ${HEADERS} + --output="${CMAKE_CURRENT_BINARY_DIR}/idotypebuiltins.c" +) + +# ayatana-ido3-0.4.so + +set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS}) +add_library("ayatana-ido3-0.4" SHARED ${SOURCES}) +set_target_properties("ayatana-ido3-0.4" PROPERTIES VERSION 0.0.0 SOVERSION 0) +target_include_directories("ayatana-ido3-0.4" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_include_directories("ayatana-ido3-0.4" PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories("ayatana-ido3-0.4" PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_definitions("ayatana-ido3-0.4" PUBLIC G_LOG_DOMAIN="IDO") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libayatana-ido3-0.4.so" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libayatana-ido3-0.4.so.0" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libayatana-ido3-0.4.so.0.0.0" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + +# ayatana-ido3-0.4.gir + +set(HEADERS + idocalendarmenuitem.h + idoentrymenuitem.h + idorange.h + idoscalemenuitem.h + idoswitchmenuitem.h + idotimeline.h +) + +find_package(GObjectIntrospection REQUIRED QUIET) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.gir" + DEPENDS "ayatana-ido3-0.4" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND + ${INTROSPECTION_SCANNER} + ${SOURCES} ${HEADERS} + --symbol-prefix=ido + --identifier-prefix=Ido + --namespace=AyatanaIdo3 + --nsversion=0.4 + --quiet + --pkg=gtk+-3.0 + --warn-all + --include=Gtk-3.0 + --library="ayatana-ido3-0.4" + --output "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.gir" +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.gir" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/gir-1.0") + +# ayatana-ido3-0.4.typelib + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.typelib" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.gir" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${INTROSPECTION_COMPILER} + --includedir=${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.gir + -o "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.typelib" +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.typelib" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/girepository-1.0") + +# ayatana-ido3-0.4.vapi + +find_package(Vala REQUIRED QUIET) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.vapi" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.typelib" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${VAPI_GEN} + --library=AyatanaIdo3-0.4 + --pkg gtk+-3.0 + AyatanaIdo3-0.4.gir +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.vapi" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/vala/vapi") + +add_custom_target("src" ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIdo3-0.4.vapi") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..1ecf8e6 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,13 @@ +# gtest-menuitems + +set_source_files_properties(gtest-menuitems.cpp PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS}) +add_executable("gtest-menuitems" gtest-menuitems.cpp) +target_include_directories("gtest-menuitems" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_include_directories("gtest-menuitems" PUBLIC "${CMAKE_SOURCE_DIR}/src") +add_test("gtest-menuitems" "gtest-menuitems") +target_link_libraries("gtest-menuitems" ${PROJECT_DEPS_LIBRARIES} "-L${CMAKE_BINARY_DIR}/src" -layatana-ido3-0.4 gtest_main) + +# coverage + +find_package(CoverageReport) +ENABLE_COVERAGE_REPORT(TARGETS "gtest-menuitems" TESTS "gtest-menuitems") |