Skip to content
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

Reorganize and beautify project generation for IDEs #2691

Merged
merged 2 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,18 @@ else()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PCL_OUTPUT_LIB_DIR}")
endif()

# Check if the current generator is an IDE.
check_if_ide(CMAKE_GENERATOR_IS_IDE)

# Add an "uninstall" target
if(CMAKE_GENERATOR_IS_IDE)
set(UNINSTALL_TARGET_NAME UNINSTALL)
else()
set(UNINSTALL_TARGET_NAME uninstall)
endif()
configure_file("${PCL_SOURCE_DIR}/cmake/uninstall_target.cmake.in"
"${PCL_BINARY_DIR}/uninstall_target.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall "${CMAKE_COMMAND}" -P
add_custom_target(${UNINSTALL_TARGET_NAME} "${CMAKE_COMMAND}" -P
"${PCL_BINARY_DIR}/uninstall_target.cmake")

###
Expand Down
9 changes: 8 additions & 1 deletion apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,11 @@ PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC})
PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}" ${incs})
PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/impl" ${impl_incs})

add_custom_target(${SUBSYS_NAME} DEPENDS ${PCL_APPS_ALL_TARGETS})
if(CMAKE_GENERATOR_IS_IDE)
set(SUBSYS_TARGET_NAME APPS_BUILD)
else()
set(SUBSYS_TARGET_NAME ${SUBSYS_NAME})
endif()
add_custom_target(${SUBSYS_TARGET_NAME} DEPENDS ${PCL_APPS_ALL_TARGETS})
set_target_properties(${SUBSYS_TARGET_NAME} PROPERTIES FOLDER "Apps")

6 changes: 1 addition & 5 deletions cmake/pcl_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ option(CMAKE_MSVC_CODE_LINK_OPTIMIZATION "Enable the /GL and /LTCG code and link
mark_as_advanced(CMAKE_MSVC_CODE_LINK_OPTIMIZATION)

# Project folders
option(USE_PROJECT_FOLDERS "Use folders to organize PCL projects in an IDE." OFF)
mark_as_advanced(USE_PROJECT_FOLDERS)
if(USE_PROJECT_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

option(BUILD_tools "Useful PCL-based command line tools" ON)

Expand Down
42 changes: 19 additions & 23 deletions cmake/pcl_targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ macro(PCL_ADD_LIBRARY _name _component)
VERSION ${PCL_VERSION}
SOVERSION ${PCL_VERSION_MAJOR}.${PCL_VERSION_MINOR}
DEFINE_SYMBOL "PCLAPI_EXPORTS")
if(USE_PROJECT_FOLDERS)
set_target_properties(${_name} PROPERTIES FOLDER "Libraries")
endif()
set_target_properties(${_name} PROPERTIES FOLDER "Libraries")

install(TARGETS ${_name}
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT pcl_${_component}
Expand Down Expand Up @@ -242,9 +240,7 @@ macro(PCL_CUDA_ADD_LIBRARY _name _component)
VERSION ${PCL_VERSION}
SOVERSION ${PCL_VERSION_MAJOR}
DEFINE_SYMBOL "PCLAPI_EXPORTS")
if(USE_PROJECT_FOLDERS)
set_target_properties(${_name} PROPERTIES FOLDER "Libraries")
endif()
set_target_properties(${_name} PROPERTIES FOLDER "Libraries")

install(TARGETS ${_name}
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT pcl_${_component}
Expand All @@ -271,8 +267,12 @@ macro(PCL_ADD_EXECUTABLE _name _component)
RELEASE_OUTPUT_NAME ${_name}${CMAKE_RELEASE_POSTFIX})
endif()

if(USE_PROJECT_FOLDERS)
set_target_properties(${_name} PROPERTIES FOLDER "Tools and demos")
# Some app targets report are defined with subsys other than apps
# It's simpler check for tools and assume everythin else as an app
if(${_component} MATCHES "tools")
set_target_properties(${_name} PROPERTIES FOLDER "Tools")
else()
set_target_properties(${_name} PROPERTIES FOLDER "Apps")
endif()

set(PCL_EXECUTABLES ${PCL_EXECUTABLES} ${_name})
Expand Down Expand Up @@ -308,8 +308,12 @@ macro(PCL_ADD_EXECUTABLE_OPT_BUNDLE _name _component)
RELEASE_OUTPUT_NAME ${_name}${CMAKE_RELEASE_POSTFIX})
endif()

