From 57b084a5b344f409c30c0d4902fa995ff82e2151 Mon Sep 17 00:00:00 2001 From: David Minton Date: Tue, 22 Aug 2023 14:32:42 -0400 Subject: [PATCH] Improvements to Windows compatibility --- CMakeLists.txt | 2 +- buildscripts/build_dependencies.sh | 9 ++++----- buildscripts/get_platform.sh | 4 ++++ swiftest/CMakeLists.txt | 7 +------ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c264fc1f3..cb2aa413c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ PROJECT(swiftest VERSION ${VERSION} LANGUAGES C Fortran) OPTION(USE_COARRAY "Use Coarray Fortran for parallelization of test particles" OFF) OPTION(USE_OPENMP "Use OpenMP for parallelization" ON) OPTION(USE_SIMD "Use SIMD vectorization" ON) -OPTION(BUILD_SHARED_LIBS "Build using shared libraries" ON) +OPTION(BUILD_SHARED_LIBS "Build using shared libraries" OFF) # The following section is modified from Numpy f2py documentation IF(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) diff --git a/buildscripts/build_dependencies.sh b/buildscripts/build_dependencies.sh index d11a9f0d5..4193c3002 100755 --- a/buildscripts/build_dependencies.sh +++ b/buildscripts/build_dependencies.sh @@ -27,10 +27,9 @@ printf "* FETCHING DEPENCENCY SOURCES *\n" printf "*********************************************************\n" printf "Copying files to ${DEPENDENCY_DIR}\n" mkdir -p ${DEPENDENCY_DIR} -cd $DEPENDENCY_DIR if [ ! -d ${DEPENDENCY_DIR}/zlib-${ZLIB_VER} ]; then [ -d ${DEPENDENCY_DIR}/zlib-* ] && rm -rf ${DEPENDENCY_DIR}/zlib-* - wget -qO- https://github.com/madler/zlib/releases/download/v${ZLIB_VER}/zlib-${ZLIB_VER}.tar.gz | tar xvz + curl -s -L https://github.com/madler/zlib/releases/download/v${ZLIB_VER}/zlib-${ZLIB_VER}.tar.gz | tar xvz - -C ${DEPENDENCY_DIR} fi printf "Checking if HDF5 source exists\n" @@ -46,17 +45,17 @@ if [[ (-d ${DEPENDENCY_DIR}/hdfsrc) && (-f ${DEPENDENCY_DIR}/hdfsrc/README.md) ] fi if [ ! -d ${DEPENDENCY_DIR}/hdfsrc ]; then - wget -qO- https://github.com/HDFGroup/hdf5/releases/download/hdf5-${HDF5_VER}/hdf5-${HDF5_VER}.tar.gz | tar xvz + curl -s -L https://github.com/HDFGroup/hdf5/releases/download/hdf5-${HDF5_VER}/hdf5-${HDF5_VER}.tar.gz | tar xvz - -C ${DEPENDENCY_DIR} fi if [ ! -d ${DEPENDENCY_DIR}/netcdf-c-${NC_VER} ]; then [ -d ${DEPENDENCY_DIR}/netcdf-c-* ] && rm -rf ${DEPENDENCY_DIR}/netcdf-c-* - wget -qO- https://github.com/Unidata/netcdf-c/archive/refs/tags/v${NC_VER}.tar.gz | tar xvz + curl -s -L https://github.com/Unidata/netcdf-c/archive/refs/tags/v${NC_VER}.tar.gz | tar xvz - -C ${DEPENDENCY_DIR} fi if [ ! -d ${DEPENDENCY_DIR}/netcdf-fortran-${NF_VER} ]; then [ -d ${DEPENDENCY_DIR}/netcdf-fortran-* ] && rm -rf ${DEPENDENCY_DIR}/netcdf-fortran-* - wget -qO- https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v${NF_VER}.tar.gz | tar xvz + curl -s -L https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v${NF_VER}.tar.gz | tar xvz - -C ${DEPENDENCY_DIR} fi cd $ROOT_DIR diff --git a/buildscripts/get_platform.sh b/buildscripts/get_platform.sh index c30592d7f..4ad7d8aeb 100755 --- a/buildscripts/get_platform.sh +++ b/buildscripts/get_platform.sh @@ -21,6 +21,7 @@ OS=$(uname -s) ARCH=$(uname -m) + case $ARCH in x86_64) ;; @@ -50,6 +51,9 @@ case $OS in Darwin) OS="MacOSX" ;; + *MSYS*) + OS="Windows" + ;; *) echo "Swiftest is currently not configured to build for platform ${OS}-${ARCH}" exit 1 diff --git a/swiftest/CMakeLists.txt b/swiftest/CMakeLists.txt index 035de8acd..9a73977af 100644 --- a/swiftest/CMakeLists.txt +++ b/swiftest/CMakeLists.txt @@ -37,12 +37,7 @@ IF(USE_OPENMP OR USE_SIMD) SET_PROPERTY(TARGET ${SWIFTEST_BINDINGS} APPEND_STRING PROPERTY COMPILE_FLAGS "${OpenMP_Fortran_FLAGS} ") ENDIF() -IF (DEFINED ENV{LIBS}) - STRING(STRIP "$ENV{LIBS}" LIBS) - SEPARATE_ARGUMENTS(LIBS NATIVE_COMMAND "$LIBS") -ENDIF() - -TARGET_LINK_LIBRARIES(${SWIFTEST_BINDINGS} swiftest ${NETCDF_LIBRARIES} $LIBS) +TARGET_LINK_LIBRARIES(${SWIFTEST_BINDINGS} swiftest ${NETCDF_LIBRARIES}) PYTHON_EXTENSION_MODULE(${SWIFTEST_BINDINGS}) TARGET_INCLUDE_DIRECTORIES(${SWIFTEST_BINDINGS} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${MOD} ${NETCDF_INCLUDE_DIR}) INSTALL(TARGETS ${SWIFTEST_BINDINGS} LIBRARY DESTINATION swiftest) \ No newline at end of file