diff --git a/CMakeLists.txt b/CMakeLists.txt index 826c0596..94a7a47b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,8 @@ endif() set(CMAKE_CXX_STANDARD 17) +include(${CMAKE_CURRENT_LIST_DIR}/hello_imgui_cmake/utils/cache_hello_imgui_paths.cmake) + ############################################################################### # hello_imgui_add_app ############################################################################### @@ -28,9 +30,7 @@ set(CMAKE_CXX_STANDARD 17) # * It will automatically link the target to the required libraries (hello_imgui, OpenGl, glad, etc) # * It will embed the assets (for desktop, mobile, and emscripten apps) # * It will perform additional customization (app icon and name on mobile platforms, etc) -set(HELLOIMGUI_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/hello_imgui_cmake CACHE STRING "" FORCE) # Make cmake function `hello_imgui_add_app` available -list(APPEND CMAKE_MODULE_PATH ${HELLOIMGUI_CMAKE_PATH}) include(hello_imgui_add_app) @@ -323,7 +323,6 @@ endif() #------------------------------------------------------------------------------ # Main build actions #------------------------------------------------------------------------------ -set(HELLOIMGUI_BASEPATH ${CMAKE_CURRENT_LIST_DIR} CACHE STRING "Hello imgui base path" FORCE) include(cmake/StandardProjectSettings.cmake) include(cmake/StaticAnalyzers.cmake) include(msvc/msvc_target_group) diff --git a/hello_imgui_cmake/hello_imgui_add_app.cmake b/hello_imgui_cmake/hello_imgui_add_app.cmake index d0a6fb35..57e17404 100644 --- a/hello_imgui_cmake/hello_imgui_add_app.cmake +++ b/hello_imgui_cmake/hello_imgui_add_app.cmake @@ -1,3 +1,5 @@ +include(${CMAKE_CURRENT_LIST_DIR}/utils/cache_hello_imgui_paths.cmake) + # # hello_imgui_add_app is a helper function, similar to cmake's "add_executable" # diff --git a/hello_imgui_cmake/utils/cache_hello_imgui_paths.cmake b/hello_imgui_cmake/utils/cache_hello_imgui_paths.cmake new file mode 100644 index 00000000..693ed0f7 --- /dev/null +++ b/hello_imgui_cmake/utils/cache_hello_imgui_paths.cmake @@ -0,0 +1,7 @@ +set(helloimgui_basepath ${CMAKE_CURRENT_LIST_DIR}/../..) +# change helloimgui_basepath to absolute path +get_filename_component(helloimgui_basepath ${helloimgui_basepath} ABSOLUTE) + +set(HELLOIMGUI_BASEPATH ${helloimgui_basepath} CACHE STRING "Hello imgui base path" FORCE) +set(HELLOIMGUI_CMAKE_PATH ${HELLOIMGUI_BASEPATH}/hello_imgui_cmake CACHE STRING "Hello imgui cmake path" FORCE) +list(APPEND CMAKE_MODULE_PATH ${HELLOIMGUI_CMAKE_PATH})