if(USE_PROJECT_FOLDERS)
set_target_properties(${_name} PROPERTIES FOLDER "Tools and demos")
# Some app targets report are defined with subsys other than apps
# It's simpler check for tools and assume everythin else as an app
if(${_component} MATCHES "tools")
set_target_properties(${_name} PROPERTIES FOLDER "Tools")
else()
set_target_properties(${_name} PROPERTIES FOLDER "Apps")
endif()

set(PCL_EXECUTABLES ${PCL_EXECUTABLES} ${_name})
Expand Down Expand Up @@ -339,9 +343,8 @@ macro(PCL_CUDA_ADD_EXECUTABLE _name _component)
RELEASE_OUTPUT_NAME ${_name}${CMAKE_RELEASE_POSTFIX})
endif()

if(USE_PROJECT_FOLDERS)
set_target_properties(${_name} PROPERTIES FOLDER "Tools and demos")
endif()
# There's a single app.
set_target_properties(${_name} PROPERTIES FOLDER "Apps")

set(PCL_EXECUTABLES ${PCL_EXECUTABLES} ${_name})
install(TARGETS ${_name} RUNTIME DESTINATION ${BIN_INSTALL_DIR}
Expand Down Expand Up @@ -377,11 +380,8 @@ macro(PCL_ADD_TEST _name _exename)

# must link explicitly against boost only on Windows
target_link_libraries(${_exename} ${Boost_LIBRARIES})
#
if(USE_PROJECT_FOLDERS)
set_target_properties(${_exename} PROPERTIES FOLDER "Tests")
endif()

set_target_properties(${_exename} PROPERTIES FOLDER "Tests")
add_test(NAME ${_name} COMMAND ${_exename} ${PCL_ADD_TEST_ARGUMENTS})

add_dependencies(tests ${_exename})
Expand All @@ -404,9 +404,7 @@ macro(PCL_ADD_EXAMPLE _name)
set_target_properties(${_name} PROPERTIES DEBUG_OUTPUT_NAME ${_name}${CMAKE_DEBUG_POSTFIX}
RELEASE_OUTPUT_NAME ${_name}${CMAKE_RELEASE_POSTFIX})
endif()
if(USE_PROJECT_FOLDERS)
set_target_properties(${_name} PROPERTIES FOLDER "Examples")
endif()
set_target_properties(${_name} PROPERTIES FOLDER "Examples")

# add target to list of example targets created at the parent scope
list(APPEND PCL_EXAMPLES_ALL_TARGETS ${_name})
Expand Down Expand Up @@ -795,9 +793,7 @@ macro (PCL_ADD_DOC _subsys)
set(doxyfile "${CMAKE_CURRENT_BINARY_DIR}/doxyfile")
configure_file("${PCL_SOURCE_DIR}/doc/doxygen/doxyfile.in" ${doxyfile})
add_custom_target(${doc_subsys} ${DOXYGEN_EXECUTABLE} ${doxyfile})
if(USE_PROJECT_FOLDERS)
set_target_properties(${doc_subsys} PROPERTIES FOLDER "Documentation")
endif()
set_target_properties(${doc_subsys} PROPERTIES FOLDER "Documentation")
endif()
endmacro()

Expand Down
20 changes: 20 additions & 0 deletions cmake/pcl_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,23 @@ function(find_python_module module)
find_package_handle_standard_args(PY_${module} DEFAULT_MSG PY_${module_upper})
endfunction(find_python_module)


###############################################################################
# Checks if the current generator is an IDE
# _out The boolean result
macro(check_if_ide _out)
# Current known pool of generators
set(_ides
"Xcode"
"Visual Studio"
)

set(${_out} FALSE)
foreach(_ide ${_ides})
# Visual Studio has multiple year releases and Win64 variants
if(CMAKE_GENERATOR MATCHES "${_ide}*")
set(${_out} TRUE)
break()
endif()
endforeach()
endmacro()
4 changes: 1 addition & 3 deletions doc/advanced/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ endif()
add_custom_target(advanced ALL
COMMAND "${SPHINX_EXECUTABLE}" -b html -a -d "${SPHINX_CACHE_DIR}" -D html_file_suffix=".${SPHINX_HTML_FILE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/content" html)
add_dependencies(advanced doc)
if(USE_PROJECT_FOLDERS)
set_target_properties(advanced PROPERTIES FOLDER "Documentation (Advanced)")
endif()
set_target_properties(advanced PROPERTIES FOLDER "Documentation (Advanced)")
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html"
DESTINATION "${DOC_INSTALL_DIR}/advanced"
COMPONENT doc)
Expand Down
4 changes: 1 addition & 3 deletions doc/doxygen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html")
set(doxyfile "${CMAKE_CURRENT_BINARY_DIR}/doxyfile")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doxyfile.in" "${doxyfile}")
add_custom_target(doc ALL "${DOXYGEN_EXECUTABLE}" "${doxyfile}")
if(USE_PROJECT_FOLDERS)
set_target_properties(doc PROPERTIES FOLDER "Documentation (Doxygen)")
endif()
set_target_properties(doc PROPERTIES FOLDER "Documentation (Doxygen)")
if(DOCUMENTATION_HTML_HELP STREQUAL YES)
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html"
DESTINATION "${DOC_INSTALL_DIR}"
Expand Down
4 changes: 1 addition & 3 deletions doc/tutorials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ endif()
add_custom_target(tutorials ALL
COMMAND "${SPHINX_EXECUTABLE}" -b html -a -d "${SPHINX_CACHE_DIR}" -D html_file_suffix=".${SPHINX_HTML_FILE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/content" html)
add_dependencies(tutorials doc)
if(USE_PROJECT_FOLDERS)
set_target_properties(tutorials PROPERTIES FOLDER "Documentation (Tutorials)")
endif()
set_target_properties(tutorials PROPERTIES FOLDER "Documentation (Tutorials)")
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html"
DESTINATION "${DOC_INSTALL_DIR}/tutorials"
COMPONENT doc)
Expand Down
7 changes: 1 addition & 6 deletions doc/tutorials/content/compiling_pcl_windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,13 @@ Once CMake has found all the needed dependencies, let's see the PCL specific CMa

