--- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,39 +22,20 @@ option(ADA_BENCHMARKS "Build benchmarks" OFF) option(ADA_TESTING "Build tests" ${BUILD_TESTING}) +set(Git_FOUND ON) # 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.14.0 - OPTIONS "BUILD_GMOCK OFF" "INSTALL_GTEST OFF" - ) + if(ADA_TESTING) + find_package(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.9.1") - 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 - GIT_TAG f91b6b4 - OPTIONS "BENCHMARK_ENABLE_TESTING OFF" - "BENCHMARK_ENABLE_INSTALL OFF" - "BENCHMARK_ENABLE_WERROR OFF" - - ) + if(ADA_BENCHMARKS AND (CMAKE_SIZEOF_VOID_P EQUAL 8)) + find_package(benchmark) endif() if (ADA_TESTING AND NOT EMSCRIPTEN) --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1 +1,6 @@ -add_subdirectory(cli) \ No newline at end of file +add_subdirectory(cli) +target_link_libraries(adaparse PRIVATE ada) +target_include_directories(adaparse PUBLIC "$") + +find_package(cxxopts) +target_link_libraries(adaparse PRIVATE cxxopts::cxxopts) --- a/tools/cli/CMakeLists.txt +++ b/tools/cli/CMakeLists.txt @@ -8,12 +8,8 @@ "$" # <--this is in-file "$") # <--this is out-file path endif() -CPMAddPackage("gh:fmtlib/fmt#10.2.1") -CPMAddPackage( - GITHUB_REPOSITORY jarro2783/cxxopts - VERSION 3.2.0 - OPTIONS "CXXOPTS_BUILD_EXAMPLES NO" "CXXOPTS_BUILD_TESTS NO" "CXXOPTS_ENABLE_INSTALL YES" -) +find_package(cxxopts) +find_package(fmt) target_link_libraries(adaparse PRIVATE cxxopts::cxxopts fmt::fmt) if(MSVC OR MINGW)