Skip to content

Commit 17e6367

Browse files
committed
Naming changes in CMakeLists.txt files
1 parent 65602e0 commit 17e6367

File tree

3 files changed

+47
-33
lines changed

3 files changed

+47
-33
lines changed

cpp/CMakeLists.txt

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
cmake_minimum_required(VERSION 3.11)
2-
project(PATCHWORK VERSION 1.0.0)
2+
project(patchworkpp VERSION 1.0.0)
33

44
set(CMAKE_CXX_STANDARD 20)
55
set(PYTHON_EXECUTABLE python3)
66
set(CMAKE_BUILD_TYPE Release)
77

8-
98
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${Open3D_C_FLAGS}")
109
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Open3D_CXX_FLAGS}")
1110
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${Open3D_EXE_LINKER_FLAGS}")
@@ -17,30 +16,37 @@ else()
1716
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
1817
endif()
1918

19+
option(BUILD_CPP_EXAMPLES "Build C++ example codes, which require Open3D for visualization" OFF)
2020

21-
list(APPEND Open3D_LIBRARIES dl)
21+
# Parameters in `patchworkpp` subdirectory.
22+
# Thus, link should be `patchworkpp::ground_seg_cores`
23+
set(PARENT_PROJECT_NAME ${PROJECT_NAME})
24+
set(TARGET_NAME ground_seg_cores)
2225

2326
add_subdirectory(patchworkpp)
2427

25-
set(INCLUDE_EXAMPLES ON CACHE BOOL "Build examples")
28+
if (BUILD_CPP_EXAMPLES)
29+
list(APPEND Open3D_LIBRARIES dl)
30+
set(INCLUDE_EXAMPLES ON CACHE BOOL "Build examples")
2631

27-
if (INCLUDE_EXAMPLES)
32+
if (INCLUDE_EXAMPLES)
2833

29-
message(STATUS "Building examples for c++")
30-
find_package(Open3D REQUIRED HINTS ${CMAKE_INSTALL_PREFIX}/lib/CMake)
34+
message(STATUS "Building examples for c++")
35+
find_package(Open3D REQUIRED HINTS ${CMAKE_INSTALL_PREFIX}/lib/CMake)
3136

32-
list(APPEND Open3D_LIBRARIES dl)
33-
link_directories(${Open3D_LIBRARY_DIRS})
34-
message(STATUS "Found Open3D ${Open3D_VERSION}")
37+
list(APPEND Open3D_LIBRARIES dl)
38+
link_directories(${Open3D_LIBRARY_DIRS})
39+
message(STATUS "Found Open3D ${Open3D_VERSION}")
3540

