Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support shared exodus library on windows #439

Merged
merged 3 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/seacas/libraries/exodus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ set_property(TARGET exodus PROPERTY C_STANDARD 99)

if (SEACASExodus_ENABLE_SHARED)
if (NOT BUILD_SHARED_LIBS)
TRIBITS_ADD_LIBRARY(
ADD_LIBRARY(
exodus_shared
SHARED
SOURCES ${SOURCES} ${DEP_SOURCES}
IMPORTEDLIBS ${TPL_Netcdf_LIBRARIES}
${SOURCES} ${DEP_SOURCES}
)
target_include_directories(exodus_shared PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(exodus_shared PUBLIC Netcdf::all_libs)
set_property(TARGET exodus_shared PROPERTY C_STANDARD 99)
set_target_properties(exodus_shared PROPERTIES OUTPUT_NAME exodus)
# This keeps the library out of the `all_libs` targets...
set_target_properties(exodus_shared PROPERTIES TRIBITS_TESTONLY_LIB TRUE)
set_target_properties(exodus_shared PROPERTIES RUNTIME_OUTPUT_NAME exodus)
INSTALL(TARGETS exodus_shared DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()
endif()
Expand Down
7 changes: 7 additions & 0 deletions packages/seacas/libraries/exodus/include/exodusII.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,13 @@ typedef struct ex_var_params
} ex_var_params;
/** @} */

#ifndef EXODUS_EXPORT
#if defined(_WIN32) && defined(exodus_shared_EXPORTS)
#define EXODUS_EXPORT __declspec(dllexport)
#endif
#endif /* EXODUS_EXPORT */


#ifndef EXODUS_EXPORT
#define EXODUS_EXPORT extern
#endif /* EXODUS_EXPORT */
Expand Down
34 changes: 17 additions & 17 deletions packages/seacas/scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if (${CMAKE_PROJECT_NAME} STREQUAL "Seacas")
INCLUDE(InstallSymLink)
INCLUDE(InstallSymLink)
endif()

SET( ACCESSDIR ${CMAKE_INSTALL_PREFIX} )
Expand All @@ -8,11 +8,11 @@ SET( SEPARATOR "_")
ASSERT_DEFINED(${PROJECT_NAME}_ENABLE_SEACASNemspread)
ASSERT_DEFINED(${PROJECT_NAME}_ENABLE_SEACASNemslice)
IF (${PROJECT_NAME}_ENABLE_SEACASNemspread AND ${PROJECT_NAME}_ENABLE_SEACASNemslice)
IF (${PROJECT_NAME}_ENABLE_Zoltan)
SET( DECOMP_DEFAULT rib )
ELSE()
SET( DECOMP_DEFAULT inertial )
ENDIF()
IF (${PROJECT_NAME}_ENABLE_Zoltan)
SET( DECOMP_DEFAULT rib )
ELSE()
SET( DECOMP_DEFAULT inertial )
ENDIF()

CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/decomp.in
Expand Down Expand Up @@ -73,16 +73,16 @@ TRIBITS_INCLUDE_DIRECTORIES(
SET(HEADERS "")

IF (NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
APPEND_GLOB(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/getopt.seacas.c)
ASSERT_DEFINED(${PROJECT_NAME}_ENABLE_SEACASBlot)
ASSERT_DEFINED(${PROJECT_NAME}_ENABLE_SEACASFastq)
ASSERT_DEFINED(${PROJECT_NAME}_ENABLE_SEACASEpu)
IF (${PROJECT_NAME}_ENABLE_SEACASBlot OR
${PROJECT_NAME}_ENABLE_SEACASFastq OR
${PROJECT_NAME}_ENABLE_SEACASEpu)
ADD_EXECUTABLE(getopt.seacas ${SOURCES} )
install_executable(getopt.seacas)
endif()
APPEND_GLOB(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/getopt.seacas.c)
ASSERT_DEFINED(${PROJECT_NAME}_ENABLE_SEACASBlot)
ASSERT_DEFINED(${PROJECT_NAME}_ENABLE_SEACASFastq)
ASSERT_DEFINED(${PROJECT_NAME}_ENABLE_SEACASEpu)
IF (${PROJECT_NAME}_ENABLE_SEACASBlot OR
${PROJECT_NAME}_ENABLE_SEACASFastq OR
${PROJECT_NAME}_ENABLE_SEACASEpu)
ADD_EXECUTABLE(getopt.seacas ${SOURCES} )
install_executable(getopt.seacas)
endif()
ENDIF()

ASSERT_DEFINED(${PROJECT_NAME}_ENABLE_SEACASExodus)
Expand Down Expand Up @@ -173,7 +173,7 @@ IF (${PROJECT_NAME}_ENABLE_SEACASExodus)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/exomerge2.py DESTINATION lib)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/exomerge3.py DESTINATION lib)

if (${CMAKE_PROJECT_NAME} STREQUAL "Seacas")
if (${CMAKE_PROJECT_NAME} STREQUAL "Seacas" AND NOT WIN32)
InstallSymLink(${EXODUSPY} ${CMAKE_INSTALL_PREFIX}/lib/exodus.py)
InstallSymLink(${EXOMERGE} ${CMAKE_INSTALL_PREFIX}/lib/exomerge.py)
endif()
Expand Down
17 changes: 12 additions & 5 deletions packages/seacas/scripts/exodus3.in.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,23 @@ class ex_options(Enum):
EX_NULLVERBOSE = 8


ACCESS = os.getenv('ACCESS', '@ACCESSDIR@')
if os.uname()[0] == 'Darwin':
EXODUS_SO = f"{ACCESS}/@SEACAS_LIBDIR@/libexodus.dylib"
if os.name == 'nt':
so_prefix = ''
so_suffix = 'dll'
else:
EXODUS_SO = f"{ACCESS}/@SEACAS_LIBDIR@/libexodus.so"
if os.uname()[0] == 'Darwin':
so_prefix = 'lib'
so_suffix = 'dylib'
else:
so_prefix = 'lib'
so_suffix = 'so'
pip_path = os.path.dirname(__file__)
pip_so_path = os.path.join(pip_path, "libexodus.so")
pip_so_path = os.path.join(pip_path, f"{so_prefix}exodus.{so_suffix}")
try:
EXODUS_LIB = ctypes.cdll.LoadLibrary(pip_so_path)
except Exception:
ACCESS = os.getenv('ACCESS', '@ACCESSDIR@')
EXODUS_SO = f"{ACCESS}/@SEACAS_LIBDIR@/{so_prefix}exodus.{so_suffix}"
EXODUS_LIB = ctypes.cdll.LoadLibrary(EXODUS_SO)

MAX_STR_LENGTH = 32 # match exodus default
Expand Down
Loading