From d9bb09cce2d81e9b76c7c577a239f32f31e759af Mon Sep 17 00:00:00 2001 From: isaachier Date: Thu, 7 Sep 2017 20:07:38 -0400 Subject: [PATCH] Apply changes to version 3.0. (#1) * Update Changelog. * Update CMake package generation. * Apply changes to version 3.0. * Improve CMake changes. * Fix mistake for build interface include dir. * Fix mistake for build interface include dir. * Use template for CMake installation. * Delete unused file. * Remove unnecessary INSTALL_INTERFACE expression. --- CMakeLists.txt | 147 +++++++++++++------- cmake/Config.cmake.in | 4 + double-conversion/CMakeLists.txt | 24 ---- double-conversion/bignum-dtoa.cc | 6 +- double-conversion/bignum-dtoa.h | 2 +- double-conversion/bignum.cc | 4 +- double-conversion/bignum.h | 2 +- double-conversion/cached-powers.cc | 4 +- double-conversion/cached-powers.h | 2 +- double-conversion/diy-fp.cc | 4 +- double-conversion/diy-fp.h | 2 +- double-conversion/double-conversion.cc | 16 +-- double-conversion/double-conversion.h | 2 +- double-conversion/fast-dtoa.cc | 8 +- double-conversion/fast-dtoa.h | 2 +- double-conversion/fixed-dtoa.cc | 4 +- double-conversion/fixed-dtoa.h | 2 +- double-conversion/ieee.h | 2 +- double-conversion/strtod.cc | 8 +- double-conversion/strtod.h | 2 +- double-conversionBuildTreeSettings.cmake.in | 2 - double-conversionConfig.cmake.in | 16 --- double-conversionConfigVersion.cmake.in | 11 -- 23 files changed, 134 insertions(+), 142 deletions(-) create mode 100644 cmake/Config.cmake.in delete mode 100644 double-conversionBuildTreeSettings.cmake.in delete mode 100644 double-conversionConfig.cmake.in delete mode 100644 double-conversionConfigVersion.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 01196ba6..143c4584 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,27 +1,34 @@ -cmake_minimum_required(VERSION 2.8.12) -project(double-conversion) +cmake_minimum_required(VERSION 3.0) +project(double-conversion VERSION 3.0.0) -include(GNUInstallDirs) +set(headers + double-conversion/bignum.h + double-conversion/cached-powers.h + double-conversion/diy-fp.h + double-conversion/double-conversion.h + double-conversion/fast-dtoa.h + double-conversion/fixed-dtoa.h + double-conversion/ieee.h + double-conversion/strtod.h + double-conversion/utils.h) -# pick a version # -set(double-conversion_VERSION 2.0.1) -set(double-conversion_SOVERSION_MAJOR 1) -set(double-conversion_SOVERSION_MINOR 0) -set(double-conversion_SOVERSION_PATCH 0) -set(double-conversion_SOVERSION - ${double-conversion_SOVERSION_MAJOR}.${double-conversion_SOVERSION_MINOR}.${double-conversion_SOVERSION_PATCH}) - -# set suffix for CMake files used for packaging -if(WIN32 AND NOT CYGWIN) - set(INSTALL_CMAKE_DIR CMake) -else() - set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/double-conversion) -endif() +add_library(double-conversion + double-conversion/bignum.cc + double-conversion/bignum-dtoa.cc + double-conversion/cached-powers.cc + double-conversion/diy-fp.cc + double-conversion/double-conversion.cc + double-conversion/fast-dtoa.cc + double-conversion/fixed-dtoa.cc + double-conversion/strtod.cc + ${headers}) +target_include_directories( + double-conversion PUBLIC + $) -# Add src subdirectory -add_subdirectory(double-conversion) +# pick a version # +set_property(TARGET double-conversion PROPERTY SOVERSION ${PROJECT_VERSION}) -# # set up testing if requested option(BUILD_TESTING "Build test programs" OFF) if(BUILD_TESTING) @@ -30,41 +37,75 @@ if(BUILD_TESTING) add_subdirectory(test) endif() -# -# mention the library target as export library -export(TARGETS double-conversion - FILE "${PROJECT_BINARY_DIR}/double-conversionLibraryDepends.cmake") +#### +# Installation (https://github.com/forexample/package-example) + +# Layout. This works for all platforms: +# * /lib/cmake/ +# * /lib/ +# * /include/ +set(config_install_dir "lib/cmake/${PROJECT_NAME}") +set(include_install_dir "include") + +set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") + +# Configuration +set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") +set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") +set(targets_export_name "${PROJECT_NAME}Targets") +set(namespace "${PROJECT_NAME}::") + +# Include module with function 'write_basic_package_version_file' +include(CMakePackageConfigHelpers) + +# Configure 'ConfigVersion.cmake' +# Note: PROJECT_VERSION is used as a VERSION +write_basic_package_version_file( + "${version_config}" COMPATIBILITY SameMajorVersion +) -# -# set this build as an importable package -export(PACKAGE double-conversion) +# Configure 'Config.cmake' +# Use variables: +# * targets_export_name +# * PROJECT_NAME +configure_package_config_file( + "cmake/Config.cmake.in" + "${project_config}" + INSTALL_DESTINATION "${config_install_dir}" +) -# -# make a cmake file -- in this case, all that needs defining -# is double-conversion_INCLUDE_DIRS -configure_file(double-conversionBuildTreeSettings.cmake.in - "${PROJECT_BINARY_DIR}/double-conversionBuildTreeSettings.cmake" - @ONLY) +# Targets: +# * /lib/libdouble-conversion.a +# * header location after install: /include/double-conversion/*.h +# * headers can be included by C++ code `#include ` +install( + TARGETS double-conversion + EXPORT "${targets_export_name}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "${include_install_dir}" +) -# -# sets up config to be used by CMake find_package -configure_file(double-conversionConfig.cmake.in - "${PROJECT_BINARY_DIR}/double-conversionConfig.cmake" - @ONLY) -# -# Export version # checked by find_package -configure_file(double-conversionConfigVersion.cmake.in - "${PROJECT_BINARY_DIR}/double-conversionConfigVersion.cmake" - @ONLY) -# -# install config files for find_package -install(FILES - "${PROJECT_BINARY_DIR}/double-conversionConfig.cmake" - "${PROJECT_BINARY_DIR}/double-conversionConfigVersion.cmake" - DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev) +# Headers: +# * double-conversion/*.h -> /include/double-conversion/*.h +install( + FILES ${headers} + DESTINATION "${include_install_dir}/double-conversion" +) +# Config +# * /lib/cmake/double-conversion/double-conversionConfig.cmake +# * /lib/cmake/double-conversion/double-conversionConfigVersion.cmake +install( + FILES "${project_config}" "${version_config}" + DESTINATION "${config_install_dir}" +) -# -# generates install cmake files to find libraries in installation. -install(EXPORT double-conversionLibraryDepends DESTINATION - "${INSTALL_CMAKE_DIR}" COMPONENT dev) +# Config +# * /lib/cmake/double-conversion/double-conversionTargets.cmake +install( + EXPORT "${targets_export_name}" + NAMESPACE "${namespace}" + DESTINATION "${config_install_dir}" +) diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in new file mode 100644 index 00000000..9b4c9ee0 --- /dev/null +++ b/cmake/Config.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/double-conversion/CMakeLists.txt b/double-conversion/CMakeLists.txt index 2d13b36a..47bd52a6 100644 --- a/double-conversion/CMakeLists.txt +++ b/double-conversion/CMakeLists.txt @@ -1,27 +1,3 @@ -set(headers - bignum.h - cached-powers.h - diy-fp.h - double-conversion.h - fast-dtoa.h - fixed-dtoa.h - ieee.h - strtod.h - utils.h - ) - -add_library(double-conversion -bignum.cc -bignum-dtoa.cc -cached-powers.cc -diy-fp.cc -double-conversion.cc -fast-dtoa.cc -fixed-dtoa.cc -strtod.cc -${headers} -) - target_include_directories(double-conversion PUBLIC $) # Add fPIC on x86_64 when supported. diff --git a/double-conversion/bignum-dtoa.cc b/double-conversion/bignum-dtoa.cc index f1ad7a5a..bdb06a29 100644 --- a/double-conversion/bignum-dtoa.cc +++ b/double-conversion/bignum-dtoa.cc @@ -27,10 +27,10 @@ #include -#include "bignum-dtoa.h" +#include -#include "bignum.h" -#include "ieee.h" +#include +#include namespace double_conversion { diff --git a/double-conversion/bignum-dtoa.h b/double-conversion/bignum-dtoa.h index 34b96199..9d15ce3d 100644 --- a/double-conversion/bignum-dtoa.h +++ b/double-conversion/bignum-dtoa.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_BIGNUM_DTOA_H_ #define DOUBLE_CONVERSION_BIGNUM_DTOA_H_ -#include "utils.h" +#include namespace double_conversion { diff --git a/double-conversion/bignum.cc b/double-conversion/bignum.cc index 8892de8f..0d2eeac3 100644 --- a/double-conversion/bignum.cc +++ b/double-conversion/bignum.cc @@ -25,8 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "bignum.h" -#include "utils.h" +#include +#include namespace double_conversion { diff --git a/double-conversion/bignum.h b/double-conversion/bignum.h index c385f223..4ff34e26 100644 --- a/double-conversion/bignum.h +++ b/double-conversion/bignum.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_BIGNUM_H_ #define DOUBLE_CONVERSION_BIGNUM_H_ -#include "utils.h" +#include namespace double_conversion { diff --git a/double-conversion/cached-powers.cc b/double-conversion/cached-powers.cc index 2b43f064..780f527b 100644 --- a/double-conversion/cached-powers.cc +++ b/double-conversion/cached-powers.cc @@ -29,9 +29,9 @@ #include #include -#include "utils.h" +#include -#include "cached-powers.h" +#include namespace double_conversion { diff --git a/double-conversion/cached-powers.h b/double-conversion/cached-powers.h index 61a50614..eabff4a1 100644 --- a/double-conversion/cached-powers.h +++ b/double-conversion/cached-powers.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_CACHED_POWERS_H_ #define DOUBLE_CONVERSION_CACHED_POWERS_H_ -#include "diy-fp.h" +#include namespace double_conversion { diff --git a/double-conversion/diy-fp.cc b/double-conversion/diy-fp.cc index ddd1891b..82b0d08a 100644 --- a/double-conversion/diy-fp.cc +++ b/double-conversion/diy-fp.cc @@ -26,8 +26,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "diy-fp.h" -#include "utils.h" +#include +#include namespace double_conversion { diff --git a/double-conversion/diy-fp.h b/double-conversion/diy-fp.h index 2edf3467..e2011d43 100644 --- a/double-conversion/diy-fp.h +++ b/double-conversion/diy-fp.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_DIY_FP_H_ #define DOUBLE_CONVERSION_DIY_FP_H_ -#include "utils.h" +#include namespace double_conversion { diff --git a/double-conversion/double-conversion.cc b/double-conversion/double-conversion.cc index 6f21a012..6609c563 100644 --- a/double-conversion/double-conversion.cc +++ b/double-conversion/double-conversion.cc @@ -28,14 +28,14 @@ #include #include -#include "double-conversion.h" - -#include "bignum-dtoa.h" -#include "fast-dtoa.h" -#include "fixed-dtoa.h" -#include "ieee.h" -#include "strtod.h" -#include "utils.h" +#include + +#include +#include +#include +#include +#include +#include namespace double_conversion { diff --git a/double-conversion/double-conversion.h b/double-conversion/double-conversion.h index 6bdfa8d2..23cdaf98 100644 --- a/double-conversion/double-conversion.h +++ b/double-conversion/double-conversion.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_ #define DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_ -#include "utils.h" +#include namespace double_conversion { diff --git a/double-conversion/fast-dtoa.cc b/double-conversion/fast-dtoa.cc index 61350383..e5c22229 100644 --- a/double-conversion/fast-dtoa.cc +++ b/double-conversion/fast-dtoa.cc @@ -25,11 +25,11 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "fast-dtoa.h" +#include -#include "cached-powers.h" -#include "diy-fp.h" -#include "ieee.h" +#include +#include +#include namespace double_conversion { diff --git a/double-conversion/fast-dtoa.h b/double-conversion/fast-dtoa.h index 5f1e8eee..ac4317c0 100644 --- a/double-conversion/fast-dtoa.h +++ b/double-conversion/fast-dtoa.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_FAST_DTOA_H_ #define DOUBLE_CONVERSION_FAST_DTOA_H_ -#include "utils.h" +#include namespace double_conversion { diff --git a/double-conversion/fixed-dtoa.cc b/double-conversion/fixed-dtoa.cc index 0f55a0b6..5b6ca5a2 100644 --- a/double-conversion/fixed-dtoa.cc +++ b/double-conversion/fixed-dtoa.cc @@ -27,8 +27,8 @@ #include -#include "fixed-dtoa.h" -#include "ieee.h" +#include +#include namespace double_conversion { diff --git a/double-conversion/fixed-dtoa.h b/double-conversion/fixed-dtoa.h index 3bdd08e2..a9436fc9 100644 --- a/double-conversion/fixed-dtoa.h +++ b/double-conversion/fixed-dtoa.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_FIXED_DTOA_H_ #define DOUBLE_CONVERSION_FIXED_DTOA_H_ -#include "utils.h" +#include namespace double_conversion { diff --git a/double-conversion/ieee.h b/double-conversion/ieee.h index b14cf4f7..1b705d2e 100644 --- a/double-conversion/ieee.h +++ b/double-conversion/ieee.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_DOUBLE_H_ #define DOUBLE_CONVERSION_DOUBLE_H_ -#include "diy-fp.h" +#include namespace double_conversion { diff --git a/double-conversion/strtod.cc b/double-conversion/strtod.cc index 17abcbb2..50eacf07 100644 --- a/double-conversion/strtod.cc +++ b/double-conversion/strtod.cc @@ -28,10 +28,10 @@ #include #include -#include "strtod.h" -#include "bignum.h" -#include "cached-powers.h" -#include "ieee.h" +#include +#include +#include +#include namespace double_conversion { diff --git a/double-conversion/strtod.h b/double-conversion/strtod.h index ed0293b8..32265162 100644 --- a/double-conversion/strtod.h +++ b/double-conversion/strtod.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_STRTOD_H_ #define DOUBLE_CONVERSION_STRTOD_H_ -#include "utils.h" +#include namespace double_conversion { diff --git a/double-conversionBuildTreeSettings.cmake.in b/double-conversionBuildTreeSettings.cmake.in deleted file mode 100644 index f46705d6..00000000 --- a/double-conversionBuildTreeSettings.cmake.in +++ /dev/null @@ -1,2 +0,0 @@ -set(double-conversion_INCLUDE_DIRS - "@PROJECT_SOURCE_DIR@/src") diff --git a/double-conversionConfig.cmake.in b/double-conversionConfig.cmake.in deleted file mode 100644 index 110df446..00000000 --- a/double-conversionConfig.cmake.in +++ /dev/null @@ -1,16 +0,0 @@ -# - Config file for the double-conversion package -# It defines the following variables -# double-conversion_INCLUDE_DIRS -# double-conversion_LIBRARIES - -get_filename_component(double-conversion_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - -if(EXISTS "${double-conversion_CMAKE_DIR}/CMakeCache.txt") - include("${double-conversion_CMAKE_DIR}/double-conversionBuildTreeSettings.cmake") -else() - set(double-conversion_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@/double-conversion") -endif() - -include("@CMAKE_INSTALL_FULL_LIBDIR@/cmake/double-conversion/double-conversionLibraryDepends.cmake") - -set(double-conversion_LIBRARIES double-conversion) diff --git a/double-conversionConfigVersion.cmake.in b/double-conversionConfigVersion.cmake.in deleted file mode 100644 index 0f2295d2..00000000 --- a/double-conversionConfigVersion.cmake.in +++ /dev/null @@ -1,11 +0,0 @@ -set(PACKAGE_VERSION "@double-conversion_VERSION@") - -# Check whether the requested PACKAGE_FIND_VERSION is compatible -if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) - endif() -endif()