From c01623c57c74667cf8c05ffbbf654c5564beac0a Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Wed, 16 Oct 2024 05:31:38 +0200 Subject: [PATCH] [triangle] Revise CMakeLists.txt and exported config (#41488) --- ports/triangle/CMakeLists.txt | 64 +++++++++++++++-------------- ports/triangle/portfile.cmake | 16 ++++++-- ports/triangle/triangleConfig.cmake | 6 +++ ports/triangle/usage | 4 ++ ports/triangle/vcpkg.json | 10 ++++- versions/baseline.json | 2 +- versions/t-/triangle.json | 5 +++ 7 files changed, 70 insertions(+), 37 deletions(-) create mode 100644 ports/triangle/triangleConfig.cmake create mode 100644 ports/triangle/usage diff --git a/ports/triangle/CMakeLists.txt b/ports/triangle/CMakeLists.txt index 6157c00f37..4ee1382b23 100644 --- a/ports/triangle/CMakeLists.txt +++ b/ports/triangle/CMakeLists.txt @@ -1,45 +1,47 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.5...3.30) project(triangle) +option(BUILD_TOOL "Build the command line tool" OFF) + include(GNUInstallDirs) -add_library(triangleLib triangle.c exports.def) -add_executable(triangle triangle.c) +add_library(triangle triangle.c exports.def) +set_target_properties(triangle PROPERTIES PUBLIC_HEADER "${CMAKE_SOURCE_DIR}/triangle.h") +target_compile_definitions(triangle PRIVATE -DTRILIBRARY) -target_compile_definitions(triangleLib PRIVATE -DTRILIBRARY -DANSI_DECLARATORS) -target_compile_definitions(triangle PRIVATE -DANSI_DECLARATORS) -if(WIN32) - target_compile_definitions(triangleLib PRIVATE -DNO_TIMER) - target_compile_definitions(triangle PRIVATE -DNO_TIMER) -endif() +add_executable(triangle_exe triangle.c) +set_target_properties(triangle_exe PROPERTIES OUTPUT_NAME "triangle") -if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - target_link_libraries(triangle m) -endif() +foreach(target IN ITEMS triangle triangle_exe) + target_compile_definitions(${target} PRIVATE -DANSI_DECLARATORS) + target_include_directories(${target} PUBLIC + "$" + "$" + ) + if(WIN32) + target_compile_definitions(${target} PRIVATE -DNO_TIMER) + endif() + if(UNIX AND NOT APPLE AND NOT ANDROID) + target_link_libraries(${target} PRIVATE m) + endif() +endforeach() -target_include_directories(triangleLib PUBLIC - $ -) - -set_target_properties(triangleLib PROPERTIES POSITION_INDEPENDENT_CODE ON) - -set_target_properties(triangleLib PROPERTIES PUBLIC_HEADER - "${CMAKE_SOURCE_DIR}/triangle.h" -) - -set_target_properties(triangleLib PROPERTIES OUTPUT_NAME "triangle") - -install(TARGETS triangleLib EXPORT triangleTargets +install(TARGETS triangle + EXPORT triangle-targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -install(TARGETS triangle DESTINATION tools/triangle) - -install(EXPORT triangleTargets - FILE triangleConfig.cmake - NAMESPACE triangle:: - DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/triangle" +install(EXPORT triangle-targets + FILE unofficial-triangle-config.cmake + NAMESPACE unofficial::triangle:: + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/unofficial-triangle" ) + +if(BUILD_TOOL) + install(TARGETS triangle_exe DESTINATION tools/triangle) +else() + set_target_properties(triangle_exe PROPERTIES EXCLUDE_FROM_ALL 1) +endif() diff --git a/ports/triangle/portfile.cmake b/ports/triangle/portfile.cmake index 505b3d4dd4..630b2dd27b 100644 --- a/ports/triangle/portfile.cmake +++ b/ports/triangle/portfile.cmake @@ -11,21 +11,31 @@ vcpkg_extract_source_archive( PATCHES "enable_64bit_architecture.patch" ) - file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") file(COPY "${CMAKE_CURRENT_LIST_DIR}/exports.def" DESTINATION "${SOURCE_PATH}") +vcpkg_check_features(OUT_FEATURE_OPTIONS options + FEATURES + tool BUILD_TOOL +) + vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${options} + OPTIONS_DEBUG + -DBUILD_TOOL=OFF ) vcpkg_cmake_install() - vcpkg_copy_pdbs() +vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-triangle) -vcpkg_cmake_config_fixup() +# migration polyfill +file(COPY "${CURRENT_PORT_DIR}/triangleConfig.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/triangle") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/tools") +file(COPY "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/triangle") file(INSTALL "${SOURCE_PATH}/README" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/triangle/triangleConfig.cmake b/ports/triangle/triangleConfig.cmake new file mode 100644 index 0000000000..531d1368de --- /dev/null +++ b/ports/triangle/triangleConfig.cmake @@ -0,0 +1,6 @@ +file(READ "${CMAKE_CURRENT_LIST_DIR}/usage" usage) +message(WARNING "find_package(${CMAKE_FIND_PACKAGE_NAME}) is deprecated.\n${usage}") + +include(CMakeFindDependencyMacro) +find_dependency(unofficial-triangle) +add_library(triangleLib ALIAS unofficial::triangle::triangle) diff --git a/ports/triangle/usage b/ports/triangle/usage new file mode 100644 index 0000000000..b065965b68 --- /dev/null +++ b/ports/triangle/usage @@ -0,0 +1,4 @@ +triangle provides CMake targets: + + find_package(unofficial-triangle CONFIG REQUIRED) + target_link_libraries(main PRIVATE unofficial::triangle::triangle) diff --git a/ports/triangle/vcpkg.json b/ports/triangle/vcpkg.json index 76376bf5d5..a4eaefac2c 100644 --- a/ports/triangle/vcpkg.json +++ b/ports/triangle/vcpkg.json @@ -1,9 +1,10 @@ { "name": "triangle", "version": "1.6", - "port-version": 3, + "port-version": 4, "description": "A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.", "homepage": "http://www.cs.cmu.edu/~quake/triangle.html", + "license": null, "supports": "!uwp", "dependencies": [ { @@ -14,5 +15,10 @@ "name": "vcpkg-cmake-config", "host": true } - ] + ], + "features": { + "tool": { + "description": "Build the command line tool." + } + } } diff --git a/versions/baseline.json b/versions/baseline.json index 73a9100281..e51255f6c6 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -9062,7 +9062,7 @@ }, "triangle": { "baseline": "1.6", - "port-version": 3 + "port-version": 4 }, "triton": { "baseline": "2023-08-16", diff --git a/versions/t-/triangle.json b/versions/t-/triangle.json index 734d6ae2a9..18b4f7cbb7 100644 --- a/versions/t-/triangle.json +++ b/versions/t-/triangle.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "bd79d7af32634104384879113cbf1158b1e72a8f", + "version": "1.6", + "port-version": 4 + }, { "git-tree": "b751d577254b617b208ac8e1e828be1a539f8123", "version": "1.6",