Skip to content

Commit

Permalink
build: changes to CMake files for more recent Intel Fortran on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
smwesten-usgs committed Jul 31, 2020
1 parent b128136 commit 94c42e8
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 21 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ message("Processing top-level CMakelists.txt for project swb2")

set(SWB_MAJOR_VERSION "2")
set(SWB_MINOR_VERSION "0")
set(SWB_PATCH_VERSION "1")
set(SWB_LATEST_VERSION_TAG "v2.0.1")
set(SWB_PATCH_VERSION "2")
set(SWB_LATEST_VERSION_TAG "v2.0.2")

#------------------------------------------------------------------------------------#
# Force out-of-source build
Expand All @@ -26,13 +26,13 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)

# try to have CMake find static libraries if possible
set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" ${CMAKE_FIND_LIBRARY_PREFIXES})

if ( CMAKE_HOST_WIN32 )
set( OUTPUT_BIN_TARGET_DIR win_x64 )
if ( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" )
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" )
add_definitions(/D_CRT_SECURE_NO_DEPRECATE /DWIN32_LEAN_AND_MEAN)
message("==> Set library suffixes to .lib")
endif()
elseif( CMAKE_HOST_APPLE )
set( OUTPUT_BIN_TARGET_DIR macOS )
Expand Down
1 change: 0 additions & 1 deletion build/win_x64/gfortran/run_cmake_mingw_gfortran.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@echo off
:: remove existing Cmake cache and directories
del /F /Q CMakeCache.*
rmdir /S /Q CMakeFiles
Expand Down
20 changes: 8 additions & 12 deletions build/win_x64/ifort/run_cmake_ifort.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@echo off
:: remove existing Cmake cache and directories
del /F /Q CMakeCache.*
rmdir /S /Q CMakeFiles
Expand All @@ -15,17 +14,14 @@ del /S /Q *.vcxproj*
del /S /Q *.cmake

:: set CMAKE-related and build-related variables
set CMAKEROOT=C:\Program Files\CMake\
set Fortran_COMPILER_NAME=ifort
set CMAKE_C_COMPILER=icl
set CMAKEROOT="C:\Program Files\CMake\"
set Fortran_COMPILER_NAME="ifort"
set CMAKE_C_COMPILER="icl"
set VERBOSE=0
set MAKE_EXECUTABLE_NAME=nmake

:: clunky, clunky, clunky: last-ditch effort to get CMake to find the netCDF libraries
set LIBRARY_PATH="C:\Program Files\netCDF 4.6.3\lib"

echo "LIBRARY_PATH:"
echo %LIBRARY_PATH%
set LIBRARY_PATH="C:\Program Files\netCDF 4.7.4\lib"

:: define other variables for use in the CMakeList.txt file
:: options are "Release", "Profile" or "Debug"
Expand All @@ -42,13 +38,13 @@ set CMAKE_C_FLAGS_RELEASE="/O2 /QxHost /MT"
:: set the type of CMAKE OUTPUT to generate
set CMAKE_OUTPUT="NMake Makefiles"

for %%i in (%CMAKE_OUTPUT%) do (
::for %%i in (%CMAKE_OUTPUT%) do (

echo "Running CMake for target %%i"
cmake ..\..\.. -G %%i ^
-DLD_LIBRARY_PATH=%LIBRARY_PATH% ^
cmake ..\..\.. -G "NMake Makefiles" ^
-DCMAKE_Fortran_COMPILER=%Fortran_COMPILER_NAME% ^
-DCMAKE_C_COMPILER=%CMAKE_C_COMPILER% ^
-DLIBRARY_PATH=%LIBRARY_PATH% ^
-DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^
-DCMAKE_INSTALL_PREFIX:PATH=%INSTALL_PREFIX% ^
-DCMAKE_Fortran_FLAGS_DEBUG=%CMAKE_Fortran_FLAGS_DEBUG% ^
Expand All @@ -59,4 +55,4 @@ cmake ..\..\.. -G %%i ^
-DCMAKE_C_FLAGS_PROFILE=%CMAKE_C_FLAGS_PROFILE% ^
-DCMAKE_C_FLAGS_RELEASE=%CMAKE_C_FLAGS_RELEASE%

)
::)
2 changes: 1 addition & 1 deletion cmake/FindHDF5.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
find_library(HDF5_LIBRARY
NAMES libhdf5 hdf5
HINTS ENV LD_LIBRARY_PATH ENV HDF5_DIR /usr "d:/MinGW64" "c:/Program Files"
PATHS ENV LD_LIBRARY_PATH ENV HDF5_DIR ${LIBRARY_PATH} /usr "d:/MinGW64" "c:/Program Files"
PATH_SUFFIXES lib lib/x86_64-linux-gnu/ local/lib/ local/lib64 x86_64-w64-mingw32/lib lib/x86_64-linux-gnu/hdf5/serial/ "netCDF"
DOC "hdf5 library"
NO_DEFAULT_PATH
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindHDF5_HL.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
find_library(HDF5_HL_LIBRARY
NAMES hdf5_hl libhdf5_hl libhdf5_serial_hl
PATHS ENV LD_LIBRARY_PATH ENV HDF5_DIR /usr "d:/MinGW64" "c:/Program Files"
PATHS ENV LD_LIBRARY_PATH ENV HDF5_DIR ${LIBRARY_PATH} /usr "d:/MinGW64" "c:/Program Files"
PATH_SUFFIXES lib lib/x86_64-linux-gnu/ local/lib/ local/lib64 x86_64-w64-mingw32/lib lib/x86_64-linux-gnu/hdf5/serial/ "netCDF"
DOC "hdf5_hl library")

Expand Down
2 changes: 1 addition & 1 deletion cmake/FindNetCDF.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
find_library(NETCDF_LIBRARY
NAMES netcdf libnetcdf
PATHS ENV LD_LIBRARY_PATH ENV NETCDF_DIR /usr "c:/MinGW64" "c:/Program Files"
PATHS ENV LD_LIBRARY_PATH ENV NETCDF_DIR ${LIBRARY_PATH} /usr "c:/MinGW64" "c:/Program Files"
PATH_SUFFIXES lib lib64 lib/x86_64-linux-gnu/ local/lib/ local/lib64 x86_64-w64-mingw32/lib "NetCDF"
DOC "netcdf library")

Expand Down
2 changes: 1 addition & 1 deletion cmake/FindZlib.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
find_library(ZLIB_LIBRARY
NAMES zlib.a libz.a zlibstatic.lib z zlib libz
HINTS ${LD_LIBRARY_PATH} /usr/local/opt/zlib /usr "c:/MinGW64" "c:/Program Files"
PATHS ${LD_LIBRARY_PATH} /usr/local/opt/zlib ${LIBRARY_PATH} /usr "c:/MinGW64" "c:/Program Files"
PATH_SUFFIXES lib lib/x86_64-linux-gnu/ local/lib/ local/lib64 x86_64-w64-mingw32/lib "NetCDF"
DOC "zlib library")

Expand Down
3 changes: 2 additions & 1 deletion cmake/print_summary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ message( " ")
message("CMAKE_HOST_WIN32: " ${CMAKE_HOST_WIN32})
message("CMAKE_HOST_APPLE: " ${CMAKE_HOST_APPLE})
message("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
message("Fortran compiler: " ${Fortran_COMPILER_NAME})
message("Fortran compiler : " ${Fortran_COMPILER_NAME})
message("Fortran compiler ID : " ${CMAKE_Fortran_COMPILER_ID})
message("CMAKE Fortran flags (Debug): " ${CMAKE_Fortran_FLAGS_DEBUG})
message("CMAKE Fortran flags (Profile): " ${CMAKE_Fortran_FLAGS_PROFILE})
message("CMAKE Fortran flags (Release): " ${CMAKE_Fortran_FLAGS_RELEASE})
Expand Down

0 comments on commit 94c42e8

Please sign in to comment.