From: Kyle Manna Date: Thu, 15 Oct 2015 20:56:20 +0000 (-0700) Subject: cmake: Auto discover NANOPB_SRC_ROOT_FOLDER X-Git-Tag: 5.0.2~186^2~101^2~1 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=863dddca69983485fdc3faf58c7dd439d0d5bf5d;p=apps%2Fagl-service-can-low-level.git cmake: Auto discover NANOPB_SRC_ROOT_FOLDER * Use CMAKE_CURRENT_LIST_DIR to learn the path of the currently running file to determine location of NanoPB. * Simplifies use in other projects. --- diff --git a/extra/FindNanopb.cmake b/extra/FindNanopb.cmake index 7734a937..9afb21d0 100644 --- a/extra/FindNanopb.cmake +++ b/extra/FindNanopb.cmake @@ -1,10 +1,6 @@ # This is an example script for use with CMake projects for locating and configuring # the nanopb library. # -# The following varialbes have to be set: -# -# NANOPB_SRC_ROOT_FOLDER - Path to nanopb source folder -# # The following variables can be set and are optional: # # @@ -217,6 +213,12 @@ if(NOT DEFINED NANOPB_GENERATE_CPP_APPEND_PATH) set(NANOPB_GENERATE_CPP_APPEND_PATH TRUE) endif() +# Make a really good guess regarding location of NANOPB_SRC_ROOT_FOLDER +if(NOT DEFINED NANOPB_SRC_ROOT_FOLDER) + get_filename_component(NANOPB_SRC_ROOT_FOLDER + ${CMAKE_CURRENT_LIST_DIR}/.. ABSOLUTE) +endif() + # Find the include directory find_path(NANOPB_INCLUDE_DIRS pb.h