Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 57 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ cmake_minimum_required(VERSION 2.8.11)
project(pqp)

include(CMakePackageConfigHelpers)
include(GenerateExportHeader)
include(GNUInstallDirs)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 3)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR})

option(BUILD_SHARED_LIBS "Build shared libraries" ON)

set(
HDRS
src/BV.h
Expand All @@ -26,32 +29,76 @@ set(
src/TriDist.cpp
)

add_library(PQP STATIC ${HDRS} ${SRCS})
add_library(PQP ${HDRS} ${SRCS})

target_include_directories(
PQP
INTERFACE
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>
)

set_target_properties(
PQP
PROPERTIES
DEBUG_POSTFIX d
POSITION_INDEPENDENT_CODE ON
VERSION ${VERSION}
)

if(MSVC)
if(BUILD_SHARED_LIBS)
set_target_properties(
PQP
PROPERTIES
DEBUG_POSTFIX d
)
else()
set_target_properties(
PQP
PROPERTIES
DEBUG_POSTFIX sd
MINSIZEREL_POSTFIX s
RELEASE_POSTFIX s
RELWITHDEBINFO_POSTFIX s
)
endif()
endif()

install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT development)

install(
TARGETS PQP
EXPORT PQP
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_SKIP
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
)
if(NOT CMAKE_VERSION VERSION_LESS 3.12)
install(
TARGETS PQP
EXPORT PQP
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_COMPONENT development
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
)
else()
install(
TARGETS PQP
EXPORT PQP
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_SKIP
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
)
if(BUILD_SHARED_LIBS)
install(
TARGETS PQP
EXPORT PQP
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development NAMELINK_ONLY
)
endif()
endif()

if(MSVC AND BUILD_SHARED_LIBS AND ${CMAKE_MAJOR_VERSION} GREATER 2 AND ${CMAKE_MINOR_VERSION} GREATER 0)
install(FILES $<TARGET_PDB_FILE:PQP> DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS Debug RelWithDebInfo COMPONENT debug)
endif()

generate_export_header(PQP EXPORT_FILE_NAME PQP_Export.h)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PQP_Export.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT development)

option(BUILD_SAMPLES "Build samples" OFF)

Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CC = g++

CFLAGS = -O2 -I.
CFLAGS = -O2 -I. -Iinclude

.SUFFIXES: .C .cpp

Expand All @@ -20,11 +20,14 @@ library: $(OBJECTS)
cp src/BV.h include/
cp src/Tri.h include/

include/PQP_Export.h:
echo "#ifndef PQP_EXPORT_H\n#define PQP_EXPORT_H\n\n#define PQP_EXPORT\n\n#endif" > include/PQP_Export.h

lib/BV.o: src/BV.cpp
$(CC) $(CFLAGS) -c src/BV.cpp -o lib/BV.o
lib/PQP.o: src/PQP.cpp
lib/PQP.o: src/PQP.cpp include/PQP_Export.h
$(CC) $(CFLAGS) -c src/PQP.cpp -o lib/PQP.o
lib/Build.o: src/Build.cpp
lib/Build.o: src/Build.cpp include/PQP_Export.h
$(CC) $(CFLAGS) -c src/Build.cpp -o lib/Build.o
lib/TriDist.o: src/TriDist.cpp
$(CC) $(CFLAGS) -c src/TriDist.cpp -o lib/TriDist.o
Expand Down
7 changes: 4 additions & 3 deletions src/PQP.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#include "PQP_Compile.h"
#include "PQP_Internal.h"
#include "PQP_Export.h"

//----------------------------------------------------------------------------
//
Expand Down Expand Up @@ -203,7 +204,7 @@ const int PQP_ERR_BUILD_EMPTY_MODEL = -5;
const int PQP_ALL_CONTACTS = 1; // find all pairwise intersecting triangles
const int PQP_FIRST_CONTACT = 2; // report first intersecting tri pair found

int
PQP_EXPORT int
PQP_Collide(PQP_CollideResult *result,
PQP_REAL R1[3][3], PQP_REAL T1[3], PQP_Model *o1,
PQP_REAL R2[3][3], PQP_REAL T2[3], PQP_Model *o2,
Expand Down Expand Up @@ -264,7 +265,7 @@ PQP_Collide(PQP_CollideResult *result,
//
//----------------------------------------------------------------------------

int
PQP_EXPORT int
PQP_Distance(PQP_DistanceResult *result,
PQP_REAL R1[3][3], PQP_REAL T1[3], PQP_Model *o1,
PQP_REAL R2[3][3], PQP_REAL T2[3], PQP_Model *o2,
Expand Down Expand Up @@ -321,7 +322,7 @@ PQP_Distance(PQP_DistanceResult *result,
//
//----------------------------------------------------------------------------

int
PQP_EXPORT int
PQP_Tolerance(PQP_ToleranceResult *res,
PQP_REAL R1[3][3], PQP_REAL T1[3], PQP_Model *o1,
PQP_REAL R2[3][3], PQP_REAL T2[3], PQP_Model *o2,
Expand Down
9 changes: 5 additions & 4 deletions src/PQP_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@

#include "Tri.h"
#include "BV.h"
#include "PQP_Export.h"

class PQP_Model
class PQP_EXPORT PQP_Model
{

public:
Expand Down Expand Up @@ -79,7 +80,7 @@ struct CollisionPair
int id2;
};

struct PQP_CollideResult
struct PQP_EXPORT PQP_CollideResult
{
// stats

Expand Down Expand Up @@ -123,7 +124,7 @@ struct PQP_CollideResult

#if PQP_BV_TYPE & RSS_TYPE // distance/tolerance are only available with RSS

struct PQP_DistanceResult
struct PQP_EXPORT PQP_DistanceResult
{
// stats

Expand Down Expand Up @@ -160,7 +161,7 @@ struct PQP_DistanceResult
const PQP_REAL *P2() { return p2; }
};

struct PQP_ToleranceResult
struct PQP_EXPORT PQP_ToleranceResult
{
// stats

Expand Down