From 84c0714ac150ef5984576172b49120e1cc52aeab Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 26 Aug 2017 12:51:20 -0700 Subject: [PATCH] build: make SeExpr support optional 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 --- CMakeLists.txt | 16 +++++++++++----- Makefile | 5 +++++ README.md | 11 ++++++++++- src/lib/CMakeLists.txt | 8 +++++--- src/py/CMakeLists.txt | 6 +++++- src/py/partio.i | 4 ++++ 6 files changed, 40 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ef1bdd4..92c1da0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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 diff --git a/Makefile b/Makefile index f5d380a5..1b9205a3 100644 --- a/Makefile +++ b/Makefile @@ -19,11 +19,16 @@ ifdef V export VERBOSE endif +# Installation location: prefix= CMAKE_FLAGS += -DCMAKE_INSTALL_PREFIX=$(prefix) + +# SeExpr v2 location: RP_SeExpr= ifdef RP_SeExpr CMAKE_FLAGS += -DSEEXPR_BASE=$(RP_SeExpr) + CMAKE_FLAGS += -DPARTIO_SE_ENABLED=1 endif +# Extra cmake flags: CMAKE_EXTRA_FLAGS= ifdef CMAKE_EXTRA_FLAGS CMAKE_FLAGS += $(CMAKE_EXTRA_FLAGS) endif diff --git a/README.md b/README.md index 166ca019..0a3ac19d 100644 --- a/README.md +++ b/README.md @@ -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=` for the SeExpr location, and `-DPARTIO_SE_ENABLED=1` +to enable the PartioSe class. + Source code overview ==================== diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 26fb94cd..95404b7d 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -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") diff --git a/src/py/CMakeLists.txt b/src/py/CMakeLists.txt index 872b3579..050bdf90 100644 --- a/src/py/CMakeLists.txt +++ b/src/py/CMakeLists.txt @@ -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}) diff --git a/src/py/partio.i b/src/py/partio.i index eab9074d..e9218246 100644 --- a/src/py/partio.i +++ b/src/py/partio.i @@ -40,7 +40,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. %{ #include #include +#if PARTIO_SE_ENABLED #include +#endif #include namespace Partio{ typedef uint64_t ParticleIndex; @@ -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); @@ -562,3 +565,4 @@ class PartioSe{ bool runRange(int istart,int iend); void setTime(float val); }; +#endif