2021-04-26 17:03:52 +02:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
2020-09-19 12:48:34 +02:00
|
|
|
project(sdrpp_core)
|
|
|
|
|
2021-10-28 10:05:31 +02:00
|
|
|
if (USE_INTERNAL_LIBCORRECT)
|
|
|
|
add_subdirectory("libcorrect/")
|
|
|
|
endif (USE_INTERNAL_LIBCORRECT)
|
2021-10-03 01:13:15 +02:00
|
|
|
|
2021-11-17 22:37:21 +01:00
|
|
|
if (USE_BUNDLE_DEFAULTS)
|
|
|
|
add_definitions(-DIS_MACOS_BUNDLE)
|
|
|
|
endif (USE_BUNDLE_DEFAULTS)
|
2021-11-16 03:33:09 +01:00
|
|
|
|
2021-10-03 03:40:16 +02:00
|
|
|
# Main code
|
|
|
|
file(GLOB_RECURSE SRC "src/*.cpp" "src/*.c")
|
|
|
|
|
|
|
|
add_definitions(-DSDRPP_IS_CORE)
|
2023-03-10 00:45:56 +01:00
|
|
|
add_definitions(-DFLOG_ANDROID_TAG="SDR++")
|
2020-09-19 12:48:34 +02:00
|
|
|
if (MSVC)
|
|
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
2021-04-18 19:12:07 +02:00
|
|
|
endif ()
|
2020-09-19 12:48:34 +02:00
|
|
|
|
2022-01-29 20:35:08 +01:00
|
|
|
# Configure backend sources
|
|
|
|
if (OPT_BACKEND_GLFW)
|
|
|
|
file(GLOB_RECURSE BACKEND_SRC "backends/glfw/*.cpp" "backends/glfw/*.c")
|
|
|
|
endif (OPT_BACKEND_GLFW)
|
2022-02-13 17:25:23 +01:00
|
|
|
if (OPT_BACKEND_ANDROID)
|
|
|
|
file(GLOB_RECURSE BACKEND_SRC "backends/android/*.cpp" "backends/android/*.c")
|
|
|
|
set(BACKEND_SRC ${BACKEND_SRC} ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
|
|
|
|
endif (OPT_BACKEND_ANDROID)
|
2022-01-29 20:35:08 +01:00
|
|
|
|
2020-09-19 12:48:34 +02:00
|
|
|
# Add code to dyn lib
|
2022-01-29 20:35:08 +01:00
|
|
|
add_library(sdrpp_core SHARED ${SRC} ${BACKEND_SRC})
|
2020-09-19 12:48:34 +02:00
|
|
|
|
2021-10-03 03:40:16 +02:00
|
|
|
# Set compiler options
|
2023-02-15 20:37:13 +01:00
|
|
|
target_compile_options(sdrpp_core PRIVATE ${SDRPP_COMPILER_FLAGS})
|
2021-10-03 03:40:16 +02:00
|
|
|
|
2021-04-26 15:17:24 +02:00
|
|
|
# Set the install prefix
|
|
|
|
target_compile_definitions(sdrpp_core PUBLIC INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
|
|
|
|
|
2020-09-19 12:48:34 +02:00
|
|
|
# Include core headers
|
|
|
|
target_include_directories(sdrpp_core PUBLIC "src/")
|
|
|
|
target_include_directories(sdrpp_core PUBLIC "src/imgui")
|
|
|
|
|
2022-01-29 20:35:08 +01:00
|
|
|
# Configure backend includes and libraries
|
|
|
|
if (OPT_BACKEND_GLFW)
|
|
|
|
target_include_directories(sdrpp_core PUBLIC "backends/glfw")
|
|
|
|
target_include_directories(sdrpp_core PUBLIC "backends/glfw/imgui")
|
|
|
|
|
|
|
|
if (MSVC)
|
|
|
|
# GLFW3
|
|
|
|
find_package(glfw3 CONFIG REQUIRED)
|
|
|
|
target_link_libraries(sdrpp_core PUBLIC glfw)
|
|
|
|
else()
|
|
|
|
find_package(PkgConfig)
|
|
|
|
pkg_check_modules(GLFW3 REQUIRED glfw3)
|
|
|
|
|
|
|
|
target_include_directories(sdrpp_core PUBLIC ${GLFW3_INCLUDE_DIRS})
|
|
|
|
target_link_directories(sdrpp_core PUBLIC ${GLFW3_LIBRARY_DIRS})
|
|
|
|
target_link_libraries(sdrpp_core PUBLIC ${GLFW3_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif (OPT_BACKEND_GLFW)
|
2022-02-13 17:25:23 +01:00
|
|
|
if (OPT_BACKEND_ANDROID)
|
|
|
|
target_include_directories(sdrpp_core PUBLIC "backends/android")
|
|
|
|
target_include_directories(sdrpp_core PUBLIC "backends/android/imgui")
|
|
|
|
endif (OPT_BACKEND_ANDROID)
|
2022-01-29 20:35:08 +01:00
|
|
|
|
2021-10-28 10:05:31 +02:00
|
|
|
# Link to libcorrect
|
|
|
|
if (USE_INTERNAL_LIBCORRECT)
|
|
|
|
target_include_directories(sdrpp_core PUBLIC "libcorrect/include")
|
|
|
|
target_link_libraries(sdrpp_core PUBLIC correct_static)
|
|
|
|
endif (USE_INTERNAL_LIBCORRECT)
|
2021-10-02 17:01:23 +02:00
|
|
|
|
2021-08-16 18:49:00 +02:00
|
|
|
if (OPT_OVERRIDE_STD_FILESYSTEM)
|
2021-10-28 10:05:31 +02:00
|
|
|
target_include_directories(sdrpp_core PUBLIC "std_replacement")
|
2021-08-16 18:49:00 +02:00
|
|
|
endif (OPT_OVERRIDE_STD_FILESYSTEM)
|
2020-09-19 12:48:34 +02:00
|
|
|
|
|
|
|
if (MSVC)
|
|
|
|
# Lib path
|
|
|
|
target_link_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/lib/")
|
|
|
|
|
|
|
|
# Misc headers
|
|
|
|
target_include_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/include/")
|
|
|
|
|
|
|
|
# Volk
|
|
|
|
target_link_libraries(sdrpp_core PUBLIC volk)
|
|
|
|
|
2022-01-22 18:03:14 +01:00
|
|
|
# OpenGL
|
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
target_link_libraries(sdrpp_core PUBLIC OpenGL::GL)
|
2020-09-19 12:48:34 +02:00
|
|
|
|
|
|
|
# GLFW3
|
|
|
|
find_package(glfw3 CONFIG REQUIRED)
|
|
|
|
target_link_libraries(sdrpp_core PUBLIC glfw)
|
|
|
|
|
|
|
|
# FFTW3
|
|
|
|
find_package(FFTW3f CONFIG REQUIRED)
|
|
|
|
target_link_libraries(sdrpp_core PUBLIC FFTW3::fftw3f)
|
|
|
|
|
2021-07-16 01:49:33 +02:00
|
|
|
# WinSock2
|
2023-01-26 03:05:32 +01:00
|
|
|
target_link_libraries(sdrpp_core PUBLIC wsock32 ws2_32 iphlpapi)
|
2021-07-16 01:49:33 +02:00
|
|
|
|
2022-01-26 13:23:55 +01:00
|
|
|
# ZSTD
|
|
|
|
find_package(zstd CONFIG REQUIRED)
|
2022-01-26 20:20:04 +01:00
|
|
|
target_link_libraries(sdrpp_core PUBLIC zstd::libzstd_shared)
|
2022-02-13 17:25:23 +01:00
|
|
|
elseif (ANDROID)
|
|
|
|
target_include_directories(sdrpp_core PUBLIC
|
2022-09-02 20:08:16 +02:00
|
|
|
/sdr-kit/${ANDROID_ABI}/include
|
2022-02-13 17:25:23 +01:00
|
|
|
${ANDROID_NDK}/sources/android/native_app_glue
|
|
|
|
)
|
2022-01-26 13:23:55 +01:00
|
|
|
|
2022-02-13 17:25:23 +01:00
|
|
|
target_link_libraries(sdrpp_core PUBLIC
|
2022-09-02 20:08:16 +02:00
|
|
|
/sdr-kit/${ANDROID_ABI}/lib/libvolk.so
|
|
|
|
/sdr-kit/${ANDROID_ABI}/lib/libfftw3f.so
|
|
|
|
/sdr-kit/${ANDROID_ABI}/lib/libzstd.so
|
2022-02-13 17:25:23 +01:00
|
|
|
android
|
|
|
|
EGL
|
|
|
|
GLESv3
|
|
|
|
log
|
|
|
|
)
|
2020-10-23 04:53:48 +02:00
|
|
|
else()
|
2020-10-23 04:25:02 +02:00
|
|
|
find_package(PkgConfig)
|
2020-10-22 02:28:43 +02:00
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
|
2020-10-23 04:25:02 +02:00
|
|
|
pkg_check_modules(FFTW3 REQUIRED fftw3f)
|
|
|
|
pkg_check_modules(VOLK REQUIRED volk)
|
|
|
|
pkg_check_modules(GLFW3 REQUIRED glfw3)
|
2022-01-26 20:20:04 +01:00
|
|
|
pkg_check_modules(LIBZSTD REQUIRED libzstd)
|
2020-10-23 04:25:02 +02:00
|
|
|
|
|
|
|
target_include_directories(sdrpp_core PUBLIC
|
2022-01-22 18:03:14 +01:00
|
|
|
${OPENGL_INCLUDE_DIRS}
|
2020-10-23 04:25:02 +02:00
|
|
|
${FFTW3_INCLUDE_DIRS}
|
|
|
|
${GLFW3_INCLUDE_DIRS}
|
2020-10-23 04:39:20 +02:00
|
|
|
${VOLK_INCLUDE_DIRS}
|
2022-01-26 20:20:04 +01:00
|
|
|
${LIBZSTD_INCLUDE_DIRS}
|
2020-12-22 20:35:31 +01:00
|
|
|
)
|
2021-10-28 10:05:31 +02:00
|
|
|
|
2021-04-29 14:30:11 +02:00
|
|
|
target_link_directories(sdrpp_core PUBLIC
|
2022-01-22 18:03:14 +01:00
|
|
|
${OPENGL_LIBRARY_DIRS}
|
2021-04-29 14:30:11 +02:00
|
|
|
${FFTW3_LIBRARY_DIRS}
|
|
|
|
${GLFW3_LIBRARY_DIRS}
|
|
|
|
${VOLK_LIBRARY_DIRS}
|
2022-01-26 20:20:04 +01:00
|
|
|
${LIBZSTD_LIBRARY_DIRS}
|
2021-04-29 14:30:11 +02:00
|
|
|
)
|
|
|
|
|
2020-10-23 04:25:02 +02:00
|
|
|
target_link_libraries(sdrpp_core PUBLIC
|
|
|
|
${OPENGL_LIBRARIES}
|
2020-12-22 20:35:31 +01:00
|
|
|
${FFTW3_LIBRARIES}
|
|
|
|
${GLFW3_LIBRARIES}
|
|
|
|
${VOLK_LIBRARIES}
|
2022-01-26 20:20:04 +01:00
|
|
|
${LIBZSTD_LIBRARIES}
|
2020-12-22 20:35:31 +01:00
|
|
|
)
|
2020-10-23 04:25:02 +02:00
|
|
|
|
2021-10-28 10:05:31 +02:00
|
|
|
if (NOT USE_INTERNAL_LIBCORRECT)
|
|
|
|
pkg_check_modules(CORRECT REQUIRED libcorrect)
|
|
|
|
target_include_directories(sdrpp_core PUBLIC ${CORRECT_INCLUDE_DIRS})
|
|
|
|
target_link_directories(sdrpp_core PUBLIC ${CORRECT_LIBRARY_DIRS})
|
|
|
|
target_link_libraries(sdrpp_core PUBLIC ${CORRECT_LIBRARIES})
|
|
|
|
endif (NOT USE_INTERNAL_LIBCORRECT)
|
|
|
|
|
2020-10-23 04:53:48 +02:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
target_link_libraries(sdrpp_core PUBLIC stdc++fs)
|
|
|
|
endif ()
|
|
|
|
|
2020-10-22 02:28:43 +02:00
|
|
|
endif ()
|
2020-09-19 12:48:34 +02:00
|
|
|
|
|
|
|
set(CORE_FILES ${RUNTIME_OUTPUT_DIRECTORY} PARENT_SCOPE)
|
|
|
|
|
2021-10-03 03:40:16 +02:00
|
|
|
# cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
2021-02-11 22:49:33 +01:00
|
|
|
|
|
|
|
# Install directives
|
|
|
|
install(TARGETS sdrpp_core DESTINATION lib)
|