Skip to content

Commit

Permalink
build: make SeExpr support optional
Browse files Browse the repository at this point in the history
Only enable SeExpr support when PARTIO_SE_ENABLED is specified to cmake.
Provide this value from the Makefile when RP_SeExpr is specified so that
users only need to specify the path to SeExpr when using the Makefile.

Closes #62
  • Loading branch information
davvid committed Aug 26, 2017
1 parent 62b980d commit 84c0714
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 10 deletions.
16 changes: 11 additions & 5 deletions CMakeLists.txt
Expand Up @@ -48,6 +48,9 @@ SET( ${PROJECT_NAME}_PATCH_LEVEL 0 )

include(GNUInstallDirs)

# PARTIO_SE_ENABLED enables SeExpr support
option(PARTIO_SE_ENABLED "PARTIO_SE_ENABLED" false)

## Setup platform specific helper defines build variants
IF(WIN32)
ADD_DEFINITIONS (-DPARTIO_WIN32 -D_USE_MATH_DEFINES)
Expand Down Expand Up @@ -95,11 +98,14 @@ SET( PARTIO_LIBRARIES partio ${ZLIB_LIBRARY} )
# make it so partio can be found
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/lib )

SET(SEEXPR_BASE "c:/aselle/seexpr-inst" CACHE STRING "path to SeExpr")
SET(SEEXPR_INCLUDE_PATH ${SEEXPR_BASE}/include)
SET(SEEXPR_LIBDIR ${CMAKE_INSTALL_LIBDIR})
SET(SEEXPR_LINK_PATH ${SEEXPR_BASE}/${SEEXPR_LIBDIR})
SET(SEEXPR_LIBS "SeExpr")
if (${PARTIO_SE_ENABLED})
add_definitions(-DPARTIO_SE_ENABLED=1)
SET(SEEXPR_BASE "c:/aselle/seexpr-inst" CACHE STRING "path to SeExpr")
SET(SEEXPR_INCLUDE_PATH ${SEEXPR_BASE}/include)
SET(SEEXPR_LIBDIR ${CMAKE_INSTALL_LIBDIR})
SET(SEEXPR_LINK_PATH ${SEEXPR_BASE}/${SEEXPR_LIBDIR})
SET(SEEXPR_LIBS "SeExpr")
endif ()


## Traverse subdirectories
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -19,11 +19,16 @@ ifdef V
export VERBOSE
endif

# Installation location: prefix=<path>
CMAKE_FLAGS += -DCMAKE_INSTALL_PREFIX=$(prefix)

# SeExpr v2 location: RP_SeExpr=<path>
ifdef RP_SeExpr
CMAKE_FLAGS += -DSEEXPR_BASE=$(RP_SeExpr)
CMAKE_FLAGS += -DPARTIO_SE_ENABLED=1
endif

# Extra cmake flags: CMAKE_EXTRA_FLAGS=<flags>
ifdef CMAKE_EXTRA_FLAGS
CMAKE_FLAGS += $(CMAKE_EXTRA_FLAGS)
endif
Expand Down
11 changes: 10 additions & 1 deletion README.md
Expand Up @@ -27,15 +27,24 @@ Getting Started
CMake is used to build the project, but we provide a top-level Makefile
for convenience that takes care of all the steps.

See the Makefile for the user-tweakable variables.
See the Makefile for the user-tweakable variables and corresponding
cmake options.

The typical usage for an installation into `/usr/local`
with a temporary staging directory of `/tmp/stage` is:

make DESTDIR=/tmp/stage RP_SeExpr=/usr/local prefix=/usr/local install

SeExpr
======
Partio depends on SeExpr v2 (current `v2.11`). SeExpr v2 and v3 can co-exist,
so you can have v2 for building partio installed alongside SeExpr v3+ (master).

SeExpr is not strictly required. SeExpr support is disabled when `RP_SeExpr`
is not specified to the Makefile. In CMake, the corresponding variables are
`-DSEEXPR_BASE=<path>` for the SeExpr location, and `-DPARTIO_SE_ENABLED=1`
to enable the PartioSe class.

Source code overview
====================

Expand Down
8 changes: 5 additions & 3 deletions src/lib/CMakeLists.txt
Expand Up @@ -44,9 +44,11 @@ IF(SEEXPR_BASE)
INCLUDE_DIRECTORIES(${SEEXPR_INCLUDE_PATH})
LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
LINK_DIRECTORIES(${SEEXPR_LINK_PATH})
ADD_LIBRARY (partioSe SHARED PartioSe.cpp)
target_link_libraries(partioSe ${PARTIO_LIBRARIES} ${SEEXPR_LIBS})
INSTALL (TARGETS partioSe DESTINATION ${CMAKE_INSTALL_LIBDIR})
if (${PARTIO_SE_ENABLED})
ADD_LIBRARY (partioSe SHARED PartioSe.cpp)
target_link_libraries(partioSe ${PARTIO_LIBRARIES} ${SEEXPR_LIBS})
INSTALL (TARGETS partioSe DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif ()
ENDIF(SEEXPR_BASE)

FILE(GLOB public_includes "*.h")
Expand Down
6 changes: 5 additions & 1 deletion src/py/CMakeLists.txt
Expand Up @@ -62,7 +62,11 @@ SET_SOURCE_FILES_PROPERTIES(partio.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(partio.i PROPERTIES SWIG_FLAGS "-includeall")
LINK_DIRECTORIES(${SEEXPR_LINK_PATH})
SWIG_ADD_MODULE(partio python partio.i)
SWIG_LINK_LIBRARIES(partio ${PYTHON_LIBRARIES} ${ZLIB_LIBRARY} partio partioSe ${SEEXPR_LIBS})
if (${PARTIO_SE_ENABLED})
SWIG_LINK_LIBRARIES(partio ${PYTHON_LIBRARIES} ${ZLIB_LIBRARY} partio partioSe ${SEEXPR_LIBS})
else ()
SWIG_LINK_LIBRARIES(partio ${PYTHON_LIBRARIES} ${ZLIB_LIBRARY} partio)
endif ()

SET(PYTHON_DEST "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION}/site-packages" )
INSTALL(TARGETS _partio DESTINATION ${PYTHON_DEST})
Expand Down
4 changes: 4 additions & 0 deletions src/py/partio.i
Expand Up @@ -40,7 +40,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
%{
#include <Partio.h>
#include <PartioIterator.h>
#if PARTIO_SE_ENABLED
#include <PartioSe.h>
#endif
#include <sstream>
namespace Partio{
typedef uint64_t ParticleIndex;
Expand Down Expand Up @@ -553,6 +555,7 @@ void print(const ParticlesData* particles);
%feature("docstring","Creates a clustered particle set");
ParticlesDataMutable* computeClustering(ParticlesDataMutable* particles,const int numNeighbors,const double radiusSearch,const double radiusInside,const int connections,const double density)=0;

#if PARTIO_SE_ENABLED
class PartioSe{
public:
PartioSe(ParticlesDataMutable* parts,const char* expr);
Expand All @@ -562,3 +565,4 @@ class PartioSe{
bool runRange(int istart,int iend);
void setTime(float val);
};
#endif

0 comments on commit 84c0714

Please sign in to comment.