From e94888d533bb69294192369c7b97be5a5773c7f8 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Fri, 23 Oct 2020 10:25:02 +0800 Subject: [PATCH] Use pkg for every module, and link them static --- .gitignore | 3 ++- core/CMakeLists.txt | 57 +++++++++++++++++++++++++------------------- soapy/CMakeLists.txt | 14 +++++++---- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 357301de..b4469ae1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ build/ *.old *.dll *.exe -*.zip \ No newline at end of file +*.zip +.DS_Store diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 9dc5c1f3..b119d924 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -60,6 +60,8 @@ if (MSVC) find_package(portaudio CONFIG REQUIRED) target_link_libraries(sdrpp_core PUBLIC portaudio portaudio_static) + target_link_libraries(sdrpp_core PUBLIC volk) + endif (MSVC) if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") @@ -76,42 +78,49 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") target_link_libraries(sdrpp_core PUBLIC Xxf86vm) target_link_libraries(sdrpp_core PUBLIC dl) target_link_libraries(sdrpp_core PUBLIC stdc++fs) + target_link_libraries(sdrpp_core PUBLIC volk) endif () if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + find_package(PkgConfig) find_package(OpenGL REQUIRED) - # find_package(GLEW REQUIRED) - # find_package(fftw3 REQUIRED) - # find_package(glfw3 REQUIRED) - # find_package(volk REQUIRED) + pkg_check_modules(GLEW REQUIRED GLEW) + pkg_check_modules(FFTW3 REQUIRED fftw3f) + pkg_check_modules(VOLK REQUIRED volk) + pkg_check_modules(GLFW3 REQUIRED glfw3) + pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) - target_include_directories(sdrpp_core PUBLIC /usr/local/opt/glew/include) - target_include_directories(sdrpp_core PUBLIC /usr/local/opt/glfw/include) - target_include_directories(sdrpp_core PUBLIC /usr/local/opt/fftw/include) - target_include_directories(sdrpp_core PUBLIC /usr/local/opt/portaudio/include) - target_include_directories(sdrpp_core PUBLIC /usr/local/opt/volk/include) - target_include_directories(sdrpp_core PUBLIC /usr/local/opt/volk/include/volk) + target_include_directories(sdrpp_core PUBLIC + ${GLEW_INCLUDE_DIRS} + ${FFTW3_INCLUDE_DIRS} + ${GLFW3_INCLUDE_DIRS} + ${VOLK_INCLUDE_DIRS} ${VOLK_INCLUDE_DIRS}/volk + ${PORTAUDIO_INCLUDE_DIRS} + ) - target_link_directories(sdrpp_core PUBLIC /usr/local/opt/glew/lib) - target_link_directories(sdrpp_core PUBLIC /usr/local/opt/volk/lib) - target_link_directories(sdrpp_core PUBLIC /usr/local/opt/glfw/lib) - target_link_directories(sdrpp_core PUBLIC /usr/local/opt/fftw/lib) - target_link_directories(sdrpp_core PUBLIC /usr/local/opt/portaudio/lib) + target_link_directories(sdrpp_core PUBLIC + ${GLEW_LIBRARY_DIRS} + ${FFTW3_LIBRARY_DIRS} + ${GLFW3_LIBRARY_DIRS} + ${VOLK_LIBRARY_DIRS} + ${PORTAUDIO_LIBRARY_DIRS} + ) - target_link_libraries(sdrpp_core PUBLIC ${OPENGL_LIBRARIES}) - target_link_libraries(sdrpp_core PUBLIC volk) - target_link_libraries(sdrpp_core PUBLIC glew) - target_link_libraries(sdrpp_core PUBLIC glfw) - target_link_libraries(sdrpp_core PUBLIC fftw3) - target_link_libraries(sdrpp_core PUBLIC fftw3f) - target_link_libraries(sdrpp_core PUBLIC portaudio) + target_link_libraries(sdrpp_core PUBLIC + ${OPENGL_LIBRARIES} + ${GLEW_STATIC_LIBRARIES} + ${FFTW3_STATIC_LIBRARIES} + ${GLFW3_STATIC_LIBRARIES} + ${VOLK_STATIC_LIBRARIES} + ${PORTAUDIO_STATIC_LIBRARIES} + ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") endif () -target_link_libraries(sdrpp_core PUBLIC volk) - set(CORE_FILES ${RUNTIME_OUTPUT_DIRECTORY} PARENT_SCOPE) # cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/Users/Alex/vcpkg/scripts/buildsystems/vcpkg.cmake" -G "Visual Studio 15 2017 Win64" diff --git a/soapy/CMakeLists.txt b/soapy/CMakeLists.txt index 19c33483..19e72e10 100644 --- a/soapy/CMakeLists.txt +++ b/soapy/CMakeLists.txt @@ -19,9 +19,15 @@ add_library(soapy SHARED ${SRC}) target_link_libraries(soapy PRIVATE sdrpp_core) set_target_properties(soapy PROPERTIES PREFIX "") -target_link_libraries(soapy PUBLIC SoapySDR) - if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - target_include_directories(soapy PUBLIC /usr/local/opt/soapysdr/include) - target_link_directories(soapy PUBLIC /usr/local/opt/soapysdr/lib) + find_package(PkgConfig) + find_package(OpenGL REQUIRED) + + pkg_check_modules(SOAPY REQUIRED soapysdr) + + target_include_directories(soapy PUBLIC ${SOAPY_INCLUDE_DIRS}) + target_link_directories(soapy PUBLIC ${SOAPY_LIBRARY_DIRS}) + target_link_libraries(soapy PUBLIC ${SOAPY_LIBRARIES}) +else () + target_link_libraries(soapy PUBLIC SoapySDR) endif ()