12e5b6d6dSopenharmony_cicmake_minimum_required(VERSION 3.0) 22e5b6d6dSopenharmony_ciproject(double-conversion VERSION 3.2.0) 32e5b6d6dSopenharmony_ci 42e5b6d6dSopenharmony_cioption(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF) 52e5b6d6dSopenharmony_ci 62e5b6d6dSopenharmony_ciif(BUILD_SHARED_LIBS AND MSVC) 72e5b6d6dSopenharmony_ci set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 82e5b6d6dSopenharmony_ciendif() 92e5b6d6dSopenharmony_ci 102e5b6d6dSopenharmony_ciset(headers 112e5b6d6dSopenharmony_ci double-conversion/bignum.h 122e5b6d6dSopenharmony_ci double-conversion/cached-powers.h 132e5b6d6dSopenharmony_ci double-conversion/diy-fp.h 142e5b6d6dSopenharmony_ci double-conversion/double-conversion.h 152e5b6d6dSopenharmony_ci double-conversion/double-to-string.h 162e5b6d6dSopenharmony_ci double-conversion/fast-dtoa.h 172e5b6d6dSopenharmony_ci double-conversion/fixed-dtoa.h 182e5b6d6dSopenharmony_ci double-conversion/ieee.h 192e5b6d6dSopenharmony_ci double-conversion/string-to-double.h 202e5b6d6dSopenharmony_ci double-conversion/strtod.h 212e5b6d6dSopenharmony_ci double-conversion/utils.h) 222e5b6d6dSopenharmony_ci 232e5b6d6dSopenharmony_ciadd_library(double-conversion 242e5b6d6dSopenharmony_ci double-conversion/bignum.cc 252e5b6d6dSopenharmony_ci double-conversion/bignum-dtoa.cc 262e5b6d6dSopenharmony_ci double-conversion/cached-powers.cc 272e5b6d6dSopenharmony_ci double-conversion/double-to-string.cc 282e5b6d6dSopenharmony_ci double-conversion/fast-dtoa.cc 292e5b6d6dSopenharmony_ci double-conversion/fixed-dtoa.cc 302e5b6d6dSopenharmony_ci double-conversion/string-to-double.cc 312e5b6d6dSopenharmony_ci double-conversion/strtod.cc 322e5b6d6dSopenharmony_ci ${headers}) 332e5b6d6dSopenharmony_citarget_include_directories( 342e5b6d6dSopenharmony_ci double-conversion PUBLIC 352e5b6d6dSopenharmony_ci $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>) 362e5b6d6dSopenharmony_ci 372e5b6d6dSopenharmony_ci# pick a version # 382e5b6d6dSopenharmony_ciset_target_properties(double-conversion PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 3) 392e5b6d6dSopenharmony_ci 402e5b6d6dSopenharmony_ci# set up testing if requested 412e5b6d6dSopenharmony_cioption(BUILD_TESTING "Build test programs" OFF) 422e5b6d6dSopenharmony_ciif(BUILD_TESTING) 432e5b6d6dSopenharmony_ci enable_testing() 442e5b6d6dSopenharmony_ci include(CTest) 452e5b6d6dSopenharmony_ci add_subdirectory(test) 462e5b6d6dSopenharmony_ciendif() 472e5b6d6dSopenharmony_ci 482e5b6d6dSopenharmony_ci#### 492e5b6d6dSopenharmony_ci# Installation (https://github.com/forexample/package-example) 502e5b6d6dSopenharmony_ci 512e5b6d6dSopenharmony_ciinclude(GNUInstallDirs) 522e5b6d6dSopenharmony_ci 532e5b6d6dSopenharmony_ci# Layout. This works for all platforms: 542e5b6d6dSopenharmony_ci# * <prefix>/lib/cmake/<PROJECT-NAME> 552e5b6d6dSopenharmony_ci# * <prefix>/lib/ 562e5b6d6dSopenharmony_ci# * <prefix>/include/ 572e5b6d6dSopenharmony_ciset(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") 582e5b6d6dSopenharmony_ci 592e5b6d6dSopenharmony_ciset(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") 602e5b6d6dSopenharmony_ci 612e5b6d6dSopenharmony_ci# Configuration 622e5b6d6dSopenharmony_ciset(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") 632e5b6d6dSopenharmony_ciset(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") 642e5b6d6dSopenharmony_ciset(targets_export_name "${PROJECT_NAME}Targets") 652e5b6d6dSopenharmony_ciset(namespace "${PROJECT_NAME}::") 662e5b6d6dSopenharmony_ci 672e5b6d6dSopenharmony_ci# Include module with function 'write_basic_package_version_file' 682e5b6d6dSopenharmony_ciinclude(CMakePackageConfigHelpers) 692e5b6d6dSopenharmony_ci 702e5b6d6dSopenharmony_ci# Configure '<PROJECT-NAME>ConfigVersion.cmake' 712e5b6d6dSopenharmony_ci# Note: PROJECT_VERSION is used as a VERSION 722e5b6d6dSopenharmony_ciwrite_basic_package_version_file( 732e5b6d6dSopenharmony_ci "${version_config}" COMPATIBILITY SameMajorVersion 742e5b6d6dSopenharmony_ci) 752e5b6d6dSopenharmony_ci 762e5b6d6dSopenharmony_ci# Configure '<PROJECT-NAME>Config.cmake' 772e5b6d6dSopenharmony_ci# Use variables: 782e5b6d6dSopenharmony_ci# * targets_export_name 792e5b6d6dSopenharmony_ci# * PROJECT_NAME 802e5b6d6dSopenharmony_ciconfigure_package_config_file( 812e5b6d6dSopenharmony_ci "cmake/Config.cmake.in" 822e5b6d6dSopenharmony_ci "${project_config}" 832e5b6d6dSopenharmony_ci INSTALL_DESTINATION "${config_install_dir}" 842e5b6d6dSopenharmony_ci) 852e5b6d6dSopenharmony_ci 862e5b6d6dSopenharmony_ci# Targets: 872e5b6d6dSopenharmony_ci# * <prefix>/lib/libdouble-conversion.a 882e5b6d6dSopenharmony_ci# * header location after install: <prefix>/include/double-conversion/*.h 892e5b6d6dSopenharmony_ci# * headers can be included by C++ code `#include <double-conversion/*.h>` 902e5b6d6dSopenharmony_ciinstall( 912e5b6d6dSopenharmony_ci TARGETS double-conversion 922e5b6d6dSopenharmony_ci EXPORT "${targets_export_name}" 932e5b6d6dSopenharmony_ci LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" 942e5b6d6dSopenharmony_ci ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" 952e5b6d6dSopenharmony_ci RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" 962e5b6d6dSopenharmony_ci INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" 972e5b6d6dSopenharmony_ci) 982e5b6d6dSopenharmony_ci 992e5b6d6dSopenharmony_ci# Headers: 1002e5b6d6dSopenharmony_ci# * double-conversion/*.h -> <prefix>/include/double-conversion/*.h 1012e5b6d6dSopenharmony_ciinstall( 1022e5b6d6dSopenharmony_ci FILES ${headers} 1032e5b6d6dSopenharmony_ci DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/double-conversion" 1042e5b6d6dSopenharmony_ci) 1052e5b6d6dSopenharmony_ci 1062e5b6d6dSopenharmony_ci# Config 1072e5b6d6dSopenharmony_ci# * <prefix>/lib/cmake/double-conversion/double-conversionConfig.cmake 1082e5b6d6dSopenharmony_ci# * <prefix>/lib/cmake/double-conversion/double-conversionConfigVersion.cmake 1092e5b6d6dSopenharmony_ciinstall( 1102e5b6d6dSopenharmony_ci FILES "${project_config}" "${version_config}" 1112e5b6d6dSopenharmony_ci DESTINATION "${config_install_dir}" 1122e5b6d6dSopenharmony_ci) 1132e5b6d6dSopenharmony_ci 1142e5b6d6dSopenharmony_ci# Config 1152e5b6d6dSopenharmony_ci# * <prefix>/lib/cmake/double-conversion/double-conversionTargets.cmake 1162e5b6d6dSopenharmony_ciinstall( 1172e5b6d6dSopenharmony_ci EXPORT "${targets_export_name}" 1182e5b6d6dSopenharmony_ci NAMESPACE "${namespace}" 1192e5b6d6dSopenharmony_ci DESTINATION "${config_install_dir}" 1202e5b6d6dSopenharmony_ci) 1212e5b6d6dSopenharmony_ci 1222e5b6d6dSopenharmony_ciif (MSVC AND BUILD_SHARED_LIBS) 1232e5b6d6dSopenharmony_ci # Install companion PDB for Visual Studio 1242e5b6d6dSopenharmony_ci install( 1252e5b6d6dSopenharmony_ci FILES $<TARGET_PDB_FILE:double-conversion> 1262e5b6d6dSopenharmony_ci TYPE BIN 1272e5b6d6dSopenharmony_ci OPTIONAL 1282e5b6d6dSopenharmony_ci ) 1292e5b6d6dSopenharmony_ciendif() 1302e5b6d6dSopenharmony_ci 131