Skip to content

Commit ed45734

Browse files
committed
CMake: Make sure to find OpenMP dependency before usage.
cmake will throw an error if OpenMP::OpenMP_C or OpenMP::OpenMP_Fortran were not found first. see: msys2/MINGW-packages#24616
1 parent b494505 commit ed45734

File tree

11 files changed

+40
-36
lines changed

11 files changed

+40
-36
lines changed

.github/workflows/apple_m.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
-DUSE_OPENMP=${{matrix.openmp}} \
105105
-DOpenMP_Fortran_LIB_NAMES=omp \
106106
-DINTERFACE64=${{matrix.ilp64}} \
107-
-DNOFORTRAN=0 \
107+
-DNOFORTRAN=OFF \
108108
-DBUILD_WITHOUT_LAPACK=0 \
109109
-DCMAKE_VERBOSE_MAKEFILE=ON \
110110
-DCMAKE_BUILD_TYPE=Release \

.github/workflows/arm64_graviton.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
"cmake")
9494
mkdir build && cd build
9595
cmake -DDYNAMIC_ARCH=1 \
96-
-DNOFORTRAN=0 \
96+
-DNOFORTRAN=OFF \
9797
-DBUILD_WITHOUT_LAPACK=0 \
9898
-DCMAKE_VERBOSE_MAKEFILE=ON \
9999
-DCMAKE_BUILD_TYPE=Release \

.github/workflows/codspeed-bench.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
"cmake")
106106
mkdir build && cd build
107107
cmake -DDYNAMIC_ARCH=1 \
108-
-DNOFORTRAN=0 \
108+
-DNOFORTRAN=OFF \
109109
-DBUILD_WITHOUT_LAPACK=0 \
110110
-DCMAKE_VERBOSE_MAKEFILE=ON \
111111
-DCMAKE_BUILD_TYPE=Release \

.github/workflows/dynamic_arch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
"cmake")
108108
mkdir build && cd build
109109
cmake -DDYNAMIC_ARCH=1 \
110-
-DNOFORTRAN=0 \
110+
-DNOFORTRAN=OFF \
111111
-DBUILD_WITHOUT_LAPACK=0 \
112112
-DCMAKE_VERBOSE_MAKEFILE=ON \
113113
-DCMAKE_BUILD_TYPE=Release \

.github/workflows/harmonyos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ jobs:
3232
run: |
3333
mkdir build && cd build
3434
${{ env.OHOS_NDK_CMAKE }} ${{ env.COMMON_CMAKE_OPTIONS }} -DOHOS_ARCH="arm64-v8a" \
35-
-DTARGET=ARMV8 -DNOFORTRAN=1 ..
35+
-DTARGET=ARMV8 -DNOFORTRAN=ON ..
3636
${{ env.OHOS_NDK_CMAKE }} --build . -j $(nproc)
3737

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ matrix:
211211
# - CMAKE=1
212212
# - <<: *test-cmake
213213
# env:
214-
# - CMAKE=1 CMAKE_ARGS="-DNOFORTRAN=1"
214+
# - CMAKE=1 CMAKE_ARGS="-DNOFORTRAN=ON"
215215
# - <<: *test-cmake
216216
# compiler: gcc
217217
# env:

