-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Catkin dependency while keeping CMake's find_package() feature #133
base: main
Are you sure you want to change the base?
Changes from all commits
e220a32
36c4e9d
be625f1
be3267b
d764d13
e685261
b94e7dd
189db8d
514acca
d6245ab
db7855c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ install: | |
- make install_deps | ||
- source setup.bash | ||
script: | ||
- make && make test | ||
- make | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,11 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
project(serial) | ||
|
||
# Find catkin | ||
find_package(catkin REQUIRED) | ||
|
||
if(APPLE) | ||
find_library(IOKIT_LIBRARY IOKit) | ||
find_library(FOUNDATION_LIBRARY Foundation) | ||
endif() | ||
|
||
if(UNIX AND NOT APPLE) | ||
# If Linux, add rt and pthread | ||
catkin_package( | ||
LIBRARIES ${PROJECT_NAME} | ||
INCLUDE_DIRS include | ||
DEPENDS rt pthread | ||
) | ||
else() | ||
# Otherwise normal call | ||
catkin_package( | ||
LIBRARIES ${PROJECT_NAME} | ||
INCLUDE_DIRS include | ||
) | ||
endif() | ||
|
||
## Sources | ||
set(serial_SRCS | ||
src/serial.cc | ||
|
@@ -45,7 +27,7 @@ else() | |
endif() | ||
|
||
## Add serial library | ||
add_library(${PROJECT_NAME} ${serial_SRCS}) | ||
add_library(${PROJECT_NAME} STATIC ${serial_SRCS}) | ||
if(APPLE) | ||
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY}) | ||
elseif(UNIX) | ||
|
@@ -54,25 +36,37 @@ else() | |
target_link_libraries(${PROJECT_NAME} setupapi) | ||
endif() | ||
|
||
## Uncomment for example | ||
## Add example project | ||
add_executable(serial_example examples/serial_example.cc) | ||
add_dependencies(serial_example ${PROJECT_NAME}) | ||
target_link_libraries(serial_example ${PROJECT_NAME}) | ||
|
||
## Include headers | ||
include_directories(include) | ||
|
||
## Install | ||
set(INSTALL_LIB_DIR lib) | ||
set(INSTALL_INCLUDE_DIR include) | ||
set(INSTALL_CMAKE_DIR share/serial/cmake) | ||
|
||
## Install executable | ||
install(TARGETS ${PROJECT_NAME} | ||
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} | ||
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} | ||
DESTINATION ${INSTALL_LIB_DIR} | ||
EXPORT ${PROJECT_NAME}-targets | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disclaimer: I'm a CMake rookie... and I tried quite a few things before coming up with this solution More about it here: https://cmake.org/Wiki/CMake/Tutorials/Packaging#Packaging_and_Exporting
|
||
) | ||
|
||
## Install headers | ||
install(FILES include/serial/serial.h include/serial/v8stdint.h | ||
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial) | ||
DESTINATION ${INSTALL_INCLUDE_DIR}/serial) | ||
|
||
## Install CMake files | ||
install(EXPORT ${PROJECT_NAME}-targets DESTINATION ${INSTALL_CMAKE_DIR}) | ||
|
||
install(FILES ${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake ${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake | ||
DESTINATION ${INSTALL_CMAKE_DIR}) | ||
|
||
## Tests | ||
if(CATKIN_ENABLE_TESTING) | ||
add_subdirectory(tests) | ||
endif() | ||
# FIXME | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR can't be merged before this is fixed |
||
#if(CATKIN_ENABLE_TESTING) | ||
# add_subdirectory(tests) | ||
#endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Usage: | ||
# | ||
# find_package(serial REQUIRED) | ||
# include_directories(${serial_INCLUDE_DIRS}) | ||
# target_link_libraries(<target> serial) | ||
|
||
if(serial_CONFIG_INCLUDED) | ||
return() | ||
endif() | ||
set(serial_CONFIG_INCLUDED TRUE) | ||
|
||
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) | ||
include(${SELF_DIR}/serial-targets.cmake) | ||
get_filename_component(serial_INCLUDE_DIRS "${SELF_DIR}/../../../include" ABSOLUTE) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
set(PACKAGE_VERSION "1.2.1") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently with Catkin, any newer version of this package is considered compatible. With this version file, the package is compatible only if:
So, if "0.9" is requested and "1.2.1" is installed => mismatch Relying on the major version number for compatibility seems to me like a good idea, and enables breaking changes to be introduced in order to keep this package alive [relates to #102 for instance]. |
||
|
||
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) | ||
set(PACKAGE_VERSION_COMPATIBLE FALSE) | ||
else() | ||
if(PACKAGE_VERSION MATCHES "^([0-9]+)\\.") | ||
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") | ||
else() | ||
set(CVF_VERSION_MAJOR PACKAGE_VERSION) | ||
endif() | ||
|
||
if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) | ||
set(PACKAGE_VERSION_COMPATIBLE TRUE) | ||
else() | ||
set(PACKAGE_VERSION_COMPATIBLE FALSE) | ||
endif() | ||
|
||
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) | ||
set(PACKAGE_VERSION_EXACT TRUE) | ||
endif() | ||
endif() |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIXME: For the time being tests are not built, so they cannot be run