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

[CMake][feat] Support FetchContent use #519

Merged
merged 1 commit into from
Dec 7, 2023
Merged

Conversation

JYLeeLYJ
Copy link
Contributor

@JYLeeLYJ JYLeeLYJ commented Dec 5, 2023

Why

related to issue : #505

Make FetchContent available without any test or example target built

What is changing

1. CMake version requirement is up ( 3.15 => 3.21)
2. Subdirectories will not add into project unless project is top-level .
3. Add some $<INSTALL_INTERFACE> and $<BUILD_INTERFACE> to avoid explicit call include_directories outside

Example

Simple testing used

cmake_minimum_required(VERSION 3.21)
project(ylt_test)

include(FetchContent)

FetchContent_Declare(
    yalantinglibs
    GIT_REPOSITORY https://github.com/JYLeeLYJ/yalantinglibs.git
    GIT_TAG feat/fetch # optional ( default master / main )
    GIT_SHALLOW 1 # optional ( --depth=1 )
)

FetchContent_MakeAvailable(yalantinglibs)
add_executable(main main.cpp)

target_link_libraries(main yalantinglibs::yalantinglibs)
target_compile_features(main PRIVATE cxx_std_20)

@CLAassistant
Copy link

CLAassistant commented Dec 5, 2023

CLA assistant check
All committers have signed the CLA.

@qicosmos
Copy link
Collaborator

qicosmos commented Dec 6, 2023

is there any way to support FetchContent with cmake 3.15?

@sunflower-knight
Copy link
Contributor

we need some time to review, this afternoon .
I think 1 and 2 is good .

  1. Subdirectories will not add into project unless [PROJECT_IS_TOP_LEVEL is false
  2. Add some $&lt;INSTALL_INTERFACE&gt; and $&lt;BUILD_INTERFACE> to avoid explicit call include_directories outsid

maybe we can do this without upgrade cmake version

@JYLeeLYJ
Copy link
Contributor Author

JYLeeLYJ commented Dec 6, 2023

maybe we can do this without upgrade cmake version

Reading property PARENT_DIRECTORY may work .

CMakeLists.txt Outdated Show resolved Hide resolved
@PikachuHyA
Copy link
Collaborator

LGTM

@qicosmos qicosmos self-requested a review December 7, 2023 02:26
Copy link
Collaborator

@qicosmos qicosmos left a comment

Choose a reason for hiding this comment

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

LGTM.
Thank you!

@qicosmos qicosmos merged commit c41e7a0 into alibaba:main Dec 7, 2023
30 checks passed
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.

5 participants