From f9b577e74ffcafb59e1fdffe42ff9c787c3a628c Mon Sep 17 00:00:00 2001 From: Matioupi Date: Tue, 7 Jan 2020 00:04:42 +0100 Subject: [PATCH] [libaaplus] Add new port (#9194) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added port for AA+ library (astronomical algorithms) * fix PR #9194 for static builds * Additionnal PR #9194 fixes following JackBoosY comments * [libaaplus] Fix export cmake, add feature tools Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> --- ports/libaaplus/CMakeLists.txt | 67 ++++++++++++++++++++++++++++++++++ ports/libaaplus/CONTROL | 7 ++++ ports/libaaplus/portfile.cmake | 36 ++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 ports/libaaplus/CMakeLists.txt create mode 100644 ports/libaaplus/CONTROL create mode 100644 ports/libaaplus/portfile.cmake diff --git a/ports/libaaplus/CMakeLists.txt b/ports/libaaplus/CMakeLists.txt new file mode 100644 index 000000000..8c658ff87 --- /dev/null +++ b/ports/libaaplus/CMakeLists.txt @@ -0,0 +1,67 @@ +PROJECT (AstronomicalAlgorithms) + +cmake_minimum_required(VERSION 3.11) +cmake_policy(VERSION 3.11) + +project(libaaplus LANGUAGES CXX) + +option(BUILD_TOOLS "Build libaaplus tools" OFF) + +file(GLOB LIBS_SRC RELATIVE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/*.cpp) + +list(REMOVE_ITEM ${LIBS_SRC} AATest.cpp) + +file(GLOB PUBLIC_HEADERS RELATIVE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/*.h) + +set(TEST_SRCS + AATest.cpp +) + +add_library(libaaplus + ${LIBS_SRC} +) + +if (MSVC AND BUILD_SHARED_LIBS) +target_compile_definitions(libaaplus + PRIVATE + -DAAPLUS_EXT_CLASS\=__declspec\(dllexport\) +) +endif (MSVC AND BUILD_SHARED_LIBS) + +install( + TARGETS libaaplus + EXPORT libaaplus + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) + +# Headers makes relative includes so directory structure must be kept +foreach(HEADER ${PUBLIC_HEADERS}) + get_filename_component(HEADER_DIR ${HEADER} DIRECTORY) + install( + FILES ${HEADER} + DESTINATION include/aaplus/${HEADER_DIR} + ) +endforeach() + + +if (BUILD_TOOLS) + add_executable(aatest AATest.cpp) + target_link_libraries(aatest PRIVATE libaaplus) + if (BUILD_SHARED_LIBS AND MSVC) + target_compile_definitions(aatest + PUBLIC + -DAAPLUS_EXT_CLASS\=__declspec\(dllimport\) + ) + endif (BUILD_SHARED_LIBS AND MSVC) + + install(TARGETS aatest RUNTIME DESTINATION tools/aaplus) +endif() + +install( + EXPORT libaaplus + DESTINATION share/libaaplus + FILE libaaplusConfig.cmake + NAMESPACE libaaplus:: +) diff --git a/ports/libaaplus/CONTROL b/ports/libaaplus/CONTROL new file mode 100644 index 000000000..3fb7f9fb3 --- /dev/null +++ b/ports/libaaplus/CONTROL @@ -0,0 +1,7 @@ +Source: libaaplus +Version: 2.1.0 +Description: libaaplus is an astronomical computations library by naughter software +Homepage: http://www.naughter.com/aa.html + +Feature: tools +Description: Build libaaplus tools \ No newline at end of file diff --git a/ports/libaaplus/portfile.cmake b/ports/libaaplus/portfile.cmake new file mode 100644 index 000000000..b1418fb18 --- /dev/null +++ b/ports/libaaplus/portfile.cmake @@ -0,0 +1,36 @@ +set(VERSION 2.10.0) + +vcpkg_download_distfile( + ARCHIVE_FILE + URLS "http://www.naughter.com/download/aaplus.zip" + FILENAME "aaplus.zip" + SHA512 ef814a36fa567e806be5e5345abd89e1a8d32da1c392c251e5b74aea86b866ebc74bc17885a0eff303b170cfe226670cd6f69095702396cc9d6fcbc1a769de4f +) + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE_FILE} + REF ${VERSION} + NO_REMOVE_ONE_LEVEL +) + +file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + tools BUILD_TOOLS +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS ${FEATURE_OPTIONS} +) + +vcpkg_install_cmake() +vcpkg_copy_pdbs() + +vcpkg_fixup_cmake_targets(CONFIG_PATH share/libaaplus) + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +file(INSTALL ${SOURCE_PATH}/AA+.htm DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)