diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..8204b67 --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,18 @@ +name: Ubuntu 22.04 + +on: [push, pull_request] + +jobs: + ubuntu-build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: '3.16.x' + - name: Use cmake + run: | + cmake -B build . + cmake --build build + ./build/repro diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..0c6a4ee --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.15) + +project(FetchContentDemo VERSION 0.1.0 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include(FetchContent) + +FetchContent_Declare( + ada + GIT_REPOSITORY git@github.com:ada-url/ada.git + GIT_SHALLOW TRUE + GIT_TAG tags/v2.7.2 + ) + +FetchContent_MakeAvailable(ada) + + + +file(WRITE main.cpp " + #include \"ada.h\" + #include + + int main(int, char *[]) { + auto url = ada::parse(\"https://www.google.com\"); + if (!url) { + std::cout << \"failure\" << std::endl; + return EXIT_FAILURE; + } + url->set_protocol(\"http\"); + std::cout << url->get_protocol() << std::endl; + std::cout << url->get_host() << std::endl; + return EXIT_SUCCESS; + }") + + + +add_executable(repro main.cpp) +target_link_libraries(repro PUBLIC ada) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6963546 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# ada_fetchcontent + +Demonstrates how to use ada as a CMake dependency with +`FetchContent`. + +``` +cmake -B build +cmake --build build +./build/repro +``` \ No newline at end of file