summaryrefslogtreecommitdiffstats
path: root/extra
diff options
context:
space:
mode:
authorKyle Manna <kyle@kylemanna.com>2015-10-15 13:56:20 -0700
committerKyle Manna <kyle@kylemanna.com>2015-10-15 13:56:20 -0700
commit863dddca69983485fdc3faf58c7dd439d0d5bf5d (patch)
tree429be9a4ab8a5da3e8317105aaea0ed4f7a02cd6 /extra
parenta97617bb41d2e03c670467a0d053b4d2eaae8dad (diff)
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.
Diffstat (limited to 'extra')
-rw-r--r--extra/FindNanopb.cmake10
1 files changed, 6 insertions, 4 deletions
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