소스 검색

cmake: Use include/lib paths from MRAA pkgconfig for cmake

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Noel Eck 9 년 전
부모
커밋
d0504bb65b
3개의 변경된 파일14개의 추가작업 그리고 11개의 파일을 삭제
  1. 2
    4
      docs/building.md
  2. 4
    0
      examples/c++/CMakeLists.txt
  3. 8
    7
      src/CMakeLists.txt

+ 2
- 4
docs/building.md 파일 보기

@@ -5,12 +5,10 @@ UPM uses cmake in order to make compilation relatively painless. Cmake runs
5 5
 build out of tree so the recommended way is to clone from git and make a build/
6 6
 directory.
7 7
 
8
-This project depends on libmraa, so that needs to be installed first. Use the
9
-following environment variables to configure the paths:
8
+This project depends on libmraa, so that needs to be installed first. Append
9
+the install location of mraa pkgconfig to the following environment variable:
10 10
 
11 11
     PKG_CONFIG_PATH=$PKG_CONFIG_PATH:.../mraa/build/lib/pkgconfig
12
-    CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:.../mraa/build/include
13
-    LIBRARY_PATH=$LIBRARY_PATH:.../mraa/build/lib
14 12
 
15 13
 UPM will attempt to build all directories inside src/ and they must contain
16 14
 individual CMakeLists.txt files.

+ 4
- 0
examples/c++/CMakeLists.txt 파일 보기

@@ -74,6 +74,10 @@ endmacro()
74 74
 
75 75
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples)
76 76
 
77
+# Set the mraa include and link directories prior to adding examples
78
+include_directories (${MRAA_INCLUDE_DIRS})
79
+link_directories (${MRAA_LIBDIR})
80
+
77 81
 # If your sample source file matches the name of the module it tests, add it here
78 82
 # Exceptions are as follows:
79 83
 #  string after first '-' is ignored (e.g. nrf24l01-transmitter maps to nrf24l01)

+ 8
- 7
src/CMakeLists.txt 파일 보기

@@ -49,9 +49,9 @@ macro(upm_SWIG_NODE)
49 49
     )
50 50
     if (${V8_VERSION_MAJOR} GREATER 3)
51 51
       if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
52
-	  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
53
-	    message(FATAL_ERROR " **ERROR** GCC 4.7 or above is required to compile jsupm_${libname} ")
54
-	  endif()
52
+        if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
53
+          message(FATAL_ERROR " **ERROR** GCC 4.7 or above is required to compile jsupm_${libname} ")
54
+        endif()
55 55
       endif()
56 56
       set_property (TARGET jsupm_${libname} PROPERTY CXX_STANDARD 11)
57 57
       set_property (TARGET jsupm_${libname} PROPERTY CXX_STANDARD_REQUIRED ON)
@@ -88,10 +88,10 @@ macro(upm_SWIG_JAVA)
88 88
       SUFFIX ".so"
89 89
     )
90 90
     install (FILES ${CMAKE_CURRENT_BINARY_DIR}/libjavaupm_${libname}.so
91
-	DESTINATION lib/java
91
+        DESTINATION lib/java
92 92
     )
93 93
     install (FILES ${CMAKE_CURRENT_BINARY_DIR}/upm_${libname}.jar
94
-	DESTINATION lib/java
94
+        DESTINATION lib/java
95 95
     )
96 96
 
97 97
     if (NOT DEFINED $ENV{JAVA_HOME_NATIVE})
@@ -168,15 +168,16 @@ if (SWIG_FOUND)
168 168
 #  if(BUILDSWIGJAVA)
169 169
 #    add_subdirectory (java)
170 170
 #  endif(BUILDSWIGJAVA)
171
-    
171
+
172 172
 endif()
173 173
 
174 174
 macro(upm_module_init)
175
+  link_directories (${MRAA_LIBDIR})
175 176
   add_library (${libname} SHARED ${module_src})
176 177
   foreach (linkflag ${ARGN})
177 178
     target_link_libraries (${libname} ${linkflag})
178 179
   endforeach ()
179
-  include_directories (${MRAA_INCLUDE_DIR} .)
180
+  include_directories (${MRAA_INCLUDE_DIRS} .)
180 181
   target_link_libraries (${libname} ${MRAA_LIBRARIES})
181 182
   set_target_properties(
182 183
     ${libname}