Compare commits

...

3 Commits

6 changed files with 553 additions and 518 deletions

View File

@@ -22,8 +22,6 @@ else()
endif() endif()
include_directories(../../imgui) include_directories(../../imgui)
add_definitions("-DIMGUI_USER_CONFIG=\"../cimconfig.h\"")
add_definitions("-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
include_directories(../../) include_directories(../../)
set(IMGUI_SOURCES set(IMGUI_SOURCES
@@ -38,11 +36,7 @@ ${TABLES_SOURCE}
set(IMGUI_SOURCES_sdl) set(IMGUI_SOURCES_sdl)
set(IMGUI_LIBRARIES ) set(IMGUI_LIBRARIES )
if (WIN32)
add_definitions("-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
else(WIN32)
add_definitions("-DIMGUI_IMPL_API=extern \"C\" ")
endif(WIN32)
add_compile_definitions("IMGUI_IMPL_OPENGL_LOADER_GL3W") add_compile_definitions("IMGUI_IMPL_OPENGL_LOADER_GL3W")
@@ -66,40 +60,41 @@ else(WIN32)#Unix
endif(WIN32) endif(WIN32)
#sdl2
list(APPEND IMGUI_SOURCES ${BAKENDS_FOLDER}imgui_impl_sdl2.cpp) list(APPEND IMGUI_SOURCES ${BAKENDS_FOLDER}imgui_impl_sdl2.cpp)
if(DEFINED SDL_PATH) include(FetchContent)
message(STATUS "SDL_PATH defined as " ${SDL_PATH}) Set(FETCHCONTENT_QUIET FALSE)
FIND_PACKAGE(SDL2 PATHS ${SDL_PATH})
else(DEFINED SDL_PATH)
# If SDL_PATH is not set, fallback and attempt to find SDL cmake script at a default location
find_package(SDL2)
endif(DEFINED SDL_PATH)
if(SDL2_FOUND) FetchContent_Declare(
get_target_property(SDL_INCLUDE SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES) SDL2
message(STATUS "sdlinclude is " ${SDL_INCLUDE}) GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
if ("${SDL_INCLUDE}" STREQUAL "" OR "${SDL_INCLUDE}" STREQUAL "SDL_INCLUDE-NOTFOUND") #if not found latest SDL2 cmake config use older GIT_TAG release-2.30.12
message(STATUS "sdlinclude2 is " ${SDL2_INCLUDE_DIRS}) #GIT_SHALLOW TRUE
include_directories(${SDL2_INCLUDE_DIRS}) GIT_PROGRESS TRUE
set(IMGUI_SDL_LIBRARY ${SDL2_LIBRARIES}) )
message(STATUS IMGUI_SDL_LIBRARY ${SDL2_LIBRARIES}) #FetchContent_MakeAvailable(SDL2)
else()#use new one SDL2 config FetchContent_GetProperties(SDL2)
include_directories(${SDL_INCLUDE}) if (NOT sdl2_POPULATED)
set(IMGUI_SDL_LIBRARY SDL2::SDL2) set(FETCHCONTENT_QUIET NO)
set(SDL_MAIN SDL2::SDL2main) FetchContent_Populate(SDL2)
message(STATUS ${SDL_MAIN} ${IMGUI_SDL_LIBRARY}) set(SDL_TEST OFF CACHE BOOL "" FORCE)
endif() set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
else(SDL2_FOUND) add_subdirectory(${sdl2_SOURCE_DIR} ${sdl2_BINARY_DIR})
if(DEFINED SDL_PATH) endif()
message(FATAL_ERROR "Cannot find SDL at SDL_PATH") include_directories(${SDL2_SOURCE_DIR}/include})
else(DEFINED SDL_PATH)
message(FATAL_ERROR "Cannot find SDL. Maybe try specifying SDL_PATH?") #if dynamic SDL2 then install
endif(DEFINED SDL_PATH) install(TARGETS SDL2 RUNTIME DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
endif(SDL2_FOUND) LIBRARY DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
)
add_library(cimgui_sdl SHARED ${IMGUI_SOURCES}) add_library(cimgui_sdl SHARED ${IMGUI_SOURCES})
target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} ${IMGUI_SDL_LIBRARY}) target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
if (WIN32)
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
else(WIN32)
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_IMPL_API=extern \"C\" ")
endif(WIN32)
target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} SDL2)
#using library #using library
include_directories(../../generator/output/) include_directories(../../generator/output/)
@@ -108,5 +103,4 @@ target_compile_definitions(test_sdl PUBLIC -DCIMGUI_USE_OPENGL3 -DCIMGUI_USE_SDL
if (MINGW) if (MINGW)
target_link_options(test_sdl PRIVATE "-mconsole") target_link_options(test_sdl PRIVATE "-mconsole")
endif() endif()
target_link_libraries(test_sdl ${IMGUI_SDL_LIBRARY} cimgui_sdl) target_link_libraries(test_sdl SDL2 cimgui_sdl)

View File

@@ -0,0 +1,2 @@
To build use `cmake path_to_example_sdl_opengl3` and then `make install`

View File

@@ -19,8 +19,7 @@ else()
endif() endif()
include_directories(../../imgui) include_directories(../../imgui)
add_definitions("-DIMGUI_USER_CONFIG=\"../cimconfig.h\"")
add_definitions("-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
include_directories(../../) include_directories(../../)
set(IMGUI_SOURCES ../../cimgui.cpp set(IMGUI_SOURCES ../../cimgui.cpp
@@ -34,11 +33,6 @@ ${TABLES_SOURCE}
set(IMGUI_SOURCES_sdl) set(IMGUI_SOURCES_sdl)
set(IMGUI_LIBRARIES ) set(IMGUI_LIBRARIES )
if (WIN32)
add_definitions("-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
else(WIN32)
add_definitions("-DIMGUI_IMPL_API=extern \"C\" ")
endif(WIN32)
#optional adding freetype #optional adding freetype
option(IMGUI_FREETYPE "add Freetype2" OFF) option(IMGUI_FREETYPE "add Freetype2" OFF)
@@ -54,41 +48,45 @@ endif(IMGUI_FREETYPE)
find_package(Vulkan REQUIRED FATAL_ERROR) find_package(Vulkan REQUIRED FATAL_ERROR)
list(APPEND IMGUI_LIBRARIES Vulkan::Vulkan) list(APPEND IMGUI_LIBRARIES Vulkan::Vulkan)
list(APPEND IMGUI_SOURCES ${BACKENDS_FOLDER}imgui_impl_vulkan.cpp) list(APPEND IMGUI_SOURCES ${BACKENDS_FOLDER}imgui_impl_vulkan.cpp)
include_directories(${Vulkan_INCLUDE_DIRS})
#sdl2 #sdl2
list(APPEND IMGUI_SOURCES ${BACKENDS_FOLDER}imgui_impl_sdl2.cpp) list(APPEND IMGUI_SOURCES ${BACKENDS_FOLDER}imgui_impl_sdl2.cpp)
if(DEFINED SDL_PATH) include(FetchContent)
message(STATUS "SDL_PATH defined as " ${SDL_PATH}) Set(FETCHCONTENT_QUIET FALSE)
FIND_PACKAGE(SDL2 PATHS ${SDL_PATH})
else(DEFINED SDL_PATH)
# If SDL_PATH is not set, fallback and attempt to find SDL cmake script at a default location
find_package(SDL2)
endif(DEFINED SDL_PATH)
if(SDL2_FOUND) FetchContent_Declare(
get_target_property(SDL_INCLUDE SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES) SDL2
message(STATUS "sdlinclude is " ${SDL_INCLUDE}) GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
if ("${SDL_INCLUDE}" STREQUAL "" OR "${SDL_INCLUDE}" STREQUAL "SDL_INCLUDE-NOTFOUND") #if not found latest SDL2 cmake config use older GIT_TAG release-2.30.12
message(STATUS "sdlinclude2 is " ${SDL2_INCLUDE_DIRS}) #GIT_SHALLOW TRUE
include_directories(${SDL2_INCLUDE_DIRS}) GIT_PROGRESS TRUE
set(IMGUI_SDL_LIBRARY ${SDL2_LIBRARIES}) )
message(STATUS IMGUI_SDL_LIBRARY ${SDL2_LIBRARIES}) FetchContent_GetProperties(SDL2)
else()#use new one SDL2 config if (NOT sdl2_POPULATED)
include_directories(${SDL_INCLUDE}) set(FETCHCONTENT_QUIET NO)
set(IMGUI_SDL_LIBRARY SDL2::SDL2) FetchContent_Populate(SDL2)
set(SDL_MAIN SDL2::SDL2main) set(SDL_TEST OFF CACHE BOOL "" FORCE)
message(STATUS ${SDL_MAIN} ${IMGUI_SDL_LIBRARY}) set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
endif() add_subdirectory(${sdl2_SOURCE_DIR} ${sdl2_BINARY_DIR})
else(SDL2_FOUND) endif()
if(DEFINED SDL_PATH) include_directories(${SDL2_SOURCE_DIR}/include)
message(FATAL_ERROR "Cannot find SDL at SDL_PATH")
else(DEFINED SDL_PATH)
message(FATAL_ERROR "Cannot find SDL. Maybe try specifying SDL_PATH?")
endif(DEFINED SDL_PATH)
endif(SDL2_FOUND)
add_library(cimgui_sdl SHARED ${IMGUI_SOURCES})
target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} ${IMGUI_SDL_LIBRARY}) #if dynamic SDL2 then install
# install(TARGETS SDL2 RUNTIME DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
# LIBRARY DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
# )
add_library(cimgui_sdl STATIC ${IMGUI_SOURCES})
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_USER_CONFIG=\"../cimconfig.h\"")
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
if (WIN32)
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
else(WIN32)
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_IMPL_API=extern \"C\" ")
endif(WIN32)
#target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} SDL2-static)
#using library #using library
include_directories(../../generator/output/) include_directories(../../generator/output/)
@@ -97,5 +95,5 @@ target_compile_definitions(test_sdl PUBLIC -DCIMGUI_USE_VULKAN -DCIMGUI_USE_SDL2
if (MINGW) if (MINGW)
target_link_options(test_sdl PRIVATE "-mconsole") target_link_options(test_sdl PRIVATE "-mconsole")
endif() endif()
target_link_libraries(test_sdl ${IMGUI_SDL_LIBRARY} cimgui_sdl) target_link_libraries(test_sdl SDL2-static cimgui_sdl ${IMGUI_LIBRARIES})

View File

@@ -0,0 +1,3 @@
This example needs vulkan generation before compilation: Vulkan SDK should be installed and then add "vulkan" to generator.bat and generate.
To build use `cmake path_to_example_sdl_vulkan` and then `make install`

File diff suppressed because it is too large Load Diff

View File

@@ -464,10 +464,11 @@ if #implementations > 0 then
extra_includes = extra_includes .. include_cmd .. inc .. " " extra_includes = extra_includes .. include_cmd .. inc .. " "
end end
end end
parser2.cimgui_inherited = dofile([[../../cimgui/generator/output/structs_and_enums.lua]])
local defines = parser2:take_lines(CPRE..extra_defines..extra_includes..source, {locati}, COMPILER) local defines = parser2:take_lines(CPRE..extra_defines..extra_includes..source, {locati}, COMPILER)
local parser3 = cpp2ffi.Parser() local parser3 = cpp2ffi.Parser()
parser3.cimgui_inherited = dofile([[../../cimgui/generator/output/structs_and_enums.lua]])
parser3:take_lines(CPRE..extra_defines..extra_includes..source, {locati}, COMPILER) parser3:take_lines(CPRE..extra_defines..extra_includes..source, {locati}, COMPILER)
parser3:do_parse() parser3:do_parse()
local cfuncsstr = func_header_impl_generate(parser3) local cfuncsstr = func_header_impl_generate(parser3)