36-
add_executable(demo_visualize ${CMAKE_CURRENT_SOURCE_DIR}/patchworkpp/examples/demo_visualize.cpp)
37-
target_link_libraries(demo_visualize PRIVATE PATCHWORK::patchworkpp ${Open3D_LIBRARIES} "stdc++fs")
38-
target_include_directories(demo_visualize PUBLIC ${Open3D_INCLUDE_DIRS})
39-
set_target_properties(demo_visualize PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/examples")
41+
add_executable(demo_visualize ${CMAKE_CURRENT_SOURCE_DIR}/patchworkpp/examples/demo_visualize.cpp)
42+
target_link_libraries(demo_visualize PRIVATE ${PARENT_PROJECT_NAME}::${TARGET_NAME} ${Open3D_LIBRARIES} "stdc++fs")
43+
target_include_directories(demo_visualize PUBLIC ${Open3D_INCLUDE_DIRS})
44+
set_target_properties(demo_visualize PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/examples")
4045

41-
add_executable(demo_sequential ${CMAKE_CURRENT_SOURCE_DIR}/patchworkpp/examples/demo_sequential.cpp)
42-
target_link_libraries(demo_sequential PRIVATE PATCHWORK::patchworkpp ${Open3D_LIBRARIES} "stdc++fs")
43-
target_include_directories(demo_sequential PUBLIC ${Open3D_INCLUDE_DIRS})
44-
set_target_properties(demo_sequential PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/examples")
46+
add_executable(demo_sequential ${CMAKE_CURRENT_SOURCE_DIR}/patchworkpp/examples/demo_sequential.cpp)
47+
target_link_libraries(demo_sequential PRIVATE ${PARENT_PROJECT_NAME}::${TARGET_NAME} ${Open3D_LIBRARIES} "stdc++fs")
48+
target_include_directories(demo_sequential PUBLIC ${Open3D_INCLUDE_DIRS})
49+
set_target_properties(demo_sequential PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/examples")
4550

46-
endif()
51+
endif()
52+
endif()

cpp/patchworkpp/CMakeLists.txt

+15-13
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,34 @@ project(patchworkpp_src)
22

33
include(GNUInstallDirs)
44

5+
message("Parent project name: " ${PARENT_PROJECT_NAME})
6+
57
find_package(Eigen3 REQUIRED QUIET)
68

7-
add_library(patchworkpp STATIC src/patchworkpp.cpp)
8-
set_target_properties(patchworkpp PROPERTIES POSITION_INDEPENDENT_CODE ON)
9+
add_library(${TARGET_NAME} STATIC src/patchworkpp.cpp)
10+
set_target_properties(${TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
911

10-
target_include_directories(patchworkpp PUBLIC
12+
target_include_directories(${TARGET_NAME} PUBLIC
1113
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
1214
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
1315
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
1416
)
15-
target_link_libraries(patchworkpp Eigen3::Eigen)
16-
add_library(PATCHWORK::patchworkpp ALIAS patchworkpp)
17+
target_link_libraries(${TARGET_NAME} Eigen3::Eigen)
18+
add_library(${PARENT_PROJECT_NAME}::${TARGET_NAME} ALIAS ${TARGET_NAME})
1719

1820
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
1921
DESTINATION include
2022
)
21-
install(TARGETS patchworkpp
22-
EXPORT PATCHWORKConfig
23+
install(TARGETS ${TARGET_NAME}
24+
EXPORT ${PARENT_PROJECT_NAME}Config
2325
LIBRARY DESTINATION lib
2426
)
2527

26-
export(TARGETS patchworkpp
27-
NAMESPACE PATCHWORK::
28-
FILE "${CMAKE_CURRENT_BINARY_DIR}/PATCHWORKConfig.cmake"
28+
export(TARGETS ${TARGET_NAME}
29+
NAMESPACE ${PARENT_PROJECT_NAME}::
30+
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PARENT_PROJECT_NAME}Config.cmake"
2931
)
30-
install(EXPORT PATCHWORKConfig
31-
DESTINATION "${CMAKE_INSTALL_DATADIR}/PATCHWORK/cmake"
32-
NAMESPACE PATCHWORK::
32+
install(EXPORT ${PARENT_PROJECT_NAME}Config
33+
DESTINATION "${CMAKE_INSTALL_DATADIR}/${PARENT_PROJECT_NAME}/cmake"
34+
NAMESPACE ${PARENT_PROJECT_NAME}::
3335
)

python/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ set(CMAKE_BUILD_TYPE Release)
66
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
77
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
88

9+
# Parameters used in `patchworkpp` subdirectory.
10+
# Thus, link should be `patchworkpp::ground_seg_cores`
11+
# See https://github.com/url-kaist/patchwork-plusplus/tree/master/cpp/CMakeLists.txt#L21
12+
set(PARENT_PROJECT_NAME patchworkpp)
13+
set(TARGET_NAME ground_seg_cores)
14+
915
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
1016
find_package(pybind11 CONFIG REQUIRED)
1117

@@ -21,7 +27,7 @@ endif()
2127

2228
pybind11_add_module(pypatchworkpp patchworkpp/pybinding.cpp)
2329

24-
target_link_libraries(pypatchworkpp PUBLIC PATCHWORK::patchworkpp)
30+
target_link_libraries(pypatchworkpp PUBLIC ${PARENT_PROJECT_NAME}::${TARGET_NAME})
2531

2632
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
2733
target_compile_options(pypatchworkpp PUBLIC -fsized-deallocation)

0 commit comments

Comments
 (0)