Skip to content

Commit

Permalink
Adding worhp
Browse files Browse the repository at this point in the history
  • Loading branch information
jgillis committed Feb 27, 2023
1 parent 1a46454 commit 8bac44b
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ add_subdirectory(octave)
add_subdirectory(knitro)
add_subdirectory(cplex)
add_subdirectory(gurobi)
add_subdirectory(worhp)
75 changes: 75 additions & 0 deletions worhp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${worhp_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${INSTALL_PREFIX}include>
)

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
)
4 changes: 4 additions & 0 deletions worhp/cmake/worhp-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
check_required_components("@PROJECT_NAME@")
61 changes: 61 additions & 0 deletions worhp/include/worhp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#ifndef WORHP_H__
#define WORHP_H__

#ifdef __cplusplus
extern "C" {
#endif

#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
#include <stdbool.h>
#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__
16 changes: 16 additions & 0 deletions worhp/src/worhp.cpp
Original file line number Diff line number Diff line change
@@ -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*) {}

0 comments on commit 8bac44b

Please sign in to comment.