Skip to content

Commit 8c03e21

Browse files
authored
Clean up repo, use CPM for dependency management (#170)
1 parent ecdb4eb commit 8c03e21

File tree

11 files changed

+363
-47
lines changed

11 files changed

+363
-47
lines changed

.github/workflows/skyr-url-ci.yml

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: skyr-url CI
44
on: [ push, pull_request ]
55

66
env:
7-
CMAKE_VERSION: 3.18.6
7+
CMAKE_VERSION: 3.21.7
88
NINJA_VERSION: 1.11.0
99

1010
jobs:
@@ -80,14 +80,14 @@ jobs:
8080
# Clang-10
8181
- {
8282
name: "Linux Clang 10 Debug (C++20)", artifact: "Linux.tar.xz",
83-
os: ubuntu-latest,
83+
os: ubuntu-20.04,
8484
build_type: Debug,
8585
cc: "clang-10", cxx: "clang++-10",
8686
cxx_standard: 20
8787
}
8888
- {
8989
name: "Linux Clang 10 Release (C++20)", artifact: "Linux.tar.xz",
90-
os: ubuntu-latest,
90+
os: ubuntu-20.04,
9191
build_type: RelWithDebInfo,
9292
cc: "clang-10", cxx: "clang++-10",
9393
cxx_standard: 20,
@@ -96,14 +96,14 @@ jobs:
9696
# Clang-11
9797
- {
9898
name: "Linux Clang 11 Debug (C++20)", artifact: "Linux.tar.xz",
99-
os: ubuntu-latest,
99+
os: ubuntu-20.04,
100100
build_type: Debug,
101101
cc: "clang-11", cxx: "clang++-11",
102102
cxx_standard: 20,
103103
}
104104
- {
105105
name: "Linux Clang 11 Release (C++20)", artifact: "Linux.tar.xz",
106-
os: ubuntu-latest,
106+
os: ubuntu-20.04,
107107
build_type: RelWithDebInfo,
108108
cc: "clang-11", cxx: "clang++-11",
109109
cxx_standard: 20,
@@ -112,14 +112,14 @@ jobs:
112112
# Clang-12
113113
- {
114114
name: "Linux Clang 12 Debug (C++20)", artifact: "Linux.tar.xz",
115-
os: ubuntu-latest,
115+
os: ubuntu-20.04,
116116
build_type: Debug,
117117
cc: "clang-12", cxx: "clang++-12",
118118
cxx_standard: 20,
119119
}
120120
- {
121121
name: "Linux Clang 12 Release (C++20)", artifact: "Linux.tar.xz",
122-
os: ubuntu-latest,
122+
os: ubuntu-20.04,
123123
build_type: RelWithDebInfo,
124124
cc: "clang-12", cxx: "clang++-12",
125125
cxx_standard: 20,
@@ -238,16 +238,16 @@ jobs:
238238
239239
if ("${{ runner.os }}" STREQUAL "Windows")
240240
set(ninja_suffix "win.zip")
241-
set(cmake_suffix "win64-x64.zip")
242-
set(cmake_dir "cmake-${cmake_version}-win64-x64/bin")
241+
set(cmake_suffix "windows-x86_64.zip")
242+
set(cmake_dir "cmake-${cmake_version}-windows-x86_64/bin")
243243
elseif ("${{ runner.os }}" STREQUAL "Linux")
244244
set(ninja_suffix "linux.zip")
245-
set(cmake_suffix "Linux-x86_64.tar.gz")
246-
set(cmake_dir "cmake-${cmake_version}-Linux-x86_64/bin")
245+
set(cmake_suffix "linux-x86_64.tar.gz")
246+
set(cmake_dir "cmake-${cmake_version}-linux-x86_64/bin")
247247
elseif ("${{ runner.os }}" STREQUAL "macOS")
248248
set(ninja_suffix "mac.zip")
249-
set(cmake_suffix "Darwin-x86_64.tar.gz")
250-
set(cmake_dir "cmake-${cmake_version}-Darwin-x86_64/CMake.app/Contents/bin")
249+
set(cmake_suffix "macos10.10-universal.tar.gz")
250+
set(cmake_dir "cmake-${cmake_version}-macos10.10-universal/CMake.app/Contents/bin")
251251
endif()
252252
253253
set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}")
@@ -267,6 +267,7 @@ jobs:
267267
COMMAND chmod +x ${cmake_dir}/cmake
268268
)
269269
270+
270271
- name: Install GCC 7
271272
id: install_gcc_7
272273
if: startsWith(matrix.config.os, 'ubuntu') && ( matrix.config.cxx == 'g++-7' )
@@ -331,6 +332,7 @@ jobs:
331332
wget https://apt.llvm.org/llvm.sh
332333
chmod +x llvm.sh
333334
sudo ./llvm.sh 11
335+
sudo apt-get install -y libc++-11-dev libc++abi-11-dev
334336
335337
- name: Install Clang 12
336338
id: install_clang_12
@@ -341,6 +343,7 @@ jobs:
341343
wget https://apt.llvm.org/llvm.sh
342344
chmod +x llvm.sh
343345
sudo ./llvm.sh 12
346+
sudo apt-get install -y libc++-12-dev libc++abi-12-dev libunwind-12-dev
344347
345348
- name: Install Clang 14
346349
id: install_clang_14
@@ -365,7 +368,7 @@ jobs:
365368
git checkout -b master origin/master
366369
export
367370
./bootstrap-vcpkg.sh
368-
./vcpkg install tl-expected range-v3 catch2 nlohmann-json fmt
371+
./vcpkg install fmt
369372
370373
- name: Install vcpkg (MacOS)
371374
id: vcpkg_macos
@@ -381,7 +384,7 @@ jobs:
381384
git checkout -b master origin/master
382385
export
383386
./bootstrap-vcpkg.sh
384-
./vcpkg install tl-expected range-v3 catch2 nlohmann-json fmt
387+
./vcpkg install fmt
385388
386389
- name: Install vcpkg (Windows)
387390
id: vcpkg_windows
@@ -391,8 +394,8 @@ jobs:
391394
git clone https://github.com/microsoft/vcpkg.git ${Env:GITHUB_WORKSPACE}\vcpkg
392395
cd ${Env:GITHUB_WORKSPACE}\vcpkg
393396
.\bootstrap-vcpkg.bat
394-
vcpkg install tl-expected range-v3 catch2 nlohmann-json fmt --triplet x64-windows
395-
vcpkg integrate install
397+
vcpkg install fmt --triplet x64-windows
398+
396399
397400
- name: Configure
398401
shell: cmake -P {0}
@@ -440,6 +443,27 @@ jobs:
440443
set(BUILD_V2 ON)
441444
endif()
442445
446+
set(USE_LLVM OFF)
447+
if("${{ matrix.config.name }}" STREQUAL "macOS Clang Debug (C++17)" OR
448+
"${{ matrix.config.name }}" STREQUAL "macOS Clang Release (C++17)" OR
449+
"${{ matrix.config.name }}" STREQUAL "macOS Clang Debug (C++20)" OR
450+
"${{ matrix.config.name }}" STREQUAL "macOS Clang Release (C++20)" OR
451+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 11 Debug (C++17)" OR
452+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 11 Release (C++17)" OR
453+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 12 Debug (C++17)" OR
454+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 12 Release (C++17)" OR
455+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 14 Debug (C++17)" OR
456+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 14 Release (C++17)" OR
457+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 11 Debug (C++20)" OR
458+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 11 Release (C++20)" OR
459+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 12 Debug (C++20)" OR
460+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 12 Release (C++20)" OR
461+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 14 Debug (C++20)" OR
462+
"${{ matrix.config.name }}" STREQUAL "Linux Clang 14 Release (C++20)"
463+
)
464+
set(USE_LLVM ON)
465+
endif()
466+
443467
execute_process(
444468
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake
445469
-S .
@@ -451,8 +475,9 @@ jobs:
451475
-D skyr_BUILD_DOCS=OFF
452476
-D skyr_BUILD_EXAMPLES=OFF
453477
-D skyr_BUILD_V2=${BUILD_V2}
478+
-D skyr_BUILD_WITH_LLVM_LIBCXX=${USE_LLVM}
479+
-D SKY_VERBOSE_BUILD=ON
454480
-D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }}
455-
-D CMAKE_TOOLCHAIN_FILE=$ENV{GITHUB_WORKSPACE}/vcpkg/scripts/buildsystems/vcpkg.cmake
456481
-D CMAKE_INSTALL_PREFIX=$ENV{GITHUB_WORKSPACE}/install
457482
RESULT_VARIABLE result
458483
)

CMakeLists.txt

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,25 @@
44
# http://www.boost.org/LICENSE_1_0.txt)
55

66

7-
cmake_minimum_required(VERSION 3.16)
7+
cmake_minimum_required(VERSION 3.21)
8+
9+
get_directory_property(skyr_is_subproject PARENT_DIRECTORY)
10+
11+
if(NOT skyr_is_subproject)
12+
set(skyr_IS_TOP_LEVEL_PROJECT YES)
13+
else()
14+
set(skyr_IS_TOP_LEVEL_PROJECT NO)
15+
endif()
816

917
project(
1018
skyr-url
11-
VERSION 2.0.0
19+
VERSION 2.0.1
1220
HOMEPAGE_URL https://cpp-netlib.github.io/url
1321
DESCRIPTION "A C++ library that implements the WhatWG URL specification"
1422
LANGUAGES CXX
1523
)
1624

17-
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
18-
set(skyr_IS_TOP_LEVEL_PROJECT YES)
19-
else()
20-
set(skyr_IS_TOP_LEVEL_PROJECT NO)
21-
endif()
25+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2226

2327
option(skyr_BUILD_TESTS "Build the URL tests." ON)
2428
option(skyr_BUILD_DOCS "Build the URL documentation." OFF)
@@ -35,23 +39,41 @@ option(skyr_BUILD_V1 "Build v1" ON)
3539
option(skyr_BUILD_V2 "Build v2, which uses C++20 features" OFF)
3640

3741
if (skyr_IS_TOP_LEVEL_PROJECT)
38-
set(CMAKE_VERBOSE_MAKEFILE true)
39-
set(CMAKE_CXX_STANDARD 17)
40-
if (skyr_BUILD_V2)
42+
if(skyr_BUILD_V2)
4143
set(CMAKE_CXX_STANDARD 20)
44+
else()
45+
set(CMAKE_CXX_STANDARD 17)
4246
endif()
47+
4348
set(CMAKE_CXX_EXTENSIONS OFF)
4449
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4550
endif()
4651

47-
find_package(tl-expected CONFIG REQUIRED)
48-
find_package(range-v3 CONFIG REQUIRED)
52+
include(skyr-url-options)
53+
include(skyr-url-env)
54+
include(skyr-url-flags)
55+
56+
include(cmake/CPM.cmake)
57+
CPMAddPackage(
58+
NAME expected
59+
GITHUB_REPOSITORY TartanLlama/expected
60+
GIT_TAG v1.1.0
61+
OPTIONS "EXPECTED_BUILD_TESTS OFF" #pulls is super old catch2
62+
)
63+
CPMAddPackage("gh:ericniebler/range-v3#0.12.0")
64+
CPMAddPackage("gh:fmtlib/fmt#10.1.1")
65+
4966

5067
if (skyr_ENABLE_JSON_FUNCTIONS)
51-
find_package(nlohmann_json CONFIG REQUIRED)
68+
CPMAddPackage(
69+
NAME json
70+
GITHUB_REPOSITORY nlohmann/json
71+
GIT_TAG v3.11.3
72+
OPTIONS "JSON_Install ON"
73+
)
5274
endif()
5375

54-
if (skyr_USE_STATIC_CRT AND ${CMAKE_CXX_COMPILER_ID} MATCHES MSVC)
76+
if (skyr_USE_STATIC_CRT AND (SKY_CXX_COMPILER_CLANGCL OR SKY_CXX_COMPILER_MSVC))
5577
include(${PROJECT_SOURCE_DIR}/cmake/skyr-url-functions.cmake)
5678
skyr_replace_dynamic_msvcrt_linker_flags()
5779
endif()
@@ -61,30 +83,31 @@ set(warnings_as_errors $<BOOL:${skyr_WARNINGS_AS_ERRORS}>)
6183
set(no_exceptions $<BOOL:${skyr_BUILD_WITHOUT_EXCEPTIONS}>)
6284
set(no_rtti $<BOOL:${skyr_BUILD_WITHOUT_RTTI}>)
6385

64-
set(gnu $<CXX_COMPILER_ID:GNU>)
65-
set(clang $<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>)
86+
set(gnu $<BOOL:${SKY_CXX_COMPILER_GCC}>)
87+
set(clang $<BOOL:${SKY_CXX_COMPILER_CLANG}>)
6688
set(libcxx $<AND:${clang},$<BOOL:${skyr_BUILD_WITH_LLVM_LIBCXX}>>)
67-
set(clang_with_gnu_stdlib $<AND:$<CXX_COMPILER_ID:Clang>,$<NOT:$<BOOL:${WIN32}>>,$<NOT:$<BOOL:${skyr_BUILD_WITH_LLVM_LIBCXX}>>>)
68-
set(msvc $<CXX_COMPILER_ID:MSVC>)
89+
set(clang_with_gnu_stdlib $<AND:${clang},$<NOT:$<BOOL:${skyr_BUILD_WITH_LLVM_LIBCXX}>>>)
90+
set(msvc $<BOOL:${SKY_CXX_COMPILER_MSVC}>)
6991

7092
add_subdirectory(src)
7193

7294
# Testing
7395
if (skyr_BUILD_TESTS)
74-
message(STATUS "Configuring tests")
96+
message(STATUS "[skyr-url] Configuring tests")
97+
CPMAddPackage("gh:catchorg/[email protected]")
7598
enable_testing()
7699
add_subdirectory(tests)
77100
endif()
78101

79102
# Documentation
80103
if (skyr_BUILD_DOCS)
81-
message(STATUS "Configuring documentation")
104+
message(STATUS "[skyr-url] Configuring documentation")
82105
add_subdirectory(docs)
83106
endif()
84107

85108
# Examples
86109
if (skyr_BUILD_EXAMPLES)
87-
message(STATUS "Configuring examples")
110+
message(STATUS "[skyr-url] Configuring examples")
88111
add_subdirectory(examples)
89112
endif()
90113

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![GitHub Actions Status](
99
https://github.com/cpp-netlib/url/workflows/skyr-url%20CI/badge.svg?branch=main)](
1010
https://github.com/cpp-netlib/url/actions?query=workflow%3A%22skyr-url+CI%22)
11-
11+
1212
## Notice
1313

1414
I've changed the name of the default branch from `master` to `main`. Please make future

cmake/CPM.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: MIT
2+
#
3+
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
4+
5+
set(CPM_DOWNLOAD_VERSION 0.38.7)
6+
set(CPM_HASH_SUM "83e5eb71b2bbb8b1f2ad38f1950287a057624e385c238f6087f94cdfc44af9c5")
7+
8+
if(CPM_SOURCE_CACHE)
9+
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
10+
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
11+
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
12+
else()
13+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
14+
endif()
15+
16+
# Expand relative path. This is important if the provided path contains a tilde (~)
17+
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
18+
19+
file(DOWNLOAD
20+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
21+
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
22+
)
23+
24+
include(${CPM_DOWNLOAD_LOCATION})

0 commit comments

Comments
 (0)