Skip to content

Commit 423f87c

Browse files
committed
cpu_count: work with Visual Studio, single target
1 parent bfd0d1c commit 423f87c

10 files changed

+28
-14
lines changed

CMakeLists.txt

+12-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,18 @@ DESCRIPTION "Lightweight object-oriented HDF5 MPI parallel Fortran interface"
1919
HOMEPAGE_URL https://github.com/geospace-code/h5fortran-mpi
2020
)
2121

22-
include(CTest)
22+
enable_testing()
23+
2324
if(NOT DEFINED ${PROJECT_NAME}_BUILD_TESTING)
24-
set(${PROJECT_NAME}_BUILD_TESTING ${BUILD_TESTING})
25+
if(DEFINED BUILD_TESTING)
26+
set(${PROJECT_NAME}_BUILD_TESTING ${BUILD_TESTING})
27+
else()
28+
set(${PROJECT_NAME}_BUILD_TESTING true)
29+
endif()
30+
endif()
31+
32+
if(benchmark)
33+
set(${PROJECT_NAME}_BUILD_TESTING true)
2534
endif()
2635

2736
if(${PROJECT_NAME}_BUILD_TESTING)
@@ -76,11 +85,10 @@ if(${PROJECT_NAME}_BUILD_TESTING)
7685
add_subdirectory(test)
7786
endif()
7887

79-
if(ENABLE_BENCHMARKS)
88+
if(benchmark)
8089
add_subdirectory(benchmark)
8190
endif()
8291

83-
8492
# additional Find*.cmake necessary
8593
install(FILES
8694
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/FindHDF5.cmake

benchmark/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ add_library(partition OBJECT partition.f90)
2929

3030
add_library(cli OBJECT cli.f90)
3131

32-
add_executable(runner frontend.f90 cpu_count.cpp)
32+
add_executable(runner frontend.f90)
3333
target_include_directories(runner PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
34-
target_link_libraries(runner PRIVATE partition cli)
34+
target_link_libraries(runner PRIVATE partition cli cpu_count)
3535
if(CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
3636
set_property(TARGET runner PROPERTY LINKER_LANGUAGE Fortran)
3737
else()

cmake/compilers.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $<$<COMPILE_LANGUAGE:Fortran>:-fimplicit-none>
3737
endif()
3838

3939
# --- code coverage
40-
if(ENABLE_COVERAGE)
40+
if(coverage)
4141
include(CodeCoverage)
4242
append_coverage_compiler_flags()
4343
set(COVERAGE_EXCLUDES ${PROJECT_SOURCE_DIR}/test)

cmake/options.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} CMake ${CMAKE_VERSION}")
22

3-
option(ENABLE_BENCHMARKS "write / read benchmarks")
4-
option(ENABLE_COVERAGE "Code coverage tests")
3+
option(benchmark "Run benchmarks")
4+
option(coverage "Code coverage tests")
55
option(hdf5_parallel "use HDF5-MPI layer" true)
66

77
set(CMAKE_TLS_VERIFY true)

codemeta.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"@type": "SoftwareSourceCode",
44
"codeRepository": "https://github.com/geospace-code/h5fortran-mpi",
55
"contIntegration": "https://github.com/geospace-code/h5fortran-mpi/actions",
6-
"dateModified": "2022-07-28",
6+
"dateModified": "2022-07-29",
77
"downloadUrl": "https://github.com/geospace-code/h5fortran-mpi/releases",
88
"issueTracker": "https://github.com/geospace-code/h5fortran-mpi/issues",
99
"name": "h5fortran-mpi",
10-
"version": "2.0.1",
10+
"version": "2.0.2",
1111
"identifier": "10.5281/zenodo.5847354",
1212
"description": "Lightweight object-oriented HDF5-MPI parallel Fortran interface",
1313
"applicationCategory": "file I/O",

fpm.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "h5fortran-mpi"
22
description = "Lightweight object-oriented HDF5 MPI parallel interface"
33
categories = "io"
4-
version = "2.0.0"
4+
version = "2.0.2"
55

66
[build]
77
auto-tests = false

test/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
add_library(cpu_count OBJECT cpu_count.cpp)
2+
target_compile_features(cpu_count PRIVATE cxx_std_11)
3+
target_compile_definitions(cpu_count PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
4+
target_include_directories(cpu_count PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
5+
16
# --- Python h5py
27
find_package(Python COMPONENTS Interpreter)
38
if(NOT DEFINED h5py_ok)
@@ -29,7 +34,7 @@ if(hdf5_parallel)
2934
add_subdirectory(mpi)
3035
endif()
3136

32-
if(ENABLE_COVERAGE)
37+
if(coverage)
3338
setup_target_for_coverage_gcovr_html(
3439
NAME coverage
3540
EXECUTABLE ${CMAKE_CTEST_COMMAND}

benchmark/cpu_count.cpp renamed to test/cpu_count.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <thread>
2020

2121
#ifdef _WIN32
22+
#define NOMINMAX
2223
#include <windows.h>
2324
#elif defined (__APPLE__)
2425
#include <sys/sysctl.h>
File renamed without changes.

test/mpi/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ endfunction(mpi_test)
3232
# --- test files
3333

3434
add_executable(test_runner runner.f90
35-
${PROJECT_SOURCE_DIR}/benchmark/cpu_count.cpp
3635
${PROJECT_SOURCE_DIR}/benchmark/partition.f90
3736
${PROJECT_SOURCE_DIR}/benchmark/cli.f90
3837
)
3938
target_include_directories(test_runner PRIVATE ${PROJECT_SOURCE_DIR}/benchmark)
39+
target_link_libraries(test_runner PRIVATE cpu_count)
4040
# not linked as libraries in case benchmarks aren't built
4141
if(CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
4242
set_property(TARGET test_runner PROPERTY LINKER_LANGUAGE Fortran)

0 commit comments

Comments
 (0)