Commit dd99138b authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Rework main CMakeLists

Perform the same steps as in ITABase previously:
- Use modern targets
- Use CPM.cmake for dependencies
- Update some functions
- Remove VistaCMakeCommon
- Improve installing
parent 10942a55
cmake_minimum_required( VERSION 2.8 )
project( ITAConvolution )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
if( NOT DEFINED ITA_CONVOLUTION_UPCONV_WITH_POWER_SAVER )
set( ITA_CONVOLUTION_UPCONV_WITH_POWER_SAVER ON CACHE BOOL "Use power saving mode for uniform partitioned convolution (do not convolve blocks with zeros)" )
endif( )
if( NOT DEFINED ITA_CONVOLUTION_WITH_NUPCONV )
set( ITA_CONVOLUTION_WITH_NUPCONV OFF CACHE BOOL "Build with non-uniform partitioned convolution engine" )
endif( )
if( NOT DEFINED ITA_CONVOLUTION_NUPCONV_WITH_PERFORMANCE_LOGGER )
set( ITA_CONVOLUTION_NUPCONV_WITH_PERFORMANCE_LOGGER OFF CACHE BOOL "Include performance logger for non-uniform partitioned convolution" )
endif( )
if( NOT DEFINED ITA_CONVOLUTION_NUPCONV_WITH_XML_READER )
set( ITA_CONVOLUTION_NUPCONV_WITH_XML_READER OFF CACHE BOOL "Include XML read/write file format for non-uniform partitioned convolution filter segmentation" )
endif( )
# dependencies
vista_use_package( ITABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITAFFT REQUIRED FIND_DEPENDENCIES )
vista_use_package( TBB REQUIRED )
# includes
include_directories( "include" )
# sources
set( ITAConvolutionHeader
"include/ITAUPConvolution.h"
"include/ITAUPFilter.h"
"include/ITAUPFilterPool.h"
"include/ITAUPTrigger.h"
"include/ITADirectConvolution.h"
"include/ITAConvolutionDefinitions.h"
)
set( ITAConvolutionSources
"src/ITAUPConvolution.cpp"
"src/ITAUPFilter.cpp"
"src/ITAUPFilterPool.cpp"
"src/ITADirectConvolution.cpp"
"src/ITADirectConvolutionImpl.cpp"
"src/ITADirectConvolutionImpl.h"
cmake_minimum_required (VERSION 3.14 FATAL_ERROR)
project (
ITAConvolution
VERSION 2021.0
LANGUAGES CXX C
)
set (CMAKE_DEBUG_POSTFIX "-d")
if (NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY AND WIN32)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
endif ()
option (ITA_CONVOLUTION_UPCONV_WITH_POWER_SAVER
"Use power saving mode for uniform partitioned convolution (do not convolve blocks with zeros)" ON
)
option (ITA_CONVOLUTION_WITH_NUPCONV "Build with non-uniform partitioned convolution engine" OFF)
option (ITA_CONVOLUTION_NUPCONV_WITH_PERFORMANCE_LOGGER
"Include performance logger for non-uniform partitioned convolution" OFF
)
option (ITA_CONVOLUTION_NUPCONV_WITH_XML_READER
"Include XML read/write file format for non-uniform partitioned convolution filter segmentation" OFF
)
option (ITA_CONVOLUTION_WITH_BENCHMARKS "Build the benchmarks for the library" OFF)
option (ITA_CONVOLUTION_WITH_PROFILERS "Build the profiling application for the library" OFF)
option (ITA_CONVOLUTION_WITH_APPS "Build the applications of the library" OFF)
option (ITA_CONVOLUTION_WITH_TESTS "Build the tests for the library" OFF)
if (ITA_CONVOLUTION_NUPCONV_WITH_PERFORMANCE_LOGGER OR ITA_CONVOLUTION_NUPCONV_WITH_XML_READER)
message (FATAL_ERROR "Performance logger is deprecated, as the XML library cannot be found.")
endif ()
add_subdirectory (external_libs)
add_library (
${PROJECT_NAME}
include/ITAUPConvolution.h
include/ITAUPFilter.h
include/ITAUPFilterPool.h
include/ITAUPTrigger.h
include/ITADirectConvolution.h
include/ITAConvolutionDefinitions.h
src/ITAUPConvolution.cpp
src/ITAUPFilter.cpp
src/ITAUPFilterPool.cpp
src/ITADirectConvolution.cpp
src/ITADirectConvolutionImpl.cpp
src/ITADirectConvolutionImpl.h
)
add_library (${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
if (ITA_CONVOLUTION_WITH_NUPCONV)
target_sources (
${PROJECT_NAME}
PRIVATE include/ITANUPConvolution.h
include/ITANUPFilter.h
src/ITADirectConvolution.cpp
src/ITADirectConvolutionImpl.cpp
src/ITADirectConvolutionImpl.h
src/ITANUPCEventLog.cpp
src/ITANUPCEventLog.h
src/ITANUPCFade.cpp
src/ITANUPCFade.h
src/ITANUPCFilterSegmentation.cpp
src/ITANUPCFilterSegmentation.h
src/ITANUPCHelpers.cpp
src/ITANUPCHelpers.h
src/ITANUPCInputBuffer1.cpp
src/ITANUPCInputBuffer1.h
src/ITANUPCOutputBuffer.cpp
src/ITANUPCOutputBuffer.h
src/ITANUPCPerformanceProfile.cpp
src/ITANUPCPerformanceProfile.h
src/ITANUPCStage.cpp
src/ITANUPCStage.h
src/ITANUPCStageInfo.h
src/ITANUPCStageStatistic.h
src/ITANUPCTask.cpp
src/ITANUPCTask.h
src/ITANUPCTaskQueue.cpp
src/ITANUPCTaskQueue.h
src/ITANUPCUFilter.cpp
src/ITANUPCUFilter.h
src/ITANUPCUFilterPool.cpp
src/ITANUPCUFilterPool.h
src/ITANUPCUtils.cpp
src/ITANUPCUtils.h
src/ITANUPConvolution.cpp
src/ITANUPConvolutionImpl.cpp
src/ITANUPConvolutionImpl.h
src/ITANUPFilterComponent.h
src/ITANUPFilterImpl.h
src/ITANUPartitioningScheme.cpp
src/ITANUPartitioningScheme.h
src/ITAUPConvolution.cpp
src/ITAUPFilter.cpp
src/ITAUPFilterPool.cpp
)
if( ITA_CONVOLUTION_WITH_NUPCONV )
list( APPEND ITAConvolutionHeader "include/ITANUPConvolution.h" "include/ITANUPFilter.h" )
set( ITANUPSources
"src/ITADirectConvolution.cpp"
"src/ITADirectConvolutionImpl.cpp"
"src/ITADirectConvolutionImpl.h"
"src/ITANUPCEventLog.cpp"
"src/ITANUPCEventLog.h"
"src/ITANUPCFade.cpp"
"src/ITANUPCFade.h"
"src/ITANUPCFilterSegmentation.cpp"
"src/ITANUPCFilterSegmentation.h"
"src/ITANUPCHelpers.cpp"
"src/ITANUPCHelpers.h"
"src/ITANUPCInputBuffer1.cpp"
"src/ITANUPCInputBuffer1.h"
"src/ITANUPCOutputBuffer.cpp"
"src/ITANUPCOutputBuffer.h"
"src/ITANUPCPerformanceProfile.cpp"
"src/ITANUPCPerformanceProfile.h"
"src/ITANUPCStage.cpp"
"src/ITANUPCStage.h"
"src/ITANUPCStageInfo.h"
"src/ITANUPCStageStatistic.h"
"src/ITANUPCTask.cpp"
"src/ITANUPCTask.h"
"src/ITANUPCTaskQueue.cpp"
"src/ITANUPCTaskQueue.h"
"src/ITANUPCUFilter.cpp"
"src/ITANUPCUFilter.h"
"src/ITANUPCUFilterPool.cpp"
"src/ITANUPCUFilterPool.h"
"src/ITANUPCUtils.cpp"
"src/ITANUPCUtils.h"
"src/ITANUPConvolution.cpp"
"src/ITANUPConvolutionImpl.cpp"
"src/ITANUPConvolutionImpl.h"
"src/ITANUPFilterComponent.h"
"src/ITANUPFilterImpl.h"
"src/ITANUPartitioningScheme.cpp"
"src/ITANUPartitioningScheme.h"
"src/ITAUPConvolution.cpp"
"src/ITAUPFilter.cpp"
"src/ITAUPFilterPool.cpp"
)
list( APPEND ITAConvolutionSources ${ITANUPSources} )
endif( )
# compiler settings
if( ITA_VISTA_BUILD_STATIC )
add_definitions( -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTATOOLS_STATIC -DVISTAINTERPROCCOMM_STATIC )
endif( )
if( BUILD_SHARED_LIBS )
add_definitions( -DITA_CONVOLUTION_EXPORT )
else( )
add_definitions( -DITA_CONVOLUTION_STATIC )
endif( )
if( ITA_CORE_LIBS_BUILD_STATIC )
add_definitions( -DITA_FFT_STATIC -DITA_BASE_STATIC -DITA_DATA_SOURCES_STATIC )
endif( )
if (ITA_CONVOLUTION_NUPCONV_WITH_PERFORMANCE_LOGGER)
target_compile_definitions (${PROJECT_NAME} PRIVATE ITA_CONVOLUTION_NUPCONV_WITH_PERFORMANCE_LOGGER)
endif ()
if( NOT WIN32 )
add_definitions( -std=gnu++11)
endif( )
if (ITA_CONVOLUTION_NUPCONV_WITH_XML_READER)
target_compile_definitions (${PROJECT_NAME} PRIVATE ITA_CONVOLUTION_NUPCONV_WITH_XML_READER)
endif ()
endif ()
if( ITA_CONVOLUTION_NUPCONV_WITH_PERFORMANCE_LOGGER )
add_definitions( -DITA_CONVOLUTION_NUPCONV_WITH_PERFORMANCE_LOGGER )
endif( )
target_include_directories (
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:INCLUDE_PATH>
)
if( ITA_CONVOLUTION_NUPCONV_WITH_XML_READER )
add_definitions( -DITA_CONVOLUTION_NUPCONV_WITH_XML_READER )
endif( )
target_link_libraries (${PROJECT_NAME} PUBLIC ITABase::ITABase ITAFFT::ITAFFT TBB::tbb)
target_compile_definitions (
${PROJECT_NAME} PUBLIC $<IF:$<BOOL:${BUILD_SHARED_LIBS}>,ITA_CONVOLUTION_EXPORT,ITA_CONVOLUTION_STATIC>
)
# linker
add_library( ITAConvolution ${ITAConvolutionHeader} ${ITAConvolutionSources} ${ProjectSources} )
target_link_libraries( ITAConvolution ${VISTA_USE_PACKAGE_LIBRARIES} )
target_compile_features (${PROJECT_NAME} PUBLIC cxx_std_11)
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set_property (TARGET ${PROJECT_NAME} PROPERTY FOLDER "ITACoreLibs")
endif ()
# configure
vista_configure_lib( ITAConvolution )
vista_install( ITAConvolution )
set( ITACONVOLUTION_INCLUDE_OUTDIR "${CMAKE_CURRENT_SOURCE_DIR}/include" )
vista_create_cmake_configs( ITAConvolution )
vista_create_default_info_file( ITAConvolution )
set_property( TARGET ITAConvolution PROPERTY FOLDER "ITACoreLibs" )
packageProject (
NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
BINARY_DIR ${PROJECT_BINARY_DIR}
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
INCLUDE_DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
DEPENDENCIES "ITABase;ITAFFT;TBB"
COMPATIBILITY ExactVersion
NAMESPACE ${PROJECT_NAME}
DISABLE_VERSION_SUFFIX YES
)
# benchmarks
if( ITA_CORE_LIBS_WITH_BENCHMARKS )
set( ITACONVOLUTION_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/benchmarks" )
endif( )
if (ITA_CONVOLUTION_WITH_BENCHMARKS)
add_subdirectory (benchmarks)
endif ()
# profiler
if( ITA_CORE_LIBS_WITH_PROFILERS )
set( ITACONVOLUTION_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/profilers" )
endif( )
if (ITA_CONVOLUTION_WITH_PROFILERS
AND ITA_CONVOLUTION_NUPCONV_WITH_PERFORMANCE_LOGGER
AND ITA_CONVOLUTION_WITH_NUPCONV
)
add_subdirectory (profilers)
endif ()
# apps
if( ITA_CORE_LIBS_WITH_APPS )
set( ITACONVOLUTION_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/apps" )
endif( )
if (ITA_CONVOLUTION_WITH_APPS)
add_subdirectory (apps)
endif ()
# tests
if( ITA_CORE_LIBS_WITH_TESTS )
set( ITACONVOLUTION_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
endif( )
if (ITA_CONVOLUTION_WITH_TESTS)
add_subdirectory (tests)
endif ()
set (CPM_DOWNLOAD_VERSION 0.32.2)
set (CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
if (NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message (STATUS "Downloading CPM.cmake")
file (DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
else (NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message ("CPM already exists, do not need to download")
endif (NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
include (${CPM_DOWNLOAD_LOCATION})
CPMAddPackage (
NAME tbb
GITHUB_REPOSITORY oneapi-src/oneTBB
GIT_TAG v2021.3.0
OPTIONS "TBB_TEST OFF" "TBBMALLOC_BUILD OFF"
)
if (tbb_ADDED)
set_target_properties (tbb tbbmalloc tbbmalloc_proxy PROPERTIES FOLDER "external_libs")
if (WIN32)
set_target_properties (
tbb tbbmalloc tbbmalloc_proxy PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
set_target_properties (
tbb tbbmalloc tbbmalloc_proxy PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
)
set_target_properties (
tbb tbbmalloc tbbmalloc_proxy PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
)
endif ()
endif ()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment