From d429d21c4fa673abb9a2c219687f0fb97f7f6dbe Mon Sep 17 00:00:00 2001 From: sillysagiri Date: Wed, 6 Nov 2024 17:29:39 +0700 Subject: [PATCH] use option to cmake --- CMakeLists.txt | 80 ++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29aedcb..bda1f99 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,36 +10,36 @@ set(PROJECT_VERSION 1.0) project(${PROJECT_NAME} VERSION ${PROJECT_VERSION}) ############################################################## -# set(RAYLIB_DIR "path/to/raylib") -# set(IMGUI_DIR "path/to/imgui-docking") -# set(RLIMGUI_DIR "path/to/rlImGui") -# set(INIFILE_DIR "path/to/inifile-cpp") +option(PANDA_INCLUDE_IMGUI "include imgui" ON) ### Fallback link -set(RAYLIB_LINK "https://github.com/raysan5/raylib/archive/refs/tags/5.0.zip") -set(IMGUI_LINK "https://github.com/ocornut/imgui/archive/refs/heads/docking.zip") -set(RLIMGUI_LINK "https://github.com/raylib-extras/rlImGui/archive/refs/heads/main.zip") -set(INIFILE_LINK "https://github.com/Rookfighter/inifile-cpp/archive/refs/heads/master.zip") +if(NOT RAYLIB_LINK) + set(RAYLIB_LINK "https://github.com/raysan5/raylib/archive/refs/tags/5.0.zip") +endif() + +if(NOT IMGUI_LINK) + set(IMGUI_LINK "https://github.com/ocornut/imgui/archive/refs/heads/docking.zip") +endif() + +if(NOT RLIMGUI_LINK) + set(RLIMGUI_LINK "https://github.com/raylib-extras/rlImGui/archive/refs/heads/main.zip") +endif() + +if(NOT INIFILE_LINK) + set(INIFILE_LINK "https://github.com/Rookfighter/inifile-cpp/archive/refs/heads/master.zip") +endif() ############################################################## -if (EXISTS ${RAYLIB_DIR}) - add_subdirectory(${RAYLIB_DIR} raylib) -else() - message(STATUS "Downloading raylib library") - include(FetchContent) - set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) - FetchContent_Declare(raylib URL ${RAYLIB_LINK}) - FetchContent_MakeAvailable(raylib) -endif() +include(FetchContent) -if (EXISTS ${INIFILE_DIR}) - set(inifile-cpp_SOURCE_DIR ${INIFILE_DIR}) -else() - message(STATUS "Downloading inifile-cpp library") - include(FetchContent) - FetchContent_Declare(inifile-cpp URL ${INIFILE_LINK}) - FetchContent_MakeAvailable(inifile-cpp) -endif() +message(STATUS "Downloading raylib library") +set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) +FetchContent_Declare(raylib URL ${RAYLIB_LINK}) +FetchContent_MakeAvailable(raylib) + +message(STATUS "Downloading inifile-cpp library") +FetchContent_Declare(inifile-cpp URL ${INIFILE_LINK}) +FetchContent_MakeAvailable(inifile-cpp) ############################################################## # yes... im using glob... dont judge me.... @@ -55,31 +55,16 @@ set(PROJECT_DEFINITION "_PANDA_CORE_") ############################################################## -if(NOT DEFINED PANDA_INCLUDE_IMGUI) - set(PANDA_INCLUDE_IMGUI "true") - message(STATUS "PANDA_INCLUDE_IMGUI not defined, default to true") -endif() - -if(DEFINED PANDA_INCLUDE_IMGUI AND PANDA_INCLUDE_IMGUI STREQUAL "true") +if(PANDA_INCLUDE_IMGUI) set(PROJECT_DEFINITION ${PROJECT_DEFINITION} PANDA_INCLUDE_IMGUI) - if (EXISTS ${IMGUI_DIR}) - set(imgui_SOURCE_DIR ${IMGUI_DIR}) - else() - message(STATUS "Downloading imgui library") - include(FetchContent) - FetchContent_Declare(imgui URL ${IMGUI_LINK}) - FetchContent_MakeAvailable(imgui) - endif() + message(STATUS "Downloading imgui library") + FetchContent_Declare(imgui URL ${IMGUI_LINK}) + FetchContent_MakeAvailable(imgui) - if (EXISTS ${RLIMGUI_DIR}) - set(rlimgui_SOURCE_DIR ${RLIMGUI_DIR}) - else() - message(STATUS "Downloading rlImGui library") - include(FetchContent) - FetchContent_Declare(rlimgui URL ${RLIMGUI_LINK}) - FetchContent_MakeAvailable(rlimgui) - endif() + message(STATUS "Downloading rlImGui library") + FetchContent_Declare(rlimgui URL ${RLIMGUI_LINK}) + FetchContent_MakeAvailable(rlimgui) file(GLOB IMGUI_SOURCES CONFIGURE_DEPENDS "${imgui_SOURCE_DIR}/*.cpp" @@ -95,7 +80,6 @@ if(DEFINED PANDA_INCLUDE_IMGUI AND PANDA_INCLUDE_IMGUI STREQUAL "true") ${rlimgui_SOURCE_DIR}) endif() - ############################################################## add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCES})