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

remove cpm from project #772

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
42 changes: 22 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(ADA_LIB_SOVERSION "2" CACHE STRING "ada library soversion")

include(GNUInstallDirs)

include(FetchContent)
include(CTest)
include(cmake/ada-flags.cmake)

Expand All @@ -22,38 +23,39 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake)
option(ADA_BENCHMARKS "Build benchmarks" OFF)
option(ADA_TESTING "Build tests" ${BUILD_TESTING})

# There are cases where when embedding ada as a dependency for other CMake
# projects as submodules or subdirectories (via FetchContent) can lead to
# errors due to CPM, so this is here to support disabling all the testing
# and tooling for ada if one only wishes to use the ada library.
if(ADA_TESTING OR ADA_BENCHMARKS OR ADA_TOOLS)
include(cmake/CPM.cmake)
# CPM requires git as an implicit dependency
find_package(Git QUIET)
# We use googletest in the tests
if(Git_FOUND AND ADA_TESTING)
CPMAddPackage(
NAME GTest
GITHUB_REPOSITORY google/googletest
VERSION 1.15.2
OPTIONS "BUILD_GMOCK OFF" "INSTALL_GTEST OFF"
FetchContent_Declare(
GTest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.2
)
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(GTest)
endif()
# We use simdjson in both the benchmarks and tests
if(Git_FOUND AND (ADA_TESTING OR ADA_BENCHMARKS))
CPMAddPackage("gh:simdjson/simdjson@3.10.1")
FetchContent_Declare(
simdjson
GIT_REPOSITORY https://github.com/simdjson/simdjson.git
GIT_TAG v3.10.1
)
FetchContent_MakeAvailable(simdjson)
endif()
# We use Google Benchmark, but it does not build under several 32-bit systems.
if(Git_FOUND AND ADA_BENCHMARKS AND (CMAKE_SIZEOF_VOID_P EQUAL 8))
CPMAddPackage(
NAME benchmark
GITHUB_REPOSITORY google/benchmark
VERSION 1.9.0
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
"BENCHMARK_ENABLE_INSTALL OFF"
"BENCHMARK_ENABLE_WERROR OFF"

FetchContent_Declare(
benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.9.0
)
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_WERROR OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(benchmark)
endif()

if (ADA_TESTING AND NOT EMSCRIPTEN)
Expand Down
33 changes: 19 additions & 14 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ target_include_directories(bench PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}
target_include_directories(bench PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/benchmarks>")

# Benchdata
CPMAddPackage("gh:ada-url/url-dataset#9749b92c13e970e70409948fa862461191504ccc")
FetchContent_Declare(
url-dataset
GIT_REPOSITORY https://github.com/ada-url/url-dataset.git
GIT_TAG 9749b92c13e970e70409948fa862461191504ccc
)
FetchContent_MakeAvailable(url-dataset)
add_executable(benchdata bench.cpp)
target_link_libraries(benchdata PRIVATE ada)
target_include_directories(benchdata PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>")
Expand Down Expand Up @@ -94,12 +99,14 @@ if(NOT ICU_FOUND)
endif(NOT ICU_FOUND)

if(ICU_FOUND)
CPMAddPackage(
NAME url_whatwg
GITHUB_REPOSITORY rmisev/url_whatwg
GIT_TAG 72bcabf
OPTIONS "URL_BUILD_TESTS OFF" "URL_USE_LIBS OFF"
FetchContent_Declare(
url_whatwg
GIT_REPOSITORY https://github.com/rmisev/url_whatwg.git
GIT_TAG 72bcabf
)
set(URL_BUILD_TESTS OFF CACHE BOOL "")
set(URL_USE_LIBS OFF CACHE BOOL "")
FetchContent_MakeAvailable(url_whatwg)
add_library(url_whatwg_lib STATIC "${url_whatwg_SOURCE_DIR}/src/url.cpp"
"${url_whatwg_SOURCE_DIR}/src/url_idna.cpp"
"${url_whatwg_SOURCE_DIR}/src/url_ip.cpp"
Expand All @@ -110,7 +117,6 @@ if(ICU_FOUND)
target_include_directories(url_whatwg_lib PUBLIC "${url_whatwg_SOURCE_DIR}/include")
target_link_libraries(url_whatwg_lib PRIVATE ICU::uc ICU::i18n)


target_link_libraries(bench PRIVATE url_whatwg_lib)
target_link_libraries(benchdata PRIVATE url_whatwg_lib)
target_link_libraries(bbc_bench PRIVATE url_whatwg_lib)
Expand Down Expand Up @@ -255,18 +261,17 @@ endif(ZURI_FOUND)

if(NOT WIN32)
# We want the check whether Rust is available before trying to build a crate.
CPMAddPackage(
NAME corrosion
GITHUB_REPOSITORY corrosion-rs/corrosion
VERSION 0.4.4
DOWNLOAD_ONLY ON
OPTIONS "Rust_FIND_QUIETLY OFF"
FetchContent_Declare(
corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.5.0
)
include("${corrosion_SOURCE_DIR}/cmake/FindRust.cmake")
set(Rust_FIND_QUIETLY OFF CACHE BOOL "")
endif()

if(RUST_FOUND)
message(STATUS "Rust found: " ${Rust_VERSION} )
FetchContent_MakeAvailable(corrosion)
add_subdirectory("${corrosion_SOURCE_DIR}" "${PROJECT_BINARY_DIR}/_deps/corrosion" EXCLUDE_FROM_ALL)
# Important: we want to build in release mode!
corrosion_import_crate(MANIFEST_PATH "competitors/servo-url/Cargo.toml" NO_LINKER_OVERRIDE PROFILE release)
Expand Down
24 changes: 0 additions & 24 deletions cmake/CPM.cmake

This file was deleted.

28 changes: 18 additions & 10 deletions tools/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,30 @@ if(MSVC AND BUILD_SHARED_LIBS)
"$<TARGET_FILE:ada>" # <--this is in-file
"$<TARGET_FILE_DIR:adaparse>") # <--this is out-file path
endif()
CPMAddPackage("gh:fmtlib/fmt#11.0.2")
CPMAddPackage(
GITHUB_REPOSITORY jarro2783/cxxopts
VERSION 3.2.0
OPTIONS "CXXOPTS_BUILD_EXAMPLES NO" "CXXOPTS_BUILD_TESTS NO" "CXXOPTS_ENABLE_INSTALL YES"
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 11.0.2
)
FetchContent_MakeAvailable(fmt)
FetchContent_Declare(
cxxopts
GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git
GIT_TAG v3.2.0
)
set(CXXOPTS_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(CXXOPTS_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(CXXOPTS_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(cxxopts)
target_link_libraries(adaparse PRIVATE cxxopts::cxxopts fmt::fmt)

if(MSVC OR MINGW)
target_compile_definitions(adaparse PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
endif()

install(
TARGETS
adaparse
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
TARGETS adaparse
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
Loading