# Set the minimum required version of cmake
cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
# Set name, version and language for the project.
project (WavePacket VERSION 0.2 LANGUAGES CXX)
# import various modules
include (CMakePrintHelpers)
include (CMakePackageConfigHelpers)
#----------------------------------------------------------------------
# User-specifiable options and defaults
#----------------------------------------------------------------------
option (Opt_BuildDemos "Build all demos" ON)
# the default build type is "Release", but do not overwrite user settings if they are set.
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release" CACHE STRING
"The build type to use. Useful values are <Debug>,<Release>,<RelWithDebInfo>"
FORCE)
endif ()
#----------------------------------------------------------------------
# Find the required libraries
# The variables set by these modules will be available in all subdirs
#----------------------------------------------------------------------
# 1. Boost
find_package (Boost 1.56 REQUIRED COMPONENTS program_options filesystem)
if (NOT Boost_FOUND)
message(FATAL_ERROR "Boost libraries 1.56 or later are required for WavePacket to function.")
endif ()
# 2. Tensor library
#
# Unfortunately, the tensor library provides its dependencies only indirectly
# through a "tensor-config" script, which creates a few problems.
# Among other things, compilation under Windows is problematic, and we need to
# explicitly set the preprocessor and linker flags instead of getting the
# dependencies and include directories (which would be automatically forwarded
# to dependent executables like the test runner)
# If you set the variable "TENSOR_CONFIG" to the full path of the script,
# skip the search
if (NOT TENSOR_CONFIG)
find_program(TENSOR_CONFIG NAMES tensor-config)
endif ()
if (NOT EXISTS ${TENSOR_CONFIG})
set(TENSOR_CONFIG "")
message (FATAL_ERROR "Tensor library configuration script not found; aborting.")
endif ()
execute_process (COMMAND ${TENSOR_CONFIG} "--cppflags"
OUTPUT_VARIABLE TENSOR_CPPFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${TENSOR_CONFIG} "--ldflags"
OUTPUT_VARIABLE TENSOR_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
#----------------------------------------------------------------------
# Refer to specialized scripts that deal with the components
#----------------------------------------------------------------------
# add a custom "distclean" target that cleans up everything you can think of
add_custom_target (distclean)
# build external libs (in particular googletest/googlemock)
message (STATUS "Processing extern/")
add_subdirectory (extern)
# build or clean the documentation, but not by default
message (STATUS "Processing doc/")
add_subdirectory (doc)
# build the actual library
message (STATUS "Processing src/")
add_subdirectory (src)
# build and run the tests
message (STATUS "Processing test/")
add_subdirectory (test)
# build demos if requested
if (Opt_BuildDemos)
message (STATUS "Processing Demos/")
add_subdirectory (Demos)
endif ()
#----------------------------------------------------------------------
# Various project-wide installation work to do
#----------------------------------------------------------------------
# installation rules for standard files
install (FILES AUTHORS LICENSE NEWS README DESTINATION doc/wavepacket)
install (FILES licenses/Boost.txt licenses/GoogleTest.txt licenses/WavePacket_DemosDocs.txt licenses/WavePacket.txt DESTINATION doc/wavepacket/licenses)
# settings for packaging and exporting of the WavePacket build
# This allows other programs to include the library by calling find_package(WavePacket)
write_basic_package_version_file (${CMAKE_CURRENT_BINARY_DIR}/WavePacketConfigVersion.cmake
COMPATIBILITY AnyNewerVersion)
install (EXPORT WavePacket DESTINATION share/WavePacket)
install (FILES WavePacketConfig.cmake DESTINATION share/WavePacket)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/WavePacketConfigVersion.cmake DESTINATION share/WavePacket)