Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'cherrypicked-cmake-options'
  • Loading branch information
gfiumara committed May 21, 2021
2 parents e9c81f2 + 95c073b commit 9eeee15
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Expand Up @@ -100,6 +100,16 @@ if (NOT MSVC AND POSSIBLE_TO_BUILD_32BIT)
message(STATUS "Bitness: 64-bit")
endif (BUILD_BIOMEVAL_32BIT)
endif (NOT MSVC AND POSSIBLE_TO_BUILD_32BIT)

# Build sources that require libhwloc
option(WITH_HWLOC "Build sources that require libhwloc" ON)
# Build sources that require OpenMPI
option(WITH_MPI "Build sources that require MPI" ON)
# Build sources that require FFMPEG
option(WITH_FFMPEG "Build sources that require FFMPEG" ON)
# Build sources that require PCSC
option(WITH_PCSC "Build sources that require PCSC" ON)

#
# The CMake config files must exist in the directories added to this config:
#
Expand Down Expand Up @@ -135,4 +145,4 @@ endif (BUILD_BIOMEVAL_TESTS)

if (BUILD_BIOMEVAL_TESTS)
add_subdirectory(src/test/ bin)
endif (BUILD_BIOMEVAL_TESTS)
endif (BUILD_BIOMEVAL_TESTS)
20 changes: 20 additions & 0 deletions src/libbiomeval/CMakeLists.txt
Expand Up @@ -188,6 +188,7 @@ endif(MSVC)
#
set(PACKAGES ${CORE} ${IO} ${RECORDSTORE} ${IMAGE} ${FEATURE} ${VIEW} ${DATA} ${FINGER} ${PALM} ${PLANTAR} ${IRIS} ${FACE} ${PROCESS} ${MESSAGE_CENTER})

if (WITH_FFMPEG)
find_package(FFMPEG)
if(FFMPEG_FOUND)
if ((MSVC AND BUILD_BIOMEVAL_SHARED) OR NOT MSVC)
Expand All @@ -199,12 +200,17 @@ if(FFMPEG_FOUND)
endif (MSVC AND BUILD_BIOMEVAL_STATIC)
message(STATUS "Adding VIDEO support.")
else(FFMPEG_FOUND)
# FIXME: Should we complain if WITH_FFMPEG=YES but FFMPEG is not found?
message(STATUS "Building without VIDEO support.")
endif(FFMPEG_FOUND)
else(WITH_FFMPEG)
message(STATUS "Building without VIDEO support.")
endif(WITH_FFMPEG)

#
# PCSC (Smartcard) support is an optional library
#
if (WITH_PCSC)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
find_library(PCSC_FRAMEWORK PCSC)
if (PCSC_FRAMEWORK)
Expand All @@ -226,15 +232,20 @@ if (PCSC_FOUND)
target_include_directories(deviceobjs-static PUBLIC ${BIOMEVAL_INCLUDE})
endif (MSVC AND BUILD_BIOMEVAL_STATIC)
else (PCSC_FOUND)
# FIXME: Should we complain if WITH_PCSC=YES but PCSC is not found?
message(STATUS "Building without PCSC support.")
endif (PCSC_FOUND)
else(WITH_PCSC)
message(STATUS "Building without PCSC support.")
endif(WITH_PCSC)

#
# Keep MPI related files separate so we can use a different compiler command.
# MPI files are built as an object-only lib (not linked) so its symbols can
# be added to the BIOMEVAL library later. MPI is optional.
#
set(MPISOURCES ${MPIBASE} ${MPIDISTRIBUTOR} ${MPIRECEIVER})
if(WITH_MPI)
# Provide some hints to help find MPI
list(APPEND CMAKE_PREFIX_PATH "/opt/local/bin")
list(APPEND CMAKE_PREFIX_PATH "/usr/lib/openmpi/bin")
Expand All @@ -257,8 +268,12 @@ if(MPI_CXX_FOUND AND NOT MSVC)
PUBLIC ${MPI_CXX_INCLUDE_DIRS} ${BIOMEVAL_INCLUDE})
endif(${CMAKE_VERSION} VERSION_LESS "3.10")
else(MPI_CXX_FOUND AND NOT MSVC)
# FIXME: Should we stop if WITH_MPI=ON, but MPI not found?
message(STATUS "Building without MPI support.")
endif(MPI_CXX_FOUND AND NOT MSVC)
else(WITH_MPI)
message(STATUS "Building without MPI support.")
endif(WITH_MPI)

