diff --git a/CMakeLists.txt b/CMakeLists.txt index 5693c822..3c93c0ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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: # @@ -135,4 +145,4 @@ endif (BUILD_BIOMEVAL_TESTS) if (BUILD_BIOMEVAL_TESTS) add_subdirectory(src/test/ bin) -endif (BUILD_BIOMEVAL_TESTS) \ No newline at end of file +endif (BUILD_BIOMEVAL_TESTS) diff --git a/src/libbiomeval/CMakeLists.txt b/src/libbiomeval/CMakeLists.txt index f412201e..2a1cbd43 100644 --- a/src/libbiomeval/CMakeLists.txt +++ b/src/libbiomeval/CMakeLists.txt @@ -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) @@ -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) @@ -226,8 +232,12 @@ 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. @@ -235,6 +245,7 @@ endif (PCSC_FOUND) # 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") @@ -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 @@ -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) @@ -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. diff --git a/src/libbiomeval/be_system.cpp b/src/libbiomeval/be_system.cpp index 910a18db..9abd3a74 100644 --- a/src/libbiomeval/be_system.cpp +++ b/src/libbiomeval/be_system.cpp @@ -18,7 +18,10 @@ #include #include #endif + +#ifdef BIOMEVAL_WITH_HWLOC #include +#endif #include @@ -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); @@ -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); @@ -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 diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 18d74a73..e5222e17 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -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) @@ -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)