From 710c1dd35387f20d817142dadf46447240152671 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Fri, 18 Oct 2024 11:45:24 -0400 Subject: [PATCH] build: get CLI11 via file download if not on system --- cmake/Libraries.cmake | 33 --------------------------------- meson.build | 7 ------- meson_options.txt | 1 - scripts/lib/meson.py | 1 - src/lib/deskflow/App.cpp | 4 ---- src/lib/deskflow/CMakeLists.txt | 24 +++++++++++++++++++++++- subprojects/cli11.wrap | 10 ---------- 7 files changed, 23 insertions(+), 57 deletions(-) delete mode 100644 subprojects/cli11.wrap diff --git a/cmake/Libraries.cmake b/cmake/Libraries.cmake index 1669dfb61..43dd1b631 100644 --- a/cmake/Libraries.cmake +++ b/cmake/Libraries.cmake @@ -30,7 +30,6 @@ macro(configure_libs) configure_openssl() configure_coverage() configure_tomlplusplus() - configure_cli11() if(BUILD_TESTS) configure_gtest() @@ -673,35 +672,3 @@ macro(configure_tomlplusplus) endif() endif() endmacro() - -macro(configure_cli11) - file(GLOB cli11_dir ${PROJECT_SOURCE_DIR}/subprojects/CLI11-*) - - if(cli11_dir) - set(DEFAULT_SYSTEM_CLI11 OFF) - else() - set(DEFAULT_SYSTEM_CLI11 ON) - endif() - - option(SYSTEM_CLI11 "Use system CLI11" ${DEFAULT_SYSTEM_CLI11}) - if(SYSTEM_CLI11) - message(VERBOSE "Using system CLI11") - find_package(CLI11) - if(CLI11_FOUND) - message(STATUS "CLI11 version: ${CLI11_VERSION}") - else() - message(WARNING "System CLI11 not found") - endif() - else() - if(EXISTS ${cli11_dir}) - message(VERBOSE "Using local CLI11") - set(HAVE_CLI11 true) - add_definitions(-DHAVE_CLI11=1) - include_directories(${cli11_dir}/include) - else() - message(WARNING "Local CLI11 subproject not found at: ${cli11_dir}") - endif() - - endif() - -endmacro() diff --git a/meson.build b/meson.build index d3eb2ef72..09b1dd723 100644 --- a/meson.build +++ b/meson.build @@ -16,13 +16,6 @@ else subproject('tomlplusplus') endif -system_cli11 = get_option('system-cli11') -if system_cli11 - dependency('cli11', required: false) -else - subproject('cli11') -endif - system_gtest = get_option('system-gtest') if system_gtest dependency('gtest', required: false) diff --git a/meson_options.txt b/meson_options.txt index 6aa59d6de..ff8f65104 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,4 +2,3 @@ option('system-gtest', type: 'boolean', value: true, description: 'Use system gt option('system-libportal', type: 'boolean', value: true, description: 'Use system libportal') option('system-libei', type: 'boolean', value: true, description: 'Use system libei') option('system-tomlplusplus', type: 'boolean', value: true, description: 'Use system tomlplusplus') -option('system-cli11', type: 'boolean', value: true, description: 'Use system cli11') diff --git a/scripts/lib/meson.py b/scripts/lib/meson.py index 7c6f68b45..22d771650 100644 --- a/scripts/lib/meson.py +++ b/scripts/lib/meson.py @@ -35,7 +35,6 @@ def setup(no_system_list, static_list): if env.is_windows(): cmd.append("-Dsystem-gtest=false") cmd.append("-Dsystem-tomlplusplus=false") - cmd.append("-Dsystem-cli11=false") for subproject in no_system_list or []: cmd.append(f"-Dsystem-{subproject}=false") diff --git a/src/lib/deskflow/App.cpp b/src/lib/deskflow/App.cpp index 8b06e3111..0a37aeb0f 100644 --- a/src/lib/deskflow/App.cpp +++ b/src/lib/deskflow/App.cpp @@ -59,9 +59,7 @@ #include #endif -#if HAVE_CLI11 #include -#endif using namespace deskflow; @@ -189,7 +187,6 @@ void App::initApp(int argc, const char **argv) { std::string configFilename; -#if HAVE_CLI11 CLI::App cliApp{kAppDescription, kAppName}; cliApp.add_option("--config-toml", configFilename, "Use TOML configuration file"); @@ -197,7 +194,6 @@ void App::initApp(int argc, const char **argv) cliApp.allow_extras(); cliApp.parse(argc, argv); -#endif // HAVE_CLI11 if (!configFilename.empty()) { Config config(configFilename, configSection()); diff --git a/src/lib/deskflow/CMakeLists.txt b/src/lib/deskflow/CMakeLists.txt index a57b5f439..3db6a3062 100644 --- a/src/lib/deskflow/CMakeLists.txt +++ b/src/lib/deskflow/CMakeLists.txt @@ -14,6 +14,24 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +find_package(CLI11 QUIET) +if(CLI11_FOUND) + message(STATUS "CLI11 [System] Version: ${CLI11_VERSION}") + set(cli11_lib CLI11::CLI11) +else() + #Be sure to update the version and MD5 together + set(CLI11_VERSION 2.4.2) + set(CLI11_MD5 d7923d1ca06d03e2299e55cad532d126) + file( + DOWNLOAD "https://github.com/CLIUtils/CLI11/releases/download/v${CLI11_VERSION}/CLI11.hpp" + "${CMAKE_BINARY_DIR}/include/CLI/CLI.hpp" + EXPECTED_MD5 ${CLI11_MD5} + ) + set(cli11_inc_dir "${CMAKE_BINARY_DIR}/include") + message(STATUS "CLI11 [Downloaded] Version: ${CLI11_VERSION}") + message(STATUS "CLI11 INC_DIR: ${cli11_inc_dir}") +endif() + set(lib_name app) file(GLOB headers "*.h" "languages/*.h") @@ -42,6 +60,8 @@ endif() add_library(${lib_name} STATIC ${sources}) +target_include_directories( ${lib_name} PRIVATE ${cli11_inc_dir}) + if(UNIX) target_link_libraries( ${lib_name} @@ -52,7 +72,9 @@ if(UNIX) base platform mt - server) + server + ${cli11_lib} + ) if(NOT APPLE) target_link_libraries(${lib_name} pugixml) diff --git a/subprojects/cli11.wrap b/subprojects/cli11.wrap deleted file mode 100644 index dd26d5924..000000000 --- a/subprojects/cli11.wrap +++ /dev/null @@ -1,10 +0,0 @@ -[wrap-file] -directory = CLI11-2.4.1 -source_url = https://github.com/CLIUtils/CLI11/archive/refs/tags/v2.4.1.tar.gz -source_filename = CLI11-2.4.1.tar.gz -source_hash = 73b7ec52261ce8fe980a29df6b4ceb66243bb0b779451dbd3d014cfec9fdbb58 -source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/cli11_2.4.1-1/CLI11-2.4.1.tar.gz -wrapdb_version = 2.4.1-1 - -[provide] -cli11 = CLI11_dep