#
# Build the Framework-local version of NBIS
Expand Down Expand Up @@ -572,6 +587,8 @@ endif(PCSC_FOUND)
#
# The Portable Hardware Locality hwloc
#
if (WITH_HWLOC)
add_definitions(-DBIOMEVAL_WITH_HWLOC)
set(HWLOC_FIND_REQUIRED TRUE)
find_package(HWLOC)
if(NOT HWLOC_FOUND)
Expand All @@ -581,6 +598,9 @@ include_directories(PUBLIC ${HWLOC_INCLUDE_DIR})
if (BUILD_BIOMEVAL_SHARED)
target_link_libraries(${SHAREDLIB} ${HWLOC_LIBRARIES})
endif (BUILD_BIOMEVAL_SHARED)
else (WITH_HWLOC)
message(STATUS "Building without HWLOC support.")
endif (WITH_HWLOC)

#
# Other libs not specifically searched for above.
Expand Down
11 changes: 11 additions & 0 deletions src/libbiomeval/be_system.cpp
Expand Up @@ -18,7 +18,10 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#endif

#ifdef BIOMEVAL_WITH_HWLOC
#include <hwloc.h>
#endif

#include <be_sysdeps.h>

Expand All @@ -35,6 +38,7 @@ BiometricEvaluation::System::getCPUCount()
uint32_t
BiometricEvaluation::System::getCPUCoreCount()
{
#ifdef BIOMEVAL_WITH_HWLOC
hwloc_topology_t topology;
hwloc_topology_init(&topology);
hwloc_topology_load(topology);
Expand All @@ -46,11 +50,15 @@ BiometricEvaluation::System::getCPUCoreCount()
uint32_t count = hwloc_get_nbobjs_by_depth(topology, depth);
hwloc_topology_destroy(topology);
return (count);
#else
throw BiometricEvaluation::Error::NotImplemented{};
#endif
}

uint32_t
BiometricEvaluation::System::getCPUSocketCount()
{
#ifdef BIOMEVAL_WITH_HWLOC
hwloc_topology_t topology;
hwloc_topology_init(&topology);
hwloc_topology_load(topology);
Expand All @@ -63,6 +71,9 @@ BiometricEvaluation::System::getCPUSocketCount()
uint32_t count = hwloc_get_nbobjs_by_depth(topology, depth);
hwloc_topology_destroy(topology);
return (count);
#else
throw BiometricEvaluation::Error::NotImplemented{};
#endif
}

uint64_t
Expand Down
4 changes: 4 additions & 0 deletions src/test/CMakeLists.txt
Expand Up @@ -85,10 +85,12 @@ endif()

# Windows doesn't have the concept of rpath. DLLs must be in PATH
if(MSVC)
if (WITH_FFMPEG)
find_package(FFMPEG)
if(FFMPEG_FOUND)
link_libraries(${FFMPEG_LIBRARIES})
endif(FFMPEG_FOUND)
endif(WITH_FFMPEG)

find_package(OPENSSL)
if(OPENSSL_FOUND)
Expand All @@ -110,10 +112,12 @@ if(MSVC)
link_libraries(${OPENJP2_LIBRARIES})
endif(OPENJP2_FOUND)

if(WITH_HWLOC)
find_package(HWLOC)
if(HWLOC_FOUND)
link_libraries(${HWLOC_LIBRARIES})
endif(HWLOC_FOUND)
endif(WITH_HWLOC)

find_package(PNG)
if(PNG_FOUND)
Expand Down

0 comments on commit 9eeee15

Please sign in to comment.