Update gtk90
This commit is contained in:
parent
2f56736ba6
commit
b83ceeeec4
|
@ -16,11 +16,51 @@ pkg_check_modules (GTKMM3 REQUIRED gtkmm-3.0)
|
||||||
include_directories (${GTKMM3_INCLUDE_DIRS})
|
include_directories (${GTKMM3_INCLUDE_DIRS})
|
||||||
link_directories (${GTKMM3_LIBRARY_DIRS})
|
link_directories (${GTKMM3_LIBRARY_DIRS})
|
||||||
|
|
||||||
add_executable(gtk90 src/main.cc src/resources.cpp)
|
#Compile a resource.cpp file
|
||||||
|
|
||||||
IF(WIN32)
|
# Step 1:
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS -mwindows)
|
find_program(GLIB_COMPILE_RESOURCES NAMES glib-compile-resources REQUIRED)
|
||||||
ENDIF(WIN32)
|
|
||||||
|
|
||||||
add_definitions (${GTKMM3_CFLAGS_OTHER})
|
set(GRESOURCE_C resource.c)
|
||||||
|
set(GRESOURCE_XML gtk89.resource.xml)
|
||||||
|
|
||||||
|
# Step 2:
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${GRESOURCE_C}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res
|
||||||
|
COMMAND ${GLIB_COMPILE_RESOURCES}
|
||||||
|
ARGS
|
||||||
|
${GRESOURCE_XML}
|
||||||
|
--target=${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
|
||||||
|
--generate-source
|
||||||
|
)
|
||||||
|
|
||||||
|
# Step 3:
|
||||||
|
add_custom_target(
|
||||||
|
my-gresource
|
||||||
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Step 4:Add the resource to compile list and compile
|
||||||
|
#For win32 platform,use rc resource and .ico icon
|
||||||
|
if(WIN32)
|
||||||
|
SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
||||||
|
set(app_WINRC icon.rc)
|
||||||
|
set_property(SOURCE icon.rc APPEND PROPERTY
|
||||||
|
OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/icon.ico
|
||||||
|
)
|
||||||
|
add_executable(gtk90 WIN32 ${app_WINRC} src/main.cc ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C})
|
||||||
|
else()
|
||||||
|
add_executable(gtk90 src/main.cc ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C})
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
|
set_source_files_properties(
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
|
||||||
|
PROPERTIES GENERATED TRUE
|
||||||
|
)
|
||||||
|
|
||||||
|
# Step 5:Add Dependencies and link
|
||||||
|
add_dependencies(${PROJECT_NAME} my-gresource)
|
||||||
|
|
||||||
|
SET (CMAKE_EXTRA_CXX_FLAGS ${GTKMM3_CFLAGS_OTHER})
|
||||||
target_link_libraries (${PROJECT_NAME} ${GTKMM3_LIBRARIES})
|
target_link_libraries (${PROJECT_NAME} ${GTKMM3_LIBRARIES})
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
|
@ -0,0 +1 @@
|
||||||
|
MAINICON ICON "Icon.ico"
|
|
@ -0,0 +1,26 @@
|
||||||
|
#A Simple Project Test
|
||||||
|
project('gtk90', 'cpp',
|
||||||
|
default_options : ['c_std=c17', 'cpp_std=c++17'])
|
||||||
|
|
||||||
|
#Initalize variants
|
||||||
|
gnome=import('gnome')
|
||||||
|
|
||||||
|
#Compile Resource
|
||||||
|
gresources = gnome.compile_resources(
|
||||||
|
'resources', 'res/gtk89.resource.xml',
|
||||||
|
source_dir: 'res',
|
||||||
|
c_name: 'resources'
|
||||||
|
)
|
||||||
|
|
||||||
|
#The Gtkmm Library as a dependency
|
||||||
|
gtkdep = dependency('gtkmm-3.0')
|
||||||
|
|
||||||
|
#Use Different Build Opinions in windows and Linux
|
||||||
|
if host_machine.system() == 'windows'
|
||||||
|
win=import('windows')
|
||||||
|
icon_res=win.compile_resources('icon.rc')
|
||||||
|
executable('gtk90', icon_res, 'src/main.cc', gresources, dependencies : gtkdep,
|
||||||
|
win_subsystem : 'windows')
|
||||||
|
else
|
||||||
|
executable('gtk90', 'src/main.cc', gresources, dependencies : gtkdep)
|
||||||
|
endif
|
Loading…
Reference in New Issue