Add glib version of xeinit

This commit is contained in:
daleclack 2022-08-31 19:51:26 +08:00
parent 8a36f77ef7
commit c8f944a4e9
2 changed files with 29 additions and 0 deletions

View File

@ -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})

8
cpp/xeinit_glib/main.c Normal file
View File

@ -0,0 +1,8 @@
#include <glib.h>
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;
}