Skip to content
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

cmake modular installation #185

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
cmake_minimum_required(VERSION 3.24)
Project(imgui_node_editor)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake-modules)

set(IMGUI_NODE_EDITOR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(${IMGUI_NODE_EDITOR_ROOT_DIR}/examples/application)

find_package(imgui REQUIRED)

set(${PROJECT_NAME}_Sources
${CMAKE_CURRENT_SOURCE_DIR}/crude_json.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_bezier_math.inl
${CMAKE_CURRENT_SOURCE_DIR}/imgui_canvas.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_extra_math.inl
${CMAKE_CURRENT_SOURCE_DIR}/imgui_node_editor_api.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_node_editor_internal.inl
${CMAKE_CURRENT_SOURCE_DIR}/imgui_node_editor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/misc/imgui_node_editor.natvis
)

set(${PROJECT_NAME}_Headers
${CMAKE_CURRENT_SOURCE_DIR}/crude_json.h
${CMAKE_CURRENT_SOURCE_DIR}/imgui_bezier_math.h
${CMAKE_CURRENT_SOURCE_DIR}/imgui_canvas.h
${CMAKE_CURRENT_SOURCE_DIR}/imgui_extra_math.h
${CMAKE_CURRENT_SOURCE_DIR}/imgui_node_editor_internal.h
${CMAKE_CURRENT_SOURCE_DIR}/imgui_node_editor.h
)

add_library(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_Sources} ${${PROJECT_NAME}_Headers})

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}/>
)

target_link_libraries(${PROJECT_NAME} PUBLIC imgui)
target_link_directories(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:lib>)

install(
TARGETS ${PROJECT_NAME} imgui application stb_image ScopeGuard
EXPORT Targets
)

if(WIN32)
install(
FILES external/DXSDK/lib/x64/d3dx11.lib
DESTINATION lib
)
endif()

install(
FILES ${${PROJECT_NAME}_Headers}
DESTINATION include/${PROJECT_NAME}
)

install(
EXPORT Targets
FILE ${PROJECT_NAME}Config.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
24 changes: 16 additions & 8 deletions examples/application/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
project(application)

set(_Application_Sources
include/application.h
source/application.cpp
source/entry_point.cpp
source/imgui_extra_keys.h
include/application.h
source/application.cpp
source/entry_point.cpp
source/imgui_extra_keys.h
source/config.h.in
source/setup.h
source/platform.h
Expand All @@ -13,11 +13,14 @@ set(_Application_Sources
source/renderer.h
source/renderer_dx11.cpp
source/renderer_ogl3.cpp
)

)
add_library(application STATIC)

target_include_directories(application PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(application PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/application>
)

find_package(imgui REQUIRED)
find_package(stb_image REQUIRED)
Expand Down Expand Up @@ -109,4 +112,9 @@ source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${_Application_Sources})

target_sources(application PRIVATE ${_Application_Sources})

set_property(TARGET application PROPERTY FOLDER "examples")
set_property(TARGET application PROPERTY FOLDER "examples")

install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/application.h
DESTINATION include/application
)
4 changes: 2 additions & 2 deletions external/ScopeGuard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(_ScopeGuard_Sources
${CMAKE_CURRENT_SOURCE_DIR}/ScopeGuard.h
)

target_include_directories(ScopeGuard INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(ScopeGuard INTERFACE ${_ScopeGuard_Sources})
target_include_directories(ScopeGuard INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_sources(ScopeGuard INTERFACE $<BUILD_INTERFACE:${_ScopeGuard_Sources}>)

source_group("ThirdParty\\ScopeGuard" FILES ${_ScopeGuard_Sources})
29 changes: 21 additions & 8 deletions external/imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
project(imgui VERSION 1.76)

set(_imgui_Sources
imconfig.h
imgui.cpp
imgui.h
imgui.natvis
imgui_demo.cpp
imgui_draw.cpp
imgui_internal.h
imgui_widgets.cpp
imgui_tables.cpp
imstb_rectpack.h
imstb_textedit.h
imstb_truetype.h
LICENSE.txt
)

add_library(${PROJECT_NAME} STATIC ${_imgui_Sources})
set(_imgui_headers
imconfig.h
imgui.h
imgui_internal.h
imstb_rectpack.h
imstb_textedit.h
imstb_truetype.h
)

add_library(${PROJECT_NAME} STATIC ${_imgui_Sources} ${_imgui_headers})

target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}/>
)

target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
#target_compile_definitions(${PROJECT_NAME} PUBLIC "ImDrawIdx=unsigned int")
target_compile_definitions(${PROJECT_NAME} PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${_imgui_Sources})

set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER "external")

install(
FILES
${_imgui_headers}
DESTINATION
include/${PROJECT_NAME}
)
5 changes: 3 additions & 2 deletions external/stb_image/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ set(_stb_image_Sources
${CMAKE_CURRENT_SOURCE_DIR}/stb_image.h
)

target_include_directories(stb_image INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(stb_image INTERFACE ${_stb_image_Sources})
target_include_directories(stb_image INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

target_sources(stb_image INTERFACE $<BUILD_INTERFACE:${_stb_image_Sources}>)

source_group("ThirdParty\\stb_image" FILES ${_stb_image_Sources})