-
Notifications
You must be signed in to change notification settings - Fork 252
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
export targets #403
export targets #403
Changes from all commits
519bf15
78e1f56
cd69f3a
26bf9a8
e293bfc
a0f916e
6eb9153
cd7611e
33fa71b
d5dcf6a
9eb4796
0e5b4d6
c9d6aef
0bdb584
5293e70
8674fb2
03702f8
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 |
---|---|---|
|
@@ -5,8 +5,9 @@ find_package(ament_cmake REQUIRED) | |
|
||
include(ExternalProject) | ||
# Single producer single consumer queue by moodycamel - header only, don't build, install | ||
ExternalProject_Add(singleproducerconsumer | ||
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/single | ||
ExternalProject_Add(ext-singleproducerconsumer | ||
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. I deliberately left in these changes because the cmake target of the |
||
PREFIX singleproducerconsumer | ||
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/download | ||
URL https://github.com/cameron314/readerwriterqueue/archive/ef7dfbf553288064347d51b8ac335f1ca489032a.zip | ||
URL_MD5 64c673dd381b8fae9254053ad7b2be4d | ||
TIMEOUT 60 | ||
|
@@ -17,8 +18,9 @@ ExternalProject_Add(singleproducerconsumer | |
) | ||
|
||
# Concurrent and blocking concurrent queue by moodycamel - header only, don't build, install | ||
ExternalProject_Add(concurrentqueue | ||
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/multiple | ||
ExternalProject_Add(ext-concurrentqueue | ||
PREFIX concurrentqueue | ||
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/download | ||
URL https://github.com/cameron314/concurrentqueue/archive/8f65a8734d77c3cc00d74c0532efca872931d3ce.zip | ||
URL_MD5 71a0d932cc89150c2ade85f0d9cac9dc | ||
TIMEOUT 60 | ||
|
@@ -28,16 +30,28 @@ ExternalProject_Add(concurrentqueue | |
INSTALL_COMMAND "" | ||
) | ||
|
||
add_library(singleproducerconsumer INTERFACE) | ||
target_include_directories(singleproducerconsumer INTERFACE $<INSTALL_INTERFACE:include/moodycamel>) | ||
|
||
add_library(concurrentqueue INTERFACE) | ||
target_include_directories(concurrentqueue INTERFACE $<INSTALL_INTERFACE:include/moodycamel>) | ||
|
||
install( | ||
TARGETS singleproducerconsumer concurrentqueue | ||
EXPORT export_${PROJECT_NAME} | ||
INCLUDES DESTINATION include | ||
) | ||
|
||
# Install headers | ||
install( | ||
FILES | ||
"${CMAKE_CURRENT_BINARY_DIR}/singleproducerconsumer-prefix/src/singleproducerconsumer/atomicops.h" | ||
"${CMAKE_CURRENT_BINARY_DIR}/singleproducerconsumer-prefix/src/singleproducerconsumer/readerwriterqueue.h" | ||
"${CMAKE_CURRENT_BINARY_DIR}/concurrentqueue-prefix/src/concurrentqueue/concurrentqueue.h" | ||
"${CMAKE_CURRENT_BINARY_DIR}/concurrentqueue-prefix/src/concurrentqueue/blockingconcurrentqueue.h" | ||
"${CMAKE_CURRENT_BINARY_DIR}/singleproducerconsumer/src/ext-singleproducerconsumer/atomicops.h" | ||
"${CMAKE_CURRENT_BINARY_DIR}/singleproducerconsumer/src/ext-singleproducerconsumer/readerwriterqueue.h" | ||
"${CMAKE_CURRENT_BINARY_DIR}/concurrentqueue/src/ext-concurrentqueue/concurrentqueue.h" | ||
"${CMAKE_CURRENT_BINARY_DIR}/concurrentqueue/src/ext-concurrentqueue/blockingconcurrentqueue.h" | ||
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/moodycamel | ||
) | ||
|
||
ament_export_include_directories(include) | ||
|
||
ament_package() | ||
ament_export_targets(export_${PROJECT_NAME}) | ||
ament_package() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Get package location hint from environment variable (if any) | ||
if(NOT zstd_ROOT_DIR AND DEFINED ENV{zstd_ROOT_DIR}) | ||
set(zstd_ROOT_DIR "$ENV{zstd_ROOT_DIR}" CACHE PATH | ||
"zstd base directory location (optional, used for nonstandard installation paths)") | ||
endif() | ||
|
||
# Search path for nonstandard package locations | ||
if(zstd_ROOT_DIR) | ||
set(zstd_INCLUDE_PATH PATHS "${zstd_ROOT_DIR}/include" NO_DEFAULT_PATH) | ||
set(zstd_LIBRARY_PATH PATHS "${zstd_ROOT_DIR}/lib" NO_DEFAULT_PATH) | ||
else() | ||
set(zstd_INCLUDE_PATH "") | ||
set(zstd_LIBRARY_PATH "") | ||
endif() | ||
|
||
# Find headers and libraries | ||
find_path(zstd_INCLUDE_DIR NAMES zstd.h PATH_SUFFIXES "zstd" ${zstd_INCLUDE_PATH}) | ||
find_library(zstd_LIBRARY NAMES zstd PATH_SUFFIXES "zstd" ${zstd_LIBRARY_PATH}) | ||
|
||
mark_as_advanced(zstd_INCLUDE_DIR zstd_LIBRARY) | ||
|
||
# Output variables generation | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(zstd DEFAULT_MSG zstd_LIBRARY zstd_INCLUDE_DIR) | ||
|
||
set(zstd_FOUND ${ZSTD_FOUND}) # Enforce case-correctness: Set appropriately cased variable... | ||
unset(ZSTD_FOUND) # ...and unset uppercase variable generated by find_package_handle_standard_args | ||
|
||
if(zstd_FOUND) | ||
set(zstd_INCLUDE_DIRS ${zstd_INCLUDE_DIR}) | ||
set(zstd_LIBRARIES ${zstd_LIBRARY}) | ||
|
||
if(NOT TARGET zstd::zstd) | ||
add_library(zstd::zstd UNKNOWN IMPORTED) | ||
set_property(TARGET zstd::zstd PROPERTY IMPORTED_LOCATION ${zstd_LIBRARY}) | ||
set_property(TARGET zstd::zstd PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${zstd_INCLUDE_DIR}) | ||
endif() | ||
list(APPEND zstd_TARGETS zstd::zstd) | ||
elseif(zstd_FIND_REQUIRED) | ||
message(FATAL_ERROR "Unable to find zstd") | ||
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. Nitpick: I usually try to exit early to avoid indentation, like:
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. Yes, exiting early is preferred. There was actually another problem in here though, in that it would fail ( |
||
endif() | ||
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. I guess this package doesn't use linters yet. 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. it does not and but can be added in a follow up PR. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
list(INSERT CMAKE_MODULE_PATH 0 "${zstd_vendor_DIR}/Modules") |
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.
How is this related to the change?
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.
From my understanding, when importing a cmake target, all dependencies have to present at cmake's generation step as opposed to using
${<pkg>_LIBRARIES}
which is applied during linking. It's therefore important to export all necessary dependencies.