- **CMAKE_INSTALL_PREFIX** is where PCL will be installed after building it (more information on this later).

If you have the Pro version of Microsoft Visual Studio, you can check **USE_PROJECT_FOLDERS** checkbox to organize PCL
projects in folders within the PCL solution. If you have an express edition, it is recommended to keep it unchecked, as in
express editions, project folders are disabled.

Once PCL configuration is ok, hit the `Generate` button. CMake will then generate Visual Studio project files (vcproj files)
and the main solution file (PCL.sln) in C:\\PCL directory.

Building PCL
--------------

Open that generated solution file (PCL.sln) to finally build the PCL libraries. This is how your solution will look like
whether you enabled **USE_PROJECT_FOLDERS** (left) or not (right).
Open that generated solution file (PCL.sln) to finally build the PCL libraries. This is how your solution will look like.

.. image:: images/windows/pcl_solution_with_projects_folder.png
:alt: PCL solution with project folders
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
9 changes: 8 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ foreach(subdir ${PCL_EXAMPLES_SUBDIRS})
add_subdirectory(${subdir})
endforeach()

add_custom_target(${SUBSYS_NAME} DEPENDS ${PCL_EXAMPLES_ALL_TARGETS})
if(CMAKE_GENERATOR_IS_IDE)
set(SUBSYS_TARGET_NAME EXAMPLES_BUILD)
else()
set(SUBSYS_TARGET_NAME ${SUBSYS_NAME})
endif()
add_custom_target(${SUBSYS_TARGET_NAME} DEPENDS ${PCL_EXAMPLES_ALL_TARGETS})
set_target_properties(${SUBSYS_TARGET_NAME} PROPERTIES FOLDER "Examples")

3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ add_library(pcl_gtest STATIC ${GTEST_SRC_DIR}/src/gtest-all.cc)

enable_testing()
add_custom_target(tests "${CMAKE_CTEST_COMMAND}" "-V" VERBATIM)
set_target_properties(tests PROPERTIES FOLDER "Tests")

add_subdirectory(2d)
add_subdirectory(common)
Expand All @@ -35,4 +36,4 @@ add_subdirectory(search)
add_subdirectory(surface)
add_subdirectory(segmentation)
add_subdirectory(sample_consensus)
add_subdirectory(visualization)
add_subdirectory(visualization)
70 changes: 69 additions & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,70 @@ else()
PCL_ADD_EXECUTABLE (pcl_voxel_grid_occlusion_estimation "${SUBSYS_NAME}" voxel_grid_occlusion_estimation.cpp)
target_link_libraries (pcl_voxel_grid_occlusion_estimation pcl_common pcl_io pcl_filters pcl_visualization)

PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_viewer ${SUBSYS_NAME} pcd_viewer.cpp)
target_link_libraries(pcl_viewer pcl_common pcl_io pcl_kdtree pcl_visualization pcl_search)

PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_pcd_image_viewer ${SUBSYS_NAME} image_viewer.cpp)
target_link_libraries(pcl_pcd_image_viewer pcl_common pcl_io pcl_kdtree pcl_visualization)