appveyor.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ before_build:
6262
- 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%
6363
- if [%COMPILER%]==[MinGW-gcc-6.3.0-32] set PATH=C:\msys64\usr\bin;C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw64\bin;%PATH%
6464
- if [%COMPILER%]==[cl] cmake -G "Visual Studio 15 2017 Win64" ..
65-
- if [%COMPILER%]==[MinGW64-gcc-7.2.0-mingw] cmake -G "MinGW Makefiles" -DNOFORTRAN=1 ..
66-
- if [%COMPILER%]==[MinGW-gcc-6.3.0-32] cmake -G "MSYS Makefiles" -DNOFORTRAN=1 ..
67-
- if [%COMPILER%]==[MinGW-gcc-5.3.0] cmake -G "MSYS Makefiles" -DNOFORTRAN=1 ..
65+
- if [%COMPILER%]==[MinGW64-gcc-7.2.0-mingw] cmake -G "MinGW Makefiles" -DNOFORTRAN=ON ..
66+
- if [%COMPILER%]==[MinGW-gcc-6.3.0-32] cmake -G "MSYS Makefiles" -DNOFORTRAN=ON ..
67+
- if [%COMPILER%]==[MinGW-gcc-5.3.0] cmake -G "MSYS Makefiles" -DNOFORTRAN=ON ..
6868
- if [%WITH_FORTRAN%]==[OFF] cmake -G "Ninja" -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_MT=mt -DMSVC_STATIC_CRT=ON ..
69-
- if [%WITH_FORTRAN%]==[ON] cmake -G "Ninja" -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_Fortran_COMPILER=flang -DCMAKE_MT=mt -DBUILD_WITHOUT_LAPACK=no -DNOFORTRAN=0 ..
69+
- if [%WITH_FORTRAN%]==[ON] cmake -G "Ninja" -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_Fortran_COMPILER=flang -DCMAKE_MT=mt -DBUILD_WITHOUT_LAPACK=no -DNOFORTRAN=OFF ..
7070
- if [%USE_OPENMP%]==[ON] cmake -DUSE_OPENMP=ON ..
7171
- if [%DYNAMIC_ARCH%]==[ON] cmake -DDYNAMIC_ARCH=ON -DDYNAMIC_LIST='CORE2;NEHALEM;SANDYBRIDGE;BULLDOZER;HASWELL' ..
7272

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
112112
mkdir build
113113
cd build
114-
cmake -G "Ninja" -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_MT=mt -DCMAKE_BUILD_TYPE=Release -DNOFORTRAN=1 -DMSVC_STATIC_CRT=ON ..
114+
cmake -G "Ninja" -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_MT=mt -DCMAKE_BUILD_TYPE=Release -DNOFORTRAN=ON -DMSVC_STATIC_CRT=ON ..
115115
cmake --build . --config Release
116116
ctest
117117
@@ -215,7 +215,7 @@ jobs:
215215
brew install llvm libomp
216216
mkdir build
217217
cd build
218-
cmake -DTARGET=CORE2 -DUSE_OPENMP=1 -DINTERFACE64=1 -DDYNAMIC_ARCH=1 -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DNOFORTRAN=1 -DNO_AVX512=1 ..
218+
cmake -DTARGET=CORE2 -DUSE_OPENMP=1 -DINTERFACE64=1 -DDYNAMIC_ARCH=1 -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DNOFORTRAN=ON -DNO_AVX512=1 ..
219219
make
220220
ctest
221221

cmake/OpenBLASConfig.cmake.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,17 @@
4848

4949
set(PN OpenBLAS)
5050

51+
include(CMakeFindDependencyMacro)
52+
5153
# need to check that the @USE_*@ evaluate to something cmake can perform boolean logic upon
5254
if(@USE_OPENMP@)
5355
set(${PN}_openmp_FOUND 1)
56+
enable_language(C)
57+
find_dependency(OpenMP COMPONENTS C REQUIRED)
58+
if(NOT @NOFORTRAN@)
59+
enable_language(Fortran)
60+
find_package(OpenMP COMPONENTS Fortran REQUIRED)
61+
endif()
5462
elseif(@USE_THREAD@)
5563
set(${PN}_pthread_FOUND 1)
5664
else()

cmake/f_check.cmake

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@ check_language(Fortran)
2525
if(CMAKE_Fortran_COMPILER)
2626
enable_language(Fortran)
2727
else()
28-
set (NOFORTRAN 1)
28+
set(NOFORTRAN ON)
2929
if (NOT NO_LAPACK)
30-
if (NOT XXXXX)
31-
message(STATUS "No Fortran compiler found, can build only BLAS and f2c-converted LAPACK")
32-
set(C_LAPACK 1)
33-
if (INTERFACE64)
34-
set (CCOMMON_OPT "${CCOMMON_OPT} -DLAPACK_ILP64")
35-
endif ()
36-
set(TIMER "NONE")
37-
else ()
38-
message(STATUS "No Fortran compiler found, can build only BLAS")
39-
endif()
30+
message(STATUS "No Fortran compiler found, can build only BLAS and f2c-converted LAPACK")
31+
set(C_LAPACK 1)
32+
if (INTERFACE64)
33+
set (CCOMMON_OPT "${CCOMMON_OPT} -DLAPACK_ILP64")
34+
endif ()
35+
set(TIMER "NONE")
4036
endif()
4137
endif()
4238

