Skip to content

Commit

Permalink
Attempt at rectifying msvc vs. gnu flags on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
willend committed May 18, 2024
1 parent 47a5cc4 commit 38375eb
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions cmake/Modules/PlatformDefaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,25 @@ function( detect_platform_variables resultvarname )
if ( NOT WINDOWS )
set(MPIFLAGS "-DUSE_MPI -l${MPILIB}")
else()
set(MPIFLAGS "-DUSE_MPI -l${MPILIB}")
if ( MCCODE_BUILD_CONDA_PKG )
set(MPIFLAGS "/DUSE_MPI /link /DYNAMICBASE ${MPILIB}")
else()
set(MPIFLAGS "-DUSE_MPI -l${MPILIB}")
if ( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" )
set(MPIFLAGS "/DUSE_MPI /link /DYNAMICBASE ${MPILIB}")
endif()
endif()
endif()
else()
if ( NOT WINDOWS )
set(MPILIB "mpi")
set(MPIFLAGS "-DUSE_MPI -l${MPILIB}")
else()
set(MPILIB "msmpi")
set(MPIFLAGS "-DUSE_MPI -l${MPILIB}")
if ( MCCODE_BUILD_CONDA_PKG )
set(MPILIB "msmpi.lib")
set(MPIFLAGS "/DUSE_MPI /link /DYNAMICBASE ${MPILIB}")
else()
set(MPILIB "msmpi")
set(MPIFLAGS "-DUSE_MPI -l${MPILIB}")
if ( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" )
set(MPILIB "msmpi.lib")
set(MPIFLAGS "/DUSE_MPI /link /DYNAMICBASE ${MPILIB}")
endif()
endif()
endif()
endif()
Expand All @@ -120,21 +122,23 @@ function( detect_platform_variables resultvarname )
if ( NOT WINDOWS )
set(MPIFLAGS "-Wl,-rpath,${MPILIBDIR} -L${MPILIBDIR} ${MPIFLAGS}")
else()
set(MPIFLAGS "-L${MPILIBDIR} ${MPIFLAGS}")
if ( MCCODE_BUILD_CONDA_PKG )
set(MPIFLAGS "${MPIFLAGS} /LIBPATH:${MPILIBDIR}")
else ()
set(MPIFLAGS "-L${MPILIBDIR} ${MPIFLAGS}")
if ( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" )
set(MPIFLAGS "${MPIFLAGS} /LIBPATH:${MPILIBDIR}")
endif()
endif()
endif()
endif()
if ( MPIINCLUDEDIR )
if ( NOT WINDOWS )
set(MPIFLAGS "-I${MPIINCLUDEDIR} ${MPIFLAGS}")
else()
set(MPIFLAGS "-I${MPIINCLUDEDIR} ${MPIFLAGS}")
if ( MCCODE_BUILD_CONDA_PKG )
set(MPIFLAGS "/I${MPIINCLUDEDIR} ${MPIFLAGS}")
else()
set(MPIFLAGS "-I${MPIINCLUDEDIR} ${MPIFLAGS}")
if ( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" )
set(MPIFLAGS "/I${MPIINCLUDEDIR} ${MPIFLAGS}")
endif()
endif()
endif()
endif()
Expand All @@ -151,10 +155,11 @@ function( detect_platform_variables resultvarname )
if ( NOT WINDOWS )
set(NEXUSFLAGS "-DUSE_NEXUS -lNeXus")#?? should probably have another value
else()
set(NEXUSFLAGS "-DUSE_NEXUS -lNeXus-0")
if ( MCCODE_BUILD_CONDA_PKG )
set(NEXUSFLAGS "/DUSE_NEXUS NeXus.lib")
else()
set(NEXUSFLAGS "-DUSE_NEXUS -lNeXus-0")
if ( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" )
set(NEXUSFLAGS "/DUSE_NEXUS NeXus.lib")
endif()
endif()
endif()
if ( NEXUSLIB )
Expand All @@ -172,8 +177,12 @@ function( detect_platform_variables resultvarname )
#Attempt to provide the relevant -isysroot on macOS, possibly found by cmake
set(MCCODE_CFLAGS "${MCCODE_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
endif()
if ( WINDOWS AND MCCODE_BUILD_CONDA_PKG )
set(MCCODE_CFLAGS "${MCCODE_CFLAGS} /I\$\{CONDA_PREFIX\}/Library/include /link /LIBPATH:\$\{CONDA_PREFIX\}/Library/lib")
if ( MCCODE_BUILD_CONDA_PKG )
if ( WINDOWS )
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
set(MCCODE_CFLAGS "${MCCODE_CFLAGS} /I\$\{CONDA_PREFIX\}/Library/include /link /LIBPATH:\$\{CONDA_PREFIX\}/Library/lib")
endif()
endif()
endif()
foreach( flag "-fno-PIC" "-fPIE" "-flto" "-O3" "-mtune=native" "-march=native" "-fno-math-errno" "-ftree-vectorize" "-g" "-DNDEBUG" "-D_POSIX_SOURCE" "-std=c99" "-lm")
#NB: plethora of "unset(tmp_test_c_flag_result ...)" statements below is
Expand Down

0 comments on commit 38375eb

Please sign in to comment.