PCL_ADD_EXECUTABLE(pcl_timed_trigger_test ${SUBSYS_NAME} timed_trigger_test.cpp)
target_link_libraries(pcl_timed_trigger_test pcl_io pcl_common pcl_kdtree pcl_visualization)

PCL_ADD_EXECUTABLE(pcl_hdl_viewer_simple ${SUBSYS_NAME} hdl_viewer_simple.cpp)
target_link_libraries(pcl_hdl_viewer_simple pcl_io pcl_common pcl_visualization)

PCL_ADD_EXECUTABLE(pcl_vlp_viewer ${SUBSYS_NAME} vlp_viewer.cpp)
target_link_libraries(pcl_vlp_viewer pcl_io pcl_common pcl_visualization)

if(WITH_OPENNI)
PCL_ADD_EXECUTABLE(pcl_openni_save_image "${SUBSYS_NAME}" openni_save_image.cpp)
target_link_libraries(pcl_openni_save_image pcl_common pcl_io pcl_visualization)

PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_pcd_grabber_viewer ${SUBSYS_NAME} pcd_grabber_viewer.cpp)
target_link_libraries(pcl_pcd_grabber_viewer pcl_common pcl_io pcl_kdtree pcl_visualization)

PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_image_grabber_saver ${SUBSYS_NAME} image_grabber_saver.cpp)
target_link_libraries(pcl_image_grabber_saver pcl_common pcl_io pcl_kdtree pcl_visualization)

PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_image_grabber_viewer ${SUBSYS_NAME} image_grabber_viewer.cpp)
target_link_libraries(pcl_image_grabber_viewer pcl_common pcl_io pcl_kdtree pcl_visualization)

#PCL_ADD_EXECUTABLE(pcl_openni_viewer_simple ${SUBSYS_NAME} openni_viewer_simple.cpp)
#target_link_libraries(pcl_openni_viewer_simple pcl_common pcl_io pcl_kdtree pcl_visualization)

PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_oni_viewer ${SUBSYS_NAME} oni_viewer_simple.cpp)
target_link_libraries(pcl_oni_viewer pcl_common pcl_io pcl_kdtree pcl_visualization)

PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_openni_viewer ${SUBSYS_NAME} openni_viewer.cpp)
target_link_libraries(pcl_openni_viewer pcl_common pcl_io pcl_kdtree pcl_visualization)

PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_openni_image ${SUBSYS_NAME} openni_image.cpp)
target_link_libraries(pcl_openni_image pcl_common pcl_io pcl_kdtree pcl_visualization)
endif()

if(WITH_OPENNI2)
PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_openni2_viewer ${SUBSYS_NAME} openni2_viewer.cpp)
target_link_libraries(pcl_openni2_viewer pcl_common pcl_io pcl_kdtree pcl_visualization)
endif()

if(WITH_ENSENSO)
PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_ensenso_viewer ${SUBSYS_NAME} ensenso_viewer.cpp)
target_link_libraries(pcl_ensenso_viewer pcl_common pcl_io pcl_visualization)
endif()

if(WITH_DAVIDSDK)
PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_davidsdk_viewer ${SUBSYS_NAME} davidsdk_viewer.cpp)
target_link_libraries(pcl_davidsdk_viewer pcl_common pcl_io pcl_visualization)
endif()

if(WITH_DSSDK)
PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_depth_sense_viewer ${SUBSYS_NAME} depth_sense_viewer.cpp)
target_link_libraries(pcl_depth_sense_viewer pcl_common pcl_io pcl_visualization)
endif()

if(WITH_RSSDK)
PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_real_sense_viewer ${SUBSYS_NAME} real_sense_viewer.cpp)
target_link_libraries(pcl_real_sense_viewer pcl_common pcl_io pcl_visualization)
endif()
endif()
endif()
Expand All @@ -274,4 +335,11 @@ if(Tide_FOUND)
${Tide_LIBRARIES})
endif()

add_custom_target(${SUBSYS_NAME} DEPENDS ${PCL_TOOLS_ALL_TARGETS})
if(CMAKE_GENERATOR_IS_IDE)
set(SUBSYS_TARGET_NAME TOOLS_BUILD)
else()
set(SUBSYS_TARGET_NAME ${SUBSYS_NAME})
endif()
add_custom_target(${SUBSYS_TARGET_NAME} DEPENDS ${PCL_TOOLS_ALL_TARGETS})
set_target_properties(${SUBSYS_TARGET_NAME} PROPERTIES FOLDER "Tools")

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions visualization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,3 @@ if(BUILD_TESTS)
add_subdirectory(test)
endif()

if(BUILD_tools)
add_subdirectory(tools)
endif()
Loading