[triangle] Revise CMakeLists.txt and exported config (#41488)

This commit is contained in:
Kai Pastor 2024-10-16 05:31:38 +02:00 committed by GitHub
parent e6943cc30e
commit c01623c57c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 70 additions and 37 deletions

View File

@ -1,45 +1,47 @@
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.5...3.30)
project(triangle) project(triangle)
option(BUILD_TOOL "Build the command line tool" OFF)
include(GNUInstallDirs) include(GNUInstallDirs)
add_library(triangleLib triangle.c exports.def) add_library(triangle triangle.c exports.def)
add_executable(triangle triangle.c) 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) add_executable(triangle_exe triangle.c)
target_compile_definitions(triangle PRIVATE -DANSI_DECLARATORS) set_target_properties(triangle_exe PROPERTIES OUTPUT_NAME "triangle")
if(WIN32)
target_compile_definitions(triangleLib PRIVATE -DNO_TIMER)
target_compile_definitions(triangle PRIVATE -DNO_TIMER)
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") foreach(target IN ITEMS triangle triangle_exe)
target_link_libraries(triangle m) target_compile_definitions(${target} PRIVATE -DANSI_DECLARATORS)
endif() target_include_directories(${target} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
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 install(TARGETS triangle
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}> EXPORT triangle-targets
)
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
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
) )
install(TARGETS triangle DESTINATION tools/triangle) install(EXPORT triangle-targets
FILE unofficial-triangle-config.cmake
install(EXPORT triangleTargets NAMESPACE unofficial::triangle::
FILE triangleConfig.cmake DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/unofficial-triangle"
NAMESPACE triangle::
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/triangle"
) )
if(BUILD_TOOL)
install(TARGETS triangle_exe DESTINATION tools/triangle)
else()
set_target_properties(triangle_exe PROPERTIES EXCLUDE_FROM_ALL 1)
endif()

View File

@ -11,21 +11,31 @@ vcpkg_extract_source_archive(
PATCHES PATCHES
"enable_64bit_architecture.patch" "enable_64bit_architecture.patch"
) )
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/exports.def" 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( vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}" SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${options}
OPTIONS_DEBUG
-DBUILD_TOOL=OFF
) )
vcpkg_cmake_install() vcpkg_cmake_install()
vcpkg_copy_pdbs() 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/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/tools") 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) file(INSTALL "${SOURCE_PATH}/README" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -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)

4
ports/triangle/usage Normal file
View File

@ -0,0 +1,4 @@
triangle provides CMake targets:
find_package(unofficial-triangle CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::triangle::triangle)

View File

@ -1,9 +1,10 @@
{ {
"name": "triangle", "name": "triangle",
"version": "1.6", "version": "1.6",
"port-version": 3, "port-version": 4,
"description": "A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.", "description": "A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.",
"homepage": "http://www.cs.cmu.edu/~quake/triangle.html", "homepage": "http://www.cs.cmu.edu/~quake/triangle.html",
"license": null,
"supports": "!uwp", "supports": "!uwp",
"dependencies": [ "dependencies": [
{ {
@ -14,5 +15,10 @@
"name": "vcpkg-cmake-config", "name": "vcpkg-cmake-config",
"host": true "host": true
} }
] ],
"features": {
"tool": {
"description": "Build the command line tool."
}
}
} }

View File

@ -9062,7 +9062,7 @@
}, },
"triangle": { "triangle": {
"baseline": "1.6", "baseline": "1.6",
"port-version": 3 "port-version": 4
}, },
"triton": { "triton": {
"baseline": "2023-08-16", "baseline": "2023-08-16",

View File

@ -1,5 +1,10 @@
{ {
"versions": [ "versions": [
{
"git-tree": "bd79d7af32634104384879113cbf1158b1e72a8f",
"version": "1.6",
"port-version": 4
},
{ {
"git-tree": "b751d577254b617b208ac8e1e828be1a539f8123", "git-tree": "b751d577254b617b208ac8e1e828be1a539f8123",
"version": "1.6", "version": "1.6",