Skip to content

Commit

Permalink
Remove duplicate find_package
Browse files Browse the repository at this point in the history
  • Loading branch information
krystophny committed Jan 19, 2024
1 parent ca5b920 commit 24aed5c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
5 changes: 1 addition & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ find_library(fftw_lib NAMES "fftw3")
find_library(fftw_omp_lib NAMES "fftw3_omp")
find_path(fftw_include_dir NAMES "fftw3.h")

find_package(HDF5 COMPONENTS C Fortran Fortran_HL REQUIRED)
if (NOT ${HDF5_FOUND})
message(FATAL_ERROR "HDF5 not found, please set environment variable HDF5_ROOT to the correct path")
endif ()
# Assumes previous include of hdf5_tools/CMakeLists.txt for find_package
include_directories(${HDF5_INCLUDE_DIRS})

set(hdf5_tools_include_dir ${CMAKE_BINARY_DIR})
Expand Down
6 changes: 6 additions & 0 deletions src/hdf5_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ if (NOT ${HDF5_FOUND})
message(FATAL_ERROR "HDF5 not found, please set environment variable HDF5_ROOT to the correct path")
endif ()

# Set variables in parent scope, so find_package is not needed there
set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS} PARENT_SCOPE)
set(HDF5_LIBRARIES ${HDF5_LIBRARIES} PARENT_SCOPE)
set(HDF5_HL_LIBRARIES ${HDF5_HL_LIBRARIES} PARENT_SCOPE)


include_directories(${HDF5_INCLUDE_DIRS})

### Define executable
Expand Down
23 changes: 1 addition & 22 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

find_package(MPI REQUIRED)

set (MAIN_LIB ${MAIN_LIB} libneo)
set (HDF5_TOOLS_LIB ${HDF5_TOOLS_LIB} hdf5_tools)
set (MAGFIE_LIB ${MAGFIE_LIB} magfie)
Expand All @@ -10,31 +8,12 @@ set(PROJLIBS /proj/plasma/Libs/ CACHE STRING "Common library path")
include_directories(${MPI_Fortran_INCLUDE_PATH})
include_directories(${PROJECT_BINARY_DIR})


if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")

set (CMAKE_Fortran_FLAGS "-g -cpp -std=f2008")

elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")

set (CMAKE_Fortran_FLAGS "-g -cpp -heap-arrays -stand f08")

endif ()

find_package(BLAS)
find_package(LAPACK)
find_package(MPI REQUIRED)

include_directories(${CMAKE_BINARY_DIR}/src/)
include_directories(${CMAKE_SOURCE_DIR}/src/MyMPILib)
include_directories(${CMAKE_SOURCE_DIR}/src/hdf5_tools)
include_directories(${MPI_Fortran_INCLUDE_PATH})


find_package(HDF5 COMPONENTS C Fortran Fortran_HL REQUIRED)
if (NOT ${HDF5_FOUND})
message(FATAL_ERROR "HDF5 not found, please set environment variable HDF5_ROOT to the correct path")
endif ()
# Assumes previous include of hdf5_tools/CMakeLists.txt for find_package
include_directories(${HDF5_INCLUDE_DIRS})

execute_process(COMMAND nc-config --flibs
Expand Down

0 comments on commit 24aed5c

Please sign in to comment.