Fix bug 135

This commit is contained in:
Michele Renda 2020-04-04 17:38:00 +03:00
parent 9407651316
commit fcf53c940a
3 changed files with 153 additions and 4 deletions

View File

@ -252,7 +252,7 @@ IF(RP3D_COMPILE_TESTS)
add_subdirectory(test/)
ENDIF()
SET_TARGET_PROPERTIES(reactphysics3d PROPERTIES PUBLIC_HEADER "${REACTPHYSICS3D_HEADERS}")
#SET_TARGET_PROPERTIES(reactphysics3d PROPERTIES PUBLIC_HEADER "${REACTPHYSICS3D_HEADERS}")
# Version number and soname for the library
SET_TARGET_PROPERTIES(reactphysics3d PROPERTIES
@ -260,12 +260,23 @@ SET_TARGET_PROPERTIES(reactphysics3d PROPERTIES
SOVERSION "0.7"
)
# Install target (install library only, not headers)
IF(RP3D_DOUBLE_PRECISION_ENABLED)
set(DECIMAL_TYPE "double")
ELSE()
set(DECIMAL_TYPE "float")
ENDIF()
configure_file("src/decimal.h.in" "decimal.h" )
# Install target
INSTALL(TARGETS reactphysics3d
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/reactphysics3d
)
# Install the headers separately (because INSTALL(TARGETS ... PUBLIC_HEADER DESTINATION ...) does not support subfolders
INSTALL(DIRECTORY src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/reactphysics3d FILES_MATCHING PATTERN "*.h")
INSTALL(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/" "${CMAKE_CURRENT_BINARY_DIR}/"
DESTINATION "include/reactphysics3d"
FILES_MATCHING PATTERN "*.h"
)

101
CMakeModules/FindRp3d.cmake Normal file
View File

@ -0,0 +1,101 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindRp3d
-------
Finds the React Physics 3D library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``Rp3d::Rp3d``
The React Physics 3D library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``Rp3d_FOUND``
True if the system has the React Physics 3D library.
``Rp3d_VERSION``
The version of the React Physics 3D library which was found.
``Rp3d_INCLUDE_DIRS``
Include directories needed to use React Physics 3D.
``Rp3d_LIBRARIES``
Libraries needed to link to React Physics 3D.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``Rp3d_INCLUDE_DIR``
The directory containing ``reactphysics3d.h``.
``Rp3d_LIBRARY``
The path to the React Physics 3D library.
#]=======================================================================]
find_package(PkgConfig)
pkg_check_modules(PC_Rp3d QUIET Rp3d)
find_path(Rp3d_INCLUDE_DIR
NAMES reactphysics3d.h
PATHS ${PC_Rp3d_INCLUDE_DIRS}
PATH_SUFFIXES reactphysics3d
HINTS "/opt/rp3d/include"
)
find_library(Rp3d_LIBRARY
NAMES reactphysics3d
PATHS ${PC_Rp3d_LIBRARY_DIRS}
HINTS "/opt/rp3d/lib"
)
#set(Foo_VERSION ${PC_Foo_VERSION})
#
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Rp3d
FOUND_VAR Rp3d_FOUND
REQUIRED_VARS
Rp3d_LIBRARY
Rp3d_INCLUDE_DIR
VERSION_VAR Rp3d_VERSION
)
if (${Rp3d_FOUND})
file(STRINGS "${Rp3d_INCLUDE_DIR}/configuration.h" Rp3d_VERSION_LINE REGEX "RP3D_VERSION = std::string\\(\"([0-9.]+)\"\\)")
string(REGEX MATCH "RP3D_VERSION = std::string\\(\"([0-9.]+)\"\\)" _ ${Rp3d_VERSION_LINE})
set(Rp3d_VERSION ${CMAKE_MATCH_1})
endif()
if(Rp3d_FOUND)
set(Rp3d_LIBRARIES ${Rp3d_LIBRARY})
set(Rp3d_INCLUDE_DIRS ${Rp3d_INCLUDE_DIR})
set(Rp3d_DEFINITIONS ${PC_Rp3d_CFLAGS_OTHER})
endif()
if(Rp3d_FOUND AND NOT TARGET Rp3d::Rp3d)
add_library(Rp3d::Rp3d UNKNOWN IMPORTED)
set_target_properties(Rp3d::Rp3d PROPERTIES
IMPORTED_LOCATION "${Rp3d_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_Rp3d_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${Rp3d_INCLUDE_DIR}"
)
endif()
mark_as_advanced(
Rp3d_INCLUDE_DIR
Rp3d_LIBRARY
)

37
src/decimal.h.in Normal file
View File

@ -0,0 +1,37 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2019 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
* In no event will the authors be held liable for any damages arising from the *
* use of this software. *
* *
* Permission is granted to anyone to use this software for any purpose, *
* including commercial applications, and to alter it and redistribute it *
* freely, subject to the following restrictions: *
* *
* 1. The origin of this software must not be misrepresented; you must not claim *
* that you wrote the original software. If you use this software in a *
* product, an acknowledgment in the product documentation would be *
* appreciated but is not required. *
* *
* 2. Altered source versions must be plainly marked as such, and must not be *
* misrepresented as being the original software. *
* *
* 3. This notice may not be removed or altered from any source distribution. *
* *
********************************************************************************/
#ifndef REACTPHYSICS3D_DECIMAL_H
#define REACTPHYSICS3D_DECIMAL_H
/// ReactPhysiscs3D namespace
namespace reactphysics3d {
using decimal = @DECIMAL_TYPE@;
}
#endif