From c8f944a4e99e39e8ab808b903e4fee005c2e85d3 Mon Sep 17 00:00:00 2001 From: daleclack Date: Wed, 31 Aug 2022 19:51:26 +0800 Subject: [PATCH] Add glib version of xeinit --- cpp/xeinit_glib/CMakeLists.txt | 21 +++++++++++++++++++++ cpp/xeinit_glib/main.c | 8 ++++++++ 2 files changed, 29 insertions(+) create mode 100644 cpp/xeinit_glib/CMakeLists.txt create mode 100644 cpp/xeinit_glib/main.c diff --git a/cpp/xeinit_glib/CMakeLists.txt b/cpp/xeinit_glib/CMakeLists.txt new file mode 100644 index 0000000..b987853 --- /dev/null +++ b/cpp/xeinit_glib/CMakeLists.txt @@ -0,0 +1,21 @@ +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_C_STANDARD 17) +cmake_minimum_required(VERSION 3.0.0) +project(xeinit_glib VERSION 9.0.0) + +set(CPACK_PROJECT_NAME ${PROJECT_NAME}) +set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) + +include(CPack) +include_directories(.) +include_directories(..) + +#Find PkgConfig to use glib +find_package(PkgConfig REQUIRED) +pkg_check_modules(GLIB2 REQUIRED glib-2.0) +include_directories(${GLIB2_INCLUDE_DIRS}) +link_directories(${GLIB2_LIBRARY_DIRS}) + +add_executable(${PROJECT_NAME} main.c) +set(CMAKE_EXTAR_FLAGS ${GLIB2_CFLAGS_OTHER}) +target_link_libraries(${PROJECT_NAME} ${GLIB2_LIBRARIES}) diff --git a/cpp/xeinit_glib/main.c b/cpp/xeinit_glib/main.c new file mode 100644 index 0000000..e7daa1f --- /dev/null +++ b/cpp/xeinit_glib/main.c @@ -0,0 +1,8 @@ +#include + +int main(int argc, char **argv){ + int x; + x = g_random_int_range(0, INT_MAX); + g_print("%d %d\n", x % 2, x); + return 0; +} \ No newline at end of file