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

Fixes when including with CMake add_subdirectory() #15

Merged
merged 3 commits into from
Aug 19, 2024

Conversation

ahogen
Copy link
Contributor

@ahogen ahogen commented Jun 29, 2024

With the included fixes, I can now include this repository as a git submodule of my own project and include it in my build directly using add_subdirectory().

my_project/external/CMakeLists.txt

set(CERBERUS_CPP_FIND_YAML_CPP OFF)
add_subdirectory(cerberus-cpp EXCLUDE_FROM_ALL)

add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL)
target_include_directories(yaml-cpp SYSTEM INTERFACE
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp/include>
)

my_project/src/CMakeLists.txt

add_executable(main main.cpp)
target_link_libraries(main
    PRIVATE
        yaml-cpp
        cerberus-cpp
)

CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Outdated
@@ -13,14 +22,16 @@ if(DOCS_ONLY)
set(REQUIRED_STRING "")
endif()

find_package(yaml-cpp 0.6 ${REQUIRED_STRING})
if(NOT ${CERBERUS_SKIP_YAML_CPP_PACKAGE_SEARCH})
Copy link
Owner

Choose a reason for hiding this comment

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

This variable name does not match the option defined in line 11. Also: Why is this even needed? We do need to find yaml-cpp anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

variable name does not match the option defined in line 11

Oops yep old variable name that I later made simpler. Fixed.

Also: Why is this even needed? We do need to find yaml-cpp anyway.

Cerberus does not need to find yamp-cpp when my project is including both repos as submodules/subdirectories, as indicated in the MR description. cerberus-cpp can use the CMake target yaml-cpp directly. I do not have nor do I want to install yaml-cpp from a DEB/RPM package.

@dokempf
Copy link
Owner

dokempf commented Aug 19, 2024

LGTM!

@dokempf dokempf merged commit 50cd91e into dokempf:main Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants