Skip to content

Commit

Permalink
Apply changes to version 3.0. (google#1)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
isaachier committed Sep 8, 2017
1 parent ca220cb commit d9bb09c
Show file tree
Hide file tree
Showing 23 changed files with 134 additions and 142 deletions.
147 changes: 94 additions & 53 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

# 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)
Expand All @@ -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:
# * <prefix>/lib/cmake/<PROJECT-NAME>
# * <prefix>/lib/
# * <prefix>/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 '<PROJECT-NAME>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 '<PROJECT-NAME>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:
# * <prefix>/lib/libdouble-conversion.a
# * header location after install: <prefix>/include/double-conversion/*.h
# * headers can be included by C++ code `#include <double-conversion/*.h>`
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 -> <prefix>/include/double-conversion/*.h
install(
FILES ${headers}
DESTINATION "${include_install_dir}/double-conversion"
)

# Config
# * <prefix>/lib/cmake/double-conversion/double-conversionConfig.cmake
# * <prefix>/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
# * <prefix>/lib/cmake/double-conversion/double-conversionTargets.cmake
install(
EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
)
4 changes: 4 additions & 0 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
check_required_components("@PROJECT_NAME@")
24 changes: 0 additions & 24 deletions double-conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)

# Add fPIC on x86_64 when supported.
Expand Down
6 changes: 3 additions & 3 deletions double-conversion/bignum-dtoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

#include <math.h>

#include "bignum-dtoa.h"
#include <double-conversion/bignum-dtoa.h>

#include "bignum.h"
#include "ieee.h"
#include <double-conversion/bignum.h>
#include <double-conversion/ieee.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/bignum-dtoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_BIGNUM_DTOA_H_
#define DOUBLE_CONVERSION_BIGNUM_DTOA_H_

#include "utils.h"
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
4 changes: 2 additions & 2 deletions double-conversion/bignum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <double-conversion/bignum.h>
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/bignum.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_BIGNUM_H_
#define DOUBLE_CONVERSION_BIGNUM_H_

#include "utils.h"
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
4 changes: 2 additions & 2 deletions double-conversion/cached-powers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#include <limits.h>
#include <math.h>

#include "utils.h"
#include <double-conversion/utils.h>

#include "cached-powers.h"
#include <double-conversion/cached-powers.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/cached-powers.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_CACHED_POWERS_H_
#define DOUBLE_CONVERSION_CACHED_POWERS_H_

#include "diy-fp.h"
#include <double-conversion/diy-fp.h>

namespace double_conversion {

Expand Down
4 changes: 2 additions & 2 deletions double-conversion/diy-fp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include "diy-fp.h"
#include "utils.h"
#include <double-conversion/diy-fp.h>
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/diy-fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_DIY_FP_H_
#define DOUBLE_CONVERSION_DIY_FP_H_

#include "utils.h"
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
16 changes: 8 additions & 8 deletions double-conversion/double-conversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
#include <limits.h>
#include <math.h>

#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 <double-conversion/double-conversion.h>

#include <double-conversion/bignum-dtoa.h>
#include <double-conversion/fast-dtoa.h>
#include <double-conversion/fixed-dtoa.h>
#include <double-conversion/ieee.h>
#include <double-conversion/strtod.h>
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/double-conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
#define DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_

#include "utils.h"
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
8 changes: 4 additions & 4 deletions double-conversion/fast-dtoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <double-conversion/fast-dtoa.h>

#include "cached-powers.h"
#include "diy-fp.h"
#include "ieee.h"
#include <double-conversion/cached-powers.h>
#include <double-conversion/diy-fp.h>
#include <double-conversion/ieee.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/fast-dtoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_FAST_DTOA_H_
#define DOUBLE_CONVERSION_FAST_DTOA_H_

#include "utils.h"
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
4 changes: 2 additions & 2 deletions double-conversion/fixed-dtoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

#include <math.h>

#include "fixed-dtoa.h"
#include "ieee.h"
#include <double-conversion/fixed-dtoa.h>
#include <double-conversion/ieee.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/fixed-dtoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_FIXED_DTOA_H_
#define DOUBLE_CONVERSION_FIXED_DTOA_H_

#include "utils.h"
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/ieee.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_DOUBLE_H_
#define DOUBLE_CONVERSION_DOUBLE_H_

#include "diy-fp.h"
#include <double-conversion/diy-fp.h>

namespace double_conversion {

Expand Down
8 changes: 4 additions & 4 deletions double-conversion/strtod.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
#include <stdarg.h>
#include <limits.h>

#include "strtod.h"
#include "bignum.h"
#include "cached-powers.h"
#include "ieee.h"
#include <double-conversion/strtod.h>
#include <double-conversion/bignum.h>
#include <double-conversion/cached-powers.h>
#include <double-conversion/ieee.h>

namespace double_conversion {

Expand Down
2 changes: 1 addition & 1 deletion double-conversion/strtod.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef DOUBLE_CONVERSION_STRTOD_H_
#define DOUBLE_CONVERSION_STRTOD_H_

#include "utils.h"
#include <double-conversion/utils.h>

namespace double_conversion {

Expand Down
2 changes: 0 additions & 2 deletions double-conversionBuildTreeSettings.cmake.in

This file was deleted.

Loading

0 comments on commit d9bb09c

Please sign in to comment.