-
Notifications
You must be signed in to change notification settings - Fork 103
use cmake #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
use cmake #91
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| cmake_minimum_required(VERSION 3.23) | ||
| project(rlImGui VERSION 0.1.0) | ||
|
|
||
| option(BUILD_EXAMPLES "Build examples" OFF) | ||
|
|
||
| include(FetchContent) | ||
|
|
||
| find_package(imgui QUIET) | ||
| if (NOT imgui_FOUND) | ||
| FetchContent_Declare( | ||
| imgui | ||
| URL https://github.com/ocornut/imgui/archive/refs/heads/master.zip | ||
| URL_HASH MD5=cc306a442c28bc853615eb9579292130 | ||
| DOWNLOAD_EXTRACT_TIMESTAMP TRUE | ||
| ) | ||
| FetchContent_MakeAvailable(imgui) | ||
| add_library(imgui STATIC) | ||
| add_library(imgui::imgui ALIAS imgui) | ||
| target_sources(imgui | ||
| PUBLIC | ||
| FILE_SET HEADERS | ||
| FILES | ||
| ${imgui_SOURCE_DIR}/imgui.h | ||
| ${imgui_SOURCE_DIR}/imgui_internal.h | ||
| ${imgui_SOURCE_DIR}/imstb_rectpack.h | ||
| ${imgui_SOURCE_DIR}/imstb_textedit.h | ||
| ${imgui_SOURCE_DIR}/imstb_truetype.h | ||
| BASE_DIRS ${imgui_SOURCE_DIR} | ||
| PRIVATE | ||
| ${imgui_SOURCE_DIR}/imgui.cpp | ||
| ${imgui_SOURCE_DIR}/imgui_demo.cpp | ||
| ${imgui_SOURCE_DIR}/imgui_draw.cpp | ||
| ${imgui_SOURCE_DIR}/imgui_tables.cpp | ||
| ${imgui_SOURCE_DIR}/imgui_widgets.cpp | ||
| ) | ||
| endif () | ||
|
|
||
| find_package(raylib QUIET) | ||
| if (NOT raylib_FOUND) | ||
| FetchContent_Declare( | ||
| raylib | ||
| URL https://github.com/raysan5/raylib/archive/refs/heads/master.zip | ||
| URL_HASH MD5=cbb82e5c9beca98fd27787821e7c0cf2 | ||
| DOWNLOAD_EXTRACT_TIMESTAMP TRUE | ||
| ) | ||
| FetchContent_MakeAvailable(raylib) | ||
| endif () | ||
|
|
||
|
|
||
| add_library(rlImGui STATIC) | ||
| target_sources(rlImGui | ||
| PUBLIC | ||
| FILE_SET HEADERS | ||
| FILES rlImGui.h rlImGuiColors.h imgui_impl_raylib.h | ||
| PRIVATE | ||
| rlImGui.cpp | ||
| ) | ||
| target_link_libraries(rlImGui PUBLIC imgui::imgui raylib) | ||
|
|
||
| set_target_properties(rlImGui PROPERTIES EXPORT_NAME "rlImGui") | ||
| install(TARGETS rlImGui | ||
| EXPORT rlImGuiTargets | ||
| ARCHIVE DESTINATION lib | ||
| FILE_SET HEADERS DESTINATION include | ||
| ) | ||
|
|
||
| install(EXPORT rlImGuiTargets | ||
| NAMESPACE rlImGui:: | ||
| DESTINATION lib/cmake/rlImGui | ||
| ) | ||
|
|
||
| include(CMakePackageConfigHelpers) | ||
| write_basic_package_version_file( | ||
| "${CMAKE_CURRENT_BINARY_DIR}/rlImGuiConfigVersion.cmake" | ||
| COMPATIBILITY SameMajorVersion | ||
| ) | ||
|
|
||
| install(FILES | ||
| "${CMAKE_CURRENT_BINARY_DIR}/rlImGuiConfigVersion.cmake" | ||
| DESTINATION lib/cmake/rlImGui | ||
| ) | ||
|
|
||
| configure_file(cmake/rlImGuiConfig.cmake.in rlImGuiConfig.cmake @ONLY) | ||
| install(FILES | ||
| "${CMAKE_CURRENT_BINARY_DIR}/rlImGuiConfig.cmake" | ||
| DESTINATION lib/cmake/rlImGui | ||
| ) | ||
|
|
||
|
|
||
| if (BUILD_EXAMPLES) | ||
| add_subdirectory(examples) | ||
| endif () | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| @PACKAGE_INIT@ | ||
|
|
||
| include("${CMAKE_CURRENT_LIST_DIR}/rlImGuiTargets.cmake") | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
|
|
||
| add_executable(simple) | ||
| target_sources(simple | ||
| PRIVATE simple.cpp | ||
| ) | ||
| target_link_libraries(simple PRIVATE rlImGui) | ||
| add_custom_command(TARGET simple POST_BUILD | ||
| COMMAND ${CMAKE_COMMAND} -E copy | ||
| "${PROJECT_SOURCE_DIR}/resources/parrots.png" "$<TARGET_FILE_DIR:simple>/resources/parrots.png" | ||
| ) | ||
|
|
||
|
|
||
| add_executable(editor) | ||
| target_sources(editor | ||
| PRIVATE editor.cpp | ||
| ) | ||
| target_link_libraries(editor PRIVATE rlImGui) | ||
| add_custom_command(TARGET editor POST_BUILD | ||
| COMMAND ${CMAKE_COMMAND} -E copy | ||
| "${PROJECT_SOURCE_DIR}/resources/parrots.png" "$<TARGET_FILE_DIR:editor>/resources/parrots.png" | ||
| ) | ||
|
|
||
|
|
||
| add_executable(imgui_style_example) | ||
| target_sources(imgui_style_example | ||
| PRIVATE imgui_style_example.cpp | ||
| ) | ||
| target_link_libraries(imgui_style_example PRIVATE rlImGui) | ||
| add_custom_command(TARGET imgui_style_example POST_BUILD | ||
| COMMAND ${CMAKE_COMMAND} -E copy | ||
|
||
| "${PROJECT_SOURCE_DIR}/resources/driusstraight.ttf" "$<TARGET_FILE_DIR:imgui_style_example>/resources/driusstraight.ttf" | ||
| ) | ||
|
|
||
|
|
||
| add_executable(docking_example) | ||
| target_sources(docking_example | ||
| PRIVATE docking_example.cpp | ||
| ) | ||
| target_link_libraries(docking_example PRIVATE rlImGui) | ||
|
|
||
|
|
||
| add_executable(asset_browser) | ||
| target_sources(asset_browser | ||
| PRIVATE asset_browser/main.cpp asset_browser/asset_browser.cpp asset_browser/imgui_utils.cpp asset_browser/item_views.cpp | ||
| asset_browser/asset_browser.h asset_browser/imgui_utils.h asset_browser/item_view.h | ||
| ) | ||
| target_link_libraries(asset_browser PRIVATE rlImGui) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this STATIC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll work on the SHARED option, I'll get back to you in a couple of days.