Skip to content

Commit

Permalink
CMake: add option HELLOIMGUI_INSTALL
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Feb 1, 2024
1 parent 40adf4b commit a8d4190
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ option(HELLOIMGUI_BUILD_TESTS "Build tests" OFF)
option(HELLOIMGUI_WITH_TEST_ENGINE "Provide ImGui Test engine" OFF)
message(STATUS "HELLOIMGUI_WITH_TEST_ENGINE=${HELLOIMGUI_WITH_TEST_ENGINE}")

#------------------------------------------------------------------------------
# Options / Install
# By default, hello_imgui install its targets only if it is the top level project
#------------------------------------------------------------------------------
option(HELLOIMGUI_INSTALL "Install hello_imgui" ${PROJECT_IS_TOP_LEVEL})

#------------------------------------------------------------------------------
# Instructions: how to enable Emscripten multithreading support
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -362,7 +368,7 @@ endif()
# find_package(hello-imgui CONFIG REQUIRED)
# hello_imgui_add_app(test test.cpp) # this will automatically link with hello_imgui
#------------------------------------------------------------------------------
if(PROJECT_IS_TOP_LEVEL)
if(HELLOIMGUI_INSTALL)
# inspired from https://iamsorush.com/posts/cpp-cmake-config/
message(STATUS "HELLOIMGUI_INSTALLABLE_DEPENDENCIES=${HELLOIMGUI_INSTALLABLE_DEPENDENCIES}")
install(TARGETS ${HELLOIMGUI_INSTALLABLE_DEPENDENCIES}
Expand Down
1 change: 0 additions & 1 deletion hello_imgui_cmake/hello-imguiConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ find_dependency(imgui CONFIG REQUIRED)
find_dependency(glad CONFIG REQUIRED)

include(${CMAKE_CURRENT_LIST_DIR}/hello_imgui_cmake/hello_imgui_add_app.cmake)
message(STATUS "including ${CMAKE_CURRENT_LIST_DIR}/hello_imgui_cmake/hello_imgui_add_app.cmake")
include(${CMAKE_CURRENT_LIST_DIR}/hello-imgui-targets.cmake)
8 changes: 4 additions & 4 deletions hello_imgui_cmake/hello_imgui_build_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function(him_build_imgui)
endfunction()

function(him_install_imgui)
if(PROJECT_IS_TOP_LEVEL)
if(HELLOIMGUI_INSTALL)
if(NOT TARGET imgui)
return()
endif()
Expand Down Expand Up @@ -433,7 +433,7 @@ function(him_add_stb_image)
target_compile_definitions(stb_hello_imgui PRIVATE STB_IMAGE_WRITE_IMPLEMENTATION)
endif()

if(PROJECT_IS_TOP_LEVEL AND NOT Stb_FOUND)
if(HELLOIMGUI_INSTALL AND NOT Stb_FOUND)
file(GLOB stb_headers ${stb_dir}/*.h)
install(FILES ${stb_headers} DESTINATION include)
endif()
Expand Down Expand Up @@ -636,7 +636,7 @@ function(_him_add_glad)
target_link_libraries(${HELLOIMGUI_TARGET} PUBLIC glad)

him_add_installable_dependency(glad)
if(PROJECT_IS_TOP_LEVEL)
if(HELLOIMGUI_INSTALL)
install(TARGETS glad DESTINATION ./lib/)
install(FILES ${glad_dir}/include/glad/glad.h DESTINATION include/glad)
install(FILES ${glad_dir}/include/KHR/khrplatform.h DESTINATION include/KHR)
Expand Down Expand Up @@ -938,7 +938,7 @@ endfunction()
# Install: API = him_install
###################################################################################################
function(him_install)
if (PROJECT_IS_TOP_LEVEL AND NOT IOS AND NOT ANDROID)
if (HELLOIMGUI_INSTALL AND NOT IOS AND NOT ANDROID)
install(TARGETS ${HELLOIMGUI_TARGET} DESTINATION lib/)
file(GLOB headers *.h)
install(FILES ${headers} DESTINATION include/hello_imgui/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function(_add_imgui_test_engine_lib)
)

# install test_engine headers
if(PROJECT_IS_TOP_LEVEL)
if(HELLOIMGUI_INSTALL)
file(GLOB te_headers ${te_source_folder}/*.h)
install(FILES ${te_headers} DESTINATION include/imgui_test_engine)
install(DIRECTORY ${te_source_folder}/thirdparty DESTINATION include)
Expand Down

0 comments on commit a8d4190

Please sign in to comment.