Commit ddd372e7 authored by Berk Onat's avatar Berk Onat

Corrected a memory error at pymolfile C++ wrapper

parent 56f1a324
......@@ -4,7 +4,7 @@ include(ExternalProject)
set(TNG_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/tng")
set(TNG_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/tng")
set(TNG_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${TNG_INSTALL_DIR})
set(TNG_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${TNG_INSTALL_DIR} -DBUILD_SHARED_LIBS=OFF)
message("TNG_PREFIX='${TNG_PREFIX}'")
message("TNG_INSTALL_DIR='${TNG_INSTALL_DIR}'")
......
......@@ -2,19 +2,23 @@ cmake_minimum_required(VERSION 2.8.12)
project(molfileplugins)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
find_package(EXPAT)
find_package(TCL)
find_package(NetCDF)
find_package(NETCDF)
include (FindNetCDF.cmake)
set (NETCDF_CXX "YES")
find_package(NetCDF REQUIRED)
if (EXISTS "${TNG_INSTALL_DIR}/lib/libtng_io.dylib"
OR EXISTS "${TNG_INSTALL_DIR}/lib/libtng_io.so"
OR EXISTS "${TNG_INSTALL_DIR}/include/tng/tng_io.h")
set(TNGIO_FOUND TRUE)
set(TNGIO_LIBRARIES "${TNG_INSTALL_DIR}/lib/")
set(TNGIO_INLCUDE_DIRS "${TNG_INSTALL_DIR}/include/")
endif()
set(TNG_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../external/tng")
message(TNG_DIR= ${TNG_INSTALL_DIR})
#if (EXISTS "${TNG_INSTALL_DIR}/lib/libtng_io.dylib"
# OR EXISTS "${TNG_INSTALL_DIR}/lib/libtng_io.so"
# OR EXISTS "${TNG_INSTALL_DIR}/include/tng/tng_io.h")
set(TNGIO_FOUND TRUE)
set(TNGIO_LIBRARIES "${TNG_INSTALL_DIR}/lib/libtng_io.a")
set(TNGIO_LIBRARY_DIRS "${TNG_INSTALL_DIR}/lib/")
set(TNGIO_INCLUDE_DIRS "${TNG_INSTALL_DIR}/include/")
#endif()
set(TARGET_ARCH_REGEX "^.*-march[= ]([^ ]+).*$")
string(REGEX MATCH "${TARGET_ARCH_REGEX}" TARGET_ARCH_MATCH "${CMAKE_C_FLAGS}" "${CMAKE_CXX_FLAGS}")
......@@ -50,21 +54,21 @@ endif()
if(LINUX)
if(CMAKE_CXX_COMPILER_ID MATCHES "^.*GNU.*$")
if(ARCH64BIT)
set(TARGET_COPT " -fPIC -m64 -o ")
set(TARGET_LOPT " -fPIC -m64 -lstdc++ -o ")
set(TARGET_CFLAGS " -m64 -O2 -fPIC -Wall ${CMAKE_C_FLAGS}")
set(TARGET_CXXFLG " -m64 -O2 -fPIC -Wall ${CMAKE_CXX_FLAGS}")
set(TARGET_COPT -fPIC;-m64;-o)
set(TARGET_LOPT -fPIC;-m64;-lstdc++;-o)
set(TARGET_CFLAGS -m64;-O2;-fPIC;-Wall;${CMAKE_C_FLAGS})
set(TARGET_CXXFLG -m64;-O2;-fPIC;-Wall;${CMAKE_CXX_FLAGS})
else()
set(TARGET_COPT " -fPIC -m32 -o ")
set(TARGET_LOPT " -fPIC -m32 -lstdc++ -o ")
set(TARGET_CFLAGS " -m32 -O2 -fPIC -Wall ${CMAKE_C_FLAGS}")
set(TARGET_CXXFLG " -m32 -O2 -fPIC -Wall ${CMAKE_CXX_FLAGS}")
set(TARGET_COPT -fPIC;-m32;-o)
set(TARGET_LOPT -fPIC;-m32;-lstdc++;-o)
set(TARGET_CFLAGS -m32;-O2;-fPIC;-Wall;${CMAKE_C_FLAGS})
set(TARGET_CXXFLG -m32;-O2;-fPIC;-Wall;${CMAKE_CXX_FLAGS})
endif()
else()
set(TARGET_COPT " -o ")
set(TARGET_LOPT " -o ")
set(TARGET_CFLAGS " -O2 -Wall ${CMAKE_C_FLAGS}")
set(TARGET_CXXFLG " -O2 -Wall ${CMAKE_CXX_FLAGS}")
set(TARGET_COPT -o)
set(TARGET_LOPT -o)
set(TARGET_CFLAGS -O2;-Wall;${CMAKE_C_FLAGS})
set(TARGET_CXXFLG -O2;-Wall;${CMAKE_CXX_FLAGS})
endif()
endif()
......@@ -77,16 +81,16 @@ if(APPLE)
set(TARGET_CFLAGS -m64;-Os;-Wall;-fPIC;-dynamic;${CMAKE_C_FLAGS})
set(TARGET_CXXFLG -m64;-Os;-Wall;-fPIC;-dynamic;${CMAKE_CXX_FLAGS})
else()
set(TARGET_COPT " -fPIC -m32 -o ")
set(TARGET_LOPT " -fPIC -m32 -o ")
set(TARGET_CFLAGS " -m32 -Os -Wall -fPIC -dynamic ${CMAKE_C_FLAGS}")
set(TARGET_CXXFLG " -m32 -Os -Wall -fPIC -dynamic ${CMAKE_CXX_FLAGS}")
set(TARGET_COPT -fPIC;-m32;-o)
set(TARGET_LOPT -fPIC;-m32;-o)
set(TARGET_CFLAGS -m32;-Os;-Wall;-fPIC;-dynamic;${CMAKE_C_FLAGS})
set(TARGET_CXXFLG -m32;-Os;-Wall;-fPIC;-dynamic;${CMAKE_CXX_FLAGS})
endif()
else()
set(TARGET_COPT " -o ")
set(TARGET_LOPT " -o ")
set(TARGET_CFLAGS " -O2 -Wall ${CMAKE_C_FLAGS}")
set(TARGET_CXXFLG " -O2 -Wall ${CMAKE_CXX_FLAGS}")
set(TARGET_COPT -o)
set(TARGET_LOPT -o)
set(TARGET_CFLAGS -O2;-Wall;${CMAKE_C_FLAGS})
set(TARGET_CXXFLG -O2;-Wall;${CMAKE_CXX_FLAGS})
endif()
endif()
......@@ -103,25 +107,31 @@ if(UNIX)
set(TCLINC "-I${TCL_INCLUDE_PATH}")
set(TCLLIB "-L${TCL_LIBRARY}")
set(TARGET_MOL_LIBS ${TARGET_MOL_LIBS} \"TCLLDFLAGS=${TCLLDFLAGS}\";\"TCLINC=${TCLINC}\";\"TCLLIB=${TCLLIB}\";)
message(TCL_FOUND= ${TCL_LIBRARY})
endif()
if(EXPAT_FOUND)
set(EXPATLDFLAGS ${EXPAT_LIBRARIES})
set(EXPATINC "-I${EXPAT_INCLUDE_DIRS}")
set(EXPATLIB "-I${EXPAT_INCLUDE_DIRS}")
set(TARGET_MOL_LIBS ${TARGET_MOL_LIBS} \"EXPATLDFLAGS=${EXPATLDFLAGS}\";\"EXPATINC=${EXPATINC}\";\"EXPATLIB=${EXPATLIB}\";)
message(EXPAT_FOUND= ${EXPAT_LIBRARIES})
endif()
if(NETCDF_FOUND)
set(NETCDFLDFLAGS ${NETCDF_LIBRARY})
set(NETCDFINC "-I${NETCDF_INCLUDE_DIRS}")
set(NETCDFLIB "-I${NETCDF_INCLUDE_DIRS}")
set(NETCDFLDFLAGS ${NETCDF_LIBRARIES})
set(NETCDFINC "-I${NETCDF_INCLUDES}")
set(NETCDFLIB "-L${NETCDF_INCLUDES}")
set(TARGET_MOL_LIBS ${TARGET_MOL_LIBS} \"NETCDFLDFLAGS=${NETCDFLDFLAGS}\";\"NETCDFINC=${NETCDFINC}\";\"NETCDFLIB=${NETCDFLIB}\";)
message(NETCDF_FOUND= ${NETCDF_LIBRARIES})
message(NETCDF_FOUND= ${NETCDF_INCLUDES})
endif()
if(TNGIO_FOUND)
set(TNGIOLDFLAGS -ltng_io)
set(TNGIOLDFLAGS ${TNGIO_LIBRARIES})
set(TNGIOINC "-I${TNGIO_INCLUDE_DIRS}")
set(TNGIOLIB "-L${TNGIO_LIBRARIES}")
set(TNGIOLIB "-L${TNGIO_LIBRARY_DIRS}")
set(TARGET_MOL_LIBS ${TARGET_MOL_LIBS} \"TNGLDFLAGS=${TNGIOLDFLAGS}\";\"TNGINC=${TNGIOINC}\";\"TNGLIB=${TNGIOLIB}\";)
message(TNGIO_FOUND= ${TNGIO_LIBRARIES})
endif()
# message(MAKE_COMMAND= "make dynlibs staticlibs bins \"ARCH = ${TARGET_ARCH}\" \"COPTO = ${TARGET_COPT} \" \"LOPTO = ${TARGET_LOPT} \" \"CC = ${CMAKE_C_COMPILER} \" \"CXX = ${CMAKE_CXX_COMPILER} \" \"DEF = ${TARGET_DEF}\" \"CCFLAGS = ${TARGET_CFLAGS} \" \"CXXFLAGS = ${TARGET_CXXFLG} \" \"AR = ${TARGET_AR}\" \"NM = ${TARGET_NM}\" \"RANLIB = ${TARGET_RANLIB}\" \"LIBTOOL = ${TARGET_LIBTOOL} \" ${TARGET_MOL_LIBS}")
add_custom_command(
OUTPUT ${LIB_MOLFILE_FILES}
COMMAND make dynlibs staticlibs bins \"ARCH = ${TARGET_ARCH}\" \"COPTO = ${TARGET_COPT} \" \"LOPTO = ${TARGET_LOPT} \" \"CC = ${CMAKE_C_COMPILER} \" \"CXX = ${CMAKE_CXX_COMPILER} \" \"DEF = ${TARGET_DEF}\" \"CCFLAGS = ${TARGET_CFLAGS} \" \"CXXFLAGS = ${TARGET_CXXFLG} \" \"AR = ${TARGET_AR}\" \"NM = ${TARGET_NM}\" \"RANLIB = ${TARGET_RANLIB}\" \"LIBTOOL = ${TARGET_LIBTOOL} \" ${TARGET_MOL_LIBS}
......
......@@ -201,7 +201,7 @@ PyObject * molfile_plugin_info(PyObject* molcapsule, int plugin_no) {
PyObject* read_fill_structure(PyObject* molpack, PyObject* prototype)
{
//Py_Initialize();
//import_array();
import_array();
int options = 0;
molfile_plugin_t* plugin;
void* file_handle;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment