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

add submodules as dirs when build in vscode #202

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
21 changes: 19 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ status_print(project_version)

declare_cache_var(ZENOHCXX_ZENOHC ON BOOL "Build for Zenoh-c target")
declare_cache_var(ZENOHCXX_ZENOHPICO OFF BOOL "Build for Zenoh-pico target")
# when project is open in vscode include git submodules "zenoh-c" and "zenoh-pico" directly
# as "add_subdirectory" without using "find_package". This is convenient to immediately
# build project in vscode using cmake-tools extension.
declare_cache_var_true_if_vscode(ZENOHCXX_INCLUDE_GIT_SUBMODULES "Include git submodules")
if (ZENOHCXX_INCLUDE_GIT_SUBMODULES)
message(STATUS "+----------------------------------------------------------+")
message(STATUS "| Building with zenoh-c and zenoh-pico from git submodules |")
message(STATUS "+----------------------------------------------------------+")
endif()

set_default_build_type(Release)

Expand All @@ -36,7 +45,11 @@ add_library(zenohcxx INTERFACE)
target_include_directories(zenohcxx INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")

if(ZENOHCXX_ZENOHPICO)
find_package(zenohpico REQUIRED)
if (ZENOHCXX_INCLUDE_GIT_SUBMODULES)
add_subdirectory(zenoh-pico)
else()
find_package(zenohpico)
endif()
if(TARGET zenohpico::lib)
message(STATUS "defined lib target zenohcxx::zenohpico for zenohpico::lib")
add_library(zenohcxx_zenohpico INTERFACE)
Expand All @@ -51,7 +64,11 @@ if(ZENOHCXX_ZENOHPICO)
endif()

if(ZENOHCXX_ZENOHC)
find_package(zenohc REQUIRED)
if (ZENOHCXX_INCLUDE_GIT_SUBMODULES)
add_subdirectory(zenoh-c)
else()
find_package(zenohc)
endif()
if(TARGET zenohc::lib)
message(STATUS "defined lib target zenohcxx::zenohc::lib for zenohc::lib")
add_library(zenohcxx_zenohc INTERFACE)
Expand Down
4 changes: 3 additions & 1 deletion cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ endfunction()
# loaded as root project into vscode
#
function(declare_cache_var_true_if_vscode var docstring)
if(CMAKE_CURRENT_BINARY_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/build")
if((CMAKE_CURRENT_BINARY_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/build") AND
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unclear why we should favor vscode over anything else.

("$ENV{TERM_PROGRAM}" STREQUAL "vscode")
)
set(in_vscode TRUE)
else()
set(in_vscode FALSE)
Expand Down
Loading