Skip to content

Commit

Permalink
cmake: use bml exported target (#151)
Browse files Browse the repository at this point in the history
* cmake: use bml exported target

* cmake: added exported target

* cmake: added support for OpenMP
  • Loading branch information
junghans authored Apr 22, 2020
1 parent 4de5a50 commit 3957caa
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.7)
cmake_minimum_required(VERSION 3.10)
project(progress C CXX Fortran)

# The library version is versioned off the major version. If the API
Expand Down Expand Up @@ -72,10 +72,15 @@ if(CMAKE_Fortran_FLAGS STRGREATER "")
endif()

include(FindPkgConfig)

pkg_check_modules(BML REQUIRED bml)
message(STATUS "Found bml: ${BML_LDFLAGS}")
list(APPEND LINK_LIBRARIES ${BML_LDFLAGS})
find_package(BML CONFIG QUIET)
if(BML_FOUND)
message(STATUS "Found bml: BML::bml")
list(APPEND LINK_LIBRARIES BML::bml)
else()
pkg_check_modules(BML REQUIRED bml)
message(STATUS "Found bml: ${BML_LDFLAGS}")
list(APPEND LINK_LIBRARIES ${BML_LDFLAGS})
endif()

set(PROGRESS_GRAPHLIB FALSE CACHE BOOL "Compile with externel graph libraries")
if(PROGRESS_GRAPHLIB)
Expand Down
17 changes: 15 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,22 @@ if(EXTRA_LINK_FLAGS)
target_link_libraries(progress ${EXTRA_LINK_FLAGS})
endif()

install(TARGETS progress
if(TARGET BML::bml)
target_link_Libraries(progress PUBLIC BML::bml_fortran BML::bml)
endif()
if(OPENMP_FOUND)
target_link_Libraries(progress PUBLIC OpenMP::OpenMP_Fortran)
endif()

target_include_directories(progress PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
install(TARGETS progress EXPORT PROGRESS_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT PROGRESS_Targets FILE PROGRESS_Targets.cmake NAMESPACE PROGRESS:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PROGRESS)
include(CMakePackageConfigHelpers)
configure_file(PROGRESSConfig.cmakein ${CMAKE_CURRENT_BINARY_DIR}/PROGRESSConfig.cmake @ONLY)
write_basic_package_version_file("PROGRESSConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY ExactVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PROGRESSConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/PROGRESSConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PROGRESS)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/coulomb_latte_mod.mod
Expand Down Expand Up @@ -109,4 +122,4 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/prg_xlkernel_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/slaterkosterforce_latte_mod.mod
${CMAKE_CURRENT_BINARY_DIR}/tbparams_latte_mod.mod
DESTINATION include)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
6 changes: 6 additions & 0 deletions src/PROGRESSConfig.cmakein
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include(CMakeFindDependencyMacro)
find_dependency(BML CONFIG REQUIRED)
if(@OPENMP_FOUND@)
find_dependency(OpenMP REQUIRED)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/PROGRESS_Targets.cmake")
5 changes: 3 additions & 2 deletions src/prg_partition_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ subroutine prg_KernLin2(gp, xadj, adjncy, partNumber, core_count, CH_count, Halo
type (graph_partitioning_t), intent(inout) :: gp
integer, allocatable, intent(inout) :: xadj(:), adjncy(:)
integer, allocatable, intent(inout) :: partNumber(:), core_count(:)
integer :: totalParts, totalNodes, i, iit, j,k, neighbor, node, part_backup
integer :: totalParts, totalNodes, i, it, iit, j,k, neighbor, node, part_backup
integer :: totalNodes2
real(dp), intent(inout) :: sumCubes, maxCH, smooth_maxCH, pnorm
real(dp) :: cost, prev_cost, prev_maxCH, minCH
Expand Down Expand Up @@ -1290,7 +1290,8 @@ subroutine prg_KernLin2(gp, xadj, adjncy, partNumber, core_count, CH_count, Halo
!> to different metrics
call random_number(r)
if (r .ge. 0.7) then
call prg_get_largest_Hedge_in_part(gp, xadj, adjncy, partNumber, core_count, CH_count, Halo_count, sumCubes, maxCH, smooth_maxCH, pnorm, i, largest_Hedge)
it = i
call prg_get_largest_Hedge_in_part(gp, xadj, adjncy, partNumber, core_count, CH_count, Halo_count, sumCubes, maxCH, smooth_maxCH, pnorm, it, largest_Hedge)
else
call prg_rand_node(gp, largest_Hedge, seed)

Expand Down

0 comments on commit 3957caa

Please sign in to comment.