Skip to content

Commit 2848292

Browse files
authored
Merge pull request #3299 from heplesser/fix-openmp-cmake
Allow passing OpenMP root directory to -Dwith-openmp
2 parents 36d182e + fe0476a commit 2848292

File tree

4 files changed

+38
-42
lines changed

4 files changed

+38
-42
lines changed

.github/workflows/nestbuildmatrix.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,7 @@ jobs:
798798
-Dwith-optimize=${{ contains(matrix.use, 'optimize') && 'ON' || 'OFF' }} \
799799
-Dwith-warning=${{ contains(matrix.use, 'warning') && 'ON' || 'OFF' }} \
800800
-Dwith-boost=${{ contains(matrix.use, 'boost') && 'ON' || 'OFF' }} \
801-
-Dwith-openmp=${{ contains(matrix.use, 'openmp') && 'ON' || 'OFF' }} \
802-
${{ contains(matrix.use, 'openmp') && '-DOpenMP_ROOT=$(brew --prefix libomp)' }} \
801+
-Dwith-openmp=${{ contains(matrix.use, 'openmp') && '$(brew --prefix libomp)' || 'OFF' }} \
803802
-Dwith-mpi=${{ contains(matrix.use, 'mpi') && 'ON' || 'OFF' }} \
804803
-Dwith-python=${{ contains(matrix.use, 'python') && 'ON' || 'OFF' }} \
805804
-Dwith-gsl=${{ contains(matrix.use, 'gsl') && 'ON' || 'OFF' }} \

cmake/ConfigureSummary.cmake

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,32 @@ function( NEST_PRINT_CONFIG_SUMMARY )
6262
message( "Python bindings : No" )
6363
endif ()
6464

65+
message( "" )
66+
if ( OpenMP_FOUND )
67+
message( "Use threading : Yes (OpenMP: ${OpenMP_CXX_FLAGS})" )
68+
message( " Libraries : ${OpenMP_CXX_LIBRARIES}" )
69+
else ()
70+
message( "Use threading : No" )
71+
endif ()
72+
73+
message( "" )
74+
if ( HAVE_MPI )
75+
message( "Use MPI : Yes (MPI: ${MPI_CXX_COMPILER})" )
76+
message( " Includes : ${MPI_CXX_INCLUDE_PATH}" )
77+
message( " Libraries : ${MPI_CXX_LIBRARIES}" )
78+
if ( MPI_CXX_COMPILE_FLAGS )
79+
message( " Compile Flags : ${MPI_CXX_COMPILE_FLAGS}" )
80+
endif ()
81+
if ( MPI_CXX_LINK_FLAGS )
82+
message( " Link Flags : ${MPI_CXX_LINK_FLAGS}" )
83+
endif ()
84+
set( MPI_LAUNCHER "${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} <np> ${MPIEXEC_PREFLAGS} <prog> ${MPIEXEC_POSTFLAGS} <args>" )
85+
string(REPLACE " " " " MPI_LAUNCHER ${MPI_LAUNCHER})
86+
message( " Launcher : ${MPI_LAUNCHER}")
87+
else ()
88+
message( "Use MPI : No" )
89+
endif ()
90+
6591
message( "" )
6692
if ( BUILD_DOCS )
6793
message( "Documentation : Yes" )
@@ -85,13 +111,6 @@ function( NEST_PRINT_CONFIG_SUMMARY )
85111
message( "Documentation : No" )
86112
endif ()
87113

88-
message( "" )
89-
if ( OPENMP_FOUND )
90-
message( "Use threading : Yes (OpenMP: ${OpenMP_CXX_FLAGS})" )
91-
message( " Libraries : ${OpenMP_CXX_LIBRARIES}" )
92-
else ()
93-
message( "Use threading : No" )
94-
endif ()
95114

96115
message( "" )
97116
if ( HAVE_GSL )
@@ -125,24 +144,6 @@ function( NEST_PRINT_CONFIG_SUMMARY )
125144
endif ()
126145
endif ()
127146

