SDRPlusPlus/core/CMakeLists.txt

176 lines
5.3 KiB
CMake
Raw Normal View History

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)
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)
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
if (MSVC)
target_compile_options(sdrpp_core PRIVATE /O2 /Ob2 /std:c++17 /EHsc)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
2021-10-03 23:58:11 +02:00
target_compile_options(sdrpp_core PRIVATE -O3 -std=c++17)
2021-10-03 03:40:16 +02:00
else ()
target_compile_options(sdrpp_core PRIVATE -O3 -std=c++17)
endif ()
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)
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-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)
# 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)
# WinSock2
2023-01-26 03:05:32 +01:00
target_link_libraries(sdrpp_core PUBLIC wsock32 ws2_32 iphlpapi)
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)
elseif (ANDROID)
target_include_directories(sdrpp_core PUBLIC
2022-09-02 20:08:16 +02:00
/sdr-kit/${ANDROID_ABI}/include
${ANDROID_NDK}/sources/android/native_app_glue
)
2022-01-26 13:23:55 +01:00
target_link_libraries(sdrpp_core PUBLIC
2022-09-02 20:08:16 +02:00
/sdr-kit/${ANDROID_ABI}/lib/libcpu_features.a
/sdr-kit/${ANDROID_ABI}/lib/libvolk.so
/sdr-kit/${ANDROID_ABI}/lib/libfftw3f.so
/sdr-kit/${ANDROID_ABI}/lib/libzstd.so
android
EGL
GLESv3
log
)
else()
find_package(PkgConfig)
2020-10-22 02:28:43 +02:00
find_package(OpenGL REQUIRED)
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)
target_include_directories(sdrpp_core PUBLIC
${OPENGL_INCLUDE_DIRS}
${FFTW3_INCLUDE_DIRS}
${GLFW3_INCLUDE_DIRS}
${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
target_link_directories(sdrpp_core PUBLIC
${OPENGL_LIBRARY_DIRS}
${FFTW3_LIBRARY_DIRS}
${GLFW3_LIBRARY_DIRS}
${VOLK_LIBRARY_DIRS}
2022-01-26 20:20:04 +01:00
${LIBZSTD_LIBRARY_DIRS}
)
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
)
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)
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)