@@ -46,18 +42,18 @@ if (NOT ONLY_CBLAS)
4642
# TODO: detect whether underscore needed, set #defines and BU appropriately - use try_compile
4743
# TODO: set FEXTRALIB flags a la f_check?
4844
if (NOT (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND x${CMAKE_Fortran_COMPILER_ID} MATCHES "IntelLLVM"))
49-
set(BU "_")
50-
file(APPEND ${TARGET_CONF_TEMP}
51-
"#define BUNDERSCORE _\n"
52-
"#define NEEDBUNDERSCORE 1\n"
53-
"#define NEED2UNDERSCORES 0\n")
45+
set(BU "_")
46+
file(APPEND ${TARGET_CONF_TEMP}
47+
"#define BUNDERSCORE _\n"
48+
"#define NEEDBUNDERSCORE 1\n"
49+
"#define NEED2UNDERSCORES 0\n")
5450
else ()
55-
set (FCOMMON_OPT "${FCOMMON_OPT} /fp:precise /recursive /names:lowercase /assume:nounderscore")
51+
set (FCOMMON_OPT "${FCOMMON_OPT} /fp:precise /recursive /names:lowercase /assume:nounderscore")
5652
endif()
5753
else ()
5854

59-
#When we only build CBLAS, we set NOFORTRAN=2
60-
set(NOFORTRAN 2)
55+
#When we only build CBLAS, we set NOFORTRAN=ON
56+
set(NOFORTRAN ON)
6157
set(NO_FBLAS 1)
6258
#set(F_COMPILER GFORTRAN) # CMake handles the fortran compiler
6359
set(BU "_")
@@ -67,6 +63,6 @@ else ()
6763
endif()
6864

6965
if (CMAKE_Fortran_COMPILER)
70-
get_filename_component(F_COMPILER ${CMAKE_Fortran_COMPILER} NAME_WE)
71-
string(TOUPPER ${F_COMPILER} F_COMPILER)
66+
get_filename_component(F_COMPILER ${CMAKE_Fortran_COMPILER} NAME_WE)
67+
string(TOUPPER ${F_COMPILER} F_COMPILER)
7268
endif()

docs/install.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ newer installed.
270270
set "CPATH=%CONDA_PREFIX%\Library\include;%CPATH%"
271271
mkdir build
272272
cd build
273-
cmake .. -G "Ninja" -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_Fortran_COMPILER=flang -DCMAKE_MT=mt -DBUILD_WITHOUT_LAPACK=no -DNOFORTRAN=0 -DDYNAMIC_ARCH=ON -DCMAKE_BUILD_TYPE=Release
273+
cmake .. -G "Ninja" -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_Fortran_COMPILER=flang -DCMAKE_MT=mt -DBUILD_WITHOUT_LAPACK=no -DNOFORTRAN=OFF -DDYNAMIC_ARCH=ON -DCMAKE_BUILD_TYPE=Release
274274
```
275275

276276
You may want to add further options in the `cmake` command here. For
@@ -736,7 +736,7 @@ contains no Fortran compiler):
736736
```bash
737737
/opt/ohos-sdk/linux/native/build-tools/cmake/bin/cmake \
738738
-DCMAKE_TOOLCHAIN_FILE=/opt/ohos-sdk/linux/native/build/cmake/ohos.toolchain.cmake \
739-
-DOHOS_ARCH="arm64-v8a" -DTARGET=ARMV8 -DNOFORTRAN=1 ..
739+
-DOHOS_ARCH="arm64-v8a" -DTARGET=ARMV8 -DNOFORTRAN=ON ..
740740
```
741741
Additional other OpenBLAS build options like `USE_OPENMP=1` or `DYNAMIC_ARCH=1`
742742
will probably work too. Finally do the build:
@@ -823,7 +823,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
823823
824824
Then build OpenBLAS with:
825825
```bash
826-
$ cmake .. -G Ninja -DCMAKE_C_COMPILER=arm-none-eabi-gcc -DCMAKE_TOOLCHAIN_FILE:PATH="toolchain.cmake" -DNOFORTRAN=1 -DTARGET=ARMV5 -DEMBEDDED=1
826+
$ cmake .. -G Ninja -DCMAKE_C_COMPILER=arm-none-eabi-gcc -DCMAKE_TOOLCHAIN_FILE:PATH="toolchain.cmake" -DNOFORTRAN=ON -DTARGET=ARMV5 -DEMBEDDED=1
827827
```
828828
829829
In your embedded application, the following functions need to be provided for OpenBLAS to work correctly:

0 commit comments

Comments
 (0)