diff --git a/CMakeLists.txt b/CMakeLists.txt index 168c023f7..c44552949 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ -# Generated by `boostdep --cmake geometry` +# Originally generated by `boostdep --cmake geometry` +# Adapted manually # Copyright 2020, 2021 Peter Dimov +# Copyright (c) 2024 Barend Gehrels, Amsterdam, the Netherlands. # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt @@ -20,12 +22,8 @@ target_link_libraries(boost_geometry Boost::assert Boost::concept_check Boost::config - Boost::container Boost::core - Boost::endian Boost::function_types - Boost::fusion - Boost::integer Boost::iterator Boost::lexical_cast Boost::math @@ -33,28 +31,99 @@ target_link_libraries(boost_geometry Boost::mpl Boost::multiprecision Boost::numeric_conversion - Boost::polygon - Boost::predef Boost::qvm Boost::range Boost::rational - Boost::serialization - Boost::smart_ptr Boost::static_assert - Boost::thread Boost::throw_exception Boost::tokenizer Boost::tuple Boost::type_traits Boost::utility Boost::variant - Boost::variant2 ) +# Required for Boost.Geometry Index +target_link_libraries(boost_geometry + INTERFACE + Boost::container + Boost::serialization +) + +# Optional requirements (for example, for adaptations) +if(BOOST_GEOMETRY_BUILD_OPTIONAL) + target_link_libraries(boost_geometry + INTERFACE + Boost::fusion + Boost::integer + Boost::polygon + Boost::variant2 + ) + + # Mentioned in SRS Shared_grids_boost (which is optional) + target_link_libraries(boost_geometry + INTERFACE + Boost::thread + ) +endif() + +# Requirements for extensions +if(BOOST_GEOMETRY_BUILD_OPTIONAL) + target_link_libraries(boost_geometry + INTERFACE + Boost::endian + Boost::predef + ) +endif() + target_compile_features(boost_geometry INTERFACE cxx_std_14) if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") + if (${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) + # Project is root. Find Boost source. + set(BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE STRING "Boost source dir to use when running CMake from this directory") + if (NOT IS_ABSOLUTE ${BOOST_SRC_DIR}) + set(BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${BOOST_SRC_DIR}") + endif() + + set(BOOST_SRC_DIR_IS_VALID ON) + foreach (PATH "CMakeLists.txt" "Jamroot" "boost-build.jam" "libs") + if (NOT EXISTS "${BOOST_SRC_DIR}/${PATH}") + message(STATUS "${BOOST_SRC_DIR}/${PATH} does not exist. Fallback to find_package.") + set(BOOST_SRC_DIR_IS_VALID OFF) + break() + endif() + endforeach() + + # Create Boost targets from source dir or boost package. + # These are the direct dependencies currently used in unit tests. + set(BOOST_INCLUDE_LIBRARIES + config + algorithm + any + lexical_cast + math + qvm + rational + serialization + tokenizer + variant + multiprecision) + + if (BOOST_SRC_DIR_IS_VALID) + set(BOOST_EXCLUDE_LIBRARIES ${PROJECT_NAME}) + add_subdirectory(${BOOST_SRC_DIR} deps_/boost EXCLUDE_FROM_ALL) + else() + find_package(Boost 1.81.0 REQUIRED) + foreach (BOOST_INCLUDE_LIBRARY ${BOOST_INCLUDE_LIBRARIES}) + add_library(Boost::${BOOST_INCLUDE_LIBRARY} ALIAS Boost::headers) + endforeach () + endif() + + endif() + + enable_testing() add_subdirectory(test) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 001d01a39..996851682 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,27 +10,61 @@ if (APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-contract=fast") endif() -set(BOOST_GEOMETRY_TEST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") - -# Set the BOOST_ROOT variable (if not avaiable) 3 folders higher, above libs/geometry/test -set(BOOST_GEOMETRY_BOOST_ROOT "") -file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.." BOOST_GEOMETRY_BOOST_ROOT) -get_filename_component(BOOST_GEOMETRY_BOOST_ROOT "${BOOST_GEOMETRY_BOOST_ROOT}" REALPATH) - function(boost_geometry_add_unit_test prefix item) - set(unit_test_name "${prefix}_${item}") + set(unit_test_name "boost_geometry_${prefix}_${item}") add_executable(${unit_test_name} ${item}.cpp) - target_include_directories(${unit_test_name} PRIVATE ${BOOST_GEOMETRY_BOOST_ROOT} ${BOOST_GEOMETRY_TEST_ROOT} .) + + target_link_libraries(${unit_test_name} PRIVATE Boost::geometry) + + target_link_libraries(${unit_test_name} + PRIVATE + Boost::algorithm + Boost::any + Boost::array + Boost::assert + Boost::concept_check + Boost::config + Boost::core + Boost::function_types + Boost::iterator + Boost::lexical_cast + Boost::math + Boost::move + Boost::mpl + Boost::multiprecision + Boost::numeric_conversion + Boost::qvm + Boost::range + Boost::rational + Boost::static_assert + Boost::throw_exception + Boost::tokenizer + Boost::tuple + Boost::type_traits + Boost::utility + Boost::variant + ) + + target_include_directories(${unit_test_name} PRIVATE "${PROJECT_SOURCE_DIR}/test" .) + + # Add the Boost.Test framework + target_include_directories(${unit_test_name} PRIVATE "${BOOST_SRC_DIR}/libs/test/include" .) + + # To compile with C++14 target_compile_features(${unit_test_name} PRIVATE cxx_std_14) + + # To be able to run ctest add_test(NAME ${unit_test_name} COMMAND ${unit_test_name}) + + # Add a dependency to the global tests target + add_dependencies(tests ${unit_test_name}) + # Inform the caller about the test name. It can then set defines, if necessary. set(BOOST_GEOMETRY_UNIT_TEST_NAME ${unit_test_name} PARENT_SCOPE) endfunction() +if (NOT TARGET tests) + add_custom_target(tests) +endif() + add_subdirectory(algorithms) - -#add_subdirectory(geometries/custom_non_copiable) -# add_subdirectory(strategies) - -#add_subdirectory(io/wkt) - diff --git a/test/algorithms/CMakeLists.txt b/test/algorithms/CMakeLists.txt index db30c48c0..51d2e90f5 100644 --- a/test/algorithms/CMakeLists.txt +++ b/test/algorithms/CMakeLists.txt @@ -4,9 +4,6 @@ # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -# add_subdirectory(detail) add_subdirectory(area) add_subdirectory(buffer) -# add_subdirectory(overlay) add_subdirectory(set_operations) -