Skip to content

Instantly share code, notes, and snippets.

@wspeirs
Created June 24, 2020 00:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wspeirs/1948869bf7fdb6f943c143b2a223fa54 to your computer and use it in GitHub Desktop.
Save wspeirs/1948869bf7fdb6f943c143b2a223fa54 to your computer and use it in GitHub Desktop.
cmake_minimum_required(VERSION 3.8.0)
# Project info
project(sdhr)
set(${PROJECT_NAME}_MAJOR "0")
set(${PROJECT_NAME}_MINOR "0")
set(${PROJECT_NAME}_PATCH "1")
set(VERSION "${${PROJECT_NAME}_MAJOR}.${${PROJECT_NAME}_MINOR}.${${PROJECT_NAME}_PATCH}")
set(CMAKE_CXX_STANDARD 11)
add_definitions(-DVERSION="0.0.1")
# add custom CMake files
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# debug build options
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O3")
# release build options
#add_definitions(-DQT_NO_DEBUG_OUTPUT)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
# settings for Linux
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
add_definitions(-Wall)
add_definitions(-Wextra)
add_definitions(-Wno-unused-parameter)
add_definitions(-Wsign-compare)
add_definitions(-fPIC)
endif()
# settings for Microsoft
if(MSVC)
#get math definitions like M_PI
add_definitions(-D_USE_MATH_DEFINES)
#use std::min()/std::max()
add_definitions(-DNOMINMAX)
#needed to dynamically link boost
add_definitions(-DBOOST_ALL_DYN_LINK)
if ("${MSVC_VERSION}" VERSION_LESS "1900")
add_definitions(-D__func__=__FUNCTION__)
endif()
endif()
# collects all source files from sub-directories
function(add_source_files list)
get_property(is_defined GLOBAL PROPERTY SRCS_LIST DEFINED)
if(NOT is_defined)
define_property(GLOBAL PROPERTY ${list}
BRIEF_DOCS "List of source files"
FULL_DOCS "List of source files to be compiled in one library")
endif()
# convert to absolute paths
set(SRCS)
foreach(s IN LISTS ARGN)
if(NOT IS_ABSOLUTE "${s}")
get_filename_component(s "${s}" ABSOLUTE)
endif()
list(APPEND SRCS "${s}")
endforeach()
# append to global list
set_property(GLOBAL APPEND PROPERTY ${list} "${SRCS}")
endfunction(add_source_files)
# find all the libraries
find_package(Qt5 COMPONENTS Core Network Widgets Svg REQUIRED)
find_package(Portaudio REQUIRED)
find_package(hamlib REQUIRED)
find_package(Sox REQUIRED)
find_package(Boost COMPONENTS system filesystem REQUIRED)
find_package(FFTW REQUIRED FLOAT_LIB)
find_package(KF5Plotting REQUIRED)
message("boost lib: ${Boost_LIBRARIES}")
message("boost inc:${Boost_INCLUDE_DIR}")
message("fftw lib: ${FFTW_LIBRARIES}")
#message("KF5: ${KF5::Plotting}")
# run moc when necessary:
set(CMAKE_AUTOMOC ON)
# tell CMake to look for include files in the binary dir:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# set include directories
include_directories(
${Qt5Widgets_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/src/utils
)
# add all subdirectories
add_subdirectory(src)
# Setup tests
enable_testing()
add_subdirectory(tests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment