Skip to content

Commit dd7ff77

Browse files
authored
Merge pull request #2175 from martin-frbg/cmake-mingw-fixes
Fix CMAKE compilation with MinGW32 and add it to Appveyor
2 parents abea977 + 8fb7613 commit dd7ff77

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ if (USE_THREAD)
211211
target_link_libraries(${OpenBLAS_LIBNAME} ${CMAKE_THREAD_LIBS_INIT})
212212
endif()
213213

214-
if (MSVC OR NOT NOFORTRAN)
214+
#if (MSVC OR NOT NOFORTRAN)
215+
if (NOT NO_CBLAS)
215216
# Broken without fortran on unix
216217
add_subdirectory(utest)
217218
endif()

appveyor.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ environment:
3535
DYNAMIC_ARCH: ON
3636
WITH_FORTRAN: no
3737
- COMPILER: cl
38-
38+
- COMPILER: MinGW64-gcc-7.2.0-mingw
39+
DYNAMIC_ARCH: OFF
40+
WITH_FORTRAN: ignore
41+
- COMPILER: MinGW64-gcc-7.2.0
42+
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
43+
COMPILER: MinGW-gcc-5.3.0
44+
WITH_FORTRAN: ignore
45+
3946
install:
4047
- if [%COMPILER%]==[clang-cl] call %CONDA_INSTALL_LOCN%\Scripts\activate.bat
4148
- if [%COMPILER%]==[clang-cl] conda config --add channels conda-forge --force
@@ -52,7 +59,14 @@ install:
5259
before_build:
5360
- ps: if (-Not (Test-Path .\build)) { mkdir build }
5461
- cd build
62+
- set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
63+
- if [%COMPILER%]==[MinGW-gcc-5.3.0] set PATH=C:\MinGW\bin;C:\msys64\usr\bin;C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
64+
- if [%COMPILER%]==[MinGW64-gcc-7.2.0-mingw] set PATH=C:\MinGW\bin;C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
65+
- if [%COMPILER%]==[MinGW64-gcc-7.2.0] set PATH=C:\msys64\usr\bin;C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
5566
- if [%COMPILER%]==[cl] cmake -G "Visual Studio 15 2017 Win64" ..
67+
- if [%COMPILER%]==[MinGW64-gcc-7.2.0-mingw] cmake -G "MinGW Makefiles" -DNOFORTRAN=1 ..
68+
- if [%COMPILER%]==[MinGW64-gcc-7.2.0] cmake -G "MSYS Makefiles" -DBINARY=32 -DNOFORTRAN=1 ..
69+
- if [%COMPILER%]==[MinGW-gcc-5.3.0] cmake -G "MSYS Makefiles" -DNOFORTRAN=1 ..
5670
- if [%WITH_FORTRAN%]==[no] cmake -G "Ninja" -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DMSVC_STATIC_CRT=ON ..
5771
- if [%WITH_FORTRAN%]==[yes] cmake -G "Ninja" -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_Fortran_COMPILER=flang -DBUILD_WITHOUT_LAPACK=no -DNOFORTRAN=0 ..
5872
- if [%DYNAMIC_ARCH%]==[ON] cmake -DDYNAMIC_ARCH=ON -DDYNAMIC_LIST='CORE2;NEHALEM;SANDYBRIDGE;BULLDOZER;HASWELL' ..
@@ -64,3 +78,4 @@ test_script:
6478
- echo Running Test
6579
- cd utest
6680
- openblas_utest
81+

cmake/arch.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ if (DYNAMIC_ARCH)
8181
endif ()
8282

8383
if (NOT DYNAMIC_CORE)
84-
unset(DYNAMIC_ARCH)
84+
message (STATUS "DYNAMIC_ARCH is not supported on this architecture, removing from options")
85+
unset(DYNAMIC_ARCH CACHE)
8586
endif ()
8687
endif ()
8788

cmake/prebuild.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ set(FU "")
5959
if (APPLE OR (MSVC AND NOT ${CMAKE_C_COMPILER_ID} MATCHES "Clang"))
6060
set(FU "_")
6161
endif()
62+
if(MINGW AND NOT MINGW64)
63+
set(FU "_")
64+
endif()
6265

6366
set(COMPILER_ID ${CMAKE_C_COMPILER_ID})
6467
if (${COMPILER_ID} STREQUAL "GNU")
@@ -82,6 +85,11 @@ endif ()
8285
# f_check
8386
if (NOT NOFORTRAN)
8487
include("${PROJECT_SOURCE_DIR}/cmake/f_check.cmake")
88+
else ()
89+
file(APPEND ${TARGET_CONF_TEMP}
90+
"#define BUNDERSCORE _\n"
91+
"#define NEEDBUNDERSCORE 1\n")
92+
set(BU "_")
8593
endif ()
8694

8795
# Cannot run getarch on target if we are cross-compiling

cmake/system.cmake

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ if (X86_64)
7070
set(GETARCH_FLAGS "${GETARCH_FLAGS} -march=native")
7171
endif ()
7272

73+
# On x86 no AVX support is available
74+
if (X86 OR X86_64)
75+
if ((DEFINED BINARY AND BINARY EQUAL 32) OR ("$CMAKE_SIZEOF_VOID_P}" EQUAL "4"))
76+
set(GETARCH_FLAGS "${GETARCH_FLAGS} -DNO_AVX -DNO_AVX2 -DNO_AVX512")
77+
endif ()
78+
endif ()
79+
7380
if (INTERFACE64)
7481
message(STATUS "Using 64-bit integers.")
7582
set(GETARCH_FLAGS "${GETARCH_FLAGS} -DUSE64BITINT")
@@ -148,7 +155,9 @@ else()
148155
endif ()
149156

150157
include("${PROJECT_SOURCE_DIR}/cmake/prebuild.cmake")
151-
158+
if (DEFINED BINARY)
159+
message(STATUS "Compiling a ${BINARY}-bit binary.")
160+
endif ()
152161
if (NOT DEFINED NEED_PIC)
153162
set(NEED_PIC 1)
154163
endif ()
@@ -165,6 +174,9 @@ include("${PROJECT_SOURCE_DIR}/cmake/cc.cmake")
165174
if (NOT NOFORTRAN)
166175
# Fortran Compiler dependent settings
167176
include("${PROJECT_SOURCE_DIR}/cmake/fc.cmake")
177+
else ()
178+
set(NO_LAPACK 1)
179+
set(NO_LAPACKE 1)
168180
endif ()
169181

170182
if (BINARY64)
@@ -190,9 +202,14 @@ if (NEED_PIC)
190202
endif ()
191203

192204
if (DYNAMIC_ARCH)
193-
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_ARCH")
194-
if (DYNAMIC_OLDER)
195-
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_OLDER")
205+
if (X86 OR X86_64 OR ARM64 OR PPC)
206+
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_ARCH")
207+
if (DYNAMIC_OLDER)
208+
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_OLDER")
209+
endif ()
210+
else ()
211+
unset (DYNAMIC_ARCH)
212+
message (STATUS "DYNAMIC_ARCH is not supported on the target architecture, removing")
196213
endif ()
197214
endif ()
198215

0 commit comments

Comments
 (0)