rethinking the python wrapper (#511)

* renames certain function parameter declarations and removes double pointer call from the deleteproject function

* deprecates conditonal compilation, removes python-specific headers and function renaming

* fixes tests and docs

* fixes test
This commit is contained in:
Sam Hatchett
2019-07-17 15:19:25 -04:00
committed by GitHub
parent 4cc16913df
commit 3fe11b98ee
18 changed files with 216 additions and 1240 deletions

View File

@@ -81,7 +81,6 @@ IF (MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
ENDIF (MSVC)
# configure file groups
file(GLOB EPANET_SOURCES RELATIVE ${PROJECT_SOURCE_DIR} src/*.c src/util/*.c)
file(GLOB EPANET_LIB_ALL RELATIVE ${PROJECT_SOURCE_DIR} src/* src/util/*)
@@ -89,49 +88,12 @@ file(GLOB EPANET_LIB_ALL RELATIVE ${PROJECT_SOURCE_DIR} src/* src/util/*)
list(REMOVE_ITEM EPANET_LIB_ALL "src/epanet_py.c")
source_group("Library" FILES ${EPANET_LIB_ALL})
# the shared library
IF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)" OR NOT MSVC)
add_library(epanet2 SHARED ${EPANET_LIB_ALL})
ELSE(TRUE)
add_library(epanet2 SHARED ${EPANET_LIB_ALL} ${PROJECT_SOURCE_DIR}/include/epanet2.def)
set_source_files_properties(${PROJECT_SOURCE_DIR}/include/epanet2.def PROPERTIES_HEADER_FILE_ONLY TRUE)
ENDIF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)" OR NOT MSVC)
# create build target for epanet library with python API
IF (BUILD_PY_LIB)
# exclude legacy epanet 2.0 API and include epanet py API
list(REMOVE_ITEM EPANET_LIB_ALL "src/epanet2.c")
add_library(epanet_py SHARED ${EPANET_LIB_ALL} src/epanet_py.c src/util/errormanager.c)
target_include_directories(epanet_py PUBLIC ${PROJECT_SOURCE_DIR}/include)
include(GenerateExportHeader)
GENERATE_EXPORT_HEADER(epanet_py
BASE_NAME epanet_py
EXPORT_MACRO_NAME EXPORT_PY_API
EXPORT_FILE_NAME epanet_py_export.h
STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/epanet_py_export.h
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include)
# create build target for code coverage
ELSEIF (BUILD_COVERAGE)
include(CodeCoverage)
set(CMAKE_BUILD_TYPE "Debug")
APPEND_COVERAGE_COMPILER_FLAGS()
set(CMAKE_C_FLAGS_DEBUG "-O0")
add_library(epanet2 SHARED ${EPANET_LIB_ALL})
target_include_directories(epanet2 PUBLIC ${PROJECT_SOURCE_DIR}/include)
# create build target for default epanet library with 2.0 and 2.2 API
ELSE (BUILD_PY_LIB)
# the shared library
IF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)" OR NOT MSVC)
add_library(epanet2 SHARED ${EPANET_LIB_ALL})
ELSE(TRUE)
add_library(epanet2 SHARED ${EPANET_LIB_ALL} ${PROJECT_SOURCE_DIR}/include/epanet2.def)
set_source_files_properties(${PROJECT_SOURCE_DIR}/include/epanet2.def PROPERTIES_HEADER_FILE_ONLY TRUE)
ENDIF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)" OR NOT MSVC)
target_include_directories(epanet2 PUBLIC ${PROJECT_SOURCE_DIR}/include)
ENDIF (BUILD_PY_LIB)