From b88bbe155f4ef56a6ce6ce40366a59756ea0dda3 Mon Sep 17 00:00:00 2001 From: Ammar ELWazir Date: Thu, 12 May 2022 01:51:10 -0500 Subject: [PATCH] Checking for missing python packages Reporting error in CMake if CppHeaderParser and argparse are not installed in the system Change-Id: I7617f662bc061fde45ce9f72c08d80a5108766d9 --- cmake_modules/env.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmake_modules/env.cmake b/cmake_modules/env.cmake index 280914ed61..beed3762eb 100644 --- a/cmake_modules/env.cmake +++ b/cmake_modules/env.cmake @@ -37,6 +37,20 @@ add_compile_options ( -Wall -Werror ) add_link_options("-Bdynamic -z,noexecstck") +find_package(Python3 COMPONENTS Interpreter REQUIRED) + +execute_process( + COMMAND ${Python3_EXECUTABLE} -c "import CppHeaderParser" + RESULT_VARIABLE CPPHEADERPARSER + OUTPUT_QUIET +) + +if(NOT ${CPPHEADERPARSER} EQUAL 0) + message(FATAL_ERROR + "The \"CppHeaderParser\" Python3 package is not installed. Please install it using the following command: \"pip3 install CppHeaderParser\"." + ) +endif() + ## CLANG options if ( "$ENV{CXX}" STREQUAL "/usr/bin/clang++" ) set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ferror-limit=1000000" )