-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake build configuration for C++ library (#150)
* rename C++ examples files to *.cpp * remove duplicated function 'fatal_error' * all examples: use 'GoPiGo3.h' header and compile 'GoPiGo3.cpp' into examples * throw exceptions instead of terminating program * remove whitespaces * CMake file for compiling GoPiGo3 library and examples * install library and header files and make them available to other projects * ROS package definition for GoPiGo3 library
- Loading branch information
1 parent
1c5fd5b
commit 625d817
Showing
11 changed files
with
211 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
project(gopigo3_cpp) | ||
|
||
### Build | ||
|
||
include_directories(.) | ||
|
||
## GoPiGo3 library | ||
add_library(gopigo3 SHARED GoPiGo3.cpp) | ||
|
||
## Examples | ||
|
||
# grove_led | ||
add_executable(grove_led Examples/grove_led.cpp) | ||
target_link_libraries(grove_led gopigo3) | ||
|
||
# i2c | ||
add_executable(i2c Examples/i2c.cpp) | ||
target_link_libraries(i2c gopigo3) | ||
|
||
# info | ||
add_executable(info Examples/info.cpp) | ||
target_link_libraries(info gopigo3) | ||
|
||
# leds | ||
add_executable(leds Examples/leds.cpp) | ||
target_link_libraries(leds gopigo3) | ||
|
||
# motors | ||
add_executable(motors Examples/motors.cpp) | ||
target_link_libraries(motors gopigo3) | ||
|
||
# sensors | ||
add_executable(sensors Examples/sensors.cpp) | ||
target_link_libraries(sensors gopigo3) | ||
|
||
### Installation | ||
|
||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ | ||
DESTINATION include | ||
FILES_MATCHING PATTERN "*.h" | ||
PATTERN "Examples" EXCLUDE | ||
) | ||
|
||
install(TARGETS gopigo3 EXPORT gopigo3Targets | ||
LIBRARY DESTINATION lib | ||
ARCHIVE DESTINATION lib | ||
RUNTIME DESTINATION bin | ||
INCLUDES DESTINATION include | ||
) | ||
|
||
### Export CMake configuration | ||
|
||
set_property(TARGET gopigo3 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/> | ||
) | ||
|
||
set(CONF_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include/) | ||
|
||
export(EXPORT gopigo3Targets | ||
FILE "${PROJECT_BINARY_DIR}/gopigo3_cppTargets.cmake") | ||
|
||
configure_file(gopigo3_cppConfig.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/gopigo3_cppConfig.cmake" @ONLY) | ||
|
||
install(FILES | ||
"${CMAKE_CURRENT_BINARY_DIR}/gopigo3_cppConfig.cmake" | ||
DESTINATION share/gopigo3_cpp/cmake) | ||
|
||
install(EXPORT gopigo3Targets | ||
FILE gopigo3_cppTargets.cmake | ||
DESTINATION share/gopigo3_cpp/cmake | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.