Skip to content

Commit

Permalink
CMake fixes + fixing compilation issues using gcc (issues #10 & #11) …
Browse files Browse the repository at this point in the history
…and MPI (issue #13), and get_filename_component error
  • Loading branch information
marcjoos-cea committed Jan 19, 2022
2 parents ce4e4a6 + a0c788a commit a36408d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
27 changes: 17 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 3.0.0)
project(wi4mpi)

if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
if(POLICY CMP0057)
CMAKE_POLICY(SET CMP0057 NEW)
endif()

set(VERSION_MAJOR 3)
set(VERSION_MINOR 5)
Expand Down Expand Up @@ -119,26 +122,30 @@ else()
set(WI4MPI_FLAGS ${CMAKE_C_FLAGS_NORMAL})
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon")

find_package(MPI REQUIRED)
if(MPI_C_FOUND AND MPI_Fortran_FOUND) #Need to be OpenMPI
if(NOT DEFINED OPENMPI_ROOT)
execute_process(COMMAND "${MPI_C_COMPILER}" -show
execute_process(COMMAND "${MPI_C_COMPILER}" --showme:version
OUTPUT_VARIABLE ERR_VAR1
OUTPUT_FILE "compiler_out"
OUTPUT_FILE "compiler_version"
ERROR_QUIET)
execute_process(COMMAND "grep" openmpi
INPUT_FILE "compiler_out"
execute_process(COMMAND "grep" -i "Open MPI"
INPUT_FILE "compiler_version"
OUTPUT_VARIABLE ERR_VAR2
RESULT_VARIABLE COMMAND_RESULT1
ERROR_QUIET)
#execute_process(COMMAND "${MPI_C_COMPILER}" -show
# COMMAND "grep" -io openmpi
# RESULT_VARIABLE RV)
#message(STATUS "res command : ${ERR_VAR2}")
message(STATUS "res command : ${ERR_VAR2}")
if(NOT ERR_VAR2)
message(FATAL_ERROR "Be sure to have an OpenMPI librarie in your PATH or set -DOPENMPI_ROOT=...")
endif()
get_filename_component(OPENMPI_ROOT ${MPI_C_INCLUDE_PATH} DIRECTORY)
foreach(p ${MPI_C_INCLUDE_PATH})
get_filename_component(OPENMPI_ROOT_TEST ${p} DIRECTORY)
if(EXISTS "${OPENMPI_ROOT_TEST}/lib")
set(OPENMPI_ROOT ${OPENMPI_ROOT_TEST})
endif ()
endforeach(p)
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion Testing/compile/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project (compile)
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 3.0.0)

# Copy source files
set (LIST_FILES mpi_init.c mpi_init.cpp mpi_init.f mpi_init.f90)
Expand Down
2 changes: 1 addition & 1 deletion Testing/mpi_init/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project (mpi_init)
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 3.0.0)

# Copy source files
set (LIST_FILES mpi_init.c mpi_init.cpp mpi_init.f mpi_init.f90)
Expand Down
2 changes: 1 addition & 1 deletion Testing/mpiio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project (mpiio)
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 3.0.0)

# Add tests
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_mpi_file_open_tests.sh
Expand Down
2 changes: 1 addition & 1 deletion Testing/mpirun/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project (mpirun)
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 3.0.0)

# Add tests
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_mpirun_tests.sh
Expand Down
2 changes: 1 addition & 1 deletion Testing/timeout/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project (timeout)
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 3.0.0)

file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/timeout_slow_add.c
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
Expand Down

0 comments on commit a36408d

Please sign in to comment.