SDRPlusPlus/core/CMakeLists.txt

121 wiersze
3.4 KiB
CMake
Czysty Zwykły widok Historia

cmake_minimum_required(VERSION 3.13)
2020-09-19 10:48:34 +00:00
project(sdrpp_core)
2021-10-28 08:05:31 +00:00
if (USE_INTERNAL_LIBCORRECT)
add_subdirectory("libcorrect/")
endif (USE_INTERNAL_LIBCORRECT)
2021-10-02 23:13:15 +00:00
2021-11-17 21:37:21 +00:00
if (USE_BUNDLE_DEFAULTS)
add_definitions(-DIS_MACOS_BUNDLE)
endif (USE_BUNDLE_DEFAULTS)
2021-11-16 02:33:09 +00:00
2021-10-03 01:40:16 +00:00
# Main code
file(GLOB_RECURSE SRC "src/*.cpp" "src/*.c")
add_definitions(-DSDRPP_IS_CORE)
2020-09-19 10:48:34 +00:00
if (MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
2021-04-18 17:12:07 +00:00
endif ()
2020-09-19 10:48:34 +00:00
# Add code to dyn lib
add_library(sdrpp_core SHARED ${SRC})
2020-09-19 10:48:34 +00:00
2021-10-03 01:40:16 +00: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 21:58:11 +00:00
target_compile_options(sdrpp_core PRIVATE -O3 -std=c++17)
2021-10-03 01:40:16 +00:00
else ()
target_compile_options(sdrpp_core PRIVATE -O3 -std=c++17)
endif ()
2021-04-26 13:17:24 +00:00
# Set the install prefix
target_compile_definitions(sdrpp_core PUBLIC INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
2020-09-19 10:48:34 +00:00
# Include core headers
target_include_directories(sdrpp_core PUBLIC "src/")
target_include_directories(sdrpp_core PUBLIC "src/imgui")
2021-10-28 08:05:31 +00: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 16:49:00 +00:00
if (OPT_OVERRIDE_STD_FILESYSTEM)
2021-10-28 08:05:31 +00:00
target_include_directories(sdrpp_core PUBLIC "std_replacement")
2021-08-16 16:49:00 +00:00
endif (OPT_OVERRIDE_STD_FILESYSTEM)
2020-09-19 10:48:34 +00: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 10:48:34 +00: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
target_link_libraries(sdrpp_core PUBLIC wsock32 ws2_32)
else()
find_package(PkgConfig)
2020-10-22 00:28:43 +00:00
find_package(OpenGL REQUIRED)
pkg_check_modules(FFTW3 REQUIRED fftw3f)
pkg_check_modules(VOLK REQUIRED volk)
pkg_check_modules(GLFW3 REQUIRED glfw3)
target_include_directories(sdrpp_core PUBLIC
${OPENGL_INCLUDE_DIRS}
${FFTW3_INCLUDE_DIRS}
${GLFW3_INCLUDE_DIRS}
${VOLK_INCLUDE_DIRS}
2020-12-22 19:35:31 +00:00
)
2021-10-28 08:05:31 +00:00
target_link_directories(sdrpp_core PUBLIC
${OPENGL_LIBRARY_DIRS}
${FFTW3_LIBRARY_DIRS}
${GLFW3_LIBRARY_DIRS}
${VOLK_LIBRARY_DIRS}
)
target_link_libraries(sdrpp_core PUBLIC
${OPENGL_LIBRARIES}
2020-12-22 19:35:31 +00:00
${FFTW3_LIBRARIES}
${GLFW3_LIBRARIES}
${VOLK_LIBRARIES}
)
2021-10-28 08:05:31 +00: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 00:28:43 +00:00
endif ()
2020-09-19 10:48:34 +00:00
set(CORE_FILES ${RUNTIME_OUTPUT_DIRECTORY} PARENT_SCOPE)
2021-10-03 01:40:16 +00:00
# cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"
2021-02-11 21:49:33 +00:00
# Install directives
install(TARGETS sdrpp_core DESTINATION lib)