128-
message( "" )
129-
if ( HAVE_MPI )
130-
message( "Use MPI : Yes (MPI: ${MPI_CXX_COMPILER})" )
131-
message( " Includes : ${MPI_CXX_INCLUDE_PATH}" )
132-
message( " Libraries : ${MPI_CXX_LIBRARIES}" )
133-
if ( MPI_CXX_COMPILE_FLAGS )
134-
message( " Compile Flags : ${MPI_CXX_COMPILE_FLAGS}" )
135-
endif ()
136-
if ( MPI_CXX_LINK_FLAGS )
137-
message( " Link Flags : ${MPI_CXX_LINK_FLAGS}" )
138-
endif ()
139-
set( MPI_LAUNCHER "${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} <np> ${MPIEXEC_PREFLAGS} <prog> ${MPIEXEC_POSTFLAGS} <args>" )
140-
string(REPLACE " " " " MPI_LAUNCHER ${MPI_LAUNCHER})
141-
message( " Launcher : ${MPI_LAUNCHER}")
142-
else ()
143-
message( "Use MPI : No" )
144-
endif ()
145-
146147
message( "" )
147148
if ( TIMER_DETAILED )
148149
message( "Detailed timers : Yes" )

cmake/FindSIONlib.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ if ( NOT SIONLIB_CONFIG STREQUAL "SIONLIB_CONFIG-NOTFOUND" )
5757
# get arguments for sionconfig --cflags and --libs
5858
set( CONF_FLAGS "--cxx" ) # we use cxx
5959
# find parallelization
60-
if ( OPENMP_FOUND AND MPI_CXX_FOUND )
60+
if ( OpenMP_FOUND AND MPI_CXX_FOUND )
6161
set( CONF_FLAGS ${CONF_FLAGS} "--ompi" )
62-
elseif ( OPENMP_FOUND )
62+
elseif ( OpenMP_FOUND )
6363
set( CONF_FLAGS ${CONF_FLAGS} "--omp" )
6464
elseif ( MPI_CXX_FOUND )
6565
set( CONF_FLAGS ${CONF_FLAGS} "--mpi" )
@@ -70,7 +70,6 @@ if ( NOT SIONLIB_CONFIG STREQUAL "SIONLIB_CONFIG-NOTFOUND" )
7070
set( CONF_FLAGS ${CONF_FLAGS} "--gcc" )
7171
endif ()
7272

73-
7473
# use sionconfig to get --cflags
7574
execute_process(
7675
COMMAND ${SIONLIB_CONFIG} ${CONF_FLAGS} --cflags

cmake/ProcessOptions.cmake

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -382,20 +382,17 @@ endfunction()
382382

383383
function( NEST_PROCESS_WITH_OPENMP )
384384
# Find OPENMP
385-
if ( with-openmp )
385+
if ( NOT "${with-openmp}" STREQUAL "OFF" )
386386
if ( NOT "${with-openmp}" STREQUAL "ON" )
387-
printInfo( "Set OpenMP argument: ${with-openmp}")
388-
# set variables in this scope
389-
set( OPENMP_FOUND ON )
390-
set( OpenMP_C_FLAGS "${with-openmp}" )
391-
set( OpenMP_CXX_FLAGS "${with-openmp}" )
392-
set( OpenMP_CXX_LIBRARIES "${with-openmp}" )
393-
else ()
394-
find_package( OpenMP )
387+
# if set, use this prefix
388+
set( OpenMP_ROOT "${with-openmp}" )
395389
endif ()
396-
if ( OPENMP_FOUND )
390+
391+
find_package( OpenMP REQUIRED )
392+
393+
if ( OpenMP_FOUND )
397394
# export found variables to parent scope
398-
set( OPENMP_FOUND "${OPENMP_FOUND}" PARENT_SCOPE )
395+
set( OpenMP_FOUND "${OpenMP_FOUND}" PARENT_SCOPE )
399396
set( OpenMP_C_FLAGS "${OpenMP_C_FLAGS}" PARENT_SCOPE )
400397
set( OpenMP_CXX_FLAGS "${OpenMP_CXX_FLAGS}" PARENT_SCOPE )
401398
set( OpenMP_CXX_LIBRARIES "${OpenMP_CXX_LIBRARIES}" PARENT_SCOPE )
@@ -405,7 +402,7 @@ function( NEST_PROCESS_WITH_OPENMP )
405402
else()
406403
printError( "CMake can not find OpenMP." )
407404
endif ()
408-
endif ()
405+
endif () # if NOT OFF
409406

410407
# Provide a dummy OpenMP::OpenMP_CXX if no OpenMP or if flags explicitly
411408
# given. Needed to avoid problems where OpenMP::OpenMP_CXX is used.

0 commit comments

Comments
 (0)