mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 20:08:31 +01:00
Freetype2 allow generation and compilation with Freetype2
This commit is contained in:
@@ -12,6 +12,15 @@ file(GLOB IMGUI_SOURCES
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(IMGUI_STATIC "no" CACHE STRING "Build as a static library")
|
set(IMGUI_STATIC "no" CACHE STRING "Build as a static library")
|
||||||
|
set(IMGUI_FREETYPE "no" CACHE STRING "Build with freetype library")
|
||||||
|
set(IMGUI_LIBRARIES )
|
||||||
|
|
||||||
|
if(IMGUI_FREETYPE)
|
||||||
|
FIND_PACKAGE(freetype REQUIRED PATHS ${FREETYPE_PATH})
|
||||||
|
list(APPEND IMGUI_LIBRARIES freetype)
|
||||||
|
list(APPEND IMGUI_SOURCES imgui/misc/freetype/imgui_freetype.cpp)
|
||||||
|
add_definitions("-DCIMGUI_FREETYPE=1")
|
||||||
|
endif(IMGUI_FREETYPE)
|
||||||
|
|
||||||
#add library and link
|
#add library and link
|
||||||
if (IMGUI_STATIC)
|
if (IMGUI_STATIC)
|
||||||
@@ -30,6 +39,7 @@ endif (WIN32)
|
|||||||
target_include_directories(cimgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(cimgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
target_include_directories(cimgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
|
target_include_directories(cimgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
|
||||||
set_target_properties(cimgui PROPERTIES PREFIX "")
|
set_target_properties(cimgui PROPERTIES PREFIX "")
|
||||||
|
target_link_libraries(cimgui ${IMGUI_LIBRARIES})
|
||||||
|
|
||||||
#install
|
#install
|
||||||
install(TARGETS cimgui
|
install(TARGETS cimgui
|
||||||
|
@@ -24,6 +24,7 @@ Notes:
|
|||||||
* git submodule update
|
* git submodule update
|
||||||
* compile
|
* compile
|
||||||
* using makefile on linux/macOS/mingw (Or use CMake to generate project)
|
* using makefile on linux/macOS/mingw (Or use CMake to generate project)
|
||||||
|
* cmake options are IMGUI_STATIC (compiling as static library), IMGUI_FREETYPE (for using Freetype2) and FREETYPE_PATH (Freetype2 cmake install location)
|
||||||
* or as in https://github.com/sonoro1234/LuaJIT-ImGui/tree/master/build
|
* or as in https://github.com/sonoro1234/LuaJIT-ImGui/tree/master/build
|
||||||
|
|
||||||
# using generator
|
# using generator
|
||||||
@@ -32,7 +33,7 @@ Notes:
|
|||||||
* you will need LuaJIT (https://github.com/LuaJIT/LuaJIT.git better 2.1 branch) or precompiled for linux/macOS/windows in https://luapower.com/luajit/download
|
* you will need LuaJIT (https://github.com/LuaJIT/LuaJIT.git better 2.1 branch) or precompiled for linux/macOS/windows in https://luapower.com/luajit/download
|
||||||
* you need to use also a C++ compiler for doing preprocessing: gcc (In windows MinGW-W64-builds for example), clang or cl (MSVC). (this repo was done with gcc)
|
* you need to use also a C++ compiler for doing preprocessing: gcc (In windows MinGW-W64-builds for example), clang or cl (MSVC). (this repo was done with gcc)
|
||||||
* update `imgui` folder to the version you desire.
|
* update `imgui` folder to the version you desire.
|
||||||
* edit `generator/generator.bat` on windows, or `generator/generator.sh` on linux, to choose between gcc, clang, or cl and to choose desired implementations and whether imgui_internal is generated or not.
|
* edit `generator/generator.bat` on windows, or `generator/generator.sh` on linux, to choose between gcc, clang, or cl and to choose desired implementations and whether imgui_internal is generated or not and Freetype2 is used or not.
|
||||||
* edit config_generator.lua for adding includes needed by your chosen implementations (vulkan needs that).
|
* edit config_generator.lua for adding includes needed by your chosen implementations (vulkan needs that).
|
||||||
* Run generator.bat or generator.sh with gcc, clang or cl and LuaJIT on your PATH.
|
* Run generator.bat or generator.sh with gcc, clang or cl and LuaJIT on your PATH.
|
||||||
* as a result some files are generated: `cimgui.cpp` and `cimgui.h` for compiling and some lua/json files with information about the binding: `definitions.json` with function info, `structs_and_enums.json` with struct and enum info, `impl_definitions.json` with functions from the implementations info.
|
* as a result some files are generated: `cimgui.cpp` and `cimgui.h` for compiling and some lua/json files with information about the binding: `definitions.json` with function info, `structs_and_enums.json` with struct and enum info, `impl_definitions.json` with functions from the implementations info.
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
|
|
||||||
#include "./imgui/imgui.h"
|
#include "./imgui/imgui.h"
|
||||||
|
#ifdef CIMGUI_FREETYPE
|
||||||
|
#include "./imgui/misc/freetype/imgui_freetype.h"
|
||||||
|
#endif
|
||||||
#include "./imgui/imgui_internal.h"
|
#include "./imgui/imgui_internal.h"
|
||||||
#include "cimgui.h"
|
#include "cimgui.h"
|
||||||
|
|
||||||
|
@@ -15,9 +15,10 @@ set PATH=%PATH%;C:\anima;C:\mingws\i686-7.2.0-release-posix-dwarf-rt_v5-rev1\min
|
|||||||
:: set PATH=%PATH%;C:\luaGL\sources\luajit-master\luajit-master\bin\mingw32;C:\mingw32\bin;
|
:: set PATH=%PATH%;C:\luaGL\sources\luajit-master\luajit-master\bin\mingw32;C:\mingw32\bin;
|
||||||
::process files
|
::process files
|
||||||
:: arg[1] compiler name gcc, clang or cl
|
:: arg[1] compiler name gcc, clang or cl
|
||||||
:: arg[2] imgui_internal functions generation: true or false
|
:: arg[2] options as words in one string: internal for imgui_internal generation, freetype for freetype generation
|
||||||
|
:: examples: "" "internal" "internal freetype"
|
||||||
:: arg[3..n] name of implementations to generate
|
:: arg[3..n] name of implementations to generate
|
||||||
luajit ./generator.lua gcc true glfw opengl3 opengl2 sdl
|
luajit ./generator.lua gcc "internal" glfw opengl3 opengl2 sdl
|
||||||
|
|
||||||
::leave console open
|
::leave console open
|
||||||
cmd /k
|
cmd /k
|
||||||
|
@@ -6,7 +6,8 @@ assert(_VERSION=='Lua 5.1',"Must use LuaJIT")
|
|||||||
assert(bit,"Must use LuaJIT")
|
assert(bit,"Must use LuaJIT")
|
||||||
local script_args = {...}
|
local script_args = {...}
|
||||||
local COMPILER = script_args[1]
|
local COMPILER = script_args[1]
|
||||||
local INTERNAL_GENERATION = script_args[2]=="true"
|
local INTERNAL_GENERATION = script_args[2]:match("internal") and true or false
|
||||||
|
local FREETYPE_GENERATION = script_args[2]:match("freetype") and true or false
|
||||||
local CPRE,CTEST
|
local CPRE,CTEST
|
||||||
if COMPILER == "gcc" or COMPILER == "clang" then
|
if COMPILER == "gcc" or COMPILER == "clang" then
|
||||||
CPRE = COMPILER..[[ -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ]]
|
CPRE = COMPILER..[[ -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ]]
|
||||||
@@ -40,6 +41,7 @@ assert(HAVE_COMPILER,"gcc, clang or cl needed to run script")
|
|||||||
|
|
||||||
print("HAVE_COMPILER",HAVE_COMPILER)
|
print("HAVE_COMPILER",HAVE_COMPILER)
|
||||||
print("INTERNAL_GENERATION",INTERNAL_GENERATION)
|
print("INTERNAL_GENERATION",INTERNAL_GENERATION)
|
||||||
|
print("FREETYPE_GENERATION",FREETYPE_GENERATION)
|
||||||
--get implementations
|
--get implementations
|
||||||
local implementations = {}
|
local implementations = {}
|
||||||
for i=3,#script_args do table.insert(implementations,script_args[i]) end
|
for i=3,#script_args do table.insert(implementations,script_args[i]) end
|
||||||
@@ -273,6 +275,10 @@ if INTERNAL_GENERATION then
|
|||||||
cimgui_header = cimgui_header..[[//with imgui_internal.h api
|
cimgui_header = cimgui_header..[[//with imgui_internal.h api
|
||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
|
if FREETYPE_GENERATION then
|
||||||
|
cimgui_header = cimgui_header..[[//with imgui_freetype.h api
|
||||||
|
]]
|
||||||
|
end
|
||||||
print("IMGUI_VERSION",imgui_version)
|
print("IMGUI_VERSION",imgui_version)
|
||||||
--get some defines----------------------------
|
--get some defines----------------------------
|
||||||
gdefines = get_defines{"IMGUI_VERSION","FLT_MAX"}
|
gdefines = get_defines{"IMGUI_VERSION","FLT_MAX"}
|
||||||
@@ -333,14 +339,26 @@ end
|
|||||||
--generation
|
--generation
|
||||||
print("------------------generation with "..COMPILER.."------------------------")
|
print("------------------generation with "..COMPILER.."------------------------")
|
||||||
local parser1
|
local parser1
|
||||||
|
local headers = [[#include "../imgui/imgui.h"
|
||||||
|
]]
|
||||||
|
local headersT = {[[imgui]]}
|
||||||
if INTERNAL_GENERATION then
|
if INTERNAL_GENERATION then
|
||||||
save_data("headers.h",[[#include "../imgui/imgui.h"
|
headers = headers .. [[#include "../imgui/imgui_internal.h"
|
||||||
#include "../imgui/imgui_internal.h"]])
|
]]
|
||||||
parser1 = parseImGuiHeader([[headers.h]],{[[imgui]],[[imgui_internal]],[[imstb_textedit]]})
|
headersT[#headersT + 1] = [[imgui_internal]]
|
||||||
os.remove("headers.h")
|
headersT[#headersT + 1] = [[imstb_textedit]]
|
||||||
else
|
|
||||||
parser1 = parseImGuiHeader([[../imgui/imgui.h]],{[[imgui]]})
|
|
||||||
end
|
end
|
||||||
|
if FREETYPE_GENERATION then
|
||||||
|
headers = headers .. [[
|
||||||
|
#include "../imgui/misc/freetype/imgui_freetype.h"
|
||||||
|
]]
|
||||||
|
headersT[#headersT + 1] = [[imgui_freetype]]
|
||||||
|
end
|
||||||
|
save_data("headers.h",headers)
|
||||||
|
local include_cmd = COMPILER=="cl" and [[ /I ]] or [[ -I ]]
|
||||||
|
local extra_includes = include_cmd.." ../imgui "
|
||||||
|
local parser1 = parseImGuiHeader(extra_includes .. [[headers.h]],headersT)
|
||||||
|
os.remove("headers.h")
|
||||||
parser1:do_parse()
|
parser1:do_parse()
|
||||||
|
|
||||||
save_data("./output/overloads.txt",parser1.overloadstxt)
|
save_data("./output/overloads.txt",parser1.overloadstxt)
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#process files
|
#process files
|
||||||
# arg[1] compiler name gcc, clang, or cl
|
# arg[1] compiler name gcc, clang, or cl
|
||||||
# arg[2] imgui_internal functions generation: true or false
|
# arg[2] options as words in one string: internal for imgui_internal generation, freetype for freetype generation
|
||||||
|
# examples: "" "internal" "internal freetype"
|
||||||
# arg[3..n] name of implementations to generate
|
# arg[3..n] name of implementations to generate
|
||||||
luajit ./generator.lua gcc true glfw opengl3 opengl2 sdl
|
luajit ./generator.lua gcc "internal" glfw opengl3 opengl2 sdl
|
||||||
|
Reference in New Issue
Block a user