-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
fix bug in import_3rdparty_library for paths without trailing '/' #2084
Merged
benjaminum
merged 2 commits into
isl-org:master
from
benjaminum:pr_bugfix_import_3rdparty_lib
Jul 17, 2020
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -182,9 +182,12 @@ endfunction() | |
# HEADER | ||
# the library headers belong to the public interface and will be | ||
# installed, but the library is linked privately. | ||
# INCLUDE_DIR | ||
# INCLUDE_DIRS | ||
# the temporary location where the library headers have been installed. | ||
# Trailing slashes have the same meaning as with install(DIRECTORY). | ||
# If your include is "#include <x.hpp>" and the path of the file is | ||
# "/path/to/libx/x.hpp" then you need to pass "/path/to/libx/" | ||
# with the trailing "/". | ||
# LIBRARIES | ||
# the built library name(s). It is assumed that the library is static. | ||
# If the library is PUBLIC, it will be renamed to Open3D_${name} at | ||
|
@@ -194,27 +197,29 @@ endfunction() | |
# CMAKE_ARCHIVE_OUTPUT_DIRECTORY. | ||
# | ||
function(import_3rdparty_library name) | ||
cmake_parse_arguments(arg "PUBLIC;HEADER" "INCLUDE_DIR;LIB_DIR" "LIBRARIES" ${ARGN}) | ||
cmake_parse_arguments(arg "PUBLIC;HEADER" "LIB_DIR" "INCLUDE_DIRS;LIBRARIES" ${ARGN}) | ||
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. remove extra space in front |
||
if(arg_UNPARSED_ARGUMENTS) | ||
message(FATAL_ERROR "Invalid syntax: import_3rdparty_library(${name} ${ARGN})") | ||
endif() | ||
if(NOT arg_LIB_DIR) | ||
set(arg_LIB_DIR "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}") | ||
endif() | ||
add_library(${name} INTERFACE) | ||
if(arg_INCLUDE_DIR) | ||
if (arg_INCLUDE_DIR MATCHES "(.*)/$") | ||
set(incl_path ${CMAKE_MATCH_1}) | ||
else() | ||
get_filename_component(incl_path "${incl}" DIRECTORY) | ||
endif() | ||
target_include_directories(${name} SYSTEM INTERFACE $<BUILD_INTERFACE:${incl_path}>) | ||
if(arg_PUBLIC OR arg_HEADER) | ||
install(DIRECTORY ${arg_INCLUDE_DIR} DESTINATION ${Open3D_INSTALL_INCLUDE_DIR}/open3d/3rdparty | ||
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" | ||
) | ||
target_include_directories(${name} INTERFACE $<INSTALL_INTERFACE:${Open3D_INSTALL_INCLUDE_DIR}/open3d/3rdparty>) | ||
endif() | ||
if(arg_INCLUDE_DIRS) | ||
foreach(incl IN LISTS arg_INCLUDE_DIRS) | ||
if (incl MATCHES "(.*)/$") | ||
set(incl_path ${CMAKE_MATCH_1}) | ||
else() | ||
get_filename_component(incl_path "${incl}" DIRECTORY) | ||
endif() | ||
target_include_directories(${name} SYSTEM INTERFACE $<BUILD_INTERFACE:${incl_path}>) | ||
if(arg_PUBLIC OR arg_HEADER) | ||
install(DIRECTORY ${incl} DESTINATION ${Open3D_INSTALL_INCLUDE_DIR}/open3d/3rdparty | ||
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" | ||
) | ||
target_include_directories(${name} INTERFACE $<INSTALL_INTERFACE:${Open3D_INSTALL_INCLUDE_DIR}/open3d/3rdparty>) | ||
endif() | ||
endforeach() | ||
endif() | ||
if(arg_LIBRARIES) | ||
list(LENGTH arg_LIBRARIES libcount) | ||
|
@@ -357,7 +362,7 @@ endif() | |
if(BUILD_GLFW) | ||
message(STATUS "Building library 3rdparty_glfw3 from source") | ||
add_subdirectory(${Open3D_3RDPARTY_DIR}/GLFW) | ||
import_3rdparty_library(3rdparty_glfw3 HEADER INCLUDE_DIR ${Open3D_3RDPARTY_DIR}/GLFW/include/ LIBRARIES glfw3) | ||
import_3rdparty_library(3rdparty_glfw3 HEADER INCLUDE_DIRS ${Open3D_3RDPARTY_DIR}/GLFW/include/ LIBRARIES glfw3) | ||
add_dependencies(3rdparty_glfw3 glfw) | ||
target_link_libraries(3rdparty_glfw3 INTERFACE Threads::Threads) | ||
if(UNIX AND NOT APPLE) | ||
|
@@ -425,7 +430,7 @@ if (BUILD_JPEG) | |
message(STATUS "Building third-party library JPEG from source") | ||
include(${Open3D_3RDPARTY_DIR}/libjpeg-turbo/libjpeg-turbo.cmake) | ||
import_3rdparty_library(3rdparty_jpeg | ||
INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo-install/include/ | ||
INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo-install/include/ | ||
LIBRARIES ${JPEG_TURBO_LIBRARIES} | ||
LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo-install/lib | ||
) | ||
|
@@ -480,7 +485,7 @@ list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS "${TRITRIINTERSECT_TARGET}") | |
if (BUILD_LIBREALSENSE) | ||
message(STATUS "Building third-party library librealsense from source") | ||
add_subdirectory(${Open3D_3RDPARTY_DIR}/librealsense) | ||
import_3rdparty_library(3rdparty_realsense INCLUDE_DIR ${Open3D_3RDPARTY_DIR}/librealsense/include/ LIBRARIES ${REALSENSE_LIBRARY}) | ||
import_3rdparty_library(3rdparty_realsense INCLUDE_DIRS ${Open3D_3RDPARTY_DIR}/librealsense/include/ LIBRARIES ${REALSENSE_LIBRARY}) | ||
add_dependencies(3rdparty_realsense ${REALSENSE_LIBRARY}) | ||
set(LIBREALSENSE_TARGET "3rdparty_realsense") | ||
list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS "${LIBREALSENSE_TARGET}") | ||
|
@@ -503,11 +508,11 @@ endif() | |
if(BUILD_PNG) | ||
message(STATUS "Building third-party library zlib from source") | ||
add_subdirectory(${Open3D_3RDPARTY_DIR}/zlib) | ||
import_3rdparty_library(3rdparty_zlib INCLUDE_DIR ${Open3D_3RDPARTY_DIR}/zlib LIBRARIES ${ZLIB_LIBRARY}) | ||
import_3rdparty_library(3rdparty_zlib INCLUDE_DIRS ${Open3D_3RDPARTY_DIR}/zlib LIBRARIES ${ZLIB_LIBRARY}) | ||
add_dependencies(3rdparty_zlib ${ZLIB_LIBRARY}) | ||
message(STATUS "Building third-party library libpng from source") | ||
add_subdirectory(${Open3D_3RDPARTY_DIR}/libpng) | ||
import_3rdparty_library(3rdparty_png INCLUDE_DIR ${Open3D_3RDPARTY_DIR}/libpng/ LIBRARIES ${PNG_LIBRARIES}) | ||
import_3rdparty_library(3rdparty_png INCLUDE_DIRS ${Open3D_3RDPARTY_DIR}/libpng/ LIBRARIES ${PNG_LIBRARIES}) | ||
add_dependencies(3rdparty_png ${PNG_LIBRARIES}) | ||
target_link_libraries(3rdparty_png INTERFACE 3rdparty_zlib) | ||
set(PNG_TARGET "3rdparty_png") | ||
|
@@ -819,7 +824,7 @@ if(ENABLE_GUI) | |
include(${Open3D_3RDPARTY_DIR}/filament/filament_download.cmake) | ||
endif() | ||
import_3rdparty_library(3rdparty_filament HEADER | ||
INCLUDE_DIR ${FILAMENT_ROOT}/include/ | ||
INCLUDE_DIRS ${FILAMENT_ROOT}/include/ | ||
LIB_DIR ${FILAMENT_ROOT}/lib/x86_64 | ||
LIBRARIES ${filament_LIBRARIES} | ||
) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Example for the opposite case?
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.
And, also add the docs to
build_3rdparty_library
function