From 8bac44b12defe30909845059b5e4a11f604cb961 Mon Sep 17 00:00:00 2001 From: Joris Gillis Date: Mon, 27 Feb 2023 13:28:18 +0100 Subject: [PATCH] Adding worhp --- CMakeLists.txt | 1 + worhp/CMakeLists.txt | 75 +++++++++++++++++++++++++++++++ worhp/cmake/worhp-config.cmake.in | 4 ++ worhp/include/worhp.h | 61 +++++++++++++++++++++++++ worhp/src/worhp.cpp | 16 +++++++ 5 files changed, 157 insertions(+) create mode 100644 worhp/CMakeLists.txt create mode 100644 worhp/cmake/worhp-config.cmake.in create mode 100644 worhp/include/worhp.h create mode 100644 worhp/src/worhp.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c5ee9b4..e79c67a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,3 +6,4 @@ add_subdirectory(octave) add_subdirectory(knitro) add_subdirectory(cplex) add_subdirectory(gurobi) +add_subdirectory(worhp) diff --git a/worhp/CMakeLists.txt b/worhp/CMakeLists.txt new file mode 100644 index 0000000..92679b6 --- /dev/null +++ b/worhp/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 3.10) + +project(worhp + LANGUAGES CXX) + +set(INSTALL_PREFIX "") + +get_directory_property(hasParent PARENT_DIRECTORY) +if(hasParent) + set(INSTALL_PREFIX "${PROJECT_NAME}/") +endif() + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + +add_library(worhp SHARED src/worhp.cpp include/worhp.h) + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(NBITS_TWO "32") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(NBITS_TWO "64") +endif() + +set(ARCHIVE_DIR lib) +set(RUNTIME_DIR bin) + +if(${CMAKE_GENERATOR} MATCHES "Visual Studio*") + set(ARCHIVE_DIR extern/lib/win${NBITS_TWO}/microsoft) + set(RUNTIME_DIR bin/win${NBITS_TWO}) +elseif(${CMAKE_GENERATOR} MATCHES "MSYS Makefiles") + set(ARCHIVE_DIR extern/lib/win${NBITS_TWO}/mingw${NBITS_TWO}) + set(RUNTIME_DIR bin/win${NBITS_TWO}) +endif() + +install(TARGETS ${LIBRARY_NAME} EXPORT worhpTargets + LIBRARY DESTINATION ${INSTALL_PREFIX}lib + ARCHIVE DESTINATION ${INSTALL_PREFIX}${ARCHIVE_DIR} + RUNTIME DESTINATION ${INSTALL_PREFIX}${RUNTIME_DIR}) + + +install(TARGETS worhp EXPORT worhpTargets + LIBRARY DESTINATION ${INSTALL_PREFIX}lib + ARCHIVE DESTINATION ${INSTALL_PREFIX}lib + RUNTIME DESTINATION ${INSTALL_PREFIX}bin + INCLUDES DESTINATION ${INSTALL_PREFIX}include) + +target_include_directories(worhp PUBLIC + $ + $ +) + +install(DIRECTORY include/ DESTINATION ${INSTALL_PREFIX}include) + +install(EXPORT worhpTargets + FILE worhpTargets.cmake + NAMESPACE worhp:: + DESTINATION cmake +) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/worhpConfigVersion.cmake + VERSION 13.1 + COMPATIBILITY SameMajorVersion +) + +configure_package_config_file( + "${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in" + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" + INSTALL_DESTINATION + cmake) + + + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/worhpConfigVersion.cmake" + DESTINATION cmake +) diff --git a/worhp/cmake/worhp-config.cmake.in b/worhp/cmake/worhp-config.cmake.in new file mode 100644 index 0000000..9c15f36 --- /dev/null +++ b/worhp/cmake/worhp-config.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/worhp/include/worhp.h b/worhp/include/worhp.h new file mode 100644 index 0000000..4da6278 --- /dev/null +++ b/worhp/include/worhp.h @@ -0,0 +1,61 @@ +#ifndef WORHP_H__ +#define WORHP_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_MSC_VER) || (_MSC_VER >= 1800) +#include +#endif + +typedef struct _OptVar OptVar; +typedef struct _Workspace Workspace; +typedef struct _Params Params; +typedef struct _Control Control; + +typedef void (*worhp_print_t) (int mode, const char s[]); + +typedef enum { + WORHP_BOOL_T, + WORHP_CUSTOM_T, + WORHP_DOUBLE_T, + WORHP_INT_T, + WORHP_NO_T, + WORHP_SINGLE_T, + WORHP_SIZE_T, + WORHP_CONST_C_STRING_T +} WorhpType; + +int CheckWorhpVersion(int, int, const char *); +/*/ U CheckWorhpVersion@@WORHP_1.0*/ +void SetWorhpPrint(worhp_print_t); +/* U SetWorhpPrint@@WORHP_1.0*/ +void WorhpFidif(OptVar*, Workspace*, Params*, Control*); +/* U WorhpFidif@@WORHP_1.0*/ +void WorhpFree(OptVar*, Workspace*, Params*, Control*); +/* U WorhpFree@@WORHP_1.0*/ +int WorhpGetParamCount(void); +/* U WorhpGetParamCount@@WORHP_1.2*/ +const char* WorhpGetParamName(int); +/* U WorhpGetParamName@@WORHP_1.2*/ +WorhpType WorhpGetParamType(int); +/* U WorhpGetParamType@@WORHP_1.2*/ +void WorhpInit(OptVar*, Workspace*, Params*, Control*); +/* U WorhpInit@@WORHP_1.0*/ +void WorhpPreInit(OptVar *, Workspace *, Params *, Control *); +/* U WorhpPreInit@@WORHP_1.0*/ +bool WorhpSetBoolParam (Params *, const char*, bool); +/* U WorhpSetBoolParam@@WORHP_1.2*/ +bool WorhpSetDoubleParam(Params *, const char*, double); +/* U WorhpSetDoubleParam@@WORHP_1.2*/ +bool WorhpSetIntParam (Params *, const char*, int); +/* U WorhpSetIntParam@@WORHP_1.2*/ +void Worhp(OptVar*, Workspace*, Params*, Control*); +/* U Worhp@@WORHP_1.0*/ + +#ifdef __cplusplus +} +#endif + +#endif // WORHP_H__ diff --git a/worhp/src/worhp.cpp b/worhp/src/worhp.cpp new file mode 100644 index 0000000..e2d6437 --- /dev/null +++ b/worhp/src/worhp.cpp @@ -0,0 +1,16 @@ +#include "worhp.h" + +int CheckWorhpVersion(int, int, const char *) { return 0; } +void SetWorhpPrint(worhp_print_t) {} +void WorhpFidif(OptVar*, Workspace*, Params*, Control*) {} +void WorhpFree(OptVar*, Workspace*, Params*, Control*) {} +int WorhpGetParamCount(void) { return 0; } +const char* WorhpGetParamName(int) { return ""; } +WorhpType WorhpGetParamType(int) { return WORHP_NO_T; } +void WorhpInit(OptVar*, Workspace*, Params*, Control*) {} +void WorhpPreInit(OptVar *, Workspace *, Params *, Control *) {} +bool WorhpSetBoolParam (Params *, const char*, bool) { return 0; } +bool WorhpSetDoubleParam(Params *, const char*, double) { return 0; } +bool WorhpSetIntParam (Params *, const char*, int) { return 0; } +void Worhp(OptVar*, Workspace*, Params*, Control*) {} +